From 48576a59dc016903ad825e8e7eb5993ebf3ef3e3 Mon Sep 17 00:00:00 2001
From: Spoike <acceptthis@users.sourceforge.net>
Date: Mon, 9 Jan 2023 05:15:31 +0000
Subject: [PATCH] A bit of a code cleanup, change a couple of prints.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6343 fc73d0e0-1445-4013-8a0c-d673dee63da5
---
 engine/client/cl_main.c  | 61 ++++++++++++++++++++++------------------
 engine/client/console.c  |  8 +++---
 engine/client/pr_csqc.c  | 19 +++----------
 engine/gl/gl_backend.c   |  2 +-
 engine/gl/gl_model.c     |  2 +-
 engine/gl/gl_shadow.c    |  6 ++--
 engine/server/pr_cmds.c  | 21 +++++++-------
 engine/server/sv_ccmds.c |  4 +--
 plugins/cef/cef.c        |  2 +-
 9 files changed, 61 insertions(+), 64 deletions(-)

diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c
index 54e869d1c..ad9982214 100644
--- a/engine/client/cl_main.c
+++ b/engine/client/cl_main.c
@@ -4858,80 +4858,80 @@ void CL_Status_f(void)
 
 	if (cls.state)
 	{
-		Con_Printf("Server address: %s\n", NET_AdrToString(adr, sizeof(adr), &cls.netchan.remote_address));	//not relevent as a limit.
-
+		Con_Printf("Server address   : %s\n", NET_AdrToString(adr, sizeof(adr), &cls.netchan.remote_address));	//not relevent as a limit.
 		switch(cls.protocol)
 		{
 		default:
 		case CP_UNKNOWN:
-			Con_Printf("Unknown protocol\n");
+			Con_Printf("Network Protocol : Unknown\n");
 			break;
 		case CP_QUAKEWORLD:
-			Con_Printf("QuakeWorld-based protocol\n");
+			Con_Printf("Network Protocol : QuakeWorld\n");
 			break;
 	#ifdef NQPROT
 		case CP_NETQUAKE:
 			switch(cls.protocol_nq)
 			{
 			case CPNQ_ID:
-				Con_Printf("NetQuake-based protocol\n");
 				if (cls.proquake_angles_hack)
-					Con_Printf("With ProQuake's extended angles\n");
+					Con_Printf("Network Protocol : ProQuake\n");
+				else
+					Con_Printf("Network Protocol : NetQuake\n");
 				break;
 			case CPNQ_NEHAHRA:
-				Con_Printf("Nehahra protocol\n");
+				Con_Printf("Network Protocol : Nehahra\n");
 				break;
 			case CPNQ_BJP1:
-				Con_Printf("BJP1 protocol\n");
+				Con_Printf("Network Protocol : BJP1\n");
 				break;
 			case CPNQ_BJP2:
-				Con_Printf("BJP2 protocol\n");
+				Con_Printf("Network Protocol : BJP2\n");
 				break;
 			case CPNQ_BJP3:
-				Con_Printf("BJP3 protocol\n");
+				Con_Printf("Network Protocol : BJP3\n");
 				break;
 			case CPNQ_FITZ666:
-				Con_Printf("FitzQuake-based protocol\n");
+				Con_Printf("Network Protocol : FitzQuake\n");
 				break;
 			case CPNQ_DP5:
-				Con_Printf("DPP5 protocol\n");
+				Con_Printf("Network Protocol : DPP5\n");
 				break;
 			case CPNQ_DP6:
-				Con_Printf("DPP6 protocol\n");
+				Con_Printf("Network Protocol : DPP6\n");
 				break;
 			case CPNQ_DP7:
-				Con_Printf("DPP7 protocol\n");
+				Con_Printf("Network Protocol : DPP7\n");
 				break;
 			}
 			break;
 	#endif
 	#ifdef Q2CLIENT
 		case CP_QUAKE2:
-			Con_Printf("Quake2-based protocol\n");
-			if (cls.protocol_q2 && cls.protocol_q2 < PROTOCOL_VERSION_Q2)
-				Con_Printf("\toutdated protocol version\n");
-			else switch (cls.protocol_q2)
+			switch (cls.protocol_q2)
 			{
 			case PROTOCOL_VERSION_Q2:
-				Con_Printf("\tStandard Quake2\n");
+				Con_Printf("Network Protocol : Quake2\n");
 				break;
 			case PROTOCOL_VERSION_R1Q2:
-				Con_Printf("\tR1Q2\n");
+				Con_Printf("Network Protocol : R1Q2\n");
 				break;
 			case PROTOCOL_VERSION_Q2PRO:
-				Con_Printf("\tQ2Pro\n");
+				Con_Printf("Network Protocol : Q2Pro\n");
+				break;
+			default:
+				Con_Printf("Network Protocol : Quake2 (OLD)\n");
 				break;
 			}
 			break;
 	#endif
 	#ifdef Q3CLIENT
 		case CP_QUAKE3:
-			Con_Printf("Quake3-based protocol\n");
+			Con_Printf("Network Protocol : Quake3\n");
 			break;
 	#endif
 	#ifdef PLUGINS
 		case CP_PLUGIN:
-			Con_Printf("external protocol\n");
+			Con_Printf("Network Protocol : (unknown, provided by plugin)\n");
 			break;
 	#endif
 		}
@@ -4947,6 +4947,10 @@ void CL_Status_f(void)
 			Con_Printf("\tvoice chat\n");
 		if (cls.fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS)
 			Con_Printf("\treplacement deltas\n");
+		if (cls.fteprotocolextensions2 & PEXT2_VRINPUTS)
+			Con_Printf("\tvrinputs\n");
+		if (cls.fteprotocolextensions2 & PEXT2_INFOBLOBS)
+			Con_Printf("\tinfoblobs\n");
 	}
 
 	if (cl.worldmodel)
