]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - csprogs.c
added a comment
[xonotic/darkplaces.git] / csprogs.c
index 1de0cf974c76047f59f28b0d29a706cfe8a5672e..f6758470c34f3fc3738a0e85c573f2fe5a1d3664 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -62,13 +62,10 @@ int csqc_fieldoff_scale;
 int csqc_fieldoff_renderflags;
 int csqc_fieldoff_tag_entity;
 int csqc_fieldoff_tag_index;
+int csqc_fieldoff_dphitcontentsmask;
 
 qboolean csqc_loaded = false;
 
-extern entity_t        *cl_csqcentities;
-extern unsigned char   *cl_csqcentities_active;
-extern int             cl_num_csqcentities;
-
 vec3_t csqc_origin, csqc_angles;
 static double csqc_frametime = 0;
 int csqc_buttons;
@@ -95,7 +92,7 @@ static void CL_VM_FindEdictFieldOffsets (void)
 
        if(CSQC_Parse_Print)
        {
-               csqc_printtextbuf = Mem_Alloc(csqc_mempool, CSQC_PRINTBUFFERLEN);
+               csqc_printtextbuf = (char *)Mem_Alloc(csqc_mempool, CSQC_PRINTBUFFERLEN);
                csqc_printtextbuf[0] = 0;
        }
 }
@@ -136,7 +133,7 @@ static void CSQC_SetGlobals (void)
                prog->globals.client->input_buttons = csqc_buttons;
                VectorSet(prog->globals.client->input_movevalues, cl.cmd.forwardmove, cl.cmd.sidemove, cl.cmd.upmove);
                //VectorCopy(cl.movement_origin, csqc_origin);
-               VectorCopy(cl_entities[cl.viewentity].render.origin, csqc_origin);
+               VectorCopy(cl.entities[cl.viewentity].render.origin, csqc_origin);
                VectorCopy(csqc_origin, prog->globals.client->pmove_org);
                prog->globals.client->maxclients = cl.maxclients;
                //VectorCopy(cl.movement_velocity, prog->globals.client->pmove_vel);
@@ -175,7 +172,7 @@ static qboolean CSQC_EdictToEntity (prvm_edict_t *ed, entity_t *e)
        int i;
        prvm_eval_t *val;
 
-       i = ed->fields.client->modelindex;
+       i = (int)ed->fields.client->modelindex;
        e->state_current.modelindex = 0;
        if(i >= MAX_MODELS || i <= -MAX_MODELS) //[515]: make work as error ?
        {
@@ -192,7 +189,7 @@ static qboolean CSQC_EdictToEntity (prvm_edict_t *ed, entity_t *e)
        i = 0;
        if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_renderflags)) && val->_float)
        {
-               i = val->_float;
+               i = (int)val->_float;
                if(i & RF_VIEWMODEL)    e->state_current.flags |= RENDER_VIEWMODEL;
                if(i & RF_EXTERNALMODEL)e->state_current.flags |= RENDER_EXTERIORMODEL;
                if(i & RF_DEPTHHACK)    e->state_current.effects |= EF_NODEPTHTEST;
@@ -206,20 +203,20 @@ static qboolean CSQC_EdictToEntity (prvm_edict_t *ed, entity_t *e)
 
        VectorCopy(ed->fields.client->origin, e->persistent.neworigin);
        VectorCopy(ed->fields.client->origin, e->state_current.origin);
-       e->state_current.colormap = ed->fields.client->colormap;
-       e->state_current.effects = ed->fields.client->effects;
-       e->state_current.frame = ed->fields.client->frame;
-       e->state_current.skin = ed->fields.client->skin;
-
-       if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_alpha)) && val->_float)             e->state_current.alpha = val->_float*255;
-       if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_scale)) && val->_float)             e->state_current.scale = val->_float*16;
-       if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_colormod)) && VectorLength2(val->vector))   VectorScale(val->vector, 32, e->state_current.colormod);
-       if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_effects)) && val->_float)   e->state_current.effects = val->_float;
+       e->state_current.colormap = (int)ed->fields.client->colormap;
+       e->state_current.effects = (int)ed->fields.client->effects;
+       e->state_current.frame = (int)ed->fields.client->frame;
+       e->state_current.skin = (int)ed->fields.client->skin;
+
+       if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_alpha)) && val->_float)             e->state_current.alpha = (int)(val->_float*255);
+       if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_scale)) && val->_float)             e->state_current.scale = (int)(val->_float*16);
+       if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_colormod)) && VectorLength2(val->vector))   {int j;for (j = 0;j < 3;j++) e->state_current.colormod[j] = (unsigned char)bound(0, val->vector[j] * 32.0f, 255);}
+       if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_effects)) && val->_float)   e->state_current.effects = (int)val->_float;
        if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_tag_entity)) && val->edict)
        {
                e->state_current.tagentity = val->edict;
                if((val = PRVM_GETEDICTFIELDVALUE(ed, csqc_fieldoff_tag_index)) && val->_float)
-                       e->state_current.tagindex = val->_float;
+                       e->state_current.tagindex = (int)val->_float;
        }
 
        return true;
