Fix bsp2 loading.

Just some problems with the handling of extended bsp29 files. I'm not
quite happy with the code, but it will do for now.
This commit is contained in:
Bill Currie 2012-09-08 09:41:00 +09:00
parent cfb856b9cf
commit 45c48a6215

View file

@ -600,10 +600,13 @@ Mod_LoadNodes (bsp_t *bsp)
for (j = 0; j < 2; j++) {
p = in->children[j];
// this check is for extended bsp 29 files
if (p < count) {
if (p >= 0 && p < count) {
out->children[j] = loadmodel->nodes + p;
} else {
p = 65535 - p; //NOTE this uses 65535 intentionally, -1 is leaf
if (p >= count)
p = 65535 - p; //NOTE 65535 is intentional, -1 is leaf
else
p = ~p;
if (p < loadmodel->numleafs) {
out->children[j] = (mnode_t *) (loadmodel->leafs + p);
} else {
@ -632,9 +635,6 @@ Mod_LoadLeafs (bsp_t *bsp)
count = bsp->numleafs;
out = Hunk_AllocName (count * sizeof (*out), loadname);
if (count > 32767)
Sys_Error ("%i leafs exceeds limit of 32767.\n", count);
loadmodel->leafs = out;
loadmodel->numleafs = count;
// snprintf(s, sizeof (s), "maps/%s.bsp",