mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 12:00:38 +00:00
Fix fold_op_cmp
This commit is contained in:
parent
ac7e1a557d
commit
43e9885a08
1 changed files with 9 additions and 4 deletions
13
fold.c
13
fold.c
|
@ -606,10 +606,15 @@ static GMQCC_INLINE ast_expression *fold_op_lteqgt(fold_t *fold, ast_value *a, a
|
|||
|
||||
static GMQCC_INLINE ast_expression *fold_op_cmp(fold_t *fold, ast_value *a, ast_value *b, bool ne) {
|
||||
if (fold_can_2(a, b)) {
|
||||
if (isfloat(a) && isfloat(b))
|
||||
return fold_constgen_float(fold, ne != (fold_immvalue_float(a) == fold_immvalue_float(b)));
|
||||
if (isvector(a) && isvector(b))
|
||||
return fold_constgen_float(fold, ne != vec3_cmp(fold_immvalue_vector(a), fold_immvalue_vector(b)));
|
||||
if (isfloat(a) && isfloat(b)) {
|
||||
float la = fold_immvalue_float(a);
|
||||
float lb = fold_immvalue_float(b);
|
||||
return (ast_expression*)fold->imm_float[!!(ne ? la != lb : la == lb)];
|
||||
} if (isvector(a) && isvector(b)) {
|
||||
vec3_t la = fold_immvalue_vector(a);
|
||||
vec3_t lb = fold_immvalue_vector(b);
|
||||
return (ast_expression*)fold->imm_float[!!(ne ? vec3_cmp(la, lb) : !vec3_cmp(la, lb))];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue