mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
Create a proper ca_active state.
Yay, no more ugly "SIGNONS" hack for whether to render :)
This commit is contained in:
parent
7d84800250
commit
82a41017ec
10 changed files with 64 additions and 46 deletions
|
@ -61,12 +61,17 @@ typedef struct
|
||||||
int _colors;
|
int _colors;
|
||||||
} scoreboard_t;
|
} scoreboard_t;
|
||||||
|
|
||||||
#define NAME_LENGTH 64
|
|
||||||
|
|
||||||
|
|
||||||
// client_state_t should hold all pieces of the client state
|
// client_state_t should hold all pieces of the client state
|
||||||
|
|
||||||
#define SIGNONS 4 // signon messages to receive before connected
|
typedef enum {
|
||||||
|
so_none,
|
||||||
|
so_prespawn,
|
||||||
|
so_spawn,
|
||||||
|
so_begin,
|
||||||
|
so_active,
|
||||||
|
} signon_t;
|
||||||
|
|
||||||
|
|
||||||
#define MAX_DEMOS 8
|
#define MAX_DEMOS 8
|
||||||
#define MAX_DEMONAME 16
|
#define MAX_DEMONAME 16
|
||||||
|
@ -75,7 +80,8 @@ typedef struct
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ca_dedicated, // a dedicated server with no ability to start a client
|
ca_dedicated, // a dedicated server with no ability to start a client
|
||||||
ca_disconnected, // full screen console with no connection
|
ca_disconnected, // full screen console with no connection
|
||||||
ca_connected // valid netcon, talking to a server
|
ca_connected, // valid netcon, talking to a server
|
||||||
|
ca_active, // fully connected
|
||||||
} cactive_t;
|
} cactive_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -86,9 +92,6 @@ typedef enum {
|
||||||
dl_single
|
dl_single
|
||||||
} dltype_t; // download type
|
} dltype_t; // download type
|
||||||
|
|
||||||
// FIXME: A grotesque (temporary) hack. They're not the same thing to QW.
|
|
||||||
#define ca_active ca_connected
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
the client_static_t structure is persistant through an arbitrary number
|
the client_static_t structure is persistant through an arbitrary number
|
||||||
of server connections
|
of server connections
|
||||||
|
@ -126,7 +129,7 @@ typedef struct
|
||||||
float td_starttime; // realtime at second frame of timedemo
|
float td_starttime; // realtime at second frame of timedemo
|
||||||
|
|
||||||
// connection information
|
// connection information
|
||||||
int signon; // 0 to SIGNONS
|
signon_t signon;
|
||||||
struct qsocket_s *netcon;
|
struct qsocket_s *netcon;
|
||||||
sizebuf_t message; // writing buffer to send to server
|
sizebuf_t message; // writing buffer to send to server
|
||||||
} client_static_t;
|
} client_static_t;
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
void
|
void
|
||||||
CL_Cmd_ForwardToServer (void)
|
CL_Cmd_ForwardToServer (void)
|
||||||
{
|
{
|
||||||
if (cls.state != ca_connected) {
|
if (cls.state < ca_connected) {
|
||||||
Sys_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0));
|
Sys_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ CL_GetDemoMessage (void)
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
// decide if it is time to grab the next message
|
// decide if it is time to grab the next message
|
||||||
if (cls.signon == SIGNONS) { // always grab until fully connected
|
if (cls.state == ca_active) { // always grab until fully connected
|
||||||
if (cls.timedemo) {
|
if (cls.timedemo) {
|
||||||
if (host_framecount == cls.td_lastframe)
|
if (host_framecount == cls.td_lastframe)
|
||||||
return 0; // already read this frame's message
|
return 0; // already read this frame's message
|
||||||
|
@ -280,7 +280,7 @@ CL_Record_f (void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == 2 && cls.state == ca_connected) {
|
if (c == 2 && cls.state >= ca_connected) {
|
||||||
Sys_Printf
|
Sys_Printf
|
||||||
("Can not record - already connected to server\nClient demo recording must be started before connecting\n");
|
("Can not record - already connected to server\nClient demo recording must be started before connecting\n");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -476,7 +476,7 @@ CL_AdjustAngles (void)
|
||||||
void
|
void
|
||||||
CL_BaseMove (usercmd_t *cmd)
|
CL_BaseMove (usercmd_t *cmd)
|
||||||
{
|
{
|
||||||
if (cls.signon != SIGNONS)
|
if (cls.state != ca_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CL_AdjustAngles ();
|
CL_AdjustAngles ();
|
||||||
|
|
|
@ -254,7 +254,7 @@ CL_Disconnect (void)
|
||||||
// if running a local server, shut it down
|
// if running a local server, shut it down
|
||||||
if (cls.demoplayback)
|
if (cls.demoplayback)
|
||||||
CL_StopPlayback ();
|
CL_StopPlayback ();
|
||||||
else if (cls.state == ca_connected) {
|
else if (cls.state >= ca_connected) {
|
||||||
if (cls.demorecording)
|
if (cls.demorecording)
|
||||||
CL_StopRecording ();
|
CL_StopRecording ();
|
||||||
|
|
||||||
|
@ -270,7 +270,6 @@ CL_Disconnect (void)
|
||||||
Host_ShutdownServer (false);
|
Host_ShutdownServer (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.signon = 0;
|
|
||||||
cl.worldmodel = NULL;
|
cl.worldmodel = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,8 +305,6 @@ CL_EstablishConnection (const char *host)
|
||||||
|
|
||||||
cls.demonum = -1; // not in the demo loop now
|
cls.demonum = -1; // not in the demo loop now
|
||||||
CL_SetState (ca_connected);
|
CL_SetState (ca_connected);
|
||||||
cls.signon = 0; // need all the signon messages
|
|
||||||
// before playing
|
|
||||||
Key_SetKeyDest (key_game);
|
Key_SetKeyDest (key_game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,12 +321,14 @@ CL_SignonReply (void)
|
||||||
Sys_MaskPrintf (SYS_DEV, "CL_SignonReply: %i\n", cls.signon);
|
Sys_MaskPrintf (SYS_DEV, "CL_SignonReply: %i\n", cls.signon);
|
||||||
|
|
||||||
switch (cls.signon) {
|
switch (cls.signon) {
|
||||||
case 1:
|
case so_none:
|
||||||
|
break;
|
||||||
|
case so_prespawn:
|
||||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||||
MSG_WriteString (&cls.message, "prespawn");
|
MSG_WriteString (&cls.message, "prespawn");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case so_spawn:
|
||||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||||
MSG_WriteString (&cls.message, va ("name \"%s\"\n", cl_name->string));
|
MSG_WriteString (&cls.message, va ("name \"%s\"\n", cl_name->string));
|
||||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||||
|
@ -341,14 +340,15 @@ CL_SignonReply (void)
|
||||||
MSG_WriteString (&cls.message, str);
|
MSG_WriteString (&cls.message, str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case so_begin:
|
||||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||||
MSG_WriteString (&cls.message, "begin");
|
MSG_WriteString (&cls.message, "begin");
|
||||||
Cache_Report (); // print remaining memory
|
Cache_Report (); // print remaining memory
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case so_active:
|
||||||
cl.loading = false;
|
cl.loading = false;
|
||||||
|
CL_SetState (ca_active);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ CL_ReadFromServer (void)
|
||||||
|
|
||||||
cl.last_received_message = realtime;
|
cl.last_received_message = realtime;
|
||||||
CL_ParseServerMessage ();
|
CL_ParseServerMessage ();
|
||||||
} while (ret && cls.state == ca_connected);
|
} while (ret && cls.state >= ca_connected);
|
||||||
|
|
||||||
if (cl_shownet->int_val)
|
if (cl_shownet->int_val)
|
||||||
Sys_Printf ("\n");
|
Sys_Printf ("\n");
|
||||||
|
@ -437,10 +437,10 @@ CL_SendCmd (void)
|
||||||
{
|
{
|
||||||
usercmd_t cmd;
|
usercmd_t cmd;
|
||||||
|
|
||||||
if (cls.state != ca_connected)
|
if (cls.state < ca_connected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cls.signon == SIGNONS) {
|
if (cls.state == ca_active) {
|
||||||
CL_BaseMove (&cmd);
|
CL_BaseMove (&cmd);
|
||||||
|
|
||||||
// send the unreliable message
|
// send the unreliable message
|
||||||
|
@ -472,21 +472,35 @@ CL_SetState (cactive_t state)
|
||||||
{
|
{
|
||||||
cactive_t old_state = cls.state;
|
cactive_t old_state = cls.state;
|
||||||
cls.state = state;
|
cls.state = state;
|
||||||
|
Sys_MaskPrintf (SYS_NET, "CL_SetState: %d -> %d\n", old_state, state);
|
||||||
if (old_state != state) {
|
if (old_state != state) {
|
||||||
if (state == ca_active) {
|
if (old_state == ca_active) {
|
||||||
// entering active state
|
|
||||||
Key_SetKeyDest (key_game);
|
|
||||||
IN_ClearStates ();
|
|
||||||
VID_SetCaption ("");
|
|
||||||
} else if (old_state == ca_active) {
|
|
||||||
// leaving active state
|
// leaving active state
|
||||||
Key_SetKeyDest (key_console);
|
Key_SetKeyDest (key_console);
|
||||||
VID_SetCaption ("Disconnected");
|
|
||||||
}
|
|
||||||
if (state == ca_connected)
|
|
||||||
S_AmbientOn ();
|
|
||||||
else
|
|
||||||
S_AmbientOff ();
|
S_AmbientOff ();
|
||||||
|
}
|
||||||
|
switch (state) {
|
||||||
|
case ca_dedicated:
|
||||||
|
break;
|
||||||
|
case ca_disconnected:
|
||||||
|
cls.signon = so_none;
|
||||||
|
VID_SetCaption ("Disconnected");
|
||||||
|
break;
|
||||||
|
case ca_connected:
|
||||||
|
cls.signon = so_none; // need all the signon messages
|
||||||
|
// before playing
|
||||||
|
Key_SetKeyDest (key_game);
|
||||||
|
IN_ClearStates ();
|
||||||
|
VID_SetCaption ("Connected");
|
||||||
|
break;
|
||||||
|
case ca_active:
|
||||||
|
// entering active state
|
||||||
|
Key_SetKeyDest (key_game);
|
||||||
|
IN_ClearStates ();
|
||||||
|
VID_SetCaption ("");
|
||||||
|
S_AmbientOn ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (con_module)
|
if (con_module)
|
||||||
con_module->data->console->force_commandline = (state != ca_active);
|
con_module->data->console->force_commandline = (state != ca_active);
|
||||||
|
|
|
@ -462,9 +462,9 @@ CL_ParseUpdate (int bits)
|
||||||
model_t *model;
|
model_t *model;
|
||||||
qboolean forcelink;
|
qboolean forcelink;
|
||||||
|
|
||||||
if (cls.signon == SIGNONS - 1) {
|
if (cls.signon == so_begin) {
|
||||||
// first update is the final signon stage
|
// first update is the final signon stage
|
||||||
cls.signon = SIGNONS;
|
cls.signon = so_active;
|
||||||
CL_SignonReply ();
|
CL_SignonReply ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,6 +868,7 @@ void
|
||||||
CL_ParseServerMessage (void)
|
CL_ParseServerMessage (void)
|
||||||
{
|
{
|
||||||
int cmd = 0, i, j;
|
int cmd = 0, i, j;
|
||||||
|
signon_t so;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
// if recording demos, copy the message out
|
// if recording demos, copy the message out
|
||||||
|
@ -1054,11 +1055,11 @@ CL_ParseServerMessage (void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_signonnum:
|
case svc_signonnum:
|
||||||
i = MSG_ReadByte (net_message);
|
so = MSG_ReadByte (net_message);
|
||||||
if (i <= cls.signon)
|
if (so <= cls.signon || so >= so_active)
|
||||||
Host_Error ("Received signon %i when at %i", i,
|
Host_Error ("Received signon %i when at %i", so,
|
||||||
cls.signon);
|
cls.signon);
|
||||||
cls.signon = i;
|
cls.signon = so;
|
||||||
CL_SignonReply ();
|
CL_SignonReply ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ SCR_CShift (void)
|
||||||
mleaf_t *leaf;
|
mleaf_t *leaf;
|
||||||
int contents = CONTENTS_EMPTY;
|
int contents = CONTENTS_EMPTY;
|
||||||
|
|
||||||
if (cls.signon == SIGNONS && cl.worldmodel) {
|
if (cls.state == ca_active && cl.worldmodel) {
|
||||||
leaf = Mod_PointInLeaf (r_data->refdef->vieworg, cl.worldmodel);
|
leaf = Mod_PointInLeaf (r_data->refdef->vieworg, cl.worldmodel);
|
||||||
contents = leaf->contents;
|
contents = leaf->contents;
|
||||||
}
|
}
|
||||||
|
|
|
@ -728,7 +728,7 @@ V_CalcRefdef (void)
|
||||||
void
|
void
|
||||||
V_RenderView (void)
|
V_RenderView (void)
|
||||||
{
|
{
|
||||||
if (cls.signon != SIGNONS) //FIXME need proper state
|
if (cls.state != ca_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// don't allow cheats in multiplayer
|
// don't allow cheats in multiplayer
|
||||||
|
|
|
@ -438,7 +438,7 @@ Host_ShutdownServer (qboolean crash)
|
||||||
sv.active = false;
|
sv.active = false;
|
||||||
|
|
||||||
// stop all client sounds immediately
|
// stop all client sounds immediately
|
||||||
if (cls.state == ca_connected)
|
if (cls.state >= ca_connected)
|
||||||
CL_Disconnect ();
|
CL_Disconnect ();
|
||||||
|
|
||||||
// flush any pending messages - like the score!!!
|
// flush any pending messages - like the score!!!
|
||||||
|
@ -585,7 +585,7 @@ Host_ClientFrame (void)
|
||||||
host_time += host_frametime;
|
host_time += host_frametime;
|
||||||
|
|
||||||
// fetch results from server
|
// fetch results from server
|
||||||
if (cls.state == ca_connected)
|
if (cls.state >= ca_connected)
|
||||||
CL_ReadFromServer ();
|
CL_ReadFromServer ();
|
||||||
|
|
||||||
// update video
|
// update video
|
||||||
|
@ -603,7 +603,7 @@ Host_ClientFrame (void)
|
||||||
time2 = Sys_DoubleTime ();
|
time2 = Sys_DoubleTime ();
|
||||||
|
|
||||||
// update audio
|
// update audio
|
||||||
if (cls.signon == SIGNONS) {
|
if (cls.state == ca_active) {
|
||||||
mleaf_t *l;
|
mleaf_t *l;
|
||||||
byte *asl = 0;
|
byte *asl = 0;
|
||||||
|
|
||||||
|
|
|
@ -750,7 +750,7 @@ Host_Name_f (void)
|
||||||
if (strcmp (cl_name->string, newName) == 0)
|
if (strcmp (cl_name->string, newName) == 0)
|
||||||
return;
|
return;
|
||||||
Cvar_Set (cl_name, va ("%.15s", newName));
|
Cvar_Set (cl_name, va ("%.15s", newName));
|
||||||
if (cls.state == ca_connected)
|
if (cls.state >= ca_connected)
|
||||||
CL_Cmd_ForwardToServer ();
|
CL_Cmd_ForwardToServer ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue