Bugfix: Involving playdemo and connection state

Post tutorials on how to do certain tasks within game or engine code here.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Bugfix: Involving playdemo and connection state

Post by Baker »

In cl_main.c, add to end of function:

cl.intermission = 0;

SCR_UpdateScreen renders depending on cl.intermission and ignores con_forcedup.

Background: con_forcedup is set to true when !cl.worldmodel || cls.signon != SIGNONS (no world model for client or not fully signed on to a server ... even if the server in question is single player or yourself). SCR_UpdateScreen doesn't check con_forcedup to determine whether or not to draw the intermission screen ... likely because the entire cl state gets wiped when a new map is loaded. But a new map isn't always loaded.

Situations this can occur:
1. Demo record is stopped during intermission. No new map is going to load.
2. Player doesn't have the next map. In particular, for being connected to a non-local server.

Trying to fix by changing how SCR_UpdateScreen works might result in undesirable results like the console flashing on-screen between maps.

Might also be beneficial put this at the end of CL_Disconnect, but I haven't tested it to verify proper behavior in all circumstances:
..
SCR_EndLoadingPlaque (); // Which also gets rid of the "Loading" plaque.

// Resulting function:

Code: Select all

/*
=====================
CL_Disconnect

Sends a disconnect message to the server
This is also called on Host_Error, so it shouldn't cause any errors
=====================
*/
void CL_Disconnect (void)
{
// stop sounds (especially looping!)
	S_StopAllSounds (true);

// if running a local server, shut it down
	if (cls.demoplayback)
		CL_StopPlayback ();
	else if (cls.state == ca_connected)
	{
		if (cls.demorecording)
			CL_Stop_f ();

		Con_DPrintf ("Sending clc_disconnect\n");
		SZ_Clear (&cls.message);
		MSG_WriteByte (&cls.message, clc_disconnect);
		NET_SendUnreliableMessage (cls.netcon, &cls.message);
		SZ_Clear (&cls.message);
		NET_Close (cls.netcon);

		cls.state = ca_disconnected;
		if (sv.active)
			Host_ShutdownServer(false);
	}

	cls.demoplayback = cls.timedemo = false;
	cls.signon = 0;
	cl.intermission = 0; // Baker: So critical.  SCR_UpdateScreen uses this.
}
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Bugfix: Involving playdemo and connection state

Post by mh »

Oddly enough, I've had this for years but for a completely different reason - I print the map name in the intermission screen, and without it I was crashing. So there's another thing fixed.

I also remove all centerprints at the same time so that's probably not a bad idea too - helps make the slate even cleaner when going to a new map.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
szo
Posts: 132
Joined: Mon Dec 06, 2010 4:42 pm

Re: Bugfix: Involving playdemo and connection state

Post by szo »

Good catch. Applied this to both quakespasm and to uhexen2. (uhexen2 was actually not 'affected' by the issue the way you documented it, but it actually used to draw the console background over the intermission pic, i.e. drawing doubly. ugh..)
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Bugfix: Involving playdemo and connection state

Post by Baker »

Baker wrote: Might also be beneficial put this at the end of CL_Disconnect, but I haven't tested it to verify proper behavior in all circumstances:
..
SCR_EndLoadingPlaque (); // Which also gets rid of the "Loading" plaque.
By the way, don't add SCR_EndLoadingPlaque () to the end of CL_Disconnect. SCR_EndLoadingPlaque shouldn't go in CL_Disconnect, if you do that then the console will display in between the starting demos (which isn't intended behavior and is very annoying).
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: Bugfix: Involving playdemo and connection state

Post by r00k »

Hadnt noticed this, been a long time since i recorded a demo all the way to the intermission, though I've noticed a bug when replaying to the end, my intermission angles are pointing to '0 0 0' :O happens in proQuake too!
taniwha
Posts: 401
Joined: Thu Jan 14, 2010 7:11 am
Contact:

Re: Bugfix: Involving playdemo and connection state

Post by taniwha »

I don't know if this particular fix is truly relevant to QF (I'll apply it anyway just in case), but investigating it did cause me to notice and fix two problems I'd introduced recently: intermission position was broken and the console was being drawn between levels.

I had a lot of "fun" with the loading plaque because for a long time, QF didn't draw the thing, but I has a few bugs in my implementation when I got it going again.
Leave others their otherness.
http://quakeforge.net/
Post Reply