]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
got rid of Mod_CheckLoaded, changed how model system restart works to make this work...
[xonotic/darkplaces.git] / cl_main.c
index 16c8a2cc7650926d856d681119b95e1834baea97..908c8d15a9f4c5b3bb987d88eae742284356c37c 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -151,15 +151,15 @@ void CL_ClearState(void)
        cl_max_lightstyle = MAX_LIGHTSTYLES;
        cl_max_brushmodel_entities = MAX_EDICTS;
 
-       cl_entities = Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t));
-       cl_entities_active = Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(qbyte));
-       cl_static_entities = Mem_Alloc(cl_mempool, cl_max_static_entities * sizeof(entity_t));
-       cl_temp_entities = Mem_Alloc(cl_mempool, cl_max_temp_entities * sizeof(entity_t));
-       cl_effects = Mem_Alloc(cl_mempool, cl_max_effects * sizeof(cl_effect_t));
-       cl_beams = Mem_Alloc(cl_mempool, cl_max_beams * sizeof(beam_t));
-       cl_dlights = Mem_Alloc(cl_mempool, cl_max_dlights * sizeof(dlight_t));
-       cl_lightstyle = Mem_Alloc(cl_mempool, cl_max_lightstyle * sizeof(lightstyle_t));
-       cl_brushmodel_entities = Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(int));
+       cl_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t));
+       cl_entities_active = (qbyte *)Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(qbyte));
+       cl_static_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_static_entities * sizeof(entity_t));
+       cl_temp_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_temp_entities * sizeof(entity_t));
+       cl_effects = (cl_effect_t *)Mem_Alloc(cl_mempool, cl_max_effects * sizeof(cl_effect_t));
+       cl_beams = (beam_t *)Mem_Alloc(cl_mempool, cl_max_beams * sizeof(beam_t));
+       cl_dlights = (dlight_t *)Mem_Alloc(cl_mempool, cl_max_dlights * sizeof(dlight_t));
+       cl_lightstyle = (lightstyle_t *)Mem_Alloc(cl_mempool, cl_max_lightstyle * sizeof(lightstyle_t));
+       cl_brushmodel_entities = (int *)Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(int));
 
        cl_lastquakeentity = 0;
        memset(cl_isquakeentity, 0, sizeof(cl_isquakeentity));
@@ -205,7 +205,7 @@ void CL_ExpandEntities(int num)
                oldmaxentities = cl_max_entities;
                oldentities = cl_entities;
                cl_max_entities = (num & ~255) + 256;
-               cl_entities = Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t));
+               cl_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t));
                memcpy(cl_entities, oldentities, oldmaxentities * sizeof(entity_t));
                Mem_Free(oldentities);
                for (i = oldmaxentities;i < cl_max_entities;i++)
@@ -588,14 +588,46 @@ void CL_LinkNetworkEntity(entity_t *e)
                e->render.scale = e->state_current.scale * (1.0f / 16.0f); // FIXME: interpolate?
                e->render.flags = e->state_current.flags;
                e->render.effects = e->state_current.effects;
+               VectorScale(e->state_current.colormod, (1.0f / 32.0f), e->render.colormod);
                if (e->state_current.flags & RENDER_COLORMAPPED)
