]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
(Round 6) Break up host_cmd.c
[xonotic/darkplaces.git] / cl_main.c
index 9958ecd51d021da8686d44917218d444bb2c39f5..e3a06b951d65d6dd914a349f4a703ea95d5fbf1c 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -209,6 +209,9 @@ void CL_ClearState(void)
        CL_Screen_NewMap();
 }
 
+extern cvar_t cl_topcolor;
+extern cvar_t cl_bottomcolor;
+
 void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allowstarkey, qboolean allowmodel, qboolean quiet)
 {
        int i;
@@ -255,11 +258,13 @@ void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allo
                }
                else if (!strcasecmp(key, "topcolor"))
                {
-                       // don't send anything, the combined color code will be updated manually
+                       MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString(&cls.netcon->message, va(vabuf, sizeof(vabuf), "color %i %i", atoi(value), cl_bottomcolor.integer));
                }
                else if (!strcasecmp(key, "bottomcolor"))
                {
-                       // don't send anything, the combined color code will be updated manually
+                       MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString(&cls.netcon->message, va(vabuf, sizeof(vabuf), "color %i %i", cl_topcolor.integer, atoi(value)));
                }
                else if (!strcasecmp(key, "rate"))
                {
@@ -498,7 +503,7 @@ CL_EstablishConnection
 Host should be either "local" or a net address
 =====================
 */
-void CL_EstablishConnection(const char *host, int firstarg)
+void CL_EstablishConnection(const char *address, int firstarg)
 {
        if (cls.state == ca_dedicated)
                return;
@@ -518,7 +523,7 @@ void CL_EstablishConnection(const char *host, int firstarg)
        // make sure the client ports are open before attempting to connect
        NetConn_UpdateSockets();
 
-       if (LHNETADDRESS_FromString(&cls.connect_address, host, 26000) && (cls.connect_mysocket = NetConn_ChooseClientSocketForAddress(&cls.connect_address)))
+       if (LHNETADDRESS_FromString(&cls.connect_address, address, 26000) && (cls.connect_mysocket = NetConn_ChooseClientSocketForAddress(&cls.connect_address)))
        {
                cls.connect_trying = true;
                cls.connect_remainingtries = 3;
@@ -2263,7 +2268,7 @@ static void CL_Locs_Save_f(cmd_state_t *cmd)
                        if (VectorCompare(loc->mins, loc->maxs))
                                break;
                if (loc)
-                       Con_Warnf("Warning: writing loc file containing a mixture of qizmo-style points and proquake-style boxes may not work in qizmo or proquake!\n");
+                       Con_Printf(CON_WARN "Warning: writing loc file containing a mixture of qizmo-style points and proquake-style boxes may not work in qizmo or proquake!\n");
        }
        for (loc = cl.locnodes;loc;loc = loc->next)
        {
@@ -2483,7 +2488,8 @@ static void CL_MeshEntities_Init(void)
                VectorSet(ent->render.render_modellight_ambient, 1, 1, 1);
                VectorSet(ent->render.render_modellight_diffuse, 0, 0, 0);
                VectorSet(ent->render.render_modellight_specular, 0, 0, 0);
-               VectorSet(ent->render.render_modellight_lightdir, 0, 0, 1);
+               VectorSet(ent->render.render_modellight_lightdir_world, 0, 0, 1);
+               VectorSet(ent->render.render_modellight_lightdir_local, 0, 0, 1); // local doesn't matter because no diffuse/specular color
                VectorSet(ent->render.render_lightmap_ambient, 0, 0, 0);
                VectorSet(ent->render.render_lightmap_diffuse, 1, 1, 1);
                VectorSet(ent->render.render_lightmap_specular, 1, 1, 1);
@@ -2659,7 +2665,7 @@ static void CL_UpdateEntityShading_Entity(entity_render_t *ent)
                ent->render_modellight_ambient[q] = a[q] * ent->colormod[q];
                ent->render_modellight_diffuse[q] = c[q] * ent->colormod[q];
                ent->render_modellight_specular[q] = c[q];
-               ent->render_modellight_lightdir[q] = dir[q];
+               ent->render_modellight_lightdir_world[q] = dir[q];
                ent->render_lightmap_ambient[q] = ent->colormod[q] * r_refdef.scene.ambientintensity;
                ent->render_lightmap_diffuse[q] = ent->colormod[q] * r_refdef.scene.lightmapintensity;
                ent->render_lightmap_specular[q] = r_refdef.scene.lightmapintensity;
@@ -2675,9 +2681,12 @@ static void CL_UpdateEntityShading_Entity(entity_render_t *ent)
                for (q = 0; q < 3; q++)
                        ent->render_rtlight_diffuse[q] = ent->render_rtlight_specular[q] = q;
 
-       if (VectorLength2(ent->render_modellight_lightdir) == 0)
-               VectorSet(ent->render_modellight_lightdir, 0, 0, 1); // have to set SOME valid vector here
-       VectorNormalize(ent->render_modellight_lightdir);
+       if (VectorLength2(ent->render_modellight_lightdir_world) == 0)
+               VectorSet(ent->render_modellight_lightdir_world, 0, 0, 1); // have to set SOME valid vector here
+       VectorNormalize(ent->render_modellight_lightdir_world);
+       // transform into local space for the entity as well
+       Matrix4x4_Transform3x3(&ent->inversematrix, ent->render_modellight_lightdir_world, ent->render_modellight_lightdir_local);
+       VectorNormalize(ent->render_modellight_lightdir_local);
 }
 
 
@@ -2750,6 +2759,8 @@ void CL_Init (void)
        //
        // register our commands
        //
+               CL_InitCommands();
+
                Cvar_RegisterVariable (&cl_upspeed);
                Cvar_RegisterVariable (&cl_forwardspeed);
                Cvar_RegisterVariable (&cl_backspeed);