]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_main.c
collision code cleanups (model->brush.TraceBox is now used for everything except...
[xonotic/darkplaces.git] / sv_main.c
index 3919dddecde528267262eac769133edf3c2185f0..bf05f17f52f7b9eea0e01ddf3f7da53adef0c2bf 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -28,8 +28,8 @@ static cvar_t sv_cullentities_trace = {0, "sv_cullentities_trace", "1"}; // tend
 static cvar_t sv_cullentities_stats = {0, "sv_cullentities_stats", "0"};
 static cvar_t sv_entpatch = {0, "sv_entpatch", "1"};
 
-server_t               sv;
-server_static_t        svs;
+server_t sv;
+server_static_t svs;
 
 static char localmodels[MAX_MODELS][5];                        // inline model names for precache
 
@@ -59,7 +59,6 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_idealpitchscale);
        Cvar_RegisterVariable (&sv_aim);
        Cvar_RegisterVariable (&sv_nostep);
-       Cvar_RegisterVariable (&sv_predict);
        Cvar_RegisterVariable (&sv_deltacompress);
        Cvar_RegisterVariable (&sv_cullentities_pvs);
        Cvar_RegisterVariable (&sv_cullentities_portal);
@@ -164,13 +163,9 @@ Larger attenuations will drop off.  (max 4 attenuation)
 
 ==================
 */
-void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
-    float attenuation)
+void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, float attenuation)
 {
-    int         sound_num;
-    int field_mask;
-    int                        i;
-       int                     ent;
+       int sound_num, field_mask, i, ent;
 
        if (volume < 0 || volume > 255)
                Host_Error ("SV_StartSound: volume = %i", volume);
@@ -185,16 +180,15 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
                return;
 
 // find precache number for sound
-    for (sound_num=1 ; sound_num<MAX_SOUNDS
-        && sv.sound_precache[sound_num] ; sound_num++)
-        if (!strcmp(sample, sv.sound_precache[sound_num]))
-            break;
+       for (sound_num=1 ; sound_num<MAX_SOUNDS && sv.sound_precache[sound_num] ; sound_num++)
+               if (!strcmp(sample, sv.sound_precache[sound_num]))
+                       break;
 
-    if ( sound_num == MAX_SOUNDS || !sv.sound_precache[sound_num] )
-    {
-        Con_Printf ("SV_StartSound: %s not precached\n", sample);
-        return;
-    }
+       if ( sound_num == MAX_SOUNDS || !sv.sound_precache[sound_num] )
+       {
+               Con_Printf ("SV_StartSound: %s not precached\n", sample);
+               return;
+       }
 
        ent = NUM_FOR_EDICT(entity);
 
@@ -251,6 +245,9 @@ void SV_SendServerinfo (client_t *client)
        char                    **s;
        char                    message[128];
 
+       // edicts get reallocated on level changes, so we need to update it here
+       client->edict = EDICT_NUM((client - svs.clients) + 1);
+
        // LordHavoc: clear entityframe tracking
        client->entityframenumber = 0;
        EntityFrame_ClearDatabase(&client->entitydatabase);
@@ -302,26 +299,24 @@ Initializes a client_t for a new net connection.  This will only be called
 once for a player each game, not once for each level change.
 ================
 */
-void SV_ConnectClient (int clientnum)
+void SV_ConnectClient (int clientnum, netconn_t *netconnection)
 {
        client_t                *client;
-       struct qsocket_s *netconnection;
        int                             i;
        float                   spawn_parms[NUM_SPAWN_PARMS];
 
        client = svs.clients + clientnum;
 
-       Con_DPrintf ("Client %s connected\n", client->netconnection->address);
-
 // set up the client_t
-       netconnection = client->netconnection;
-
        if (sv.loadgame)
                memcpy (spawn_parms, client->spawn_parms, sizeof(spawn_parms));
        memset (client, 0, sizeof(*client));
        client->netconnection = netconnection;
 
-       strcpy (client->name, "unconnected");
+       Con_DPrintf("Client %s connected\n", client->netconnection->address);
+
+       strcpy(client->name, "unconnected");
+       strcpy(client->old_name, "unconnected");
        client->active = true;
        client->spawned = false;
        client->edict = EDICT_NUM(clientnum+1);
@@ -333,7 +328,7 @@ void SV_ConnectClient (int clientnum)
                memcpy (client->spawn_parms, spawn_parms, sizeof(spawn_parms));
        else
        {
-       // call the progs to get default spawn parms for the new client
+               // call the progs to get default spawn parms for the new client
                PR_ExecuteProgram (pr_global_struct->SetNewParms, "QC function SetNewParms is missing");
                for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
                        client->spawn_parms[i] = (&pr_global_struct->parm1)[i];
@@ -343,45 +338,6 @@ void SV_ConnectClient (int clientnum)
 }
 
 
-/*
-===================
-SV_CheckForNewClients
-
-===================
-*/
-void SV_CheckForNewClients (void)
-{
-       struct qsocket_s        *ret;
-       int                             i;
-
-//
-// check for new connections
-//
-       while (1)
-       {
-               ret = NET_CheckNewConnections ();
-               if (!ret)
-                       break;
-
-       //
-       // init a new client structure
-       //
-               for (i=0 ; i<svs.maxclients ; i++)
-                       if (!svs.clients[i].active)
-                               break;
-               if (i == svs.maxclients)
-                       Sys_Error ("Host_CheckForNewClients: no free clients");
-
-               svs.clients[i].netconnection = ret;
-               SV_ConnectClient (i);
-
-               net_activeconnections++;
-               NET_Heartbeat (1);
-       }
-}
-
-
-
 /*
 ===============================================================================
 
@@ -429,7 +385,7 @@ void SV_AddToFatPVS (vec3_t org, mnode_t *node)
                {
                        if (node->contents != CONTENTS_SOLID)
                        {
-                               pvs = Mod_LeafPVS ( (mleaf_t *)node, sv.worldmodel);
+                               pvs = sv.worldmodel->brushq1.LeafPVS(sv.worldmodel, (mleaf_t *)node);
                                for (i=0 ; i<fatbytes ; i++)
                                        fatpvs[i] |= pvs[i];
                        }
@@ -460,9 +416,9 @@ given point.
 */
 qbyte *SV_FatPVS (vec3_t org)
 {
-       fatbytes = (sv.worldmodel->numleafs+31)>>3;
+       fatbytes = (sv.worldmodel->brushq1.numleafs+31)>>3;
        memset (fatpvs, 0, fatbytes);
-       SV_AddToFatPVS (org, sv.worldmodel->nodes);
+       SV_AddToFatPVS (org, sv.worldmodel->brushq1.nodes);
        return fatpvs;
 }
 
@@ -478,7 +434,7 @@ loc0:
                // leaf
                if (node->contents == CONTENTS_SOLID)
                        return false;
-               leafnum = (mleaf_t *)node - sv.worldmodel->leafs - 1;
+               leafnum = (mleaf_t *)node - sv.worldmodel->brushq1.leafs - 1;
                return pvs[leafnum >> 3] & (1 << (leafnum & 7));
        }
 
@@ -520,7 +476,6 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
        edict_t *ent;
        eval_t *val;
        entity_state_t *baseline; // LordHavoc: delta or startup baseline
-       trace_t trace;
        model_t *model;
 
        Mod_CheckLoaded(sv.worldmodel);
@@ -593,17 +548,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                }
 
                VectorCopy(ent->v->angles, angles);
