]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
ignore various MSVC files (.opt, .plg, .ncb) and .exe
[xonotic/darkplaces.git] / sv_main.c
index fde0d7490b0ba0d08ba7f645366f65fb292eee91..00fb05819c92674998f43b42610125150d146083 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -35,6 +35,8 @@ static mempool_t *sv_edicts_mempool = NULL;
 
 //============================================================================
 
+extern void SV_Phys_Init (void);
+
 /*
 ===============
 SV_Init
@@ -61,6 +63,8 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_cullentities_trace);
        Cvar_RegisterVariable (&sv_cullentities_stats);
 
+       SV_Phys_Init();
+
        for (i = 0;i < MAX_MODELS;i++)
                sprintf (localmodels[i], "*%i", i);
 
@@ -333,7 +337,14 @@ void SV_ConnectClient (int clientnum)
                        client->spawn_parms[i] = (&pr_global_struct->parm1)[i];
        }
 
+#if NOROUTINGFIX
        SV_SendServerinfo (client);
+#else
+       // send serverinfo on first nop
+       client->waitingforconnect = true;
+       client->sendsignon = true;
+       client->spawned = false;                // need prespawn, spawn, etc
+#endif
 }
 
 
@@ -508,28 +519,25 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
        int e, clentnum, bits, alpha, glowcolor, glowsize, scale, effects;
        int culled_pvs, culled_portal, culled_trace, visibleentities, totalentities;
        qbyte *pvs;
-       vec3_t org, origin, angles, entmins, entmaxs;
+       vec3_t origin, angles, entmins, entmaxs, testorigin, testeye;
        float nextfullupdate;
        edict_t *ent;
        eval_t *val;
        entity_state_t *baseline; // LordHavoc: delta or startup baseline
        trace_t trace;
        model_t *model;
-       double testeye[3];
-       double testorigin[3];
 
        Mod_CheckLoaded(sv.worldmodel);
 
 // find the client's PVS
-       VectorAdd (clent->v.origin, clent->v.view_ofs, org);
-       VectorCopy (org, testeye);
-       pvs = SV_FatPVS (org);
+       VectorAdd (clent->v.origin, clent->v.view_ofs, testeye);
+       pvs = SV_FatPVS (testeye);
        /*
        // dp protocol
        MSG_WriteByte(msg, svc_playerposition);
-       MSG_WriteFloat(msg, org[0]);
-       MSG_WriteFloat(msg, org[1]);
-       MSG_WriteFloat(msg, org[2]);
+       MSG_WriteFloat(msg, testeye[0]);
+       MSG_WriteFloat(msg, testeye[1]);
+       MSG_WriteFloat(msg, testeye[2]);
        */
 
        culled_pvs = 0;
@@ -648,7 +656,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                        }
 
                        // or not visible through the portals
