]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.c
Split the global cmd interpreter into 4 separate ones for specific uses (client conso...
[xonotic/darkplaces.git] / model_shared.c
index 48b4315ba67c3a96053c105868db7c0841d48343..cb04f3bc76ef2427105f5ddc0995192b9d07661d 100644 (file)
@@ -148,10 +148,10 @@ static void mod_newmap(void)
 Mod_Init
 ===============
 */
-static void Mod_Print(void);
-static void Mod_Precache (void);
-static void Mod_Decompile_f(void);
-static void Mod_GenerateLightmaps_f(void);
+static void Mod_Print_f(cmd_state_t *cmd);
+static void Mod_Precache_f(cmd_state_t *cmd);
+static void Mod_Decompile_f(cmd_state_t *cmd);
+static void Mod_GenerateLightmaps_f(cmd_state_t *cmd);
 void Mod_Init (void)
 {
        mod_mempool = Mem_AllocPool("modelinfo", 0, NULL);
@@ -174,10 +174,10 @@ void Mod_Init (void)
        Cvar_RegisterVariable(&mod_generatelightmaps_vertexradius);
        Cvar_RegisterVariable(&mod_generatelightmaps_gridradius);
 
-       Cmd_AddCommand ("modellist", Mod_Print, "prints a list of loaded models");
-       Cmd_AddCommand ("modelprecache", Mod_Precache, "load a model");
-       Cmd_AddCommand ("modeldecompile", Mod_Decompile_f, "exports a model in several formats for editing purposes");
-       Cmd_AddCommand ("mod_generatelightmaps", Mod_GenerateLightmaps_f, "rebuilds lighting on current worldmodel");
+       Cmd_AddCommand(&cmd_client, "modellist", Mod_Print_f, "prints a list of loaded models");
+       Cmd_AddCommand(&cmd_client, "modelprecache", Mod_Precache_f, "load a model");
+       Cmd_AddCommand(&cmd_client, "modeldecompile", Mod_Decompile_f, "exports a model in several formats for editing purposes");
+       Cmd_AddCommand(&cmd_client, "mod_generatelightmaps", Mod_GenerateLightmaps_f, "rebuilds lighting on current worldmodel");
 }
 
 void Mod_RenderInit(void)
@@ -460,7 +460,7 @@ dp_model_t *Mod_LoadModel(dp_model_t *mod, qboolean crash, qboolean checkdisk)
        
        SCR_PushLoadingScreen(true, mod->name, 1);
 
-       // LordHavoc: unload the existing model in this slot (if there is one)
+       // LadyHavoc: unload the existing model in this slot (if there is one)
        if (mod->loaded || mod->mempool)
                Mod_UnloadModel(mod);
 
@@ -527,7 +527,7 @@ dp_model_t *Mod_LoadModel(dp_model_t *mod, qboolean crash, qboolean checkdisk)
        }
        else if (crash)
        {
-               // LordHavoc: Sys_Error was *ANNOYING*
+               // LadyHavoc: Sys_Error was *ANNOYING*
                Con_Printf ("Mod_LoadModel: %s not found\n", mod->name);
        }
 
@@ -663,7 +663,7 @@ unsigned char *mod_base;
 Mod_Print
 ================
 */
-static void Mod_Print(void)
+static void Mod_Print_f(cmd_state_t *cmd)
 {
        int i;
        int nummodels = (int)Mem_ExpandableArray_IndexRange(&models);
@@ -687,10 +687,10 @@ static void Mod_Print(void)
 Mod_Precache
 ================
 */
-static void Mod_Precache(void)
+static void Mod_Precache_f(cmd_state_t *cmd)
 {
-       if (Cmd_Argc() == 2)
-               Mod_ForName(Cmd_Argv(1), false, true, Cmd_Argv(1)[0] == '*' ? cl.model_name[1] : NULL);
+       if (Cmd_Argc(cmd) == 2)
+               Mod_ForName(Cmd_Argv(cmd, 1), false, true, Cmd_Argv(cmd, 1)[0] == '*' ? cl.model_name[1] : NULL);
        else
                Con_Print("usage: modelprecache <filename>\n");
 }
@@ -1113,9 +1113,9 @@ void Mod_ShadowMesh_CalcBBox(shadowmesh_t *mesh, vec3_t mins, vec3_t maxs, vec3_
        VectorCopy(mesh->vertex3f, nmaxs);
        for (i = 0, v = mesh->vertex3f;i < mesh->numverts;i++, v += 3)
        {
-               if (nmins[0] > v[0]) nmins[0] = v[0];if (nmaxs[0] < v[0]) nmaxs[0] = v[0];
-               if (nmins[1] > v[1]) nmins[1] = v[1];if (nmaxs[1] < v[1]) nmaxs[1] = v[1];
-               if (nmins[2] > v[2]) nmins[2] = v[2];if (nmaxs[2] < v[2]) nmaxs[2] = v[2];
+               if (nmins[0] > v[0]) { nmins[0] = v[0]; } if (nmaxs[0] < v[0]) { nmaxs[0] = v[0]; }
+               if (nmins[1] > v[1]) { nmins[1] = v[1]; } if (nmaxs[1] < v[1]) { nmaxs[1] = v[1]; }
+               if (nmins[2] > v[2]) { nmins[2] = v[2]; } if (nmaxs[2] < v[2]) { nmaxs[2] = v[2]; }
        }
        // calculate center and radius
        ncenter[0] = (nmins[0] + nmaxs[0]) * 0.5f;
@@ -1431,14 +1431,6 @@ static void Q3Shader_AddToHash (q3shaderinfo_t* shader)
        memcpy (&entry->shader, shader, sizeof (q3shaderinfo_t));
 }
 
-extern cvar_t mod_noshader_default_offsetmapping;
-extern cvar_t mod_q3shader_default_offsetmapping;
-extern cvar_t mod_q3shader_default_offsetmapping_scale;
-extern cvar_t mod_q3shader_default_offsetmapping_bias;
-extern cvar_t mod_q3shader_default_polygonoffset;
-extern cvar_t mod_q3shader_default_polygonfactor;
-extern cvar_t mod_q3shader_force_addalpha;
-extern cvar_t mod_q3shader_force_terrain_alphaflag;
 void Mod_LoadQ3Shaders(void)
 {
        int j;
@@ -2473,6 +2465,7 @@ nothing                GL_ZERO GL_ONE
                texture->specularscalemod = shader->specularscalemod;
                texture->specularpowermod = shader->specularpowermod;
                texture->rtlightambient = shader->rtlightambient;
+               texture->refractive_index = mod_q3shader_default_refractive_index.value;
                if (shader->dpreflectcube[0])
                        texture->reflectcubetexture = R_GetCubemap(shader->dpreflectcube);
 
@@ -2893,6 +2886,9 @@ void Mod_MakeSortedSurfaces(dp_model_t *mod)
 
 void Mod_BuildVBOs(void)
 {
+       if(cls.state == ca_dedicated)
+               return;
+
        if (!loadmodel->surfmesh.num_vertices)
                return;
 
@@ -3242,7 +3238,7 @@ Mod_Decompile_f
 decompiles a model to editable files
 ================
 */
-static void Mod_Decompile_f(void)
+static void Mod_Decompile_f(cmd_state_t *cmd)
 {
        int i, j, k, l, first, count;
        dp_model_t *mod;
@@ -3260,13 +3256,13 @@ static void Mod_Decompile_f(void)
        int framegroupstextsize = 0;
        char vabuf[1024];
 
-       if (Cmd_Argc() != 2)
+       if (Cmd_Argc(cmd) != 2)
        {
                Con_Print("usage: modeldecompile <filename>\n");
                return;
        }
 
-       strlcpy(inname, Cmd_Argv(1), sizeof(inname));
+       strlcpy(inname, Cmd_Argv(cmd, 1), sizeof(inname));
        FS_StripExtension(inname, basename, sizeof(basename));
 
        mod = Mod_ForName(inname, false, true, inname[0] == '*' ? cl.model_name[1] : NULL);
@@ -4351,9 +4347,9 @@ static void Mod_GenerateLightmaps(dp_model_t *model)
        loadmodel = oldloadmodel;
 }
 
-static void Mod_GenerateLightmaps_f(void)
+static void Mod_GenerateLightmaps_f(cmd_state_t *cmd)
 {
-       if (Cmd_Argc() != 1)
+       if (Cmd_Argc(cmd) != 1)
        {
                Con_Printf("usage: mod_generatelightmaps\n");
                return;