-               if (DotProduct(ent->v->velocity, ent->v->velocity) >= 1.0f)
-               {
-                       VectorMA(ent->v->origin, host_client->latency, ent->v->velocity, origin);
-                       // LordHavoc: trace predicted movement to avoid putting things in walls
-                       trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, origin, MOVE_NORMAL, ent);
-                       VectorCopy(trace.endpos, origin);
-               }
-               else
-               {
-                       VectorCopy(ent->v->origin, origin);
-               }
+               VectorCopy(ent->v->origin, origin);
 
                // ent has survived every check so far, check if it is visible
                if (ent != clent && ((bits & U_VIEWMODEL) == 0))
@@ -638,7 +583,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                        totalentities++;
 
                        // if not touching a visible leaf
-                       if (sv_cullentities_pvs.integer && !SV_BoxTouchingPVS(pvs, entmins, entmaxs, sv.worldmodel->nodes))
+                       if (sv_cullentities_pvs.integer && !SV_BoxTouchingPVS(pvs, entmins, entmaxs, sv.worldmodel->brushq1.nodes))
                        {
                                culled_pvs++;
                                continue;
@@ -659,9 +604,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]);
 
-                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
-
-                               if (trace.fraction == 1)
+                               if (SV_Move(testeye, vec3_origin, vec3_origin, testorigin, MOVE_NOMONSTERS, NULL).fraction == 1)
                                        client->visibletime[e] = realtime + 1;
                                else
                                {
@@ -670,9 +613,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                        testorigin[1] = bound(entmins[1], testeye[1], entmaxs[1]);
                                        testorigin[2] = bound(entmins[2], testeye[2], entmaxs[2]);
 
-                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
-
-                                       if (trace.fraction == 1)
+                                       if (SV_Move(testeye, vec3_origin, vec3_origin, testorigin, MOVE_NOMONSTERS, NULL).fraction == 1)
                                                client->visibletime[e] = realtime + 1;
                                        else if (realtime > client->visibletime[e])
                                        {
@@ -865,7 +806,6 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
        vec3_t origin, angles, entmins, entmaxs, lightmins, lightmaxs, testorigin, testeye;
        edict_t *ent;
        eval_t *val;
-       trace_t trace;
        model_t *model;
        entity_state_t *s;
 
@@ -975,17 +915,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                }
 
                VectorCopy(ent->v->angles, angles);
-               if (DotProduct(ent->v->velocity, ent->v->velocity) >= 1.0f && host_client->latency >= 0.01f)
-               {
-                       VectorMA(ent->v->origin, host_client->latency, ent->v->velocity, origin);
-                       // LordHavoc: trace predicted movement to avoid putting things in walls
-                       trace = SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, origin, MOVE_NORMAL, ent);
-                       VectorCopy(trace.endpos, origin);
-               }
-               else
-               {
-                       VectorCopy(ent->v->origin, origin);
-               }
+               VectorCopy(ent->v->origin, origin);
 
                // ent has survived every check so far, check if it is visible
                // always send embedded brush models, they don't generate much traffic
@@ -1027,7 +957,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                        totalentities++;
 
                        // if not touching a visible leaf
