From 7df09a3487c9441f41a4bdea4cf5504cb9088ca7 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 20 Aug 2001 17:48:16 +0000 Subject: [PATCH] centralize client state setting --- nq/include/client.h | 2 ++ nq/source/cl_demo.c | 4 ++-- nq/source/cl_main.c | 20 ++++++++++++++++++-- nq/source/host.c | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/nq/include/client.h b/nq/include/client.h index 96f12240d..b188e2b28 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -362,4 +362,6 @@ void Cvar_Info (struct cvar_s *var); void CL_UpdateScreen (double realtime); +void CL_SetState (cactive_t state); + #endif // __client_h diff --git a/nq/source/cl_demo.c b/nq/source/cl_demo.c index 0773baa53..9a2f1e04c 100644 --- a/nq/source/cl_demo.c +++ b/nq/source/cl_demo.c @@ -75,7 +75,7 @@ CL_StopPlayback (void) Qclose (cls.demofile); cls.demoplayback = false; cls.demofile = NULL; - cls.state = ca_disconnected; + CL_SetState (ca_disconnected); if (cls.timedemo) CL_FinishTimeDemo (); @@ -306,7 +306,7 @@ CL_PlayDemo_f (void) } cls.demoplayback = true; - cls.state = ca_connected; + CL_SetState (ca_connected); cls.forcetrack = 0; key_dest = key_game; game_target = IMT_DEFAULT; diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index 1e7c0612a..8f0220a4b 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -241,7 +241,7 @@ CL_Disconnect (void) SZ_Clear (&cls.message); NET_Close (cls.netcon); - cls.state = ca_disconnected; + CL_SetState (ca_disconnected); if (sv.active) Host_ShutdownServer (false); } @@ -282,7 +282,7 @@ CL_EstablishConnection (const char *host) Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host); cls.demonum = -1; // not in the demo loop now - cls.state = ca_connected; + CL_SetState (ca_connected); cls.signon = 0; // need all the signon messages // before playing key_dest = key_game; @@ -752,6 +752,22 @@ CL_SendCmd (void) } +void +CL_SetState (cactive_t state) +{ + cls.state = state; + if (cls.state == ca_active) { + r_active = true; + game_target = IMT_DEFAULT; + key_dest = key_game; + } else { + r_active = false; + game_target = IMT_CONSOLE; + key_dest = key_console; + } +} + + void Force_CenterView_f (void) { diff --git a/nq/source/host.c b/nq/source/host.c index 20b30fab4..4fb651520 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -997,6 +997,7 @@ Host_Init (quakeparms_t *parms) Sbar_Init (); CL_Init (); } + CL_SetState (ca_disconnected); Cbuf_InsertText ("exec quake.rc\n"); Cmd_Exec_File (fs_usercfg->string);