mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Add nolerp filtering by *
This commit is contained in:
parent
9f8af6ec54
commit
318cd69318
10 changed files with 159 additions and 119 deletions
|
@ -460,6 +460,7 @@ set(Client-Source
|
|||
${COMMON_SRC_DIR}/shared/flash.c
|
||||
${COMMON_SRC_DIR}/shared/rand.c
|
||||
${COMMON_SRC_DIR}/shared/shared.c
|
||||
${COMMON_SRC_DIR}/shared/utils.c
|
||||
${COMMON_SRC_DIR}/unzip/ioapi.c
|
||||
${COMMON_SRC_DIR}/unzip/miniz.c
|
||||
${COMMON_SRC_DIR}/unzip/unzip.c
|
||||
|
@ -523,6 +524,7 @@ set(Server-Source
|
|||
${COMMON_SRC_DIR}/zone.c
|
||||
${COMMON_SRC_DIR}/shared/rand.c
|
||||
${COMMON_SRC_DIR}/shared/shared.c
|
||||
${COMMON_SRC_DIR}/shared/utils.c
|
||||
${COMMON_SRC_DIR}/unzip/ioapi.c
|
||||
${COMMON_SRC_DIR}/unzip/miniz.c
|
||||
${COMMON_SRC_DIR}/unzip/unzip.c
|
||||
|
@ -573,6 +575,7 @@ set(GL1-Source
|
|||
${REF_SRC_DIR}/files/wal.c
|
||||
${REF_SRC_DIR}/files/pvs.c
|
||||
${COMMON_SRC_DIR}/shared/shared.c
|
||||
${COMMON_SRC_DIR}/shared/utils.c
|
||||
${COMMON_SRC_DIR}/md4.c
|
||||
)
|
||||
|
||||
|
@ -609,6 +612,7 @@ set(GL3-Source
|
|||
${REF_SRC_DIR}/files/wal.c
|
||||
${REF_SRC_DIR}/files/pvs.c
|
||||
${COMMON_SRC_DIR}/shared/shared.c
|
||||
${COMMON_SRC_DIR}/shared/utils.c
|
||||
${COMMON_SRC_DIR}/md4.c
|
||||
)
|
||||
|
||||
|
@ -663,6 +667,7 @@ set(SOFT-Source
|
|||
${REF_SRC_DIR}/files/wal.c
|
||||
${REF_SRC_DIR}/files/pvs.c
|
||||
${COMMON_SRC_DIR}/shared/shared.c
|
||||
${COMMON_SRC_DIR}/shared/utils.c
|
||||
${COMMON_SRC_DIR}/md4.c
|
||||
)
|
||||
|
||||
|
|
5
Makefile
5
Makefile
|
@ -882,6 +882,7 @@ CLIENT_OBJS_ := \
|
|||
src/common/shared/flash.o \
|
||||
src/common/shared/rand.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/shared/utils.o \
|
||||
src/common/unzip/ioapi.o \
|
||||
src/common/unzip/miniz.o \
|
||||
src/common/unzip/unzip.o \
|
||||
|
@ -934,6 +935,7 @@ REFGL1_OBJS_ := \
|
|||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/pvs.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/shared/utils.o \
|
||||
src/common/md4.o
|
||||
|
||||
ifeq ($(YQ2_OSTYPE), Windows)
|
||||
|
@ -966,6 +968,7 @@ REFGL3_OBJS_ := \
|
|||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/pvs.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/shared/utils.o \
|
||||
src/common/md4.o
|
||||
|
||||
REFGL3_OBJS_GLADE_ := \
|
||||
|
@ -1009,6 +1012,7 @@ REFSOFT_OBJS_ := \
|
|||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/pvs.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/shared/utils.o \
|
||||
src/common/md4.o
|
||||
|
||||
ifeq ($(YQ2_OSTYPE), Windows)
|
||||
|
@ -1041,6 +1045,7 @@ SERVER_OBJS_ := \
|
|||
src/common/zone.o \
|
||||
src/common/shared/rand.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/shared/utils.o \
|
||||
src/common/unzip/ioapi.o \
|
||||
src/common/unzip/miniz.o \
|
||||
src/common/unzip/unzip.o \
|
||||
|
|
|
@ -688,7 +688,7 @@ IN_Update(void)
|
|||
event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||
{
|
||||
Key_MarkAllUp();
|
||||
|
||||
|
||||
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
{
|
||||
S_Activate(false);
|
||||
|
@ -1688,116 +1688,6 @@ static char *default_haptic_filter = (
|
|||
"world/*train2 "
|
||||
);
|
||||
|
||||
/*
|
||||
* name: sound name
|
||||
* filter: sound name rule with '*'
|
||||
* return false for empty filter
|
||||
*/
|
||||
static qboolean
|
||||
Haptic_Feedback_Filtered_Line(const char *name, const char *filter)
|
||||
{
|
||||
const char *current_filter = filter;
|
||||
|
||||
// skip empty filter
|
||||
if (!*current_filter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
while (*current_filter)
|
||||
{
|
||||
char part_filter[MAX_QPATH];
|
||||
const char *name_part;
|
||||
const char *str_end;
|
||||
|
||||
str_end = strchr(current_filter, '*');
|
||||
if (!str_end)
|
||||
{
|
||||
if (!strstr(name, current_filter))
|
||||
{
|
||||
// no such part in string
|
||||
return false;
|
||||
}
|
||||
// have such part
|
||||
break;
|
||||
}
|
||||
// copy filter line
|
||||
if ((str_end - current_filter) >= MAX_QPATH)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
memcpy(part_filter, current_filter, str_end - current_filter);
|
||||
part_filter[str_end - current_filter] = 0;
|
||||
// place part in name
|
||||
name_part = strstr(name, part_filter);
|
||||
if (!name_part)
|
||||
{
|
||||
// no such part in string
|
||||
return false;
|
||||
}
|
||||
// have such part
|
||||
name = name_part + strlen(part_filter);
|
||||
// move to next filter
|
||||
current_filter = str_end + 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* name: sound name
|
||||
* filter: sound names separated by space, and '!' for skip file
|
||||
*/
|
||||
static qboolean
|
||||
Haptic_Feedback_Filtered(const char *name, const char *filter)
|
||||
{
|
||||
const char *current_filter = filter;
|
||||
|
||||
while (*current_filter)
|
||||
{
|
||||
char line_filter[MAX_QPATH];
|
||||
const char *str_end;
|
||||
|
||||
str_end = strchr(current_filter, ' ');
|
||||
// its end of filter
|
||||
if (!str_end)
|
||||
{
|
||||
// check rules inside line
|
||||
if (Haptic_Feedback_Filtered_Line(name, current_filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// copy filter line
|
||||
if ((str_end - current_filter) >= MAX_QPATH)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
memcpy(line_filter, current_filter, str_end - current_filter);
|
||||
line_filter[str_end - current_filter] = 0;
|
||||
// check rules inside line
|
||||
if (*line_filter == '!')
|
||||
{
|
||||
// has invert rule
|
||||
if (Haptic_Feedback_Filtered_Line(name, line_filter + 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Haptic_Feedback_Filtered_Line(name, line_filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// move to next filter
|
||||
current_filter = str_end + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Haptic Feedback:
|
||||
* effect_volume=0..SHRT_MAX
|
||||
|
@ -1833,7 +1723,7 @@ Haptic_Feedback(const char *name, int effect_volume, int effect_duration,
|
|||
|
||||
last_haptic_volume = joy_haptic_magnitude->value * 16;
|
||||
|
||||
if (Haptic_Feedback_Filtered(name, haptic_feedback_filter->string))
|
||||
if (Utils_FilenameFiltered(name, haptic_feedback_filter->string, ' '))
|
||||
{
|
||||
int effect_id;
|
||||
|
||||
|
|
|
@ -223,9 +223,9 @@ R_TextureMode(char *string)
|
|||
if (unfiltered2D && glt->type == it_pic)
|
||||
{
|
||||
// exception to that exception: stuff on the r_lerp_list
|
||||
nolerp = (lerplist== NULL) || (strstr(lerplist, glt->name) == NULL);
|
||||
nolerp = (lerplist == NULL) || Utils_FilenameFiltered(glt->name, lerplist, ' ');
|
||||
}
|
||||
else if(nolerplist != NULL && strstr(nolerplist, glt->name) != NULL)
|
||||
else if (nolerplist != NULL && Utils_FilenameFiltered(glt->name, nolerplist, ' '))
|
||||
{
|
||||
nolerp = true;
|
||||
}
|
||||
|
|
|
@ -1229,7 +1229,7 @@ R_Register(void)
|
|||
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
|
||||
|
||||
/* don't bilerp characters and crosshairs */
|
||||
gl_nolerp_list = ri.Cvar_Get("r_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", CVAR_ARCHIVE);
|
||||
gl_nolerp_list = ri.Cvar_Get("r_nolerp_list", DEFAULT_NOLERP_LIST, CVAR_ARCHIVE);
|
||||
/* textures that should always be filtered, even if r_2D_unfiltered or an unfiltered gl mode is used */
|
||||
r_lerp_list = ri.Cvar_Get("r_lerp_list", "", CVAR_ARCHIVE);
|
||||
/* don't bilerp any 2D elements */
|
||||
|
|
|
@ -99,9 +99,9 @@ GL3_TextureMode(char *string)
|
|||
if (unfiltered2D && glt->type == it_pic)
|
||||
{
|
||||
// exception to that exception: stuff on the r_lerp_list
|
||||
nolerp = (lerplist== NULL) || (strstr(lerplist, glt->name) == NULL);
|
||||
nolerp = (lerplist == NULL) || Utils_FilenameFiltered(glt->name, lerplist, ' ');
|
||||
}
|
||||
else if(nolerplist != NULL && strstr(nolerplist, glt->name) != NULL)
|
||||
else if (nolerplist != NULL && Utils_FilenameFiltered(glt->name, nolerplist, ' '))
|
||||
{
|
||||
nolerp = true;
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ GL3_Register(void)
|
|||
r_validation = ri.Cvar_Get("r_validation", "0", CVAR_ARCHIVE);
|
||||
|
||||
/* don't bilerp characters and crosshairs */
|
||||
gl_nolerp_list = ri.Cvar_Get("r_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", CVAR_ARCHIVE);
|
||||
gl_nolerp_list = ri.Cvar_Get("r_nolerp_list", DEFAULT_NOLERP_LIST, CVAR_ARCHIVE);
|
||||
/* textures that should always be filtered, even if r_2D_unfiltered or an unfiltered gl mode is used */
|
||||
r_lerp_list = ri.Cvar_Get("r_lerp_list", "", CVAR_ARCHIVE);
|
||||
/* don't bilerp any 2D elements */
|
||||
|
|
|
@ -74,7 +74,7 @@ typedef enum
|
|||
} modtype_t;
|
||||
|
||||
#define MAX_LBM_HEIGHT 480
|
||||
|
||||
#define DEFAULT_NOLERP_LIST "pics/conchars.* pics/ch1.* pics/ch2. pics/ch3.*"
|
||||
extern void R_Printf(int level, const char* msg, ...) PRINTF_ATTR(2, 3);
|
||||
|
||||
/* Shared images load */
|
||||
|
|
|
@ -372,6 +372,9 @@ float frandk(void);
|
|||
float crandk(void);
|
||||
void randk_seed(void);
|
||||
|
||||
/* Addition code utilities */
|
||||
qboolean Utils_FilenameFiltered(const char *name, const char *filter, char sepator);
|
||||
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
|
|
137
src/common/shared/utils.c
Normal file
137
src/common/shared/utils.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* Additional functions shared between client and renders
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include "../header/shared.h"
|
||||
|
||||
/*
|
||||
* name: file name
|
||||
* filter: file name line rule with '*'
|
||||
* return false for empty filter
|
||||
*/
|
||||
static qboolean
|
||||
Utils_FilenameFiltered_Line(const char *name, const char *filter)
|
||||
{
|
||||
const char *current_filter = filter;
|
||||
|
||||
// skip empty filter
|
||||
if (!*current_filter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
while (*current_filter)
|
||||
{
|
||||
char part_filter[MAX_QPATH];
|
||||
const char *name_part;
|
||||
const char *str_end;
|
||||
|
||||
str_end = strchr(current_filter, '*');
|
||||
if (!str_end)
|
||||
{
|
||||
if (!strstr(name, current_filter))
|
||||
{
|
||||
// no such part in string
|
||||
return false;
|
||||
}
|
||||
// have such part
|
||||
break;
|
||||
}
|
||||
// copy filter line
|
||||
if ((str_end - current_filter) >= MAX_QPATH)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
memcpy(part_filter, current_filter, str_end - current_filter);
|
||||
part_filter[str_end - current_filter] = 0;
|
||||
// place part in name
|
||||
name_part = strstr(name, part_filter);
|
||||
if (!name_part)
|
||||
{
|
||||
// no such part in string
|
||||
return false;
|
||||
}
|
||||
// have such part
|
||||
name = name_part + strlen(part_filter);
|
||||
// move to next filter
|
||||
current_filter = str_end + 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* name: file name
|
||||
* filter: file names separated by sepator, and '!' for skip file
|
||||
*/
|
||||
qboolean
|
||||
Utils_FilenameFiltered(const char *name, const char *filter, char sepator)
|
||||
{
|
||||
const char *current_filter = filter;
|
||||
|
||||
while (*current_filter)
|
||||
{
|
||||
char line_filter[MAX_QPATH];
|
||||
const char *str_end;
|
||||
|
||||
str_end = strchr(current_filter, sepator);
|
||||
// its end of filter
|
||||
if (!str_end)
|
||||
{
|
||||
// check rules inside line
|
||||
if (Utils_FilenameFiltered_Line(name, current_filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// copy filter line
|
||||
if ((str_end - current_filter) >= MAX_QPATH)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
memcpy(line_filter, current_filter, str_end - current_filter);
|
||||
line_filter[str_end - current_filter] = 0;
|
||||
// check rules inside line
|
||||
if (*line_filter == '!')
|
||||
{
|
||||
// has invert rule
|
||||
if (Utils_FilenameFiltered_Line(name, line_filter + 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Utils_FilenameFiltered_Line(name, line_filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// move to next filter
|
||||
current_filter = str_end + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
Loading…
Reference in a new issue