From e9857d82138de83d546d774c3d5efd41db7d7580 Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV Date: Sat, 19 May 2001 20:57:29 +0000 Subject: [PATCH] Merges, and cl_writecfg now works in nq. --- nq/source/cl_main.c | 8 ++--- nq/source/com.c | 7 ++-- nq/source/gl_rmain.c | 16 ++++++---- nq/source/host.c | 36 ++++++++++----------- qw/source/cl_main.c | 8 ++--- qw/source/com.c | 2 +- qw/source/gl_rmain.c | 76 ++++++++++++++++++++++++++++++++++++++++++-- 7 files changed, 112 insertions(+), 41 deletions(-) diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index a341b260d..577565bfb 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -1,4 +1,3 @@ - /* cl_main.c @@ -51,13 +50,10 @@ byte *vid_colormap; -// we need to declare some mouse variables here, because the menu system -// references them even when on a unix system. - // these two are not intended to be set directly cvar_t *cl_name; -cvar_t *writecfg; +cvar_t *cl_writecfg; cvar_t *cl_shownet; cvar_t *cl_nolerp; @@ -133,6 +129,8 @@ CL_InitCvars (void) "swim/fly up/down speed"); cl_yawspeed = Cvar_Get ("cl_yawspeed", "140", CVAR_NONE, NULL, "turning speed"); + cl_writecfg = Cvar_Get ("cl_writecfg", "1", CVAR_NONE, NULL, + "write config files?"); cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_NONE, NULL, "show network packets. 0=off, 1=basic, 2=verbose"); cl_nolerp = Cvar_Get ("cl_nolerp", "0", CVAR_NONE, NULL, diff --git a/nq/source/com.c b/nq/source/com.c index fca6de646..8e46091c1 100644 --- a/nq/source/com.c +++ b/nq/source/com.c @@ -1,7 +1,7 @@ /* com.c - @description@ + misc functions used in client and server Copyright (C) 1996-1997 Id Software, Inc. @@ -75,9 +75,10 @@ COM_CheckRegistered (void) void -COM_Init () +COM_Init (void) { - registered = Cvar_Get ("registered", "0", CVAR_NONE, NULL, "None"); + registered = Cvar_Get ("registered", "0", CVAR_NONE, NULL, + "Is the game the registered version. 1 yes 0 no"); cmdline = Cvar_Get ("cmdline", "0", CVAR_SERVERINFO, Cvar_Info, "None"); Cmd_AddCommand ("path", COM_Path_f, "No Description"); diff --git a/nq/source/gl_rmain.c b/nq/source/gl_rmain.c index 2421597f8..ba8e1c0d0 100644 --- a/nq/source/gl_rmain.c +++ b/nq/source/gl_rmain.c @@ -50,9 +50,9 @@ #include "QF/sys.h" #include "QF/vid.h" -#include "client.h" #include "chase.h" -#include "game.h" +#include "client.h" +//#include "game.h" #include "glquake.h" #include "r_cvar.h" #include "r_dynamic.h" @@ -652,7 +652,7 @@ R_DrawAliasModel (entity_t *e) } // clamp lighting so it doesn't overbright as much - shadelight = min (shadelight, 200); + shadelight = min (shadelight, 100); // was 200 // never allow players to go totally black if (strequal (clmodel->name, "progs/player.mdl")) { @@ -1080,7 +1080,10 @@ R_RenderScene (void) R_RenderDlights (); } + void R_RenderBrushPoly (msurface_t *fa); + + void R_Mirror (void) { @@ -1093,9 +1096,8 @@ R_Mirror (void) memcpy (r_base_world_matrix, r_world_matrix, sizeof (r_base_world_matrix)); - d = - DotProduct (r_refdef.vieworg, - mirror_plane->normal) - mirror_plane->dist; + d = DotProduct (r_refdef.vieworg, mirror_plane->normal) - + mirror_plane->dist; VectorMA (r_refdef.vieworg, -2 * d, mirror_plane->normal, r_refdef.vieworg); d = DotProduct (vpn, mirror_plane->normal); @@ -1157,7 +1159,7 @@ R_RenderView (void) if (!r_worldentity.model || !cl.worldmodel) Sys_Error ("R_RenderView: NULL worldmodel"); -// glFinish (); +// glFinish (); mirror = false; diff --git a/nq/source/host.c b/nq/source/host.c index d38ef413d..19dd35af5 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -1,4 +1,3 @@ - /* host.c @@ -73,28 +72,29 @@ Memory is cleared / released when a server or client begins, not when they end. extern int fps_count; -qboolean msg_suppress_1 = 0; +qboolean msg_suppress_1 = 0; quakeparms_t host_parms; -qboolean host_initialized; // true if into command execution +qboolean host_initialized; // true if into command execution -double host_frametime; -double host_time; -double realtime; // without any filtering or bounding -double oldrealtime; // last frame run -int host_framecount; +double host_frametime; +double host_time; +double realtime; // without any filtering or bounding +double oldrealtime; // last frame run +int host_framecount; +int host_hunklevel; -int host_hunklevel; - -int minimum_memory; +int minimum_memory; client_t *host_client; // current client -jmp_buf host_abortserver; +jmp_buf host_abortserver; byte *vid_basepal; +extern cvar_t *cl_writecfg; + cvar_t *fs_globalcfg; cvar_t *fs_usercfg; @@ -161,7 +161,7 @@ Host_Error (char *error, ...) Sys_Error ("Host_Error: recursively entered"); inerror = true; -// SCR_EndLoadingPlaque (); // reenable screen updates +// SCR_EndLoadingPlaque (); // reenable screen updates va_start (argptr, error); vsnprintf (string, sizeof (string), error, argptr); @@ -172,7 +172,7 @@ Host_Error (char *error, ...) Host_ShutdownServer (false); if (cls.state == ca_dedicated) - Sys_Error ("Host_Error: %s\n", string); // dedicated servers exit + Sys_Error ("Host_Error: %s\n", string); // dedicated servers exit CL_Disconnect (); cls.demonum = -1; @@ -257,8 +257,7 @@ Host_InitLocal (void) Host_FindMaxClients (); - host_time = 1.0; // so a think at time 0 won't get - // called + host_time = 1.0; // so a think at time 0 won't get called } @@ -274,8 +273,9 @@ Host_WriteConfiguration (void) // dedicated servers initialize the host but don't parse and set the // config.cfg cvars - if (host_initialized & !isDedicated) { - f = Qopen (va ("%s/config.cfg", com_gamedir), "w"); + if (cl_writecfg->int_val && (host_initialized & !isDedicated)) { + char *path = va ("%s/config.cfg", com_gamedir); + f = Qopen (path, "w"); if (!f) { Con_Printf ("Couldn't write config.cfg.\n"); return; diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 3ef5c13d6..202b9d899 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -145,9 +145,7 @@ cvar_t *localid; static qboolean allowremotecmd = true; -// -// info mirrors -// +/* info mirrors */ cvar_t *password; cvar_t *spectator; cvar_t *cl_name; @@ -1241,6 +1239,8 @@ CL_Init_Cvars (void) "swim/fly up/down speed"); cl_yawspeed = Cvar_Get ("cl_yawspeed", "140", CVAR_NONE, NULL, "turning speed"); + cl_writecfg = Cvar_Get ("cl_writecfg", "1", CVAR_NONE, NULL, + "write config files?"); cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_NONE, NULL, "show network packets. 0=off, 1=basic, 2=verbose"); cl_sbar = Cvar_Get ("cl_sbar", "0", CVAR_ARCHIVE, NULL, "status bar mode"); @@ -1272,8 +1272,6 @@ CL_Init_Cvars (void) "display realtime frames per second"); show_time = Cvar_Get ("show_time", "0", CVAR_NONE, NULL, "display the current time"); - cl_writecfg = Cvar_Get ("cl_writecfg", "1", CVAR_NONE, NULL, - "write config files?"); cl_predict_players2 = Cvar_Get ("cl_predict_players2", "1", CVAR_NONE, NULL, "If this and cl_predict_players are " "0, no player prediction is done"); diff --git a/qw/source/com.c b/qw/source/com.c index 173e5044b..ba76ca6bb 100644 --- a/qw/source/com.c +++ b/qw/source/com.c @@ -91,5 +91,5 @@ void COM_Init_Cvars (void) { registered = Cvar_Get ("registered", "0", CVAR_NONE, NULL, - "Is the game the registered version. 1 yes 0 no"); + "Is the game the registered version. 1 yes 0 no"); } diff --git a/qw/source/gl_rmain.c b/qw/source/gl_rmain.c index df1b5fc46..3ffacccbb 100644 --- a/qw/source/gl_rmain.c +++ b/qw/source/gl_rmain.c @@ -54,6 +54,7 @@ #include "cl_cam.h" #include "cl_main.h" #include "cl_parse.h" //FIXME CL_NewTranslation +#include "cl_tent.h" // only for mirror support #include "glquake.h" #include "r_cvar.h" #include "r_dynamic.h" @@ -651,7 +652,7 @@ R_DrawAliasModel (entity_t *e) } // clamp lighting so it doesn't overbright as much - shadelight = min (shadelight, 100); + shadelight = min (shadelight, 100); // was 200 // never allow players to go totally black if (strequal (clmodel->name, "progs/player.mdl")) { @@ -1077,6 +1078,72 @@ R_RenderScene (void) R_RenderDlights (); } + +void R_RenderBrushPoly (msurface_t *fa); + + +void +R_Mirror (void) +{ +#if 0 + float d; + msurface_t *s; + entity_t **ent; + + if (!mirror) + return; + + memcpy (r_base_world_matrix, r_world_matrix, sizeof (r_base_world_matrix)); + + d = DotProduct (r_refdef.vieworg, mirror_plane->normal) - + mirror_plane->dist; + VectorMA (r_refdef.vieworg, -2 * d, mirror_plane->normal, r_refdef.vieworg); + + d = DotProduct (vpn, mirror_plane->normal); + VectorMA (vpn, -2 * d, mirror_plane->normal, vpn); + + r_refdef.viewangles[0] = -asin (vpn[2]) / M_PI * 180; + r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0]) / M_PI * 180; + r_refdef.viewangles[2] = -r_refdef.viewangles[2]; + + ent = CL_NewTempEntity(); + if (ent) + *ent = &cl_entities[cl.viewentity]; + + gldepthmin = 0.5; + gldepthmax = 1; + glDepthRange (gldepthmin, gldepthmax); + glDepthFunc (GL_LEQUAL); + + R_RenderScene (); + R_DrawWaterSurfaces (); + + gldepthmin = 0; + gldepthmax = 1;//XXX 0.5; + glDepthRange (gldepthmin, gldepthmax); + glDepthFunc (GL_LEQUAL); + + // blend on top + glMatrixMode (GL_PROJECTION); + if (mirror_plane->normal[2]) + glScalef (1, -1, 1); + else + glScalef (-1, 1, 1); + glCullFace (GL_FRONT); + glMatrixMode (GL_MODELVIEW); + + glLoadMatrixf (r_base_world_matrix); + + glColor4f (1, 1, 1, r_mirroralpha->value); + s = cl.worldmodel->textures[mirrortexturenum]->texturechain; + for (; s; s = s->texturechain) + R_RenderBrushPoly (s); + cl.worldmodel->textures[mirrortexturenum]->texturechain = NULL; + glColor4f (1, 1, 1, 1); +#endif +} + + /* R_RenderView @@ -1091,7 +1158,9 @@ R_RenderView (void) if (!r_worldentity.model || !cl.worldmodel) Sys_Error ("R_RenderView: NULL worldmodel"); -// glFinish (); +// glFinish (); + + mirror = false; R_Clear (); @@ -1105,4 +1174,7 @@ R_RenderView (void) R_DrawParticles (); R_DrawViewModel (); + + // render mirror view + R_Mirror (); }