[PATCH] Fix sprite loading code again

Okay, so the mod->cache.data pointer is still needed by the sprite drawing
code. Just make sure we set it back to NULL when we clear the models
again. This should probably be done differently eventually (don't like
bypassing the Cache_Alloc/Free functions...)

diff -urN -X exclude a/common/gl_model.c head/common/gl_model.c
--- a/common/gl_model.c	2006-06-10 18:57:16.000000000 +0930
+++ head/common/gl_model.c	2006-06-11 20:33:58.000000000 +0930
@@ -178,9 +178,16 @@
     int i;
     model_t *mod;
 
-    for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
+    for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++) {
 	if (mod->type != mod_alias)
 	    mod->needload = true;
+	/*
+	 * FIXME: sprites use the cache data pointer for their own purposes,
+	 *        bypassing the Cache_Alloc/Free functions.
+	 */
+	if (mod->type == mod_sprite)
+	    mod->cache.data = NULL;
+    }
 }
 
 /*
diff -urN -X exclude a/common/model.c head/common/model.c
--- a/common/model.c	2006-06-10 20:36:00.000000000 +0930
+++ head/common/model.c	2006-06-11 20:29:55.000000000 +0930
@@ -172,9 +172,16 @@
     int i;
     model_t *mod;
 
-    for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
+    for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++) {
 	if (mod->type != mod_alias)
 	    mod->needload = true;
+	/*
+	 * FIXME: sprites use the cache data pointer for their own purposes,
+	 *        bypassing the Cache_Alloc/Free functions.
+	 */
+	if (mod->type == mod_sprite)
+	    mod->cache.data = NULL;
+    }
 }
 
 /*
@@ -1781,10 +1788,10 @@
 		  "(%i should be %i)", mod->name, version, SPRITE_VERSION);
 
     numframes = LittleLong(pin->numframes);
-
     size = sizeof(msprite_t) + (numframes - 1) * sizeof(psprite->frames);
-
     psprite = Hunk_AllocName(size, loadname);
+    mod->cache.data = psprite;
+
     psprite->type = LittleLong(pin->type);
     psprite->maxwidth = LittleLong(pin->width);
     psprite->maxheight = LittleLong(pin->height);
