diff --git a/libs/gamecode/engine/pr_builtins.c b/libs/gamecode/engine/pr_builtins.c index eeee8f53d..053081d77 100644 --- a/libs/gamecode/engine/pr_builtins.c +++ b/libs/gamecode/engine/pr_builtins.c @@ -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->numbuiltins = PR_AUTOBUILTIN; if (!pr->builtins) - PR_Error (pr, "PR_AddBuiltin: memory allocation error!\n"); + PR_Error (pr, "PR_AddBuiltin: memory allocation error!"); } 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->numbuiltins * sizeof (builtin_t*)); if (!pr->builtins) - PR_Error (pr, "PR_AddBuiltin: memory allocation error!\n"); + PR_Error (pr, "PR_AddBuiltin: memory allocation error!"); } } else { 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]) - PR_Error (pr, "PR_AddBuiltin: builtin number already exists.\n"); + PR_Error (pr, "PR_AddBuiltin: builtin number already exists."); i = num; } pr->builtins[i] = malloc (sizeof (builtin_t)); diff --git a/libs/gamecode/engine/pr_edict.c b/libs/gamecode/engine/pr_edict.c index 26c5cc973..5198da8c2 100644 --- a/libs/gamecode/engine/pr_edict.c +++ b/libs/gamecode/engine/pr_edict.c @@ -461,7 +461,7 @@ ED_Print (progs_t * pr, edict_t *ed) continue; break; default: - PR_Error (pr, "ED_Print: Unhandled type %d\n", type); + PR_Error (pr, "ED_Print: Unhandled type %d", type); } Sys_Printf ("%s", name); diff --git a/libs/gamecode/engine/pr_exec.c b/libs/gamecode/engine/pr_exec.c index fcbb4682d..0c6dda530 100644 --- a/libs/gamecode/engine/pr_exec.c +++ b/libs/gamecode/engine/pr_exec.c @@ -196,7 +196,7 @@ PR_EnterFunction (progs_t * pr, dfunction_t *f) // save off any locals that the new function steps on c = f->locals; 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], &pr->pr_globals[f->parm_start], @@ -234,7 +234,7 @@ PR_LeaveFunction (progs_t * pr) c = pr->pr_xfunction->locals; pr->localstack_used -= c; 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], &pr->localstack[pr->localstack_used], @@ -481,7 +481,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum) pr->pr_edictareasize)) { pr->pr_xstatement = st - pr->pr_statements; PR_RunError (pr, "Progs attempted to address an out of " - "bounds edict\n"); + "bounds edict"); return; } if (pr_boundscheck->int_val @@ -495,7 +495,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum) pr->progs->entityfields)) { pr->pr_xstatement = st - pr->pr_statements; PR_RunError (pr, "Progs attempted to address an invalid " - "field in an edict\n"); + "field in an edict"); return; } 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_xstatement = st - pr->pr_statements; PR_RunError (pr, "Progs attempted to read an out of " - "bounds edict number\n"); + "bounds edict number"); return; } if (pr_boundscheck->int_val @@ -532,7 +532,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum) pr->progs->entityfields)) { pr->pr_xstatement = st - pr->pr_statements; PR_RunError (pr, "Progs attempted to read an invalid " - "field in an edict\n"); + "field in an edict"); return; } 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_xstatement = st - pr->pr_statements; PR_RunError (pr, "Progs attempted to read an out of " - "bounds edict number\n"); + "bounds edict number"); return; } if (pr_boundscheck->int_val @@ -552,7 +552,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum) || OPB.integer_var + 2 >= pr->progs->entityfields)) { pr->pr_xstatement = st - pr->pr_statements; PR_RunError (pr, "Progs attempted to read an invalid " - "field in an edict\n"); + "field in an edict"); return; } 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 && (OPA.uinteger_var >= pr->progs->numstatements)) { pr->pr_xstatement = st - pr->pr_statements; - PR_RunError (pr, "Invalid jump destination\n"); + PR_RunError (pr, "Invalid jump destination"); return; } st = &pr->pr_statements[OPA.uinteger_var]; @@ -690,7 +690,7 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum) if (pr_boundscheck->int_val && (pointer >= pr->progs->numstatements)) { pr->pr_xstatement = st - pr->pr_statements; - PR_RunError (pr, "Invalid jump destination\n"); + PR_RunError (pr, "Invalid jump destination"); return; } 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) { pr->pr_xstatement = st - pr->pr_statements; 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; } break; diff --git a/libs/gamecode/engine/pr_opcode.c b/libs/gamecode/engine/pr_opcode.c index 4d5154535..464bc8825 100644 --- a/libs/gamecode/engine/pr_opcode.c +++ b/libs/gamecode/engine/pr_opcode.c @@ -296,7 +296,7 @@ check_branch (progs_t *pr, dstatement_t *st, opcode_t *op, short offset) address += offset; 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); } @@ -325,7 +325,7 @@ check_global (progs_t *pr, dstatement_t *st, opcode_t *op, etype_t type, return; error: 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); } @@ -343,7 +343,7 @@ PR_Check_Opcodes (progs_t *pr) op = PR_Opcode (st->op); if (!op) { 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)); } switch (st->op) { diff --git a/libs/gamecode/engine/pr_resolve.c b/libs/gamecode/engine/pr_resolve.c index 9924f45fa..7c5d6b0bc 100644 --- a/libs/gamecode/engine/pr_resolve.c +++ b/libs/gamecode/engine/pr_resolve.c @@ -162,11 +162,15 @@ int PR_ResolveGlobals (progs_t *pr) { char *sym; + ddef_t *def; - if (!(pr->globals.time = (float*)PR_GetGlobalPointer (pr, sym = "time"))) - goto error; - if (!(pr->globals.self = (int*)PR_GetGlobalPointer (pr, sym = "self"))) + if (!(def = PR_FindGlobal (pr, sym = "time"))) 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) goto error; if ((pr->fields.frame = ED_GetFieldIndex (pr, sym = "frame")) == -1) @@ -175,7 +179,7 @@ PR_ResolveGlobals (progs_t *pr) goto error; return 1; error: - Sys_Printf ("%s: undefined symbol: %s", pr->progs_name, sym); + Sys_Printf ("%s: undefined symbol: %s\n", pr->progs_name, sym); return 0; } diff --git a/nq/source/sv_progs.c b/nq/source/sv_progs.c index 39f5bbde1..dd9f8c061 100644 --- a/nq/source/sv_progs.c +++ b/nq/source/sv_progs.c @@ -143,7 +143,6 @@ SV_LoadProgs (void) sv_globals.self = sv_pr_state.globals.self; 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.world = PR_GetGlobalPointer (&sv_pr_state, "world"); (void *) sv_globals.time = PR_GetGlobalPointer (&sv_pr_state, "time");