mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- Added modulus to FParseContext/xlat.
- Fixed: Division of tag arguments for xlat was in the wrong order. SVN r3344 (trunk)
This commit is contained in:
parent
b21062c39a
commit
4b2ae689ed
5 changed files with 22 additions and 7 deletions
|
@ -137,13 +137,14 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
|
|||
int tagop = (linetrans->flags >> (LINETRANS_TAGSHIFT + t*TAGOP_NUMBITS)) & TAGOP_MASK;
|
||||
switch (tagop)
|
||||
{
|
||||
case TAGOP_None: default: break;
|
||||
case TAGOP_Add: ld->args[t] += tag; break;
|
||||
case TAGOP_Mul: ld->args[t] *= tag; break;
|
||||
case TAGOP_Div: ld->args[t] /= tag; break;
|
||||
case TAGOP_And: ld->args[t] &= tag; break;
|
||||
case TAGOP_Or: ld->args[t] |= tag; break;
|
||||
case TAGOP_Xor: ld->args[t] ^= tag; break;
|
||||
case TAGOP_None: default: break;
|
||||
case TAGOP_Add: ld->args[t] += tag; break;
|
||||
case TAGOP_Mul: ld->args[t] *= tag; break;
|
||||
case TAGOP_Div: ld->args[t] = tag / ld->args[t]; break;
|
||||
case TAGOP_Mod: ld->args[t] = tag % ld->args[t]; break;
|
||||
case TAGOP_And: ld->args[t] &= tag; break;
|
||||
case TAGOP_Or: ld->args[t] |= tag; break;
|
||||
case TAGOP_Xor: ld->args[t] ^= tag; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -267,6 +267,7 @@ loop:
|
|||
case '-': return TokenTrans[MINUS];
|
||||
case '+': return TokenTrans[PLUS];
|
||||
case '*': return TokenTrans[MULTIPLY];
|
||||
case '%': return TokenTrans[MODULUS];
|
||||
case '(': return TokenTrans[LPAREN];
|
||||
case ')': return TokenTrans[RPAREN];
|
||||
case ',': return TokenTrans[COMMA];
|
||||
|
|
|
@ -47,6 +47,7 @@ enum
|
|||
PLUS ,
|
||||
MULTIPLY ,
|
||||
DIVIDE ,
|
||||
MODULUS ,
|
||||
NUM ,
|
||||
FLOATVAL ,
|
||||
LPAREN ,
|
||||
|
@ -78,6 +79,7 @@ enum
|
|||
prefix##PLUS, \
|
||||
prefix##MULTIPLY, \
|
||||
prefix##DIVIDE, \
|
||||
prefix##MODULUS, \
|
||||
prefix##NUM, \
|
||||
prefix##FLOATVAL, \
|
||||
prefix##LPAREN, \
|
||||
|
|
|
@ -10,6 +10,7 @@ enum ELineTransTagOp
|
|||
TAGOP_Add,
|
||||
TAGOP_Mul,
|
||||
TAGOP_Div,
|
||||
TAGOP_Mod,
|
||||
TAGOP_And,
|
||||
TAGOP_Or,
|
||||
TAGOP_Xor,
|
||||
|
|
|
@ -36,6 +36,7 @@ exp(A) ::= exp(B) PLUS exp(C). { A = B + C; }
|
|||
exp(A) ::= exp(B) MINUS exp(C). { A = B - C; }
|
||||
exp(A) ::= exp(B) MULTIPLY exp(C). { A = B * C; }
|
||||
exp(A) ::= exp(B) DIVIDE exp(C). { if (C != 0) A = B / C; else context->PrintError("Division by zero"); }
|
||||
exp(A) ::= exp(B) MODULUS exp(C). { if (C != 0) A = B % C; else context->PrintError("Division by zero"); }
|
||||
exp(A) ::= exp(B) OR exp(C). { A = B | C; }
|
||||
exp(A) ::= exp(B) AND exp(C). { A = B & C; }
|
||||
exp(A) ::= exp(B) XOR exp(C). { A = B ^ C; }
|
||||
|
@ -135,6 +136,15 @@ special_arg(Z) ::= TAG DIVIDE exp(A).
|
|||
context->PrintError("Division by zero");
|
||||
}
|
||||
}
|
||||
special_arg(Z) ::= TAG MODULUS exp(A).
|
||||
{
|
||||
Z.arg = A;
|
||||
Z.tagop = TAGOP_Mod;
|
||||
if (A == 0)
|
||||
{
|
||||
context->PrintError("Division by zero");
|
||||
}
|
||||
}
|
||||
special_arg(Z) ::= TAG OR exp(A).
|
||||
{
|
||||
Z.arg = A;
|
||||
|
|
Loading…
Reference in a new issue