]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
some cleaning of the model headers, and added bufferend parameter to all model loaders
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 28 Aug 2005 20:41:12 +0000 (20:41 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 28 Aug 2005 20:41:12 +0000 (20:41 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5666 d7cf8633-e32d-0410-b094-e92efae38249

model_alias.c
model_alias.h
model_brush.c
model_brush.h
model_shared.c
model_shared.h
model_sprite.c
model_sprite.h

index 572f038b7becc441de8f3a93e2d8ea3efd35f828..e7e6a1ee117093779855e9ba4523fc90a23f67da 100644 (file)
@@ -419,7 +419,7 @@ static void Mod_BuildAliasSkinsFromSkinFiles(texture_t *skin, skinfile_t *skinfi
 extern void R_Q1BSP_Draw(entity_render_t *ent);
 extern void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs);
 extern void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces, const int *surfacelist);
-void Mod_IDP0_Load(model_t *mod, void *buffer)
+void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int i, j, version, totalskins, skinwidth, skinheight, groupframes, groupskins, numverts;
        float scales, scalet, scale[3], translate[3], interval;
@@ -741,7 +741,7 @@ static void Mod_MD2_ConvertVerts (vec3_t scale, vec3_t translate, trivertx_t *v,
        }
 }
 
-void Mod_IDP2_Load(model_t *mod, void *buffer)
+void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int i, j, k, hashindex, num, numxyz, numst, xyz, st, skinwidth, skinheight, *vertremap, version, end, numverts;
        float *stverts, s, t, scale[3], translate[3];
@@ -985,7 +985,7 @@ void Mod_IDP2_Load(model_t *mod, void *buffer)
        surface->num_vertices = surface->groupmesh->num_vertices;
 }
 
-void Mod_IDP3_Load(model_t *mod, void *buffer)
+void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int i, j, k, version;
        qbyte *data;
@@ -1123,7 +1123,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer)
        Mod_FreeSkinFiles(skinfiles);
 }
 
-void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer)
+void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend)
 {
        zymtype1header_t *pinmodel, *pheader;
        qbyte *pbase;
@@ -1419,7 +1419,7 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer)
        Mem_Free(outtexcoord2f);
 }
 
-void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer)
+void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend)
 {
        dpmheader_t *pheader;
        dpmframe_t *frame;
index 2b69fac964f35d615b0659c1d349e7f8b342bbab..c15d81a3113f441f7be80ae9f87aa4c8439dc0b6 100644 (file)
@@ -116,14 +116,6 @@ typedef struct
        int                     ofs_end;                // end of file
 } md2_t;
 
-extern void Mod_IDP0_Load(struct model_s *mod, void *buffer);
-extern void Mod_IDP2_Load(struct model_s *mod, void *buffer);
-extern void Mod_IDP3_Load(struct model_s *mod, void *buffer);
-extern void Mod_ZYMOTICMODEL_Load(struct model_s *mod, void *buffer);
-extern void Mod_DARKPLACESMODEL_Load(struct model_s *mod, void *buffer);
-
-extern void Mod_AliasInit(void);
-
 #include "model_zymotic.h"
 
 #include "model_dpmodel.h"
@@ -232,10 +224,5 @@ typedef struct aliasbone_s
 }
 aliasbone_t;
 
-struct frameblend_s;
-void Mod_Alias_GetMesh_Vertex3f(const struct model_s *model, const struct frameblend_s *frameblend, const struct surfmesh_s *mesh, float *out3f);
-int Mod_Alias_GetTagMatrix(const struct model_s *model, int poseframe, int tagindex, matrix4x4_t *outmatrix);
-int Mod_Alias_GetTagIndexForName(const struct model_s *model, unsigned int skin, const char *tagname);
-
 #endif
 
index 253edee91523b2654a1b9e9919db7dc7f209f8c4..4cca197c43c502d12328c52f539cbebe0ba1e3a1 100644 (file)
@@ -2917,7 +2917,7 @@ extern void R_Q1BSP_Draw(entity_render_t *ent);
 extern void R_Q1BSP_GetLightInfo(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, qbyte *outleafpvs, int *outnumleafspointer, int *outsurfacelist, qbyte *outsurfacepvs, int *outnumsurfacespointer);
 extern void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs);
 extern void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolor, int numsurfaces, const int *surfacelist);
-void Mod_Q1BSP_Load(model_t *mod, void *buffer)
+void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int i, j, k;
        dheader_t *header;
