mirror of
https://github.com/yquake2/ref_vk.git
synced 2024-11-22 20:11:27 +00:00
Apply shared filtering logic for lerplist
This commit is contained in:
parent
aefe787eca
commit
335b8855e2
3 changed files with 130 additions and 6 deletions
|
@ -39,4 +39,9 @@ int LongNoSwap(int l);
|
|||
float FloatSwap(float f);
|
||||
float FloatNoSwap(float f);
|
||||
|
||||
/*
|
||||
* TODO: Sync with yquake
|
||||
*/
|
||||
qboolean File_Filtered(const char *name, const char *filter);
|
||||
|
||||
#endif // COMMON_SHARED_SAFE_H
|
||||
|
|
|
@ -1421,3 +1421,121 @@ Info_SetValueForKey(char *s, char *key, char *value)
|
|||
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Sync with yquake
|
||||
*/
|
||||
|
||||
/*
|
||||
* name: file name
|
||||
* filter: file name line rule with '*'
|
||||
* return false for empty filter
|
||||
*/
|
||||
static qboolean
|
||||
File_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 = index(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 space, and '!' for skip file
|
||||
*/
|
||||
qboolean
|
||||
File_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 = index(current_filter, ' ');
|
||||
// its end of filter
|
||||
if (!str_end)
|
||||
{
|
||||
// check rules inside line
|
||||
if (File_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 (File_Filtered_Line(name, line_filter + 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (File_Filtered_Line(name, line_filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// move to next filter
|
||||
current_filter = str_end + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* End of unsynced code
|
||||
*/
|
||||
|
|
|
@ -693,9 +693,9 @@ void Vk_TextureMode( char *string )
|
|||
if (unfiltered2D && image->type == it_pic)
|
||||
{
|
||||
// exception to that exception: stuff on the r_lerp_list
|
||||
nolerp = (lerplist== NULL) || (strstr(lerplist, image->name) == NULL);
|
||||
nolerp = (lerplist == NULL) || File_Filtered(image->name, lerplist);
|
||||
}
|
||||
else if (nolerplist != NULL && strstr(nolerplist, image->name) != NULL)
|
||||
else if (nolerplist != NULL && File_Filtered(image->name, nolerplist))
|
||||
{
|
||||
nolerp = true;
|
||||
}
|
||||
|
@ -1098,18 +1098,19 @@ Vk_LoadPic(const char *name, byte *pic, int width, int realwidth,
|
|||
image_t *image;
|
||||
byte *texBuffer = NULL;
|
||||
int upload_width, upload_height;
|
||||
|
||||
const char* nolerplist = r_nolerp_list->string;
|
||||
const char* lerplist = r_lerp_list->string;
|
||||
qboolean nolerp = false;
|
||||
|
||||
if (r_2D_unfiltered->value && type == it_pic)
|
||||
{
|
||||
// if r_2D_unfiltered is true(ish), nolerp should usually be true,
|
||||
// *unless* the texture is on the r_lerp_list
|
||||
nolerp = (r_lerp_list->string == NULL) || (strstr(r_lerp_list->string, name) == NULL);
|
||||
nolerp = (lerplist == NULL) || File_Filtered(name, lerplist);
|
||||
}
|
||||
else if (r_nolerp_list != NULL && r_nolerp_list->string != NULL)
|
||||
else if (nolerplist != NULL)
|
||||
{
|
||||
nolerp = strstr(r_nolerp_list->string, name) != NULL;
|
||||
nolerp = File_Filtered(name, nolerplist);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue