search for .self' before self'

This commit is contained in:
Bill Currie 2002-05-18 00:49:16 +00:00
parent e11e2f3718
commit f78f921285
6 changed files with 27 additions and 24 deletions

View file

@ -73,7 +73,7 @@ PR_AddBuiltin (progs_t *pr, const char *name, builtin_proc builtin, int num)
pr->builtins = calloc (PR_AUTOBUILTIN, sizeof (builtin_t*)); pr->builtins = calloc (PR_AUTOBUILTIN, sizeof (builtin_t*));
pr->numbuiltins = PR_AUTOBUILTIN; pr->numbuiltins = PR_AUTOBUILTIN;
if (!pr->builtins) if (!pr->builtins)
PR_Error (pr, "PR_AddBuiltin: memory allocation error!\n"); PR_Error (pr, "PR_AddBuiltin: memory allocation error!");
} }
if (num < 0) { if (num < 0) {
@ -85,13 +85,13 @@ PR_AddBuiltin (progs_t *pr, const char *name, builtin_proc builtin, int num)
pr->builtins = realloc (pr->builtins, pr->builtins = realloc (pr->builtins,
pr->numbuiltins * sizeof (builtin_t*)); pr->numbuiltins * sizeof (builtin_t*));
if (!pr->builtins) if (!pr->builtins)
PR_Error (pr, "PR_AddBuiltin: memory allocation error!\n"); PR_Error (pr, "PR_AddBuiltin: memory allocation error!");
} }
} else { } else {
if (num >= PR_AUTOBUILTIN || num == 0) if (num >= PR_AUTOBUILTIN || num == 0)
PR_Error (pr, "PR_AddBuiltin: invalid builtin number.\n"); PR_Error (pr, "PR_AddBuiltin: invalid builtin number.");
if (pr->builtins[num]) if (pr->builtins[num])
PR_Error (pr, "PR_AddBuiltin: builtin number already exists.\n"); PR_Error (pr, "PR_AddBuiltin: builtin number already exists.");
i = num; i = num;
} }
pr->builtins[i] = malloc (sizeof (builtin_t)); pr->builtins[i] = malloc (sizeof (builtin_t));

View file

@ -461,7 +461,7 @@ ED_Print (progs_t * pr, edict_t *ed)
continue; continue;
break; break;
default: default:
PR_Error (pr, "ED_Print: Unhandled type %d\n", type); PR_Error (pr, "ED_Print: Unhandled type %d", type);
} }
Sys_Printf ("%s", name); Sys_Printf ("%s", name);

View file

@ -196,7 +196,7 @@ PR_EnterFunction (progs_t * pr, dfunction_t *f)
// save off any locals that the new function steps on // save off any locals that the new function steps on
c = f->locals; c = f->locals;
if (pr->localstack_used + c > LOCALSTACK_SIZE) if (pr->localstack_used + c > LOCALSTACK_SIZE)
PR_RunError (pr, "PR_ExecuteProgram: locals stack overflow\n"); PR_RunError (pr, "PR_ExecuteProgram: locals stack overflow");
memcpy (&pr->localstack[pr->localstack_used], memcpy (&pr->localstack[pr->localstack_used],
&pr->pr_globals[f->parm_start], &pr->pr_globals[f->parm_start],
@ -234,7 +234,7 @@ PR_LeaveFunction (progs_t * pr)
c = pr->pr_xfunction->locals; c = pr->pr_xfunction->locals;
pr->localstack_used -= c; pr->localstack_used -= c;
if (pr->localstack_used < 0) if (pr->localstack_used < 0)
PR_RunError (pr, "PR_ExecuteProgram: locals stack underflow\n"); PR_RunError (pr, "PR_ExecuteProgram: locals stack underflow");
memcpy (&pr->pr_globals[pr->pr_xfunction->parm_start], memcpy (&pr->pr_globals[pr->pr_xfunction->parm_start],
&pr->localstack[pr->localstack_used], &pr->localstack[pr->localstack_used],
@ -481,7 +481,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
pr->pr_edictareasize)) { pr->pr_edictareasize)) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Progs attempted to address an out of " PR_RunError (pr, "Progs attempted to address an out of "
"bounds edict\n"); "bounds edict");
return; return;
} }
if (pr_boundscheck->int_val if (pr_boundscheck->int_val
@ -495,7 +495,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
pr->progs->entityfields)) { pr->progs->entityfields)) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Progs attempted to address an invalid " PR_RunError (pr, "Progs attempted to address an invalid "
"field in an edict\n"); "field in an edict");
return; return;
} }
ed = PROG_TO_EDICT (pr, OPA.entity_var); ed = PROG_TO_EDICT (pr, OPA.entity_var);
@ -524,7 +524,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
pr->pr_edictareasize)) { pr->pr_edictareasize)) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Progs attempted to read an out of " PR_RunError (pr, "Progs attempted to read an out of "
"bounds edict number\n"); "bounds edict number");
return; return;
} }
if (pr_boundscheck->int_val if (pr_boundscheck->int_val
@ -532,7 +532,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
pr->progs->entityfields)) { pr->progs->entityfields)) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Progs attempted to read an invalid " PR_RunError (pr, "Progs attempted to read an invalid "
"field in an edict\n"); "field in an edict");
return; return;
} }
ed = PROG_TO_EDICT (pr, OPA.entity_var); ed = PROG_TO_EDICT (pr, OPA.entity_var);
@ -544,7 +544,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
pr->pr_edictareasize)) { pr->pr_edictareasize)) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Progs attempted to read an out of " PR_RunError (pr, "Progs attempted to read an out of "
"bounds edict number\n"); "bounds edict number");
return; return;
} }
if (pr_boundscheck->int_val if (pr_boundscheck->int_val
@ -552,7 +552,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|| OPB.integer_var + 2 >= pr->progs->entityfields)) { || OPB.integer_var + 2 >= pr->progs->entityfields)) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Progs attempted to read an invalid " PR_RunError (pr, "Progs attempted to read an invalid "
"field in an edict\n"); "field in an edict");
return; return;
} }
ed = PROG_TO_EDICT (pr, OPA.entity_var); ed = PROG_TO_EDICT (pr, OPA.entity_var);
@ -677,7 +677,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
if (pr_boundscheck->int_val if (pr_boundscheck->int_val
&& (OPA.uinteger_var >= pr->progs->numstatements)) { && (OPA.uinteger_var >= pr->progs->numstatements)) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Invalid jump destination\n"); PR_RunError (pr, "Invalid jump destination");
return; return;
} }
st = &pr->pr_statements[OPA.uinteger_var]; st = &pr->pr_statements[OPA.uinteger_var];
@ -690,7 +690,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
if (pr_boundscheck->int_val if (pr_boundscheck->int_val
&& (pointer >= pr->progs->numstatements)) { && (pointer >= pr->progs->numstatements)) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Invalid jump destination\n"); PR_RunError (pr, "Invalid jump destination");
return; return;
} }
st = &pr->pr_statements[pointer]; st = &pr->pr_statements[pointer];
@ -838,7 +838,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
if (OPA.integer_var < 0 || OPA.integer_var >= st->b) { if (OPA.integer_var < 0 || OPA.integer_var >= st->b) {
pr->pr_xstatement = st - pr->pr_statements; pr->pr_xstatement = st - pr->pr_statements;
PR_RunError (pr, "Progs boundcheck failed at line number " PR_RunError (pr, "Progs boundcheck failed at line number "
"%d, value is < 0 or >= %d\n", st->b, st->c); "%d, value is < 0 or >= %d", st->b, st->c);
return; return;
} }
break; break;

View file

@ -296,7 +296,7 @@ check_branch (progs_t *pr, dstatement_t *st, opcode_t *op, short offset)
address += offset; address += offset;
if (address < 0 || address >= pr->progs->numstatements) if (address < 0 || address >= pr->progs->numstatements)
PR_Error (pr, "PR_Check_Opcodes: invalid branch (statement %ld: %s)\n", PR_Error (pr, "PR_Check_Opcodes: invalid branch (statement %ld: %s)",
(long)(st - pr->pr_statements), op->opname); (long)(st - pr->pr_statements), op->opname);
} }
@ -325,7 +325,7 @@ check_global (progs_t *pr, dstatement_t *st, opcode_t *op, etype_t type,
return; return;
error: error:
PR_PrintStatement (pr, st); PR_PrintStatement (pr, st);
PR_Error (pr, "PR_Check_Opcodes: %s (statement %ld: %s)\n", msg, PR_Error (pr, "PR_Check_Opcodes: %s (statement %ld: %s)", msg,
(long)(st - pr->pr_statements), op->opname); (long)(st - pr->pr_statements), op->opname);
} }
@ -343,7 +343,7 @@ PR_Check_Opcodes (progs_t *pr)
op = PR_Opcode (st->op); op = PR_Opcode (st->op);
if (!op) { if (!op) {
PR_Error (pr, PR_Error (pr,
"PR_Check_Opcodes: unknown opcode %d at statement %ld\n", "PR_Check_Opcodes: unknown opcode %d at statement %ld",
st->op, (long)(st - pr->pr_statements)); st->op, (long)(st - pr->pr_statements));
} }
switch (st->op) { switch (st->op) {

View file

@ -162,11 +162,15 @@ int
PR_ResolveGlobals (progs_t *pr) PR_ResolveGlobals (progs_t *pr)
{ {
char *sym; char *sym;
ddef_t *def;
if (!(pr->globals.time = (float*)PR_GetGlobalPointer (pr, sym = "time"))) if (!(def = PR_FindGlobal (pr, sym = "time")))
goto error;
if (!(pr->globals.self = (int*)PR_GetGlobalPointer (pr, sym = "self")))
goto error; goto error;
pr->globals.time = &G_FLOAT (pr, def->ofs);
if (!(def = PR_FindGlobal (pr, ".self")))
if (!(def = PR_FindGlobal (pr, "self")))
goto error;
pr->globals.self = &G_INT (pr, def->ofs);
if ((pr->fields.nextthink = ED_GetFieldIndex (pr, sym = "nextthink")) == -1) if ((pr->fields.nextthink = ED_GetFieldIndex (pr, sym = "nextthink")) == -1)
goto error; goto error;
if ((pr->fields.frame = ED_GetFieldIndex (pr, sym = "frame")) == -1) if ((pr->fields.frame = ED_GetFieldIndex (pr, sym = "frame")) == -1)
@ -175,7 +179,7 @@ PR_ResolveGlobals (progs_t *pr)
goto error; goto error;
return 1; return 1;
error: error:
Sys_Printf ("%s: undefined symbol: %s", pr->progs_name, sym); Sys_Printf ("%s: undefined symbol: %s\n", pr->progs_name, sym);
return 0; return 0;
} }

View file

@ -143,7 +143,6 @@ SV_LoadProgs (void)
sv_globals.self = sv_pr_state.globals.self; sv_globals.self = sv_pr_state.globals.self;
sv_globals.time = sv_pr_state.globals.time; sv_globals.time = sv_pr_state.globals.time;
(void *) sv_globals.self = PR_GetGlobalPointer (&sv_pr_state, "self");
(void *) sv_globals.other = PR_GetGlobalPointer (&sv_pr_state, "other"); (void *) sv_globals.other = PR_GetGlobalPointer (&sv_pr_state, "other");
(void *) sv_globals.world = PR_GetGlobalPointer (&sv_pr_state, "world"); (void *) sv_globals.world = PR_GetGlobalPointer (&sv_pr_state, "world");
(void *) sv_globals.time = PR_GetGlobalPointer (&sv_pr_state, "time"); (void *) sv_globals.time = PR_GetGlobalPointer (&sv_pr_state, "time");