@@ -3539,7 +3539,7 @@ static void Mod_Q2BSP_LoadModels(lump_t *l)
 */
 }
 
-void static Mod_Q2BSP_Load(model_t *mod, void *buffer)
+void static Mod_Q2BSP_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int i;
        q2dheader_t *header;
@@ -5412,7 +5412,7 @@ void Mod_Q3BSP_RecursiveFindNumLeafs(mnode_t *node)
                loadmodel->brush.num_leafs = numleafs;
 }
 
-void Mod_Q3BSP_Load(model_t *mod, void *buffer)
+void Mod_Q3BSP_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int i, j, numshadowmeshtriangles;
        q3dheader_t *header;
@@ -5568,18 +5568,18 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer)
        }
 }
 
-void Mod_IBSP_Load(model_t *mod, void *buffer)
+void Mod_IBSP_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int i = LittleLong(((int *)buffer)[1]);
        if (i == Q3BSPVERSION)
-               Mod_Q3BSP_Load(mod,buffer);
+               Mod_Q3BSP_Load(mod,buffer, bufferend);
        else if (i == Q2BSPVERSION)
-               Mod_Q2BSP_Load(mod,buffer);
+               Mod_Q2BSP_Load(mod,buffer, bufferend);
        else
                Host_Error("Mod_IBSP_Load: unknown/unsupported version %i\n", i);
 }
 
-void Mod_MAP_Load(model_t *mod, void *buffer)
+void Mod_MAP_Load(model_t *mod, void *buffer, void *bufferend)
 {
        Host_Error("Mod_MAP_Load: not yet implemented\n");
 }
index 1bf8be8d355cdc1a5a79503e132c40e86b416263..f2de302ca3a16eeabd51729ae52e126f112c65c3 100644 (file)
@@ -211,12 +211,6 @@ typedef struct mlight_s
 }
 mlight_t;
 
-struct model_s;
-void Mod_Q1BSP_Load(struct model_s *mod, void *buffer);
-void Mod_IBSP_Load(struct model_s *mod, void *buffer);
-void Mod_MAP_Load(struct model_s *mod, void *buffer);
-void Mod_BrushInit(void);
-
 // Q2 bsp stuff
 
 #define Q2BSPVERSION   38
index b0de85635ea7cfca72ec6d62e7775f2c2e52264c..7dd2e45fab19e444a5a2ceab93389cde7fdd49d2 100644 (file)
@@ -189,19 +189,20 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolea
 
        if (buf)
        {
+               char *bufend = buf + fs_filesize;
                num = LittleLong(*((int *)buf));
                // call the apropriate loader
                loadmodel = mod;
-                    if (!memcmp(buf, "IDPO", 4)) Mod_IDP0_Load(mod, buf);
-               else if (!memcmp(buf, "IDP2", 4)) Mod_IDP2_Load(mod, buf);
-               else if (!memcmp(buf, "IDP3", 4)) Mod_IDP3_Load(mod, buf);
-               else if (!memcmp(buf, "IDSP", 4)) Mod_IDSP_Load(mod, buf);
-               else if (!memcmp(buf, "IDS2", 4)) Mod_IDS2_Load(mod, buf);
-               else if (!memcmp(buf, "IBSP", 4)) Mod_IBSP_Load(mod, buf);
-               else if (!memcmp(buf, "ZYMOTICMODEL", 12)) Mod_ZYMOTICMODEL_Load(mod, buf);
-               else if (!memcmp(buf, "DARKPLACESMODEL", 16)) Mod_DARKPLACESMODEL_Load(mod, buf);
-               else if (strlen(mod->name) >= 4 && !strcmp(mod->name - 4, ".map")) Mod_MAP_Load(mod, buf);
-               else if (num == BSPVERSION || num == 30) Mod_Q1BSP_Load(mod, buf);
+                    if (!memcmp(buf, "IDPO", 4)) Mod_IDP0_Load(mod, buf, bufend);
+               else if (!memcmp(buf, "IDP2", 4)) Mod_IDP2_Load(mod, buf, bufend);
+               else if (!memcmp(buf, "IDP3", 4)) Mod_IDP3_Load(mod, buf, bufend);
+               else if (!memcmp(buf, "IDSP", 4)) Mod_IDSP_Load(mod, buf, bufend);
+               else if (!memcmp(buf, "IDS2", 4)) Mod_IDS2_Load(mod, buf, bufend);
+               else if (!memcmp(buf, "IBSP", 4)) Mod_IBSP_Load(mod, buf, bufend);
+               else if (!memcmp(buf, "ZYMOTICMODEL", 12)) Mod_ZYMOTICMODEL_Load(mod, buf, bufend);
+               else if (!memcmp(buf, "DARKPLACESMODEL", 16)) Mod_DARKPLACESMODEL_Load(mod, buf, bufend);
+               else if (strlen(mod->name) >= 4 && !strcmp(mod->name - 4, ".map")) Mod_MAP_Load(mod, buf, bufend);
+               else if (num == BSPVERSION || num == 30) Mod_Q1BSP_Load(mod, buf, bufend);
                else Con_Printf("Mod_LoadModel: model \"%s\" is of unknown/unsupported type\n", mod->name);
                Mem_Free(buf);
        }
