From: havoc Date: Thu, 28 Feb 2013 00:21:01 +0000 (+0000) Subject: implemented loading of the RMQe variant of BSP2 ("2PSB") X-Git-Tag: xonotic-v0.8.0~96^2~127 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d67837d6d6ba53a1cc1c20cc8fad1bf96a4cdba2;p=xonotic%2Fdarkplaces.git implemented loading of the RMQe variant of BSP2 ("2PSB") git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11912 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/console.c b/console.c index a54cd629..983786d1 100644 --- a/console.c +++ b/console.c @@ -2039,11 +2039,14 @@ qboolean GetMapList (const char *s, char *completedname, int completednamebuffer const char *data = NULL; char keyname[64]; char entfilename[MAX_QPATH]; - strlcpy(message, "^1**ERROR**^7", sizeof(message)); + char desc[64]; + desc[0] = 0; + strlcpy(message, "^1ERROR: open failed^7", sizeof(message)); p = 0; f = FS_OpenVirtualFile(t->filenames[i], true); if(f) { + strlcpy(message, "^1ERROR: not a known map format^7", sizeof(message)); memset(buf, 0, 1024); FS_Read(f, buf, 1024); if (!memcmp(buf, "IBSP", 4)) @@ -2054,21 +2057,46 @@ qboolean GetMapList (const char *s, char *completedname, int completednamebuffer q3dheader_t *header = (q3dheader_t *)buf; lumpofs = LittleLong(header->lumps[Q3LUMP_ENTITIES].fileofs); lumplen = LittleLong(header->lumps[Q3LUMP_ENTITIES].filelen); + dpsnprintf(desc, sizeof(desc), "Q3BSP%i", p); } else if (p == Q2BSPVERSION) { q2dheader_t *header = (q2dheader_t *)buf; lumpofs = LittleLong(header->lumps[Q2LUMP_ENTITIES].fileofs); lumplen = LittleLong(header->lumps[Q2LUMP_ENTITIES].filelen); + dpsnprintf(desc, sizeof(desc), "Q2BSP%i", p); } + else + dpsnprintf(desc, sizeof(desc), "IBSP%i", p); } - else if((p = BuffLittleLong(buf)) == BSPVERSION || p == 30 || !memcmp(buf, "BSP2", 4)) + else if (BuffLittleLong(buf) == BSPVERSION) { lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES); lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4); + dpsnprintf(desc, sizeof(desc), "BSP29"); + } + else if (BuffLittleLong(buf) == 30) + { + lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES); + lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4); + dpsnprintf(desc, sizeof(desc), "BSPHL"); + } + else if (!memcmp(buf, "BSP2", 4)) + { + lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES); + lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4); + dpsnprintf(desc, sizeof(desc), "BSP2"); + } + else if (!memcmp(buf, "2PSB", 4)) + { + lumpofs = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES); + lumplen = BuffLittleLong(buf + 4 + 8 * LUMP_ENTITIES + 4); + dpsnprintf(desc, sizeof(desc), "BSP2RMQe"); } else - p = 0; + { + dpsnprintf(desc, sizeof(desc), "unknown%i", BuffLittleLong(buf)); + } strlcpy(entfilename, t->filenames[i], sizeof(entfilename)); memcpy(entfilename + strlen(entfilename) - 4, ".ent", 5); entities = (char *)FS_LoadFile(entfilename, tempmempool, true, NULL); @@ -2116,15 +2144,7 @@ qboolean GetMapList (const char *s, char *completedname, int completednamebuffer if(f) FS_Close(f); *(t->filenames[i]+len[i]+5) = 0; - switch(p) - { - case Q3BSPVERSION: strlcpy((char *)buf, "Q3", sizeof(buf));break; - case Q2BSPVERSION: strlcpy((char *)buf, "Q2", sizeof(buf));break; - case BSPVERSION: strlcpy((char *)buf, "Q1", sizeof(buf));break; - case 30: strlcpy((char *)buf, "HL", sizeof(buf));break; - default: strlcpy((char *)buf, "??", sizeof(buf));break; - } - Con_Printf("%16s (%s) %s\n", t->filenames[i]+5, buf, message); + Con_Printf("%16s (%-8s) %s\n", t->filenames[i]+5, desc, message); } Con_Print("\n"); for(p=o;pbrush.isbsp2 ? 44 : 24; + size_t structsize = loadmodel->brush.isbsp2rmqe ? 32 : (loadmodel->brush.isbsp2 ? 44 : 24); if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadNodes: funny lump size in %s",loadmodel->name); @@ -2786,7 +2786,20 @@ static void Mod_Q1BSP_LoadNodes(sizebuf_t *sb) p = MSG_ReadLittleLong(sb); out->plane = loadmodel->brush.data_planes + p; - if (loadmodel->brush.isbsp2) + if (loadmodel->brush.isbsp2rmqe) + { + child[0] = MSG_ReadLittleLong(sb); + child[1] = MSG_ReadLittleLong(sb); + out->mins[0] = MSG_ReadLittleShort(sb); + out->mins[1] = MSG_ReadLittleShort(sb); + out->mins[2] = MSG_ReadLittleShort(sb); + out->maxs[0] = MSG_ReadLittleShort(sb); + out->maxs[1] = MSG_ReadLittleShort(sb); + out->maxs[2] = MSG_ReadLittleShort(sb); + out->firstsurface = MSG_ReadLittleLong(sb); + out->numsurfaces = MSG_ReadLittleLong(sb); + } + else if (loadmodel->brush.isbsp2) { child[0] = MSG_ReadLittleLong(sb); child[1] = MSG_ReadLittleLong(sb); @@ -2860,7 +2873,7 @@ static void Mod_Q1BSP_LoadLeafs(sizebuf_t *sb) { mleaf_t *out; int i, j, count, p, firstmarksurface, nummarksurfaces; - size_t structsize = loadmodel->brush.isbsp2 ? 44 : 28; + size_t structsize = loadmodel->brush.isbsp2rmqe ? 32 : (loadmodel->brush.isbsp2 ? 44 : 28); if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadLeafs: funny lump size in %s",loadmodel->name); @@ -2894,7 +2907,19 @@ static void Mod_Q1BSP_LoadLeafs(sizebuf_t *sb) Mod_Q1BSP_DecompressVis(loadmodel->brushq1.data_compressedpvs + p, loadmodel->brushq1.data_compressedpvs + loadmodel->brushq1.num_compressedpvs, loadmodel->brush.data_pvsclusters + out->clusterindex * loadmodel->brush.num_pvsclusterbytes, loadmodel->brush.data_pvsclusters + (out->clusterindex + 1) * loadmodel->brush.num_pvsclusterbytes); } - if (loadmodel->brush.isbsp2) + if (loadmodel->brush.isbsp2rmqe) + { + out->mins[0] = MSG_ReadLittleShort(sb); + out->mins[1] = MSG_ReadLittleShort(sb); + out->mins[2] = MSG_ReadLittleShort(sb); + out->maxs[0] = MSG_ReadLittleShort(sb); + out->maxs[1] = MSG_ReadLittleShort(sb); + out->maxs[2] = MSG_ReadLittleShort(sb); + + firstmarksurface = MSG_ReadLittleLong(sb); + nummarksurfaces = MSG_ReadLittleLong(sb); + } + else if (loadmodel->brush.isbsp2) { out->mins[0] = MSG_ReadLittleFloat(sb); out->mins[1] = MSG_ReadLittleFloat(sb); @@ -3757,13 +3782,18 @@ void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend) mod->brush.ishlbsp = true; mod->modeldatatypestring = "HLBSP"; break; + case ('2' + 'P' * 256 + 'S' * 65536 + 'B' * 16777216): + mod->brush.isbsp2 = true; + mod->brush.isbsp2rmqe = true; // like bsp2 except leaf/node bounds are 16bit (unexpanded) + mod->modeldatatypestring = "Q1BSP2rmqe"; + break; case ('B' + 'S' * 256 + 'P' * 65536 + '2' * 16777216): mod->brush.isbsp2 = true; mod->modeldatatypestring = "Q1BSP2"; break; default: mod->modeldatatypestring = "Unknown BSP"; - Host_Error("Mod_Q1BSP_Load: %s has wrong version number %i: supported versions are 29 (Quake), 30 (Half-Life), \"BSP2\"", mod->name, i); + Host_Error("Mod_Q1BSP_Load: %s has wrong version number %i: supported versions are 29 (Quake), 30 (Half-Life), \"BSP2\" or \"2PSB\" (rmqe)", mod->name, i); return; } diff --git a/model_shared.h b/model_shared.h index dc8177ae..4a50833f 100644 --- a/model_shared.h +++ b/model_shared.h @@ -743,7 +743,9 @@ typedef struct model_brush_s { // true if this model is a HalfLife .bsp file qboolean ishlbsp; - // true if this model is a BSP2 .bsp file (expanded 32bit bsp format for DarkPlaces, RMQ, others?) + // true if this model is a BSP2rmqe .bsp file (expanded 32bit bsp format for rmqe) + qboolean isbsp2rmqe; + // true if this model is a BSP2 .bsp file (expanded 32bit bsp format for DarkPlaces, others?) qboolean isbsp2; // string of entity definitions (.map format) char *entities;