@@ -4962,6 +4966,7 @@ void CL_Status_f(void)
 		extern int num_sfx;
 		int count = 0, i;
 		edict_t *e;
+		Con_Printf ("csqc             : loaded\n");
 		for (i = 0; i < csqc_world.num_edicts; i++)
 		{
 			e = EDICT_NUM_PB(csqc_world.progs, i);
@@ -4969,21 +4974,23 @@ void CL_Status_f(void)
 				continue;	//free, and older than the zombie time
 			count++;
 		}
-		Con_Printf("entities         : %i/%i/%i (mem: %.1f%%)\n", count, csqc_world.num_edicts, csqc_world.max_edicts, 100*(float)(csqc_world.progs->stringtablesize/(double)csqc_world.progs->stringtablemaxsize));
+		Con_Printf("csqc entities    : %i/%i/%i (mem: %.1f%%)\n", count, csqc_world.num_edicts, csqc_world.max_edicts, 100*(float)(csqc_world.progs->stringtablesize/(double)csqc_world.progs->stringtablemaxsize));
 		for (count = 1; count < MAX_PRECACHE_MODELS; count++)
 			if (!*cl.model_csqcname[count])
 				break;
-		Con_Printf("models           : %i/%i\n", count, MAX_PRECACHE_MODELS);
-		Con_Printf("sounds           : %i/\n", num_sfx);	//there is a limit, its just private. :(
+		Con_Printf("csqc models      : %i/%i\n", count, MAX_PRECACHE_MODELS);
+		Con_Printf("client sounds    : %i\n", num_sfx);	//there is a limit, its just private. :(
 
 		for (count = 1; count < MAX_SSPARTICLESPRE; count++)
 			if (!cl.particle_csname[count])
 				break;
 		if (count!=1)
-			Con_Printf("particles        : %i/%i\n", count, MAX_SSPARTICLESPRE);
+			Con_Printf("csqc particles   : %i/%i\n", count, MAX_CSPARTICLESPRE);
 		if (cl.csqcdebug)
 			Con_Printf("csqc debug       : true\n");
 	}
