mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
change the types of the statement operands to unsigned short to clean up
most of the uses
This commit is contained in:
parent
45fd3e084d
commit
283b0e1a21
3 changed files with 26 additions and 25 deletions
|
@ -192,7 +192,7 @@ void PR_Opcode_Init (void);
|
|||
typedef struct statement_s
|
||||
{
|
||||
unsigned short op;
|
||||
short a,b,c;
|
||||
unsigned short a,b,c;
|
||||
} dstatement_t;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -1186,14 +1186,16 @@ PR_LoadProgs (progs_t * pr, const char *progsname)
|
|||
switch (st->op) {
|
||||
case OP_IF:
|
||||
case OP_IFNOT:
|
||||
if ((unsigned short) st->a >= pr->progs->numglobals
|
||||
|| st->b + i < 0 || st->b + i >= pr->progs->numstatements)
|
||||
if (st->a >= pr->progs->numglobals
|
||||
|| (short)st->b + i < 0
|
||||
|| (short)st->b + i >= pr->progs->numstatements)
|
||||
PR_Error
|
||||
(pr, "PR_LoadProgs: out of bounds IF/IFNOT (statement %d)\n",
|
||||
i);
|
||||
break;
|
||||
case OP_GOTO:
|
||||
if (st->a + i < 0 || st->a + i >= pr->progs->numstatements)
|
||||
if ((short)st->a + i < 0
|
||||
|| (short)st->a + i >= pr->progs->numstatements)
|
||||
PR_Error
|
||||
(pr, "PR_LoadProgs: out of bounds GOTO (statement %d)\n",
|
||||
i);
|
||||
|
@ -1266,9 +1268,9 @@ PR_LoadProgs (progs_t * pr, const char *progsname)
|
|||
case OP_SHR_F:
|
||||
case OP_SHL_I:
|
||||
case OP_SHR_I:
|
||||
if ((unsigned short) st->a >= pr->progs->numglobals
|
||||
|| (unsigned short) st->b >= pr->progs->numglobals
|
||||
|| (unsigned short) st->c >= pr->progs->numglobals)
|
||||
if (st->a >= pr->progs->numglobals
|
||||
|| st->b >= pr->progs->numglobals
|
||||
|| st->c >= pr->progs->numglobals)
|
||||
PR_Error
|
||||
(pr, "PR_LoadProgs: out of bounds global index (statement %d)\n",
|
||||
i);
|
||||
|
@ -1279,8 +1281,8 @@ PR_LoadProgs (progs_t * pr, const char *progsname)
|
|||
case OP_NOT_S:
|
||||
case OP_NOT_FNC:
|
||||
case OP_NOT_ENT:
|
||||
if ((unsigned short) st->a >= pr->progs->numglobals
|
||||
|| (unsigned short) st->c >= pr->progs->numglobals)
|
||||
if (st->a >= pr->progs->numglobals
|
||||
|| st->c >= pr->progs->numglobals)
|
||||
PR_Error
|
||||
(pr, "PR_LoadProgs: out of bounds global index (statement %d)\n",
|
||||
i);
|
||||
|
@ -1301,8 +1303,8 @@ PR_LoadProgs (progs_t * pr, const char *progsname)
|
|||
case OP_STORE_V:
|
||||
case OP_STORE_I:
|
||||
case OP_STOREP_I:
|
||||
if ((unsigned short) st->a >= pr->progs->numglobals
|
||||
|| (unsigned short) st->b >= pr->progs->numglobals)
|
||||
if (st->a >= pr->progs->numglobals
|
||||
|| st->b >= pr->progs->numglobals)
|
||||
PR_Error
|
||||
(pr, "PR_LoadProgs: out of bounds global index (statement %d)\n",
|
||||
i);
|
||||
|
@ -1319,7 +1321,7 @@ PR_LoadProgs (progs_t * pr, const char *progsname)
|
|||
case OP_CALL8:
|
||||
case OP_DONE:
|
||||
case OP_RETURN:
|
||||
if ((unsigned short) st->a >= pr->progs->numglobals)
|
||||
if (st->a >= pr->progs->numglobals)
|
||||
PR_Error
|
||||
(pr, "PR_LoadProgs: out of bounds global index (statement %d)\n",
|
||||
i);
|
||||
|
|
|
@ -77,22 +77,21 @@ PR_PrintStatement (progs_t * pr, dstatement_t *s)
|
|||
|
||||
if (s->op == OP_IF || s->op == OP_IFNOT)
|
||||
Con_Printf ("%sbranch %i (%i)",
|
||||
PR_GlobalString (pr, (unsigned short) s->a), s->b,
|
||||
PR_GlobalString (pr, s->a), s->b,
|
||||
addr + s->b);
|
||||
else if (s->op == OP_GOTO) {
|
||||
Con_Printf ("branch %i (%i)", s->a, addr + s->a);
|
||||
} else if ((unsigned int) (s->op - OP_STORE_F) < 6) {
|
||||
Con_Printf ("%s", PR_GlobalString (pr, (unsigned short) s->a));
|
||||
Con_Printf ("%s", PR_GlobalString (pr, s->a));
|
||||
Con_Printf ("%s",
|
||||
PR_GlobalStringNoContents (pr, (unsigned short) s->b));
|
||||
PR_GlobalStringNoContents (pr, s->b));
|
||||
} else {
|
||||
if (s->a)
|
||||
Con_Printf ("%s", PR_GlobalString (pr, (unsigned short) s->a));
|
||||
Con_Printf ("%s", PR_GlobalString (pr, s->a));
|
||||
if (s->b)
|
||||
Con_Printf ("%s", PR_GlobalString (pr, (unsigned short) s->b));
|
||||
Con_Printf ("%s", PR_GlobalString (pr, s->b));
|
||||
if (s->c)
|
||||
Con_Printf ("%s",
|
||||
PR_GlobalStringNoContents (pr, (unsigned short) s->c));
|
||||
Con_Printf ("%s", PR_GlobalStringNoContents (pr, s->c));
|
||||
}
|
||||
Con_Printf ("\n");
|
||||
}
|
||||
|
@ -269,9 +268,9 @@ PR_LeaveFunction (progs_t * pr)
|
|||
|
||||
The interpretation main loop
|
||||
*/
|
||||
#define OPA (pr->pr_globals[(unsigned short) st->a])
|
||||
#define OPB (pr->pr_globals[(unsigned short) st->b])
|
||||
#define OPC (pr->pr_globals[(unsigned short) st->c])
|
||||
#define OPA (pr->pr_globals[st->a])
|
||||
#define OPB (pr->pr_globals[st->b])
|
||||
#define OPC (pr->pr_globals[st->c])
|
||||
|
||||
extern cvar_t *pr_boundscheck;
|
||||
|
||||
|
@ -596,14 +595,14 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
// ==================
|
||||
case OP_IFNOT:
|
||||
if (!OPA.integer_var)
|
||||
st += st->b - 1; // offset the s++
|
||||
st += (short)st->b - 1; // offset the s++
|
||||
break;
|
||||
case OP_IF:
|
||||
if (OPA.integer_var)
|
||||
st += st->b - 1; // offset the s++
|
||||
st += (short)st->b - 1; // offset the s++
|
||||
break;
|
||||
case OP_GOTO:
|
||||
st += st->a - 1; // offset the s++
|
||||
st += (short)st->a - 1; // offset the s++
|
||||
break;
|
||||
case OP_CALL0:
|
||||
case OP_CALL1:
|
||||
|
|
Loading…
Reference in a new issue