]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed a severe bug with pointer_color state tracking (no longer checks .colorarray...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 25 May 2003 11:44:31 +0000 (11:44 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 25 May 2003 11:44:31 +0000 (11:44 +0000)
fixed a crash when entire sequentialchain is emptied while trying to get space for a new cache item (this happened!  I can't guess why though)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3029 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c

index 76ab088c35d7644f8538e77fcfbca6ef2e865e5d..55788e8934328995d468cdadcb5fc5ff6d0f5671 100644 (file)
@@ -1093,22 +1093,19 @@ void R_Mesh_MainState(const rmeshstate_t *m)
                qglVertexPointer(3, GL_FLOAT, sizeof(float[3]), p ? p : varray_buf_vertex3f);CHECKGLERROR
        }
 
-       if (gl_state.colorarray)
+       p = gl_state.pointervertexcount ? m->pointer_color : NULL;
+       if (gl_state.pointer_color != p)
        {
-               p = gl_state.pointervertexcount ? m->pointer_color : NULL;
-               if (gl_state.pointer_color != p)
-               {
 #ifdef MESH_BATCH
-                       if (gl_batchelementcount)
-                               R_Mesh_EndBatch();
+               if (gl_batchelementcount)
+                       R_Mesh_EndBatch();
 #endif
-                       gl_state.pointer_color = p;
-                       if (p || gl_mesh_floatcolors.integer)
-                               qglColorPointer(4, GL_FLOAT, sizeof(float[4]), p ? p : varray_buf_color4f);
-                       else
-                               qglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(GLubyte[4]), p ? p : varray_buf_color4b);
-                       CHECKGLERROR
-               }
+               gl_state.pointer_color = p;
+               if (p || gl_mesh_floatcolors.integer)
+                       qglColorPointer(4, GL_FLOAT, sizeof(float[4]), p ? p : varray_buf_color4f);
+               else
+                       qglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(GLubyte[4]), p ? p : varray_buf_color4b);
+               CHECKGLERROR
        }
 }
 
@@ -1729,38 +1726,35 @@ int R_Mesh_CacheArray(rcachearrayrequest_t *r)
        l = r_mesh_rcachesequentialchain_current;
        if (l == lhead)
                l = l->next;
-       if (l != lhead)
+       while (l != lhead && l->data->offset < offsetend && l->data->offset + l->data->request.data_size > offset)
        {
-               while (l->data->offset < offsetend && l->data->offset + l->data->request.data_size > offset)
-               {
        //r_mesh_rcachesequentialchain_current = l;
        //R_Mesh_CacheArray_ValidateState(8);
-                       lnext = l->next;
-                       // if at the end of the chain, wrap around
-                       if (lnext == lhead)
-                               lnext = lnext->next;
+               lnext = l->next;
+               // if at the end of the chain, wrap around
+               if (lnext == lhead)
+                       lnext = lnext->next;
        //r_mesh_rcachesequentialchain_current = lnext;
        //R_Mesh_CacheArray_ValidateState(10);
 
-                       // unlink from sequential chain
-                       l->next->prev = l->prev;
-                       l->prev->next = l->next;
+               // unlink from sequential chain
+               l->next->prev = l->prev;
+               l->prev->next = l->next;
        //R_Mesh_CacheArray_ValidateState(11);
-                       // link into free chain
-                       l->next = &r_mesh_rcachefreechain;
-                       l->prev = l->next->prev;
-                       l->next->prev = l->prev->next = l;
+               // link into free chain
+               l->next = &r_mesh_rcachefreechain;
+               l->prev = l->next->prev;
+               l->next->prev = l->prev->next = l;
        //R_Mesh_CacheArray_ValidateState(12);
 
-                       l = &l->data->hashlink;
-                       // unlink from hash chain
-                       l->next->prev = l->prev;
-                       l->prev->next = l->next;
+               l = &l->data->hashlink;
+               // unlink from hash chain
+               l->next->prev = l->prev;
+               l->prev->next = l->next;
 
-                       l = lnext;
+               l = lnext;
        //r_mesh_rcachesequentialchain_current = l;
        //R_Mesh_CacheArray_ValidateState(9);
-               }
        }
        //r_mesh_rcachesequentialchain_current = l;
        //R_Mesh_CacheArray_ValidateState(5);