@@ -227,8 +224,8 @@ static qboolean CSQC_EdictToEntity (prvm_edict_t *ed, entity_t *e)
 
 void CSQC_ClearCSQCEntities (void)
 {
-       memset(cl_csqcentities_active, 0, sizeof(cl_csqcentities_active));
-       cl_num_csqcentities = 0;
+       memset(cl.csqcentities_active, 0, sizeof(cl.csqcentities_active));
+       cl.num_csqcentities = 0;
        csqc_drawmask = 0;
 }
 
@@ -243,15 +240,15 @@ void CSQC_RelinkCSQCEntities (void)
        *prog->time = cl.time;
        for(i=1;i<prog->num_edicts;i++)
        {
-               if(i >= cl_max_csqcentities)
+               if(i >= cl.max_csqcentities)
                        CL_ExpandCSQCEntities(i);
 
-               e = &cl_csqcentities[i];
+               e = &cl.csqcentities[i];
                ed = &prog->edicts[i];
                if(ed->priv.required->free)
                {
                        e->state_current.active = false;
-                       cl_csqcentities_active[i] = false;
+                       cl.csqcentities_active[i] = false;
                        continue;
                }
                VectorAdd(ed->fields.client->origin, ed->fields.client->mins, ed->fields.client->absmin);
@@ -260,23 +257,23 @@ void CSQC_RelinkCSQCEntities (void)
                if(ed->priv.required->free)
                {
                        e->state_current.active = false;
-                       cl_csqcentities_active[i] = false;
+                       cl.csqcentities_active[i] = false;
                        continue;
                }
                CSQC_Predraw(ed);
                if(ed->priv.required->free)
                {
                        e->state_current.active = false;
-                       cl_csqcentities_active[i] = false;
+                       cl.csqcentities_active[i] = false;
                        continue;
                }
-               if(!cl_csqcentities_active[i])
+               if(!cl.csqcentities_active[i])
                if(!((int)ed->fields.client->drawmask & csqc_drawmask))
                        continue;
 
                e->state_previous       = e->state_current;
                e->state_current        = defaultstate;
-               if((cl_csqcentities_active[i] = CSQC_EdictToEntity(ed, e)))
+               if((cl.csqcentities_active[i] = CSQC_EdictToEntity(ed, e)))
                {
                        if(!e->state_current.active)
                        {
@@ -286,7 +283,7 @@ void CSQC_RelinkCSQCEntities (void)
                                e->state_current.active = true;
                        }
                        e->persistent.lerpdeltatime = 0;//prog->globals.client->frametime;
-                       cl_num_csqcentities++;
+                       cl.num_csqcentities++;
                }
        }
 }
@@ -294,7 +291,7 @@ void CSQC_RelinkCSQCEntities (void)
 //[515]: omfg... it's all weird =/
 void CSQC_AddEntity (int n)
 {
-       cl_csqcentities_active[n] = true;
+       cl.csqcentities_active[n] = true;
 }
 
 qboolean CL_VM_InputEvent (qboolean pressed, int key)
@@ -322,7 +319,7 @@ qboolean CL_VM_UpdateView (void)
                *prog->time = cl.time;
                CSQC_SetGlobals();
                csqc_drawmask = 0;
-               cl_num_csqcentities = 0;
+               cl.num_csqcentities = 0;
                PRVM_ExecuteProgram (prog->globals.client->CSQC_UpdateView, CL_F_UPDATEVIEW);
                //VectorCopy(oldangles, cl.viewangles);
        CSQC_END
@@ -401,12 +398,13 @@ static void CL_VM_Parse_Print (const char *msg)
 
 void CSQC_AddPrintText (const char *msg)
 {
-       int i;
+       size_t i;
        if(!csqc_loaded || !CSQC_Parse_Print)
        {
                Con_Print(msg);
                return;
        }
+       // FIXME: is this bugged?
        i = strlen(msg)-1;
        if(msg[i] != '\n' && msg[i] != '\r')
        {
@@ -578,14 +576,14 @@ void CL_VM_Init (void)
        PRVM_End;
        csqc_loaded = true;
 
-       csqc_sv2csqcents = Mem_Alloc(csqc_mempool, MAX_EDICTS*sizeof(unsigned short));
+       csqc_sv2csqcents = (unsigned short *)Mem_Alloc(csqc_mempool, MAX_EDICTS*sizeof(unsigned short));
        memset(csqc_sv2csqcents, 0, MAX_EDICTS*sizeof(unsigned short));
 
        cl.csqc_vidvars.drawcrosshair = false;
        cl.csqc_vidvars.drawenginesbar = false;
 
        // local state
-       ent = &cl_csqcentities[0];
+       ent = &cl.csqcentities[0];
        // entire entity array was cleared, so just fill in a few fields
        ent->state_current.active = true;
        ent->render.model = cl.worldmodel = cl.model_precache[1];