+	else
+		Con_Printf ("csqc             : not loaded\n");
 #endif
 	Con_Printf("gamedir          : %s\n", FS_GetGamedir(true));
 }
diff --git a/engine/client/console.c b/engine/client/console.c
index 12ec13dc3..f857d9c8f 100644
--- a/engine/client/console.c
+++ b/engine/client/console.c
@@ -1930,10 +1930,10 @@ static int Con_DrawProgress(int left, int right, int y)
 		if (progresspercent < 0)
 		{
 			if ((int)(realtime/2)&1 || total == 0)
-				sprintf(progresspercenttext, " (%ukbps)", CL_DownloadRate()/1000);
+				sprintf(progresspercenttext, " (%ukB/s)", CL_DownloadRate()/1000);
 			else
 			{
-				sprintf(progresspercenttext, " (%u%skb)", (int)(total/1024), extra?"+":"");
+				sprintf(progresspercenttext, " (%u%sKiB)", (int)(total/1024), extra?"+":"");
 			}
 
 			//do some marquee thing, so the user gets the impression that SOMETHING is happening.
@@ -1945,10 +1945,10 @@ static int Con_DrawProgress(int left, int right, int y)
 		else
 		{
 			if ((int)(realtime/2)&1 || total == 0)
-				sprintf(progresspercenttext, " %5.1f%% (%ukbps)", progresspercent, CL_DownloadRate()/1000);
+				sprintf(progresspercenttext, " %5.1f%% (%ukB/s)", progresspercent, CL_DownloadRate()/1000);
 			else
 			{
-				sprintf(progresspercenttext, " %5.1f%% (%u%skb)", progresspercent, (int)(total/1024), extra?"+":"");
+				sprintf(progresspercenttext, " %5.1f%% (%u%sKiB)", progresspercent, (int)(total/1024), extra?"+":"");
 			}
 		}
 	}
diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c
index 675bd8b90..a6b48299a 100644
--- a/engine/client/pr_csqc.c
+++ b/engine/client/pr_csqc.c
@@ -1992,7 +1992,7 @@ float csqc_proj_matrix[16];
 float csqc_proj_matrix_inverse[16];
 float csqc_proj_frustum[2];
 void V_ApplyAFov(playerview_t *pv);
-void buildmatricies(void)
+static void cs_buildmatricies(void)
 {
 	float modelview[16];
 	float proj[16];
@@ -2035,7 +2035,7 @@ void buildmatricies(void)
 static void QCBUILTIN PF_cs_project (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
 {
 	if (csqc_rebuildmatricies)
-		buildmatricies();
+		cs_buildmatricies();
 
 
 	{
@@ -2081,7 +2081,7 @@ static void QCBUILTIN PF_cs_project (pubprogfuncs_t *prinst, struct globalvars_s
 static void QCBUILTIN PF_cs_unproject (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
 {
 	if (csqc_rebuildmatricies)
-		buildmatricies();
+		cs_buildmatricies();
 
 	{
 		float *in = G_VECTOR(OFS_PARM0);
@@ -9011,18 +9011,7 @@ qboolean CSQC_DrawView(void)
 	host_frametime = clframetime;
 
 	if (csqcg.frametime)
-	{
-		if (1)//csqc_isdarkplaces)
-		{
-			if (cl.paused)
-				*csqcg.frametime = 0;	//apparently people can't cope with microstutter when they're using this as a test to see if the game is paused.
-			else
-				*csqcg.frametime = bound(0, cl.time - cl.lasttime, 0.1);
-		}
-		else
-			*csqcg.frametime = host_frametime;
-	}
-
+		*csqcg.frametime = cl.paused?0:bound(0, cl.time - cl.lasttime, 0.1);
 	if (csqcg.clframetime)
 		*csqcg.clframetime = host_frametime;
 
diff --git a/engine/gl/gl_backend.c b/engine/gl/gl_backend.c
index 804722820..876d2ebe3 100644
--- a/engine/gl/gl_backend.c
+++ b/engine/gl/gl_backend.c
@@ -80,7 +80,7 @@ void GLBE_SubmitBatch(batch_t *batch);
 static qboolean GLBE_RegisterLightShader(int mode);
 #endif
 
-struct {
+static struct {
 	//internal state
 	struct {
 		int lastpasstmus;
diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c
index aa5423eec..ff846e4b9 100644
--- a/engine/gl/gl_model.c
+++ b/engine/gl/gl_model.c
@@ -5317,7 +5317,6 @@ static qboolean QDECL Mod_LoadBrushModel (model_t *mod, void *buffer, size_t fsi
 
 	mod_base = (qbyte *)buffer;
 	memcpy(&header, mod_base, sizeof(header));
-	header.version = LittleLong(header.version);
 	for (i=0 ; i<countof(header.lumps)/4 ; i++)
 	{
 		header.lumps[i].filelen = LittleLong(header.lumps[i].filelen);
@@ -5355,6 +5354,7 @@ static qboolean QDECL Mod_LoadBrushModel (model_t *mod, void *buffer, size_t fsi
 		Con_Printf (CON_ERROR "Mod_LoadBrushModel: %s has wrong version number (%i)\n", mod->name, i);
 		return false;
 	}
+	header.version = LittleLong(header.version);
 
 	mod->lightmaps.width = 128;//LMBLOCK_WIDTH;
 	mod->lightmaps.height = 128;//LMBLOCK_HEIGHT; 
diff --git a/engine/gl/gl_shadow.c b/engine/gl/gl_shadow.c
index 8aa5c0bd9..1c3391173 100644
--- a/engine/gl/gl_shadow.c
+++ b/engine/gl/gl_shadow.c
@@ -1188,7 +1188,7 @@ static void SHM_RecursiveWorldNodeQ2_r (dlight_t *dl, mnode_t *node)
 	SHM_RecursiveWorldNodeQ2_r (dl, node->children[!side]);
 }
 
-static void SHM_MarkLeavesQ2(dlight_t *dl, unsigned char *lvis)
+static void SHM_MarkLeavesQ2(dlight_t *dl, const unsigned char *lvis)
 {
 	mnode_t *node;
 	int i;
@@ -1241,9 +1241,9 @@ static void SHM_MarkLeavesQ2(dlight_t *dl, unsigned char *lvis)
 		}
 	}
 }
-void Q2BSP_GenerateShadowMesh(model_t *model, dlight_t *dl, qbyte *lvis, int type)
+void Q2BSP_GenerateShadowMesh(model_t *model, dlight_t *dl, const qbyte *lightvis, qbyte *litvis, void (*callback)(msurface_t *surf))
 {
-	SHM_MarkLeavesQ2(dl, lvis);
+	SHM_MarkLeavesQ2(dl, lightvis);
 	SHM_RecursiveWorldNodeQ2_r(dl, model->nodes);
 }
 #endif
diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c
index f67feb9ad..4c9903f9d 100644
--- a/engine/server/pr_cmds.c
+++ b/engine/server/pr_cmds.c
@@ -11327,14 +11327,14 @@ static BuiltinList_t BuiltinList[] = {				//nq	qw		h2		ebfs
 	{"WriteEntity",		PF_WriteEntity,		59,		59,		59,		0,	D("void(float to, entity val)", "Writes the index of the specified entity (the network data size is not specified). This can be read clientside using the readentitynum builtin, with caveats.")},	//59
 
 #if defined(HAVE_LEGACY) && defined(NETPREPARSE)
-	{"swritebyte",		PF_qtSingle_WriteByte,			0,		0,		0,		0,	D("void(float val)", "A legacy of qtest - like WriteByte, except writes explicitly to the MSG_ONE target."), true},	//52
-	{"swritechar",		PF_qtSingle_WriteChar,			0,		0,		0,		0,	D("void(float val)", NULL), true},	//53
-	{"swriteshort",		PF_qtSingle_WriteShort,			0,		0,		0,		0,	D("void(float val)", NULL), true},	//54
-	{"swritelong",		PF_qtSingle_WriteLong,			0,		0,		0,		0,	D("void(float val)", NULL), true},	//55
-	{"swritecoord",		PF_qtSingle_WriteCoord,			0,		0,		0,		0,	D("void(float val)", NULL), true},	//56
-	{"swriteangle",		PF_qtSingle_WriteAngle,			0,		0,		0,		0,	D("void(float val)", NULL), true},	//57
-	{"swritestring",	PF_qtSingle_WriteString,		0,		0,		0,		0,	D("void(string val)", NULL), true},	//58
-	{"swriteentity",	PF_qtSingle_WriteEntity,		0,		0,		0,		0,	D("void(entity val)", NULL), true},
+	{"swritebyte",		PF_qtSingle_WriteByte,			0,		0,		0,		0,	D("void(entity to, float val)", "A legacy of qtest - like WriteByte, except writes explicitly to the MSG_ONE target."), true},	//52
+	{"swritechar",		PF_qtSingle_WriteChar,			0,		0,		0,		0,	D("void(entity to, float val)", NULL), true},	//53
+	{"swriteshort",		PF_qtSingle_WriteShort,			0,		0,		0,		0,	D("void(entity to, float val)", NULL), true},	//54
+	{"swritelong",		PF_qtSingle_WriteLong,			0,		0,		0,		0,	D("void(entity to, float val)", NULL), true},	//55
+	{"swritecoord",		PF_qtSingle_WriteCoord,			0,		0,		0,		0,	D("void(entity to, float val)", NULL), true},	//56
+	{"swriteangle",		PF_qtSingle_WriteAngle,			0,		0,		0,		0,	D("void(entity to, float val)", NULL), true},	//57
+	{"swritestring",	PF_qtSingle_WriteString,		0,		0,		0,		0,	D("void(entity to, string val)", NULL), true},	//58
+	{"swriteentity",	PF_qtSingle_WriteEntity,		0,		0,		0,		0,	D("void(entity to, entity val)", NULL), true},
 
 	{"bwritebyte",		PF_qtBroadcast_WriteByte,		0,		0,		0,		0,	D("void(float byte)", "A legacy of qtest - like WriteByte, except writes explicitly to the MSG_ALL target."), true},	//59
 	{"bwritechar",		PF_qtBroadcast_WriteChar,		0,		0,		0,		0,	D("void(float val)", NULL), true},	//60
@@ -11391,8 +11391,8 @@ static BuiltinList_t BuiltinList[] = {				//nq	qw		h2		ebfs
 	{"ex_bot_followentity",PF_Fixme,		0,		0,		0,0,	D("float(entity bot, entity goal)", "Behaviour is undocumented.")},
 	{"ex_CheckPlayerEXFlags",PF_CheckPlayerEXFlags_qex,0,0,	0,0,	D("float(entity playerEnt)", "Behaviour is undocumented.")},
 	{"ex_walkpathtogoal",PF_walkpathtogoal_qex,0,	0,		0,0,	D("float(float movedist, vector goal)", "Behaviour is undocumented.")},
-	{"ex_prompt",		PF_prompt_qex,		0,		0,		0,0,	D("void(entity player, string text, float numchoices)", "Behaviour is undocumented.")},
-	{"ex_promptchoice",	PF_promptchoice_qex,0,		0,		0,0,	D("void(entity player, string text, float impulse)", "Behaviour is undocumented.")},
+	{"ex_prompt",		PF_prompt_qex,		0,		0,		0,0,	D("void(entity player, string text, float numchoices)", "Initiates a user prompt. You must call ex_promptchoice once per choice.")},
+	{"ex_promptchoice",	PF_promptchoice_qex,0,		0,		0,0,	D("void(entity player, string text, float impulse)", "Follows a call to ex_prompt.")},
 	{"ex_clearprompt",	PF_prompt_qex,		0,		0,		0,0,	D("void(entity player)", "Behaviour is undocumented.")},
 //End QuakeEx, for now. :(
 
@@ -13616,6 +13616,7 @@ void PR_DumpPlatform_f(void)
 		{"SOUNDFLAG_NOREPLACE",		"const float",	QW|NQ|CS,	D("Sounds started with this flag will be ignored when there's already a sound playing on that same ent-channel."), CF_NOREPLACE},
 		{"SOUNDFLAG_UNICAST",		"const float",	QW|NQ,		D("The sound will be sent only by the player specified by msg_entity. Spectators and related splitscreen players will also hear the sound."), CF_SV_UNICAST},
 		{"SOUNDFLAG_SENDVELOCITY",	"const float",	QW|NQ,		D("The entity's current velocity will be sent to the client, only useful if doppler is enabled."), CF_SV_SENDVELOCITY},
+		{"SOUNDFLAG_INACTIVE",		"const float",	CS,			D("The sound will ignore the value of the snd_inactive cvar."), CF_CLI_INACTIVE},
 
 		{"ATTN_NONE",		"const float", QW|NQ|CS, D("Sounds with this attenuation can be heard throughout the map"), ATTN_NONE},
 		{"ATTN_NORM",		"const float", QW|NQ|CS, D("Standard attenuation"), ATTN_NORM},
diff --git a/engine/server/sv_ccmds.c b/engine/server/sv_ccmds.c
index ab03ac952..4fc732dab 100644
--- a/engine/server/sv_ccmds.c
+++ b/engine/server/sv_ccmds.c
@@ -2331,7 +2331,7 @@ static void SV_Status_f (void)
 #define C_USERID	COLUMN(1, "userid", Con_Printf("%6i ", (int)cl->userid))
 #define C_ADDRESS	COLUMN(2, "address        ", Con_Printf("%-16.16s", s))
 #define C_NAME		COLUMN(3, "name           ", Con_Printf("%-16.16s", cl->name))
-#define C_RATE		COLUMN(4, "rate", Con_Printf("%4i ", (cl->frameunion.frames&&cl->netchan.frame_rate>0)?(int)(1/cl->netchan.frame_rate):0))
+#define C_RATE		COLUMN(4, "  hz", Con_Printf("%4i ", (cl->frameunion.frames&&cl->netchan.frame_rate>0)?(int)(0.5f+1/cl->netchan.frame_rate):0))
 #define C_PING		COLUMN(5, "ping", Con_Printf("%4i ", (int)SV_CalcPing (cl, false)))
 #define C_DROP		COLUMN(6, "drop", Con_Printf("%4.1f ", 100.0*cl->netchan.drop_count / cl->netchan.incoming_sequence))
 #define C_DLP		COLUMN(7, "dl ", if (!cl->download||!cl->downloadsize)Con_Printf("    ");else Con_Printf("%3.0f ", (cl->downloadcount*100.0)/cl->downloadsize))
@@ -2401,7 +2401,7 @@ static void SV_Status_f (void)
 
 			safeswitch(cl->protocol)
 			{
-			case SCP_BAD:			p = "none"; break;
+			case SCP_BAD:			p = "-----"; break;
 			case SCP_QUAKEWORLD:	p = (cl->fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS)?"fteqw":"qw"; break;
 			case SCP_QUAKE2:		p = "q2"; break;
 			case SCP_QUAKE3:		p = "q3"; break;
diff --git a/plugins/cef/cef.c b/plugins/cef/cef.c
index 2467fff30..c9d55fa5b 100644
--- a/plugins/cef/cef.c
+++ b/plugins/cef/cef.c
@@ -2186,7 +2186,7 @@ void Cef_ExecuteCommand(void)
 		strcpy(videomap, "cef:");
 		cmdfuncs->Argv(1, videomap+4, sizeof(videomap)-4);
 		if (!videomap[4])
-			strcpy(videomap, "cef:http://fte.triptohell.info");
+			strcpy(videomap, "cef:https://fte.triptohell.info");
 
 		confuncs->SetConsoleString(f, "title", videomap+4);
 		confuncs->SetConsoleFloat(f, "iswindow", true);