From 548d3b68f88ebc989f86c382dc856afbcb453fbc Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 13 Mar 2003 18:45:45 +0000 Subject: [PATCH] pr_load.c: PR_RelocateBuiltins must be called before PR_InitRuntime pr_obj.c: don't segfault on broken classes --- libs/gamecode/engine/pr_load.c | 3 +++ libs/gamecode/engine/pr_obj.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/gamecode/engine/pr_load.c b/libs/gamecode/engine/pr_load.c index 4fecaa16a..ce3978669 100644 --- a/libs/gamecode/engine/pr_load.c +++ b/libs/gamecode/engine/pr_load.c @@ -281,6 +281,9 @@ PR_LoadProgs (progs_t *pr, const char *progsname, int edicts, int zone) if (!pr->progs) return; + if (!PR_RelocateBuiltins (pr)) + PR_Error (pr, "unable to load %s", progsname); + if (!PR_ResolveGlobals (pr)) PR_Error (pr, "unable to load %s", progsname); diff --git a/libs/gamecode/engine/pr_obj.c b/libs/gamecode/engine/pr_obj.c index 7028e8839..b00c16bde 100644 --- a/libs/gamecode/engine/pr_obj.c +++ b/libs/gamecode/engine/pr_obj.c @@ -145,8 +145,12 @@ finish_class (progs_t *pr, pr_class_t *class, pointer_t object_ptr) meta->class_pointer = object_ptr; if (class->super_class) { - val = Hash_Find (pr->classes, PR_GetString (pr, - class->super_class)); + const char *super_class = PR_GetString (pr, class->super_class); + const char *class_name = PR_GetString (pr, class->name); + val = Hash_Find (pr->classes, super_class); + if (!val) + PR_Error (pr, "broken class %s: super class %s not found", + class_name, super_class); meta->super_class = val->class_pointer; class->super_class = POINTER_TO_PROG (pr, val); } else {