implemented loading of the RMQe variant of BSP2 ("2PSB")
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 28 Feb 2013 00:21:01 +0000 (00:21 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 28 Feb 2013 00:21:01 +0000 (00:21 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11912 d7cf8633-e32d-0410-b094-e92efae38249

console.c
model_brush.c
model_shared.h

index a54cd62..983786d 100644 (file)
--- 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;p<min;p++)
index 702e115..b8e64da 100644 (file)
@@ -2769,7 +2769,7 @@ static void Mod_Q1BSP_LoadNodes(sizebuf_t *sb)
 {
        int                     i, j, count, p, child[2];
        mnode_t         *out;
-       size_t structsize = loadmodel->brush.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;
        }
 
index dc8177a..4a50833 100644 (file)
@@ -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;