mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-11 07:42:18 +00:00
[gamecode] Make string ops mostly conform with bools
The compare/ne operator returns "random" -ve, 0, +ve values (really, just the numerical difference between the chars of the strings), but all the rest return -1 for true and 0 for false, as with the rest of the comparison operators.
This commit is contained in:
parent
c8362c28fe
commit
1aa4844bf6
1 changed files with 7 additions and 7 deletions
|
@ -3280,12 +3280,12 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
||||||
int cmp = strcmp (PR_GetString (pr, OPA(string)),
|
int cmp = strcmp (PR_GetString (pr, OPA(string)),
|
||||||
PR_GetString (pr, OPB(string)));
|
PR_GetString (pr, OPB(string)));
|
||||||
switch (st_op) {
|
switch (st_op) {
|
||||||
case OP_EQ_S: cmp = (cmp == 0); break;
|
case OP_EQ_S: cmp = -(cmp == 0); break;
|
||||||
case OP_LT_S: cmp = (cmp < 0); break;
|
case OP_LT_S: cmp = -(cmp < 0); break;
|
||||||
case OP_GT_S: cmp = (cmp > 0); break;
|
case OP_GT_S: cmp = -(cmp > 0); break;
|
||||||
case OP_GE_S: cmp = (cmp >= 0); break;
|
case OP_GE_S: cmp = -(cmp >= 0); break;
|
||||||
case OP_LE_S: cmp = (cmp <= 0); break;
|
case OP_LE_S: cmp = -(cmp <= 0); break;
|
||||||
case OP_NOT_S: break;
|
case OP_CMP_S: break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
OPC(int) = cmp;
|
OPC(int) = cmp;
|
||||||
|
@ -3296,7 +3296,7 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
||||||
PR_GetString (pr, OPB(string)));
|
PR_GetString (pr, OPB(string)));
|
||||||
break;
|
break;
|
||||||
case OP_NOT_S:
|
case OP_NOT_S:
|
||||||
OPC(int) = !OPA(string) || !*PR_GetString (pr, OPA(string));
|
OPC(int) = -(!OPA(string) || !*PR_GetString (pr, OPA(string)));
|
||||||
break;
|
break;
|
||||||
// 1 0111
|
// 1 0111
|
||||||
OP_op_T (ASR, I, int, ivec2, ivec4, >>);
|
OP_op_T (ASR, I, int, ivec2, ivec4, >>);
|
||||||
|
|
Loading…
Reference in a new issue