index eaed415f089ec45ad2344adf354b321e92926f6c..c61a03d1ba47d834e0c1ac3ae36e70fa1627723a 100644 (file)
@@ -578,10 +578,6 @@ void Mod_ShadowMesh_Free(shadowmesh_t *mesh);
 int Mod_LoadSkinFrame(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture);
 int Mod_LoadSkinFrame_Internal(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture, qbyte *skindata, int width, int height);
 
-// used for talking to the QuakeC mainly
-int Mod_Q1BSP_NativeContentsFromSuperContents(struct model_s *model, int supercontents);
-int Mod_Q1BSP_SuperContentsFromNativeContents(struct model_s *model, int nativecontents);
-
 extern cvar_t r_mipskins;
 
 typedef struct skinfileitem_s
@@ -606,5 +602,33 @@ int Mod_CountSkinFiles(skinfile_t *skinfile);
 void Mod_SnapVertices(int numcomponents, int numvertices, float *vertices, float snap);
 int Mod_RemoveDegenerateTriangles(int numtriangles, const int *inelement3i, int *outelement3i, const float *vertex3f);
 
+// bsp models
+void Mod_BrushInit(void);
+// used for talking to the QuakeC mainly
+int Mod_Q1BSP_NativeContentsFromSuperContents(struct model_s *model, int supercontents);
+int Mod_Q1BSP_SuperContentsFromNativeContents(struct model_s *model, int nativecontents);
+
+// alias models
+struct frameblend_s;
+void Mod_AliasInit(void);
+void Mod_Alias_GetMesh_Vertex3f(const model_t *model, const struct frameblend_s *frameblend, const struct surfmesh_s *mesh, float *out3f);
+int Mod_Alias_GetTagMatrix(const model_t *model, int poseframe, int tagindex, matrix4x4_t *outmatrix);
+int Mod_Alias_GetTagIndexForName(const model_t *model, unsigned int skin, const char *tagname);
+
+// sprite models
+void Mod_SpriteInit(void);
+
+// loaders
+void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IBSP_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_MAP_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend);
+void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend);
+
 #endif // MODEL_SHARED_H
 
index 7d2960f5718476952fe326e8da314cb056ddaf8e..6e94c8b42e1a5587d7fc33e55d6d0d1c8362c51c 100644 (file)
@@ -204,7 +204,7 @@ static void Mod_Sprite_SharedSetup(const qbyte *datapointer, int version, const
 }
 
 extern void R_Model_Sprite_Draw(entity_render_t *ent);
-void Mod_IDSP_Load(model_t *mod, const void *buffer)
+void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int version;
        const qbyte *datapointer;
@@ -317,12 +317,12 @@ void Mod_IDSP_Load(model_t *mod, const void *buffer)
 }
 
 
-void Mod_IDS2_Load(model_t *mod, const void *buffer)
+void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend)
 {
        int i, version;
        const dsprite2_t *pinqsprite;
        float modelradius;
-       
+
        loadmodel->type = mod_sprite;
        loadmodel->flags2 = EF_FULLBRIGHT;
 
index 12ef2414add28d09b484ad0905e7e68f5b6d4f6b..355385052e81e6842192c64a7b7edcffeb76dcb0 100644 (file)
@@ -38,9 +38,5 @@ typedef struct mspriteframe_s
        rtexture_t *texture, *fogtexture;
 } mspriteframe_t;
 
-extern void Mod_IDSP_Load(struct model_s *mod, const void *buffer);
-extern void Mod_IDS2_Load(struct model_s *mod, const void *buffer);
-extern void Mod_SpriteInit(void);
-
 #endif