From 75afd36f8da83a849f09c36e48e8cd733ad14a8d Mon Sep 17 00:00:00 2001
From: havoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Sun, 16 Apr 2006 11:37:07 +0000
Subject: [PATCH] fix crash when loading .dpm models

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6297 d7cf8633-e32d-0410-b094-e92efae38249
---
 model_alias.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/model_alias.c b/model_alias.c
index d8ebba5b..beb9b00f 100644
--- a/model_alias.c
+++ b/model_alias.c
@@ -1524,15 +1524,14 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend)
 	meshtriangles = 0;
 	numvertexboneweights = 0;
 
-	// load the meshes now
+	// gather combined statistics from the meshes
 	dpmmesh = (dpmmesh_t *) (pbase + pheader->ofs_meshs);
-	for (i = 0;i < loadmodel->num_surfaces;i++)
+	for (i = 0;i < (int)pheader->num_meshs;i++)
 	{
 		int numverts = BigLong(dpmmesh->num_verts);
 		meshvertices += numverts;;
 		meshtriangles += BigLong(dpmmesh->num_tris);
 
-		// to find out how many weights exist we two a two-stage load...
 		data = (unsigned char *) (pbase + BigLong(dpmmesh->ofs_verts));
 		for (j = 0;j < numverts;j++)
 		{
-- 
2.39.5