]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
Lots of str[n]cat, str[n]cpy, and [v]sprintf have been replaced by strlcat, strlcpy...
[xonotic/darkplaces.git] / cl_main.c
index 18503b6ee6de09c68af24a314daf22159c414b22..b57f4507ea86457b4d4be696451a8d9cb0e6f78b 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -98,6 +98,7 @@ void CL_ClearState(void)
        if (!sv.active)
                Host_ClearMemory ();
 
+       // note: this also gets rid of the entity database
        Mem_EmptyPool(cl_entities_mempool);
 
 // wipe the entire cl structure
@@ -221,13 +222,13 @@ void CL_EstablishConnection(const char *host)
 
        // clear menu's connect error message
        m_return_reason[0] = 0;
-
-       // stop demo loop in case this fails
        cls.demonum = -1;
-       CL_Disconnect();
 
        if (LHNETADDRESS_FromString(&cls.connect_address, host, 26000) && (cls.connect_mysocket = NetConn_ChooseClientSocketForAddress(&cls.connect_address)))
        {
+               // stop demo loop in case this fails
+               CL_Disconnect();
+
                cls.connect_trying = true;
                cls.connect_remainingtries = 3;
                cls.connect_nextsendtime = 0;
@@ -243,6 +244,11 @@ void CL_EstablishConnection(const char *host)
                        NetConn_ServerFrame();
                }
        }
+       else
+       {
+               Con_Printf("Unable to find a suitable network socket to connect to server.\n");
+               strcpy(m_return_reason, "No network");
+       }
 }
 
 /*
@@ -262,10 +268,9 @@ static void CL_PrintEntities_f(void)
                        continue;
 
                if (ent->render.model)
-                       strncpy(name, ent->render.model->name, 25);
+                       strlcpy (name, ent->render.model->name, 25);
                else
                        strcpy(name, "--no model--");
-               name[25] = 0;
                for (j = strlen(name);j < 25;j++)
                        name[j] = ' ';
                Con_Printf ("%3i: %s:%04i (%5i %5i %5i) [%3i %3i %3i] %4.2f %5.3f\n", i, name, ent->render.frame, (int) ent->render.origin[0], (int) ent->render.origin[1], (int) ent->render.origin[2], (int) ent->render.angles[0] % 360, (int) ent->render.angles[1] % 360, (int) ent->render.angles[2] % 360, ent->render.scale, ent->render.alpha);
@@ -349,7 +354,7 @@ static float CL_LerpPoint(void)
 
        // LordHavoc: lerp in listen games as the server is being capped below the client (usually)
        f = cl.mtime[0] - cl.mtime[1];
-       if (!f || cl_nolerp.integer || cls.timedemo || (sv.active && svs.maxclients == 1))
+       if (!f || cl_nolerp.integer || cls.timedemo || cl.islocalgame)
        {
                cl.time = cl.mtime[0];
                return 1;
@@ -461,7 +466,6 @@ void CL_DecayLights(void)
                        dl->radius = (cl.time < dl->die) ? max(0, dl->radius - time * dl->decay) : 0;
 }
 
-extern qboolean Nehahrademcompatibility;
 #define MAXVIEWMODELS 32
 entity_t *viewmodels[MAXVIEWMODELS];
 int numviewmodels;
@@ -602,7 +606,7 @@ void CL_LinkNetworkEntity(entity_t *e)
                if (e->render.model)
                {
                        Mod_CheckLoaded(e->render.model);
-                       if (e->render.model->type != mod_brush)
+                       if (e->render.model->type == mod_alias || e->render.model->type == mod_sprite)
                                angles[0] = -angles[0];
                        if (e->render.model->flags & EF_ROTATE)
                        {
@@ -709,7 +713,7 @@ void CL_LinkNetworkEntity(entity_t *e)
                if (e->persistent.muzzleflash > 0)
                {
                        Matrix4x4_Transform(&e->render.matrix, muzzleflashorigin, v2);
-                       CL_TraceLine(origin, v2, v, NULL, 0, true, NULL);
+                       CL_TraceLine(origin, v2, v, NULL, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY);
                        CL_AllocDlight(NULL, v, e->persistent.muzzleflash, 1, 1, 1, 0, 0);
                        e->persistent.muzzleflash -= cl.frametime * 1000;
                }
@@ -785,12 +789,12 @@ void CL_LinkNetworkEntity(entity_t *e)
                if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE))
                 && (e->render.alpha == 1)
                 && !(e->render.flags & RENDER_VIEWMODEL)
-                && ((e - cl_entities) != cl.viewentity || (!cl.intermission && !Nehahrademcompatibility && !cl_noplayershadow.integer)))
+                && ((e - cl_entities) != cl.viewentity || (!cl.intermission && cl.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
                        e->render.flags |= RENDER_SHADOW;
                // as soon as player is known we can call V_CalcRefDef
                if ((e - cl_entities) == cl.viewentity)
                        V_CalcRefdef();
-               if (e->render.model && e->render.model->name[0] == '*' && e->render.model->type == mod_brush)
+               if (e->render.model && e->render.model->name[0] == '*' && e->render.model->brush.TraceBox)
                        cl_brushmodel_entities[cl_num_brushmodel_entities++] = &e->render;
                // don't show entities with no modelindex (note: this still shows
                // entities which have a modelindex that resolved to a NULL model)