/* ================= Mod_LoadBrushModel ================= */ void Mod_LoadBrushModel (model_t *mod, void *buffer) { int i, j; dheader_t *header; dmodel_t *bm; loadmodel->type = mod_brush; header = (dheader_t *)buffer; i = LittleLong (header->version); if (i != BSPVERSION) Sys_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION); // swap all the lumps mod_base = (byte *)header; for (i=0 ; i<sizeof(dheader_t)/4 ; i++) ((int *)header)[i] = LittleLong ( ((int *)header)[i]); // load into heap Mod_LoadVertexes (&header->lumps[LUMP_VERTEXES]); Mod_LoadEdges (&header->lumps[LUMP_EDGES]); Mod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]); Mod_LoadTextures (&header->lumps[LUMP_TEXTURES]); Mod_LoadLighting (&header->lumps[LUMP_LIGHTING]); Mod_LoadPlanes (&header->lumps[LUMP_PLANES]); Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]); Mod_LoadFaces (&header->lumps[LUMP_FACES]); Mod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]); Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]); Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]); Mod_LoadNodes (&header->lumps[LUMP_NODES]); Mod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]); Mod_LoadEntities (&header->lumps[LUMP_ENTITIES]); Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]); Mod_MakeHull0 (); mod->numframes = 2; // regular and alternate animation // // set up the submodels (FIXME: this is confusing) // for (i=0 ; i<mod->numsubmodels ; i++) { bm = &mod->submodels[i]; mod->hulls[0].firstclipnode = bm->headnode[0]; for (j=1 ; j<MAX_MAP_HULLS ; j++) { mod->hulls[j].firstclipnode = bm->headnode[j]; mod->hulls[j].lastclipnode = mod->numclipnodes-1; } mod->firstmodelsurface = bm->firstface; mod->nummodelsurfaces = bm->numfaces; VectorCopy (bm->maxs, mod->maxs); VectorCopy (bm->mins, mod->mins); mod->radius = RadiusFromBounds (mod->mins, mod->maxs); mod->numleafs = bm->visleafs; if (i < mod->numsubmodels-1) { // duplicate the basic information char name[10]; sprintf (name, "*%i", i+1); loadmodel = Mod_FindName (name); *loadmodel = *mod; strcpy (loadmodel->name, name); mod = loadmodel; } } }
/* ================= Mod_LoadBrushModel ================= */ void Mod_LoadBrushModel (model_t *mod, void *buffer) { int i, j; dheader_t *header; dmodel_t *bm; loadmodel->type = mod_brush; header = (dheader_t *)buffer; i = LittleLong (header->version); if (i != BSPVERSION) SV_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION); // swap all the lumps mod_base = (byte *)header; for (i=0 ; i<sizeof(dheader_t)/4 ; i++) ((int *)header)[i] = LittleLong ( ((int *)header)[i]); // load into heap mod->checksum = 0; mod->checksum2 = 0; // checksum all of the map, except for entities for (i = 0; i < HEADER_LUMPS; i++) { if (i == LUMP_ENTITIES) continue; mod->checksum ^= LittleLong(Com_BlockChecksum(mod_base + header->lumps[i].fileofs, header->lumps[i].filelen)); if (i == LUMP_VISIBILITY || i == LUMP_LEAFS || i == LUMP_NODES) continue; mod->checksum2 ^= LittleLong(Com_BlockChecksum(mod_base + header->lumps[i].fileofs, header->lumps[i].filelen)); } Mod_LoadPlanes (&header->lumps[LUMP_PLANES]); Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]); Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]); Mod_LoadNodes (&header->lumps[LUMP_NODES]); Mod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]); Mod_LoadEntities (&header->lumps[LUMP_ENTITIES]); Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]); Mod_MakeHull0 (); mod->numframes = 2; // regular and alternate animation // // set up the submodels (FIXME: this is confusing) // for (i=0 ; i<mod->numsubmodels ; i++) { bm = &mod->submodels[i]; mod->hulls[0].firstclipnode = bm->headnode[0]; for (j=1 ; j<MAX_MAP_HULLS ; j++) { mod->hulls[j].firstclipnode = bm->headnode[j]; mod->hulls[j].lastclipnode = mod->numclipnodes-1; } VectorCopy (bm->maxs, mod->maxs); VectorCopy (bm->mins, mod->mins); mod->numleafs = bm->visleafs; if (i < mod->numsubmodels-1) { // duplicate the basic information char name[10]; sprintf (name, "*%i", i+1); loadmodel = Mod_FindName (name); *loadmodel = *mod; strcpy (loadmodel->name, name); mod = loadmodel; } } }
void Mod_LoadBrushModel (model_t *mod, void *buffer, loadedfile_t *brush_fileinfo) // 2001-09-12 .ENT support by Maddes { int i, j; dheader_t *header; dmodel_t *bm; int fhandle; // 2001-12-28 .VIS support by Maddes if (r_coloredlights->value == 2){ coloredlights = 1; // normal light quality if (hqlite) coloredmethod = 0; // don't do lookup stuff else coloredmethod = 1; // do lookup stuff because we don't have a high quality table. :( } else if (r_coloredlights->value == 1){ coloredlights = 1; // normal light quality coloredmethod = 1; // do lookup stuff } else if (r_coloredlights->value == 3){ coloredlights = 2; // dithered light quality coloredmethod = 0; // don't do lookup stuff } else { coloredlights = 0; // mono lights coloredmethod = 0; // don't do lookup stuff } truecolor = (int)r_truecolor->value; // sanity check lowworld = (int)r_lowworld->value; // sanity check ditheredrend = (int)r_dither->value; // sanity checking also // FogTableRefresh(); if (nolookups){ coloredlights = 0; // DON'T ALLOW THESE THINGS!!! ditheredrend = 0; } // if(overbrights != r_overbrightBits->value || (fullbrights != (int)r_fullbrights->value)){ // overbrights = r_overbrightBits->value; // fullbrights = r_fullbrights->value; // GrabColorMap(); // } loadmodel->type = mod_brush; header = (dheader_t *)buffer; i = LittleLong (header->version); if ((i != BSPVERSION) && (i != BSPVERSIONHL) && (i != BSPVERSION91)) // 2001-12-16 No crash on wrong BSP version by MrG start // Sys_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION); { Con_Printf("Mod_LoadBrushModel: %s has wrong version number (%i should be 28, 29 or 30)", mod->name, i, BSPVERSION); mod->numvertexes=-1; // HACK - incorrect BSP version is no longer fatal return; } // 2001-12-16 No crash on wrong BSP version by MrG end if (i == BSPVERSIONHL) loadmodel->fromgame = fg_halflife; if (i == BSPVERSION91) loadmodel->fromgame = fg_quakeold; // swap all the lumps mod_base = (byte *)header; for (i=0 ; i<sizeof(dheader_t)/4 ; i++) ((int *)header)[i] = LittleLong ( ((int *)header)[i]); // load into heap Mod_LoadVertexes (&header->lumps[LUMP_VERTEXES]); Mod_LoadEdges (&header->lumps[LUMP_EDGES]); Mod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]); if (truecolor) Mod_LoadTextures32 (&header->lumps[LUMP_TEXTURES]); else Mod_LoadTextures (&header->lumps[LUMP_TEXTURES]); Mod_LoadLighting (&header->lumps[LUMP_LIGHTING]); Mod_LoadPlanes (&header->lumps[LUMP_PLANES]); Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]); Mod_LoadFaces (&header->lumps[LUMP_FACES]); Mod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]); // 2001-12-28 .VIS support by Maddes start loadmodel->visdata = NULL; loadmodel->leafs = NULL; loadmodel->numleafs = 0; fhandle = Mod_FindExternalVIS (brush_fileinfo); if (fhandle >= 0) { Mod_LoadExternalVisibility (fhandle); Mod_LoadExternalLeafs (fhandle); } if ((loadmodel->visdata == NULL) || (loadmodel->leafs == NULL) || (loadmodel->numleafs == 0)) { if (fhandle >= 0) { Con_Printf("External VIS data are invalid!!!\n"); } // 2001-12-28 .VIS support by Maddes end Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]); Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]); // 2001-12-28 .VIS support by Maddes start } if (fhandle >= 0) { COM_CloseFile(fhandle); } // 2001-12-28 .VIS support by Maddes end Mod_LoadNodes (&header->lumps[LUMP_NODES]); Mod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]); Mod_LoadEntities (&header->lumps[LUMP_ENTITIES], brush_fileinfo); // 2001-09-12 .ENT support by Maddes Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]); Mod_MakeHull0 (); mod->numframes = 2; // regular and alternate animation #ifndef GLQUAKE mod->flags = 0; #endif // // set up the submodels (FIXME: this is confusing) // for (i=0 ; i<mod->numsubmodels ; i++) { bm = &mod->submodels[i]; mod->hulls[0].firstclipnode = bm->headnode[0]; for (j=1 ; j<MAX_MAP_HULLS ; j++) { mod->hulls[j].firstclipnode = bm->headnode[j]; mod->hulls[j].lastclipnode = mod->numclipnodes-1; } mod->firstmodelsurface = bm->firstface; mod->nummodelsurfaces = bm->numfaces; VectorCopy (bm->maxs, mod->maxs); VectorCopy (bm->mins, mod->mins); mod->radius = RadiusFromBounds (mod->mins, mod->maxs); mod->numleafs = bm->visleafs; if (i < mod->numsubmodels-1) { // duplicate the basic information char name[10]; sprintf (name, "*%i", i+1); loadmodel = Mod_FindName (name); *loadmodel = *mod; strcpy (loadmodel->name, name); mod = loadmodel; } } // if (sv.worldmodel && !lightingavailable) // LoadPointLighting(sv.worldmodel->entities); }
/* ================= Mod_LoadBrushModel ================= */ void Mod_LoadBrushModel (model_t *mod, void *buffer) { int i, j, maxhulls; dheader_t *header; mmodel_t *bm; extern cvar_t host_mapname; loadmodel->type = mod_brush; header = (dheader_t *)buffer; #ifdef BSP23TEST mod_bspversion = #endif i = LittleLong (header->version); if ((i != BSPVERSION) && (i != BSPVERSION-1)) // JDH: bsps from v0.8 beta work fine too // Sys_Error ("Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION); #ifdef BSP23TEST if (i != 23) #endif { Con_Printf ("Mod_LoadBrushModel: %s has wrong version number %i (should be %i)\n", mod->name, i, BSPVERSION); mod->numsubmodels = -1; // HACK - incorrect BSP version is no longer fatal return; } loadmodel->isworldmodel = COM_FilenamesEqual (loadmodel->name, va("maps/%s.bsp", host_mapname.string)); if (loadmodel->isworldmodel) mod_oversized = false; // swap all the lumps mod_base = (byte *)header; #ifdef BSP23TEST if (mod_bspversion == 23) { for (i=0 ; i<sizeof(dheader_t)/4 - 8 ; i++) ((int *)header)[i] = LittleLong (((int *)header)[i]); Mod_LoadPlanes (&header->lumps[LUMP_PLANES]); #ifndef RQM_SV_ONLY Mod_LoadVertexes (&header->lumps[LUMP_VERTEXES]); Mod_LoadEdges (&header->lumps[LUMP_EDGES-1]); Mod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES-1]); Mod_LoadTextures (&header->lumps[LUMP_TEXTURES]); Mod_LoadLighting (&header->lumps[LUMP_LIGHTING-1]); // Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]); Mod_LoadFaces (&header->lumps[LUMP_FACES-1]); Mod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES-1]); #endif Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]); Mod_LoadLeafs (&header->lumps[LUMP_LEAFS-1]); Mod_LoadNodes (&header->lumps[LUMP_NODES]); Mod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES-1]); Mod_LoadEntities (&header->lumps[LUMP_ENTITIES]); Mod_LoadSubmodels (&header->lumps[LUMP_MODELS-1]); } else #endif { for (i=0 ; i<sizeof(dheader_t)/4 ; i++) ((int *)header)[i] = LittleLong (((int *)header)[i]); // load into heap Mod_LoadPlanes (&header->lumps[LUMP_PLANES]); #ifndef RQM_SV_ONLY Mod_LoadVertexes (&header->lumps[LUMP_VERTEXES]); Mod_LoadEdges (&header->lumps[LUMP_EDGES]); Mod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]); Mod_LoadTextures (&header->lumps[LUMP_TEXTURES]); Mod_LoadLighting (&header->lumps[LUMP_LIGHTING]); Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]); Mod_LoadFaces (&header->lumps[LUMP_FACES]); Mod_LoadMarksurfaces (&header->lumps[LUMP_MARKSURFACES]); #endif Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]); Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]); Mod_LoadNodes (&header->lumps[LUMP_NODES]); Mod_LoadClipnodes (&header->lumps[LUMP_CLIPNODES]); Mod_LoadEntities (&header->lumps[LUMP_ENTITIES]); Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]); } Mod_MakeHull0 (); if (loadmodel->isworldmodel && mod_oversized) Mod_RecalcNodeBounds (); #ifndef RQM_SV_ONLY mod->numframes = 2; // regular and alternate animation #endif #ifdef HEXEN2_SUPPORT if (hexen2) maxhulls = MAX_MAP_HULLS_H2; else #endif maxhulls = MAX_MAP_HULLS; // set up the submodels (FIXME: this is confusing) for (i = 0 ; i < mod->numsubmodels ; i++) { bm = &mod->submodels[i]; mod->hulls[0].firstclipnode = bm->headnode[0]; for (j=1 ; j<maxhulls ; j++) { mod->hulls[j].firstclipnode = bm->headnode[j]; mod->hulls[j].lastclipnode = mod->numclipnodes - 1; } mod->firstmodelsurface = bm->firstface; mod->nummodelsurfaces = bm->numfaces; VectorCopy (bm->maxs, mod->maxs); VectorCopy (bm->mins, mod->mins); #ifndef RQM_SV_ONLY mod->radius = RadiusFromBounds (mod->mins, mod->maxs); #endif mod->numleafs = bm->visleafs; if (i < mod->numsubmodels - 1) { // duplicate the basic information char name[10]; sprintf (name, "*%i", i+1); loadmodel = Mod_FindName (name); *loadmodel = *mod; Q_strcpy (loadmodel->name, name, sizeof(loadmodel->name)); mod = loadmodel; } } /**********JDH************/ // can't do this in Mod_LoadLeafs, since the "loadmodel" at that time // is not what becomes the worldmodel /*if ( origmod->isworldmodel ) { Mod_DecompressVis( mod ); }*/ /**********JDH************/ }