-                       if (sv_cullentities_pvs.integer && !SV_BoxTouchingPVS(pvs, lightmins, lightmaxs, sv.worldmodel->nodes))
+                       if (sv_cullentities_pvs.integer && !SV_BoxTouchingPVS(pvs, lightmins, lightmaxs, sv.worldmodel->brushq1.nodes))
                        {
                                culled_pvs++;
                                continue;
@@ -1046,8 +976,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                testorigin[0] = (entmins[0] + entmaxs[0]) * 0.5f;
                                testorigin[1] = (entmins[1] + entmaxs[1]) * 0.5f;
                                testorigin[2] = (entmins[2] + entmaxs[2]) * 0.5f;
-                               Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
-                               if (trace.fraction == 1)
+                               if (SV_Move(testeye, vec3_origin, vec3_origin, testorigin, MOVE_NOMONSTERS, NULL).fraction == 1)
                                        client->visibletime[e] = realtime + 1;
                                else
                                {
@@ -1055,8 +984,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                        testorigin[0] = lhrandom(entmins[0], entmaxs[0]);
                                        testorigin[1] = lhrandom(entmins[1], entmaxs[1]);
                                        testorigin[2] = lhrandom(entmins[2], entmaxs[2]);
-                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
-                                       if (trace.fraction == 1)
+                                       if (SV_Move(testeye, vec3_origin, vec3_origin, testorigin, MOVE_NOMONSTERS, NULL).fraction == 1)
                                                client->visibletime[e] = realtime + 1;
                                        else
                                        {
@@ -1066,8 +994,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg)
                                                        testorigin[0] = lhrandom(lightmins[0], lightmaxs[0]);
                                                        testorigin[1] = lhrandom(lightmins[1], lightmaxs[1]);
                                                        testorigin[2] = lhrandom(lightmins[2], lightmaxs[2]);
-                                                       Collision_ClipTrace(&trace, NULL, sv.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, testeye, vec3_origin, vec3_origin, testorigin);
-                                                       if (trace.fraction == 1)
+                                                       if (SV_Move(testeye, vec3_origin, vec3_origin, testorigin, MOVE_NOMONSTERS, NULL).fraction == 1)
                                                                client->visibletime[e] = realtime + 1;
                                                        else
                                                        {
@@ -1392,7 +1319,7 @@ qboolean SV_SendClientDatagram (client_t *client)
                SZ_Write (&msg, sv.datagram.data, sv.datagram.cursize);
 
 // send the datagram
-       if (NET_SendUnreliableMessage (client->netconnection, &msg) == -1)
+       if (NetConn_SendUnreliableMessage (client->netconnection, &msg) == -1)
        {
                SV_DropClient (true);// if the message couldn't send, kick off
                return false;
@@ -1410,31 +1337,78 @@ void SV_UpdateToReliableMessages (void)
 {
        int i, j;
        client_t *client;
+       eval_t *val;
+       char *s;
 
 // check for changes to be sent over the reliable streams
        for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
        {
-               sv_player = host_client->edict;
-               if (host_client->old_frags != sv_player->v->frags)
+               // only update the client fields if they've spawned in
+               if (host_client->spawned)
                {
-                       for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
+                       // update the host_client fields we care about according to the entity fields
+                       sv_player = host_client->edict;
+                       s = PR_GetString(sv_player->v->netname);
+                       if (s != host_client->name)
                        {
-                               if (!client->active || !client->spawned)
-                                       continue;
-                               MSG_WriteByte (&client->message, svc_updatefrags);
-                               MSG_WriteByte (&client->message, i);
-                               MSG_WriteShort (&client->message, sv_player->v->frags);
+                               if (s == NULL)
+                                       s = "";
+                               // point the string back at host_client->name to keep it safe
+                               strncpy(host_client->name, s, sizeof(host_client->name) - 1);
+                               sv_player->v->netname = PR_SetString(host_client->name);
+                       }
+                       if ((val = GETEDICTFIELDVALUE(sv_player, eval_clientcolors)) && host_client->colors != val->_float)
+                               host_client->colors = val->_float;
+                       host_client->frags = sv_player->v->frags;
+                       if (gamemode == GAME_NEHAHRA)
+                               if ((val = GETEDICTFIELDVALUE(sv_player, eval_pmodel)) && host_client->pmodel != val->_float)
+                                       host_client->pmodel = val->_float;
+
+                       // if the fields changed, send messages about the changes
+                       if (strcmp(host_client->old_name, host_client->name))
+                       {
+                               strcpy(host_client->old_name, host_client->name);
+                               for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
+                               {
+                                       if (!client->active || !client->spawned)
+                                               continue;
+                                       MSG_WriteByte (&client->message, svc_updatename);
+                                       MSG_WriteByte (&client->message, i);
+                                       MSG_WriteString (&client->message, host_client->name);
+                               }
+                       }
+                       if (host_client->old_colors != host_client->colors)
+                       {
+                               host_client->old_colors = host_client->colors;
+                               for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
+                               {
+                                       if (!client->active || !client->spawned)
+                                               continue;
+                                       MSG_WriteByte (&client->message, svc_updatecolors);
+                                       MSG_WriteByte (&client->message, i);
+                                       MSG_WriteByte (&client->message, host_client->colors);
+                               }
+                       }
+                       if (host_client->old_frags != host_client->frags)
+                       {
+                               host_client->old_frags = host_client->frags;
+                               for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
+                               {
+                                       if (!client->active || !client->spawned)
+                                               continue;
+                                       MSG_WriteByte (&client->message, svc_updatefrags);
+                                       MSG_WriteByte (&client->message, i);
+                                       MSG_WriteShort (&client->message, host_client->frags);
+                               }
                        }
-
-                       host_client->old_frags = sv_player->v->frags;
                }
        }
 
-       for (j=0, host_client = svs.clients ; j<svs.maxclients ; j++, host_client++)
+       for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
        {
-               if (!host_client->active)
+               if (!client->active)
                        continue;
-               SZ_Write (&host_client->message, sv.reliable_datagram.data, sv.reliable_datagram.cursize);
+               SZ_Write (&client->message, sv.reliable_datagram.data, sv.reliable_datagram.cursize);
        }
 
        SZ_Clear (&sv.reliable_datagram);
@@ -1460,7 +1434,7 @@ void SV_SendNop (client_t *client)
 
        MSG_WriteChar (&msg, svc_nop);
 
-       if (NET_SendUnreliableMessage (client->netconnection, &msg) == -1)
+       if (NetConn_SendUnreliableMessage (client->netconnection, &msg) == -1)
                SV_DropClient (true);   // if the message couldn't send, kick off
        client->last_message = realtime;
 }
@@ -1483,6 +1457,12 @@ void SV_SendClientMessages (void)
                if (!host_client->active)
                        continue;
 
+               if (host_client->deadsocket)
+               {
+                       SV_DropClient (true);   // if the message couldn't send, kick off
+                       continue;
+               }
+
                if (host_client->spawned)
                {
                        if (!SV_SendClientDatagram (host_client))
@@ -1515,14 +1495,14 @@ void SV_SendClientMessages (void)
 
                if (host_client->message.cursize || host_client->dropasap)
                {
-                       if (!NET_CanSendMessage (host_client->netconnection))
+                       if (!NetConn_CanSendMessage (host_client->netconnection))
                                continue;
 
                        if (host_client->dropasap)
                                SV_DropClient (false);  // went to another level
                        else
                        {
-                               if (NET_SendMessage (host_client->netconnection, &host_client->message) == -1)
+                               if (NetConn_SendReliableMessage (host_client->netconnection, &host_client->message) == -1)
                                        SV_DropClient (true);   // if the message couldn't send, kick off
                                SZ_Clear (&host_client->message);
                                host_client->last_message = realtime;
@@ -1659,7 +1639,7 @@ void SV_SendReconnect (void)
 
        MSG_WriteChar (&msg, svc_stufftext);
        MSG_WriteString (&msg, "reconnect\n");
-       NET_SendToAll (&msg, 5);
+       NetConn_SendToAll (&msg, 5);
 
        if (cls.state != ca_dedicated)
                Cmd_ExecuteString ("reconnect\n", src_command);
@@ -1702,9 +1682,16 @@ void SV_IncreaseEdicts(void)
        void *oldedictsfields = sv.edictsfields;
        void *oldmoved_edicts = sv.moved_edicts;
 
+       if (sv.max_edicts >= MAX_EDICTS)
+               return;
+
        // links don't survive the transition, so unlink everything
-       for (i = 0;i < sv.max_edicts;i++)
-               SV_UnlinkEdict (sv.edicts + i);
+       for (i = 0, ent = sv.edicts;i < sv.max_edicts;i++, ent++)
+       {
+               if (!ent->e->free)
+                       SV_UnlinkEdict(sv.edicts + i);
+               memset(&ent->e->areagrid, 0, sizeof(ent->e->areagrid));
+       }
        SV_ClearWorld();
 
        sv.max_edicts   = min(sv.max_edicts + 32, MAX_EDICTS);
@@ -1715,13 +1702,12 @@ void SV_IncreaseEdicts(void)
        memcpy(sv.edictsengineprivate, oldedictsengineprivate, oldmax_edicts * sizeof(edict_engineprivate_t));
        memcpy(sv.edictsfields, oldedictsfields, oldmax_edicts * pr_edict_size);
 
-       for (i = 0;i < sv.max_edicts;i++)
+       for (i = 0, ent = sv.edicts;i < sv.max_edicts;i++, ent++)
        {
-               ent = sv.edicts + i;
                ent->e = sv.edictsengineprivate + i;
                ent->v = (void *)((qbyte *)sv.edictsfields + i * pr_edict_size);
                // link every entity except world
-               if (i > 0)
+               if (!ent->e->free)
                        SV_LinkEdict(ent, false);
        }
 
@@ -1758,6 +1744,8 @@ void SV_SpawnServer (const char *server)
 //
        if (sv.active)
                SV_SendReconnect ();
+       else
+               NetConn_OpenServerPorts(svs.maxclients > 1);
 
 //
 // make cvars consistant
@@ -1816,8 +1804,6 @@ void SV_SpawnServer (const char *server)
 
 // leave slots at start for clients only
        sv.num_edicts = svs.maxclients+1;
-       for (i=0 ; i<svs.maxclients ; i++)
-               svs.clients[i].edict = EDICT_NUM(i+1);
 
        sv.state = ss_loading;
        sv.paused = false;
@@ -1846,7 +1832,7 @@ void SV_SpawnServer (const char *server)
 
        sv.model_precache[0] = "";
        sv.model_precache[1] = sv.modelname;
-       for (i = 1;i < sv.worldmodel->numsubmodels;i++)
+       for (i = 1;i < sv.worldmodel->brushq1.numsubmodels;i++)
        {
                sv.model_precache[i+1] = localmodels[i];
                sv.models[i+1] = Mod_ForName (localmodels[i], false, false, false);
@@ -1863,7 +1849,7 @@ void SV_SpawnServer (const char *server)
        ent->v->solid = SOLID_BSP;
        ent->v->movetype = MOVETYPE_PUSH;
 
-       if (coop.integer)
+       if (coop.value)
                pr_global_struct->coop = coop.integer;
        else
                pr_global_struct->deathmatch = deathmatch.integer;
@@ -1884,7 +1870,7 @@ void SV_SpawnServer (const char *server)
                Mem_Free(entities);
        }
        else
-               ED_LoadFromFile (sv.worldmodel->entities);
+               ED_LoadFromFile (sv.worldmodel->brush.entities);
 
 
        // LordHavoc: clear world angles (to fix e3m3.bsp)
@@ -1896,10 +1882,11 @@ void SV_SpawnServer (const char *server)
        sv.state = ss_active;
 
 // run two frames to allow everything to settle
-       sv.frametime = pr_global_struct->frametime = host_frametime = 0.1;
-       SV_Physics ();
-       sv.frametime = pr_global_struct->frametime = host_frametime = 0.1;
-       SV_Physics ();
+       for (i = 0;i < 2;i++)
+       {
+               sv.frametime = pr_global_struct->frametime = host_frametime = 0.1;
+               SV_Physics ();
+       }
 
        Mod_PurgeUnused();
 
@@ -1914,6 +1901,6 @@ void SV_SpawnServer (const char *server)
                        SV_SendServerinfo (host_client);
 
        Con_DPrintf ("Server spawned.\n");
-       NET_Heartbeat (2);
+       NetConn_Heartbeat (2);
 }