-                       if (sv_cullentities_portal.integer && !Portal_CheckBox(sv.worldmodel, org, entmins, entmaxs))
+                       if (sv_cullentities_portal.integer && !Portal_CheckBox(sv.worldmodel, testeye, entmins, entmaxs))
                        {
                                culled_portal++;
                                continue;
@@ -662,36 +670,18 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                testorigin[1] = lhrandom(entmins[1], entmaxs[1]);
                                testorigin[2] = lhrandom(entmins[2], entmaxs[2]);
 
-                               memset (&trace, 0, sizeof(trace_t));
-                               trace.fraction = 1;
-                               trace.allsolid = true;
-                               VectorCopy(testorigin, trace.endpos);
-
-                               VectorCopy(org, RecursiveHullCheckInfo.start);
-                               VectorSubtract(testorigin, testeye, RecursiveHullCheckInfo.dist);
-                               RecursiveHullCheckInfo.hull = sv.worldmodel->hulls;
-                               RecursiveHullCheckInfo.trace = &trace;
-                               SV_RecursiveHullCheck (sv.worldmodel->hulls->firstclipnode, 0, 1, testeye, testorigin);
+                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
 
                                if (trace.fraction == 1)
                                        client->visibletime[e] = realtime + 1;
                                else
                                {
                                        //test nearest point on bbox
-                                       testorigin[0] = bound(entmins[0], org[0], entmaxs[0]);
-                                       testorigin[1] = bound(entmins[1], org[1], entmaxs[1]);
-                                       testorigin[2] = bound(entmins[2], org[2], entmaxs[2]);
-
-                                       memset (&trace, 0, sizeof(trace_t));
-                                       trace.fraction = 1;
-                                       trace.allsolid = true;
-                                       VectorCopy(testorigin, trace.endpos);
+                                       testorigin[0] = bound(entmins[0], testeye[0], entmaxs[0]);
+                                       testorigin[1] = bound(entmins[1], testeye[1], entmaxs[1]);
+                                       testorigin[2] = bound(entmins[2], testeye[2], entmaxs[2]);
 
-                                       VectorCopy(org, RecursiveHullCheckInfo.start);
-                                       VectorSubtract(testorigin, testeye, RecursiveHullCheckInfo.dist);
-                                       RecursiveHullCheckInfo.hull = sv.worldmodel->hulls;
-                                       RecursiveHullCheckInfo.trace = &trace;
-                                       SV_RecursiveHullCheck (sv.worldmodel->hulls->firstclipnode, 0, 1, testeye, testorigin);
+                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
 
                                        if (trace.fraction == 1)
                                                client->visibletime[e] = realtime + 1;
@@ -884,13 +874,11 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
        int e, clentnum, flags, alpha, glowcolor, glowsize, scale, effects;
        int culled_pvs, culled_portal, culled_trace, visibleentities, totalentities;
        qbyte *pvs;
-       vec3_t org, origin, angles, entmins, entmaxs;
+       vec3_t origin, angles, entmins, entmaxs, testorigin, testeye;
        edict_t *ent;
        eval_t *val;
        trace_t trace;
        model_t *model;
-       double testeye[3];
-       double testorigin[3];
        entity_frame_t entityframe;
        entity_state_t *s;
 
@@ -901,9 +889,8 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
 
 // find the client's PVS
        VectorAdd (clent->v.origin, clent->v.view_ofs, testeye);
-       VectorCopy (testeye, org);
-       pvs = SV_FatPVS (org);
-       EntityFrame_Clear(&entityframe, org);
+       pvs = SV_FatPVS (testeye);
+       EntityFrame_Clear(&entityframe, testeye);
 
        culled_pvs = 0;
        culled_portal = 0;
@@ -1017,7 +1004,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                        }
 
                        // or not visible through the portals
-                       if (sv_cullentities_portal.integer && !Portal_CheckBox(sv.worldmodel, org, entmins, entmaxs))
+                       if (sv_cullentities_portal.integer && !Portal_CheckBox(sv.worldmodel, testeye, entmins, entmaxs))
                        {
                                culled_portal++;
                                continue;
@@ -1030,16 +1017,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                testorigin[1] = lhrandom(entmins[1], entmaxs[1]);
                                testorigin[2] = lhrandom(entmins[2], entmaxs[2]);
 
-                               memset (&trace, 0, sizeof(trace_t));
-                               trace.fraction = 1;
-                               trace.allsolid = true;
-                               VectorCopy(testorigin, trace.endpos);
-
-                               VectorCopy(org, RecursiveHullCheckInfo.start);
-                               VectorSubtract(testorigin, testeye, RecursiveHullCheckInfo.dist);
-                               RecursiveHullCheckInfo.hull = sv.worldmodel->hulls;
-                               RecursiveHullCheckInfo.trace = &trace;
-                               SV_RecursiveHullCheck (sv.worldmodel->hulls->firstclipnode, 0, 1, testeye, testorigin);
+                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
 
                                if (trace.fraction == 1)
                                        client->visibletime[e] = realtime + 1;
@@ -1345,7 +1323,7 @@ qboolean SV_SendClientDatagram (client_t *client)
        MSG_WriteByte (&msg, svc_time);
        MSG_WriteFloat (&msg, sv.time);
 
-       if (!client->sendsignon)
+       if (client->spawned)
        {
                // add the client specific data to the datagram
                SV_WriteClientdataToMessage (client->edict, &msg);
@@ -1448,6 +1426,14 @@ void SV_SendClientMessages (void)
                if (!host_client->active)
                        continue;
 
+#ifndef NOROUTINGFIX
+               if (host_client->sendserverinfo)
+               {
+                       host_client->sendserverinfo = false;
+                       SV_SendServerinfo (host_client);
+               }
+#endif
+
                if (host_client->spawned)
                {
                        if (!SV_SendClientDatagram (host_client))
@@ -1790,7 +1776,7 @@ void SV_SpawnServer (char *server)
 
 // serverflags are for cross level information (sigils)
        pr_global_struct->serverflags = svs.serverflags;
-       
+
        ED_LoadFromFile (sv.worldmodel->entities);
        // LordHavoc: clear world angles (to fix e3m3.bsp)
        VectorClear(sv.edicts->v.angles);