]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - pr_cmds.c
no time to explain, more changes on the path to q3bsp support
[xonotic/darkplaces.git] / pr_cmds.c
index 956e01e9dd0fab296cb8aa32399316fb29a9de3c..0f801f8a4e6f6afd8ea26343ed5b957408b9f160 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -818,6 +818,7 @@ void PF_checkpos (void)
 
 //============================================================================
 
+int checkpvsbytes;
 qbyte checkpvs[MAX_MAP_LEAFS/8];
 
 int PF_newcheckclient (int check)
@@ -851,8 +852,10 @@ int PF_newcheckclient (int check)
        }
 
 // get the PVS for the entity
-       VectorAdd (ent->v->origin, ent->v->view_ofs, org);
-       memcpy (checkpvs, sv.worldmodel->brushq1.LeafPVS(sv.worldmodel, sv.worldmodel->brushq1.PointInLeaf(sv.worldmodel, org)), (sv.worldmodel->brushq1.numleafs+7)>>3 );
+       VectorAdd(ent->v->origin, ent->v->view_ofs, org);
+       checkpvsbytes = 0;
+       if (sv.worldmodel && sv.worldmodel->brush.FatPVS)
+               checkpvsbytes = sv.worldmodel->brush.FatPVS(sv.worldmodel, org, 0, checkpvs, sizeof(checkpvs));
 
        return i;
 }
@@ -876,8 +879,6 @@ int c_invis, c_notvis;
 void PF_checkclient (void)
 {
        edict_t *ent, *self;
-       mleaf_t *leaf;
-       int             l;
        vec3_t  view;
 
        // find a new check if on a new frame
@@ -897,17 +898,12 @@ void PF_checkclient (void)
 
        // if current entity can't possibly see the check entity, return 0
        self = PROG_TO_EDICT(pr_global_struct->self);
-       VectorAdd (self->v->origin, self->v->view_ofs, view);
-       leaf = sv.worldmodel->brushq1.PointInLeaf(sv.worldmodel, view);
-       if (leaf)
+       VectorAdd(self->v->origin, self->v->view_ofs, view);
+       if (sv.worldmodel && checkpvsbytes && !sv.worldmodel->brush.BoxTouchingPVS(sv.worldmodel, checkpvs, view, view))
        {
-               l = (leaf - sv.worldmodel->brushq1.leafs) - 1;
-               if ( (l<0) || !(checkpvs[l>>3] & (1<<(l&7)) ) )
-               {
-                       c_notvis++;
-                       RETURN_EDICT(sv.edicts);
-                       return;
-               }
+               c_notvis++;
+               RETURN_EDICT(sv.edicts);
+               return;
        }
 
        // might be able to see it
@@ -1301,7 +1297,7 @@ void PF_precache_model (void)
                Host_Error ("PF_Precache_*: Precache can only be done in spawn functions");
 
        s = G_STRING(OFS_PARM0);
-       if (sv.worldmodel->brushq1.ishlbsp && ((!s) || (!s[0])))
+       if (sv.worldmodel->brush.ishlbsp && ((!s) || (!s[0])))
                return;
        G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
        PR_CheckEmptyString (s);
@@ -1843,10 +1839,11 @@ void PF_setspawnparms (void)
 
        ent = G_EDICT(OFS_PARM0);
        i = NUM_FOR_EDICT(ent);
-       if (i < 1 || i > MAX_SCOREBOARD || !(client = svs.connectedclients[i-1]))
+       if (i < 1 || i > MAX_SCOREBOARD || !svs.connectedclients[i-1])
                Host_Error ("Entity is not a client");
 
        // copy spawn parms out of the client_t
+       client = svs.connectedclients[i-1];
        for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
                (&pr_global_struct->parm1)[i] = client->spawn_parms[i];
 }
@@ -1906,7 +1903,6 @@ void PF_randomvec (void)
        VectorCopy (temp, G_VECTOR(OFS_RETURN));
 }
 
-void SV_LightPoint (vec3_t color, vec3_t p);
 /*
 =================
 PF_GetLight
@@ -1921,11 +1917,15 @@ getlight(vector)
 */
 void PF_GetLight (void)
 {
-       vec3_t          color;
-       vec_t*          p;
+       vec3_t ambientcolor, diffusecolor, diffusenormal;
+       vec_t *p;
        p = G_VECTOR(OFS_PARM0);
-       SV_LightPoint (color, p);
-       VectorCopy (color, G_VECTOR(OFS_RETURN));
+       VectorClear(ambientcolor);
+       VectorClear(diffusecolor);
+       VectorClear(diffusenormal);
+       if (sv.worldmodel && sv.worldmodel->brush.LightPoint)
+               sv.worldmodel->brush.LightPoint(sv.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
+       VectorMA(ambientcolor, 0.5, diffusecolor, G_VECTOR(OFS_RETURN));
 }
 
 #define MAX_QC_CVARS 128