+               {
+                       int cb;
+                       qbyte *cbcolor;
                        e->render.colormap = e->state_current.colormap;
-               else if (cl.scores != NULL && e->state_current.colormap)
+                       cb = (e->render.colormap & 0xF) << 4;cb += (cb >= 128 && cb < 224) ? 4 : 12;
+                       cbcolor = (qbyte *) (&palette_complete[cb]);
+                       e->render.colormap_pantscolor[0] = cbcolor[0] * (1.0f / 255.0f) * e->render.colormod[0];
+                       e->render.colormap_pantscolor[1] = cbcolor[1] * (1.0f / 255.0f) * e->render.colormod[1];
+                       e->render.colormap_pantscolor[2] = cbcolor[2] * (1.0f / 255.0f) * e->render.colormod[2];
+                       cb = (e->render.colormap & 0xF0);cb += (cb >= 128 && cb < 224) ? 4 : 12;
+                       cbcolor = (qbyte *) (&palette_complete[cb]);
+                       e->render.colormap_shirtcolor[0] = cbcolor[0] * (1.0f / 255.0f) * e->render.colormod[0];
+                       e->render.colormap_shirtcolor[1] = cbcolor[1] * (1.0f / 255.0f) * e->render.colormod[1];
+                       e->render.colormap_shirtcolor[2] = cbcolor[2] * (1.0f / 255.0f) * e->render.colormod[2];
+               }
+               else if (e->state_current.colormap && cl.scores != NULL)
+               {
+                       int cb;
+                       qbyte *cbcolor;
                        e->render.colormap = cl.scores[e->state_current.colormap - 1].colors; // color it
+                       cb = (e->render.colormap & 0xF) << 4;cb += (cb >= 128 && cb < 224) ? 4 : 12;
+                       cbcolor = (qbyte *) (&palette_complete[cb]);
+                       e->render.colormap_pantscolor[0] = cbcolor[0] * (1.0f / 255.0f) * e->render.colormod[0];
+                       e->render.colormap_pantscolor[1] = cbcolor[1] * (1.0f / 255.0f) * e->render.colormod[1];
+                       e->render.colormap_pantscolor[2] = cbcolor[2] * (1.0f / 255.0f) * e->render.colormod[2];
+                       cb = (e->render.colormap & 0xF0);cb += (cb >= 128 && cb < 224) ? 4 : 12;
+                       cbcolor = (qbyte *) (&palette_complete[cb]);
+                       e->render.colormap_shirtcolor[0] = cbcolor[0] * (1.0f / 255.0f) * e->render.colormod[0];
+                       e->render.colormap_shirtcolor[1] = cbcolor[1] * (1.0f / 255.0f) * e->render.colormod[1];
+                       e->render.colormap_shirtcolor[2] = cbcolor[2] * (1.0f / 255.0f) * e->render.colormod[2];
+               }
                else
+               {
                        e->render.colormap = -1; // no special coloring
+                       VectorClear(e->render.colormap_pantscolor);
+                       VectorClear(e->render.colormap_shirtcolor);
+               }
                e->render.skinnum = e->state_current.skin;
-               VectorScale(e->state_current.colormod, (1.0f / 32.0f), e->render.colormod);
                if (e->render.flags & RENDER_VIEWMODEL && !e->state_current.tagentity)
                {
                        if (!r_drawviewmodel.integer || chase_active.integer || envmap)
@@ -676,7 +708,6 @@ void CL_LinkNetworkEntity(entity_t *e)
                e->render.model = cl.model_precache[e->state_current.modelindex];
                if (e->render.model)
                {
-                       Mod_CheckLoaded(e->render.model);
                        // if model is alias or this is a tenebrae-like dlight, reverse pitch direction
                        if (e->render.model->type == mod_alias || (e->state_current.lightpflags & PFLAGS_FULLDYNAMIC))
                                angles[0] = -angles[0];
@@ -983,7 +1014,6 @@ static void CL_RelinkStaticEntities(void)
        entity_t *e;
        for (i = 0, e = cl_static_entities;i < cl_num_static_entities && r_refdef.numentities < r_refdef.maxentities;i++, e++)
        {
-               Mod_CheckLoaded(e->render.model);
                e->render.flags = 0;
                // transparent stuff can't be lit during the opaque stage
                if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
@@ -1410,10 +1440,10 @@ void CL_Init (void)
        memset(&r_refdef, 0, sizeof(r_refdef));
        // max entities sent to renderer per frame
        r_refdef.maxentities = MAX_EDICTS + 256 + 512;
-       r_refdef.entities = Mem_Alloc(cl_mempool, sizeof(entity_render_t *) * r_refdef.maxentities);
+       r_refdef.entities = (entity_render_t **)Mem_Alloc(cl_mempool, sizeof(entity_render_t *) * r_refdef.maxentities);
        // 256k drawqueue buffer
        r_refdef.maxdrawqueuesize = 256 * 1024;
-       r_refdef.drawqueue = Mem_Alloc(cl_mempool, r_refdef.maxdrawqueuesize);
+       r_refdef.drawqueue = (qbyte *)Mem_Alloc(cl_mempool, r_refdef.maxdrawqueuesize);
 
        cls.message.data = cls.message_buf;
        cls.message.maxsize = sizeof(cls.message_buf);