mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
console.c mergable. Little bit of cleanup of client.h
This commit is contained in:
parent
a735b92bab
commit
1dbfea351a
4 changed files with 173 additions and 150 deletions
|
@ -38,12 +38,13 @@
|
|||
#include "QF/quakefs.h"
|
||||
#include "QF/sound.h"
|
||||
|
||||
#include "protocol.h"
|
||||
#include "net.h"
|
||||
#include "protocol.h"
|
||||
#include "r_local.h"
|
||||
#include "render.h"
|
||||
#include "game.h"
|
||||
|
||||
|
||||
typedef struct usercmd_s
|
||||
{
|
||||
vec3_t viewangles;
|
||||
|
@ -75,17 +76,16 @@ typedef struct
|
|||
#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
|
||||
|
||||
#define MAX_EFRAGS 640
|
||||
|
||||
#define MAX_MAPSTRING 2048
|
||||
#define MAX_DEMOS 8
|
||||
#define MAX_DEMONAME 16
|
||||
#define MAX_EFRAGS 640
|
||||
#define MAX_MAPSTRING 2048
|
||||
|
||||
typedef enum {
|
||||
ca_dedicated, // a dedicated server with no ability to start a client
|
||||
|
@ -93,14 +93,21 @@ ca_disconnected, // full screen console with no connection
|
|||
ca_connected // valid netcon, talking to a server
|
||||
} cactive_t;
|
||||
|
||||
typedef enum {
|
||||
dl_none,
|
||||
dl_model,
|
||||
dl_sound,
|
||||
dl_skin,
|
||||
dl_single
|
||||
} 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
|
||||
// of server connections
|
||||
//
|
||||
/*
|
||||
the client_static_t structure is persistant through an arbitrary number
|
||||
of server connections
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
cactive_t state;
|
||||
|
@ -109,6 +116,14 @@ typedef struct
|
|||
char mapstring[MAX_QPATH];
|
||||
char spawnparms[MAX_MAPSTRING]; // to restart a level
|
||||
|
||||
// file transfer from server
|
||||
QFile *download;
|
||||
char downloadtempname[MAX_OSPATH];
|
||||
char downloadname[MAX_OSPATH];
|
||||
int downloadnumber;
|
||||
dltype_t downloadtype;
|
||||
int downloadpercent;
|
||||
|
||||
// demo loop control
|
||||
int demonum; // -1 = don't play demos
|
||||
char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
|
||||
|
@ -124,7 +139,6 @@ typedef struct
|
|||
int td_startframe; // host_framecount at start
|
||||
float td_starttime; // realtime at second frame of timedemo
|
||||
|
||||
|
||||
// connection information
|
||||
int signon; // 0 to SIGNONS
|
||||
struct qsocket_s *netcon;
|
||||
|
@ -134,10 +148,10 @@ typedef struct
|
|||
|
||||
extern client_static_t cls;
|
||||
|
||||
//
|
||||
// the client_state_t structure is wiped completely at every
|
||||
// server signon
|
||||
//
|
||||
/*
|
||||
the client_state_t structure is wiped completely at every
|
||||
server signon
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int movemessages; // since connecting to this server
|
||||
|
@ -195,9 +209,8 @@ typedef struct
|
|||
|
||||
float last_received_message; // (realtime) for net trouble icon
|
||||
|
||||
//
|
||||
// information that is static for the entire time connected to a server
|
||||
//
|
||||
/* information that is static for the entire time connected to a server */
|
||||
|
||||
struct model_s *model_precache[MAX_MODELS];
|
||||
struct sfx_s *sound_precache[MAX_SOUNDS];
|
||||
|
||||
|
@ -219,17 +232,16 @@ typedef struct
|
|||
scoreboard_t *scores; // [cl.maxclients]
|
||||
|
||||
#ifdef QUAKE2
|
||||
// light level at player's position including dlights
|
||||
// this is sent back to the server each frame
|
||||
// architectually ugly but it works
|
||||
// light level at player's position including dlights this is sent back to the
|
||||
// server each frame architectually ugly but it works
|
||||
int light_level;
|
||||
#endif
|
||||
} client_state_t;
|
||||
|
||||
|
||||
//
|
||||
// cvars
|
||||
//
|
||||
/*
|
||||
cvars
|
||||
*/
|
||||
extern cvar_t *cl_name;
|
||||
extern cvar_t *cl_color;
|
||||
|
||||
|
@ -275,11 +287,10 @@ extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
|||
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||
extern dlight_t cl_dlights[MAX_DLIGHTS];
|
||||
|
||||
//=============================================================================
|
||||
|
||||
//
|
||||
// cl_main
|
||||
//
|
||||
/*
|
||||
cl_main
|
||||
*/
|
||||
dlight_t *CL_AllocDlight (int key);
|
||||
void CL_DecayLights (void);
|
||||
|
||||
|
@ -300,10 +311,10 @@ void CL_NextDemo (void);
|
|||
extern int cl_numvisedicts;
|
||||
extern entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
|
||||
//
|
||||
// cl_input
|
||||
//
|
||||
|
||||
/*
|
||||
cl_input
|
||||
*/
|
||||
void CL_InitInput (void);
|
||||
void CL_SendCmd (void);
|
||||
void CL_SendMove (usercmd_t *cmd);
|
||||
|
@ -313,14 +324,14 @@ void CL_UpdateTEnts (void);
|
|||
|
||||
void CL_ClearState (void);
|
||||
|
||||
|
||||
int CL_ReadFromServer (void);
|
||||
void CL_WriteToServer (usercmd_t *cmd);
|
||||
void CL_BaseMove (usercmd_t *cmd);
|
||||
|
||||
//
|
||||
// cl_demo.c
|
||||
//
|
||||
|
||||
/*
|
||||
cl_demo.c
|
||||
*/
|
||||
void CL_StopPlayback (void);
|
||||
int CL_GetMessage (void);
|
||||
|
||||
|
@ -329,15 +340,17 @@ void CL_Record_f (void);
|
|||
void CL_PlayDemo_f (void);
|
||||
void CL_TimeDemo_f (void);
|
||||
|
||||
//
|
||||
// cl_parse.c
|
||||
//
|
||||
|
||||
/*
|
||||
cl_parse.c
|
||||
*/
|
||||
void CL_ParseServerMessage (void);
|
||||
void CL_NewTranslation (int slot);
|
||||
|
||||
//
|
||||
// view
|
||||
//
|
||||
|
||||
/*
|
||||
view
|
||||
*/
|
||||
void V_StartPitchDrift (void);
|
||||
void V_StopPitchDrift (void);
|
||||
|
||||
|
@ -348,9 +361,9 @@ void V_ParseDamage (void);
|
|||
void V_SetContentsColor (int contents);
|
||||
|
||||
|
||||
//
|
||||
// cl_tent
|
||||
//
|
||||
/*
|
||||
cl_tent
|
||||
*/
|
||||
void CL_TEnts_Init (void);
|
||||
void CL_ClearEnts (void);
|
||||
void CL_ClearTEnts (void);
|
||||
|
@ -359,6 +372,9 @@ struct entity_s **CL_NewTempEntity (void);
|
|||
void CL_ParseTEnt (void);
|
||||
void CL_SignonReply (void);
|
||||
|
||||
|
||||
extern double realtime;
|
||||
|
||||
void Cvar_Info (struct cvar_s *var);
|
||||
|
||||
#endif // __client_h
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
#include "QF/cmd.h"
|
||||
#include "QF/compat.h"
|
||||
#include "QF/console.h"
|
||||
#include "QF/draw.h"
|
||||
#include "QF/input.h"
|
||||
|
@ -49,7 +50,6 @@
|
|||
#include "QF/va.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "host.h"
|
||||
|
||||
int con_ormask;
|
||||
console_t con_main;
|
||||
|
@ -61,7 +61,6 @@ int con_totallines; // total lines in console scrollback
|
|||
|
||||
float con_cursorspeed = 4;
|
||||
|
||||
|
||||
cvar_t *con_notifytime; // seconds
|
||||
|
||||
#define NUM_CON_TIMES 4
|
||||
|
@ -74,13 +73,14 @@ int con_notifylines; // scan lines to clear for notify lines
|
|||
qboolean con_debuglog;
|
||||
|
||||
#define MAXCMDLINE 256
|
||||
|
||||
extern char key_lines[32][MAXCMDLINE];
|
||||
extern int edit_line;
|
||||
extern int key_linepos;
|
||||
|
||||
|
||||
qboolean con_initialized;
|
||||
|
||||
|
||||
void
|
||||
Key_ClearTyping (void)
|
||||
{
|
||||
|
@ -88,9 +88,7 @@ Key_ClearTyping (void)
|
|||
key_linepos = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
Con_ToggleConsole_f
|
||||
*/
|
||||
|
||||
void
|
||||
Con_ToggleConsole_f (void)
|
||||
{
|
||||
|
@ -105,9 +103,7 @@ Con_ToggleConsole_f (void)
|
|||
Con_ClearNotify ();
|
||||
}
|
||||
|
||||
/*
|
||||
Con_ToggleChat_f
|
||||
*/
|
||||
|
||||
void
|
||||
Con_ToggleChat_f (void)
|
||||
{
|
||||
|
@ -122,9 +118,7 @@ Con_ToggleChat_f (void)
|
|||
Con_ClearNotify ();
|
||||
}
|
||||
|
||||
/*
|
||||
Con_Clear_f
|
||||
*/
|
||||
|
||||
void
|
||||
Con_Clear_f (void)
|
||||
{
|
||||
|
@ -136,9 +130,6 @@ Con_Clear_f (void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_ClearNotify
|
||||
*/
|
||||
void
|
||||
Con_ClearNotify (void)
|
||||
{
|
||||
|
@ -149,9 +140,6 @@ Con_ClearNotify (void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_MessageMode_f
|
||||
*/
|
||||
void
|
||||
Con_MessageMode_f (void)
|
||||
{
|
||||
|
@ -161,9 +149,7 @@ Con_MessageMode_f (void)
|
|||
key_dest = key_message;
|
||||
}
|
||||
|
||||
/*
|
||||
Con_MessageMode2_f
|
||||
*/
|
||||
|
||||
void
|
||||
Con_MessageMode2_f (void)
|
||||
{
|
||||
|
@ -173,9 +159,7 @@ Con_MessageMode2_f (void)
|
|||
key_dest = key_message;
|
||||
}
|
||||
|
||||
/*
|
||||
Con_Resize
|
||||
*/
|
||||
|
||||
void
|
||||
Con_Resize (console_t *con)
|
||||
{
|
||||
|
@ -239,9 +223,6 @@ Con_CheckResize (void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_Init
|
||||
*/
|
||||
void
|
||||
Con_Init (void)
|
||||
{
|
||||
|
@ -253,9 +234,7 @@ Con_Init (void)
|
|||
|
||||
Con_Printf ("Console initialized.\n");
|
||||
|
||||
//
|
||||
// register our commands
|
||||
//
|
||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f,
|
||||
"Toggle the console up and down");
|
||||
Cmd_AddCommand ("togglechat", Con_ToggleChat_f,
|
||||
|
@ -268,6 +247,7 @@ Con_Init (void)
|
|||
con_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_Init_Cvars (void)
|
||||
{
|
||||
|
@ -277,9 +257,6 @@ Con_Init_Cvars (void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_Linefeed
|
||||
*/
|
||||
void
|
||||
Con_Linefeed (void)
|
||||
{
|
||||
|
@ -293,6 +270,7 @@ Con_Linefeed (void)
|
|||
' ', con_linewidth);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_Print
|
||||
|
||||
|
@ -324,7 +302,6 @@ Con_Print (char *txt)
|
|||
} else
|
||||
mask = 0;
|
||||
|
||||
|
||||
while ((c = *txt)) {
|
||||
// count word length
|
||||
for (l = 0; l < con_linewidth; l++)
|
||||
|
@ -392,8 +369,7 @@ Con_DrawInput (void)
|
|||
char temp[MAXCMDLINE];
|
||||
|
||||
if (key_dest != key_console && cls.state == ca_active)
|
||||
return; // don't draw anything (always draw
|
||||
// if not active)
|
||||
return; // don't draw anything (always draw if not active)
|
||||
|
||||
text = strcpy (temp, key_lines[edit_line]);
|
||||
|
||||
|
@ -453,7 +429,6 @@ Con_DrawNotify (void)
|
|||
v += 8;
|
||||
}
|
||||
|
||||
|
||||
if (key_dest == key_message) {
|
||||
clearnotify = 0;
|
||||
scr_copytop = 1;
|
||||
|
@ -483,6 +458,7 @@ Con_DrawNotify (void)
|
|||
con_notifylines = v;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Con_DrawConsole
|
||||
|
||||
|
@ -537,8 +513,49 @@ Con_DrawConsole (int lines)
|
|||
Con_DrawInput ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Con_DrawDownload (int lines)
|
||||
{
|
||||
}
|
||||
int i, j, x, y, n;
|
||||
char *text;
|
||||
char dlbar[1024];
|
||||
|
||||
if (!cls.download)
|
||||
return;
|
||||
|
||||
text = COM_SkipPath(cls.downloadname);
|
||||
|
||||
x = con_linewidth - ((con_linewidth * 7) / 40);
|
||||
y = x - strlen (text) - 8;
|
||||
i = con_linewidth / 3;
|
||||
if (strlen (text) > i) {
|
||||
y = x - i - 11;
|
||||
strncpy (dlbar, text, i);
|
||||
dlbar[i] = 0;
|
||||
strncat (dlbar, "...", sizeof (dlbar) - strlen (dlbar));
|
||||
} else
|
||||
strncpy (dlbar, text, sizeof (dlbar));
|
||||
strncat (dlbar, ": ", sizeof (dlbar) - strlen (dlbar));
|
||||
i = strlen (dlbar);
|
||||
dlbar[i++] = '\x80';
|
||||
// where's the dot go?
|
||||
if (cls.downloadpercent == 0)
|
||||
n = 0;
|
||||
else
|
||||
n = y * cls.downloadpercent / 100;
|
||||
for (j = 0; j < y; j++)
|
||||
if (j == n)
|
||||
dlbar[i++] = '\x83';
|
||||
else
|
||||
dlbar[i++] = '\x81';
|
||||
dlbar[i++] = '\x82';
|
||||
dlbar[i] = 0;
|
||||
|
||||
snprintf (dlbar + strlen (dlbar), sizeof (dlbar) - strlen (dlbar),
|
||||
" %02d%%", cls.downloadpercent);
|
||||
// draw it
|
||||
y = lines - 22 + 8;
|
||||
for (i = 0; i < strlen (dlbar); i++)
|
||||
Draw_Character8 ((i + 1) << 3, y, dlbar[i]);
|
||||
}
|
||||
|
|
|
@ -39,8 +39,11 @@
|
|||
#include "r_local.h"
|
||||
#include "render.h"
|
||||
|
||||
// player_state_t is the information needed by a player entity
|
||||
// to do move prediction and to generate a drawable entity
|
||||
|
||||
/*
|
||||
player_state_t is the information needed by a player entity
|
||||
to do move prediction and to generate a drawable entity
|
||||
*/
|
||||
typedef struct player_state_s {
|
||||
int messagenum; // all player's won't be updated each frame
|
||||
|
||||
|
@ -68,6 +71,7 @@ typedef struct player_state_s {
|
|||
|
||||
#undef MAX_SCOREBOARDNAME
|
||||
#define MAX_SCOREBOARDNAME 16
|
||||
|
||||
typedef struct player_info_s
|
||||
{
|
||||
int userid;
|
||||
|
@ -102,17 +106,15 @@ typedef struct
|
|||
|
||||
// received from server
|
||||
double receivedtime; // time message was received, or -1
|
||||
player_state_t playerstate[MAX_CLIENTS]; // message received that reflects performing
|
||||
// the usercmd
|
||||
player_state_t playerstate[MAX_CLIENTS]; // message received that
|
||||
// reflects performing the
|
||||
// usercmd
|
||||
packet_entities_t packet_entities;
|
||||
qboolean invalid; // true if the packet_entities delta was invalid
|
||||
} frame_t;
|
||||
|
||||
|
||||
//
|
||||
// client_state_t should hold all pieces of the client state
|
||||
//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int length;
|
||||
|
@ -120,11 +122,10 @@ typedef struct
|
|||
} lightstyle_t;
|
||||
|
||||
|
||||
|
||||
#define MAX_EFRAGS 512
|
||||
|
||||
#define MAX_DEMOS 8
|
||||
#define MAX_DEMONAME 16
|
||||
#define MAX_EFRAGS 512
|
||||
|
||||
|
||||
typedef enum {
|
||||
ca_disconnected, // full screen console with no connection
|
||||
|
@ -142,10 +143,10 @@ typedef enum {
|
|||
dl_single
|
||||
} dltype_t; // download type
|
||||
|
||||
//
|
||||
// the client_static_t structure is persistant through an arbitrary number
|
||||
// of server connections
|
||||
//
|
||||
/*
|
||||
the client_static_t structure is persistant through an arbitrary number
|
||||
of server connections
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
// connection information
|
||||
|
@ -161,7 +162,8 @@ typedef struct
|
|||
|
||||
int qport;
|
||||
|
||||
QFile *download; // file transfer from server
|
||||
// file transfer from server
|
||||
QFile *download;
|
||||
char downloadtempname[MAX_OSPATH];
|
||||
char downloadname[MAX_OSPATH];
|
||||
int downloadnumber;
|
||||
|
@ -189,10 +191,9 @@ typedef struct
|
|||
|
||||
extern client_static_t cls;
|
||||
|
||||
//
|
||||
// the client_state_t structure is wiped completely at every
|
||||
// server signon
|
||||
//
|
||||
/*
|
||||
the client_state_t structure is wiped completely at every server signon
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int servercount; // server identification for prespawns
|
||||
|
@ -224,9 +225,8 @@ typedef struct
|
|||
cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
|
||||
cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
|
||||
|
||||
// the client maintains its own idea of view angles, which are
|
||||
// sent to the server each frame. And only reset at level change
|
||||
// and teleport times
|
||||
// the client maintains its own idea of view angles, which are sent to the
|
||||
// server each frame. And only reset at level change and teleport times
|
||||
vec3_t viewangles;
|
||||
|
||||
// the client simulates or interpolates movement to get these values
|
||||
|
@ -252,9 +252,8 @@ typedef struct
|
|||
int intermission; // don't change view angle, full screen, etc
|
||||
int completed_time; // latched ffrom time at intermission start
|
||||
|
||||
//
|
||||
// information that is static for the entire time connected to a server
|
||||
//
|
||||
/* information that is static for the entire time connected to a server */
|
||||
|
||||
char model_name[MAX_MODELS][MAX_QPATH];
|
||||
char sound_name[MAX_SOUNDS][MAX_QPATH];
|
||||
|
||||
|
@ -281,9 +280,9 @@ typedef struct
|
|||
} client_state_t;
|
||||
|
||||
|
||||
//
|
||||
// cvars
|
||||
//
|
||||
/*
|
||||
cvars
|
||||
*/
|
||||
extern struct cvar_s *cl_warncmd;
|
||||
extern struct cvar_s *cl_upspeed;
|
||||
extern struct cvar_s *cl_forwardspeed;
|
||||
|
@ -329,8 +328,6 @@ extern char *server_version; // version of server we connected to
|
|||
|
||||
extern double realtime;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
||||
void Cvar_Info (struct cvar_s *var);
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ int con_totallines; // total lines in console scrollback
|
|||
|
||||
float con_cursorspeed = 4;
|
||||
|
||||
|
||||
cvar_t *con_notifytime; // seconds
|
||||
|
||||
#define NUM_CON_TIMES 4
|
||||
|
@ -74,11 +73,11 @@ int con_notifylines; // scan lines to clear for notify lines
|
|||
qboolean con_debuglog;
|
||||
|
||||
#define MAXCMDLINE 256
|
||||
|
||||
extern char key_lines[32][MAXCMDLINE];
|
||||
extern int edit_line;
|
||||
extern int key_linepos;
|
||||
|
||||
|
||||
qboolean con_initialized;
|
||||
|
||||
|
||||
|
@ -235,9 +234,7 @@ Con_Init (void)
|
|||
|
||||
Con_Printf ("Console initialized.\n");
|
||||
|
||||
//
|
||||
// register our commands
|
||||
//
|
||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f,
|
||||
"Toggle the console up and down");
|
||||
Cmd_AddCommand ("togglechat", Con_ToggleChat_f,
|
||||
|
@ -305,7 +302,6 @@ Con_Print (char *txt)
|
|||
} else
|
||||
mask = 0;
|
||||
|
||||
|
||||
while ((c = *txt)) {
|
||||
// count word length
|
||||
for (l = 0; l < con_linewidth; l++)
|
||||
|
@ -373,8 +369,7 @@ Con_DrawInput (void)
|
|||
char temp[MAXCMDLINE];
|
||||
|
||||
if (key_dest != key_console && cls.state == ca_active)
|
||||
return; // don't draw anything (always draw
|
||||
// if not active)
|
||||
return; // don't draw anything (always draw if not active)
|
||||
|
||||
text = strcpy (temp, key_lines[edit_line]);
|
||||
|
||||
|
@ -434,7 +429,6 @@ Con_DrawNotify (void)
|
|||
v += 8;
|
||||
}
|
||||
|
||||
|
||||
if (key_dest == key_message) {
|
||||
clearnotify = 0;
|
||||
scr_copytop = 1;
|
||||
|
@ -565,4 +559,3 @@ Con_DrawDownload (int lines)
|
|||
for (i = 0; i < strlen (dlbar); i++)
|
||||
Draw_Character8 ((i + 1) << 3, y, dlbar[i]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue