📄 client.pas
字号:
unit Client;
{=> client\CLIENT.H <=}
{ NOTES: }
{ ====== }
{ I have left a lot of the EXTERN elements at the top, but commented out }
{ so as to help with the eventual construction of the Uses Clause. }
{ Scott Price, 19-Jan-2002, 1123 GMT }
{ Updated: 03-jun-2002 Juha Hartikainen (juha@linearteam.org) }
{ - Added missing units to uses clause }
{ - Fixed couple language errors to make this fully compile (!) }
{ - Commented out duplicate type definitions }
{ Copyright (C) 1997-2001 Id Software, Inc. }
{ This program is free software; you can redistribute it and/or }
{ modify it under the terms of the GNU General Public License }
{ as published by the Free Software Foundation; either version 2 }
{ of the License, or (at your option) any later version. }
{ This program is distributed in the hope that it will be useful, }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. }
{ See the GNU General Public License for more details. }
{ You should have received a copy of the GNU General Public License }
{ along with this program; if not, write to the Free Software }
{ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. }
interface
uses
Common,
q_shared,
qfiles,
snd_loc,
ref,
sound_h,
{$IFDEF WIN32}
Windows;
{$ELSE}
WinTypes, WinProcs;
{$ENDIF}
{ Constants moved together }
const
MAX_CLIENTWEAPONMODELS = 20; { PGM -- upped from 16 to fit the chainfist vwep }
CMD_BACKUP = 64; { allow a lot of command backups for very fast systems }
{ the cl_parse_entities must be large enough to hold UPDATE_BACKUP frames of }
{ entities, so that when a delta compressed message arives from the server }
{ it can be un-deltad from the original }
MAX_PARSE_ENTITIES = 1024;
MAX_SUSTAINS = 32;
PARTICLE_GRAVITY = 40;
BLASTER_PARTICLE_COLOR = $e0;
{ PMM }
INSTANT_PARTICLE = -10000.0;
{ PGM }
{ Types Moved Together }
type
{ Juha: Added this type to make it a bit more clear that this is file
handle, not just "integer" }
TFileHandle = Integer;
pimage_s = pointer;
image_p = pimage_s;
pmodel_s = pointer;
model_p = pmodel_s;
{ frame_t }
frame_p = ^frame_t;
frame_t = packed record
valid: QBOOLEAN; { cleared if delta parsing was invalid }
serverframe: Integer;
servertime: Integer; { server time the message is valid for (in msec) }
deltaframe: Integer;
areabits: Array[0..(MAX_MAP_AREAS shr 3)-1] of BYTE; { portalarea visibility bits }
playerstate: PLAYER_STATE_T;
num_entities: Integer;
parse_entities: Integer; { non-masked index into cl_parse_entities array }
end { frame_t };
{ centity_t }
centity_p = ^centity_t;
centity_t = packed record
baseline: ENTITY_STATE_T; { delta from this if not from a previous frame }
current: ENTITY_STATE_T;
prev: ENTITY_STATE_T; { will always be valid, but might just be a copy of current }
serverframe: Integer; { if not current, this ent isn't in the frame }
trailcount: Integer; { for diminishing grenade trails }
lerp_origin: VEC3_T; { for trails (variable hz) }
fly_stoptime: Integer;
end { centity_t };
{ clientinfo_t }
clientinfo_p = ^clientinfo_t;
clientinfo_t = packed record
name: Array[0..MAX_QPATH-1] of Char;
cinfo: Array[0..MAX_QPATH-1] of Char;
skin: PIMAGE_S;
icon: PIMAGE_S;
iconname: Array[0..MAX_QPATH-1] of Char;
model: PMODEL_S;
weaponmodel: Array[0..MAX_CLIENTWEAPONMODELS-1] of PMODEL_S;
end { clientinfo_t };
Pclientinfo_t = ^clientinfo_t;
TClientInfo_T = clientinfo_t;
//PClientInfo_T = Pclientinfo_t;
{ client_state_t }
{ The client_state_t structure is wiped completely at every }
{ server map change }
client_state_p = ^client_state_t;
client_state_t = packed record
timeoutcount: Integer;
timedemo_frames: Integer;
timedemo_start: Integer;
refresh_prepped: QBOOLEAN; { false if on new level or new ref dll }
sound_prepped: QBOOLEAN; { ambient sounds can start }
force_refdef: QBOOLEAN; { vid has changed, so we can't use a paused refdef }
parse_entities: Integer; { index (not anded off) into cl_parse_entities[] }
cmd: USERCMD_T;
cmds: Array[0..CMD_BACKUP-1] of USERCMD_T; { each mesage will send several old cmds }
cmd_time: Array[0..CMD_BACKUP-1] of Integer; { time sent, for calculating pings }
predicted_origins: Array[0..CMD_BACKUP-1] of Array[0..3-1] of SmallInt; { for debug comparing against server }
predicted_step: Single; { for stair up smoothing }
predicted_step_time: Word;
predicted_origin: VEC3_T; { generated by CL_PredictMovement }
predicted_angles: VEC3_T;
prediction_error: VEC3_T;
frame: FRAME_T; { received from server }
surpressCount: Integer; { number of messages rate supressed }
frames: Array[0..UPDATE_BACKUP-1] of FRAME_T;
{ the client maintains its own idea of view angles, which are }
{ sent to the server each frame. It is cleared to 0 upon entering each level. }
{ the server sends a delta each frame which is added to the locally }
{ tracked view angles to account for standing on rotating objects, }
{ and teleport direction changes }
viewangles: VEC3_T;
time: Integer; { this is the time value that the client }
{ is rendering at. always <= cls.realtime }
lerpfrac: Single; { between oldframe and frame }
refdef: REFDEF_T;
v_forward, v_right, v_up: VEC3_T; { set when refdef.angles is set }
{/// }
{ transient data from server }
{/// }
layout: Array[0..1024-1] of Char; { general 2D overlay }
inventory: Array[0..MAX_ITEMS-1] of Integer;
{/// }
{ non-gameserver infornamtion }
{ FIXME: move this cinematic stuff into the cin_t structure }
cinematic_file: TFileHandle;
cinematictime: Integer; { cls.realtime for first cinematic frame }
cinematicframe: Integer;
cinematicpalette: Array[0..768-1] of Char;
cinematicpalette_active: QBOOLEAN;
{/// }
{ server state information }
{/// }
attractloop: QBOOLEAN; { running the attract loop, any key will menu }
servercount: Integer; { server identification for prespawns }
gamedir: Array[0..MAX_QPATH-1] of Char;
playernum: Integer;
configstrings: Array[0..MAX_CONFIGSTRINGS-1] of Array[0..MAX_QPATH-1] of Char;
{/// }
{ locally derived information from server state }
{/// }
model_draw: Array[0..MAX_MODELS-1] of PMODEL_S;
model_clip: Array[0..MAX_MODELS-1] of PCMODEL_S;
sound_precache: Array[0..MAX_SOUNDS-1] of sfx_p;
image_precache: Array[0..MAX_IMAGES-1] of PIMAGE_S;
clientinfo: Array[0..MAX_CLIENTS-1] of CLIENTINFO_T;
baseclientinfo: CLIENTINFO_T;
end { client_state_t };
Pclient_state_t = ^client_state_t;
TClient_State_T = client_state_t;
//PClient_State_T = Pclient_state_t;
{ ================================================================== }
{ the client_static_t structure is persistant through an arbitrary
{ number of server connections }
{ ================================================================== }
{ connstate_t enumeration }
connstate_t = (ca_uninitialized, ca_disconnected, ca_connecting, ca_connected, ca_active);
TConnState_T = connstate_t;
{ dltype_t enumeration }
dltype_t = (dl_none, dl_model, dl_sound, dl_skin, dl_single);
TDLType_T = dltype_t;
{ keydest_t enumeration }
keydest_t = (key_game, key_console, key_message, key_menu);
TKeyDest_T = keydest_t;
{ client_static_t }
client_static_t = packed record
state: CONNSTATE_T;
key_dest: KEYDEST_T;
framecount: Integer;
realtime: Integer; { always increasing, no clamping, etc }
frametime: Single; { seconds since last frame }
{ screen rendering information }
disable_screen: Single; { showing loading plaque between levels }
{ or changing rendering dlls }
{ if time gets > 30 seconds ahead, break it }
disable_servercount: Integer; { when we receive a frame and cl.servercount }
{ > cls.disable_servercount, clear disable_screen }
{ connection information }
servername: Array[0..MAX_OSPATH-1] of Char; { name of server from original connect }
connect_time: Single; { for connection retransmits }
quakePort: Integer; { a 16 bit value that allows quake servers }
{ to work around address translating routers }
netchan: NETCHAN_T;
serverProtocol: Integer; { in case we are doing some kind of version hack }
challenge: Integer; { from the server to use for connecting }
download: TFileHandle; { file transfer from server }
downloadtempname: Array[0..MAX_OSPATH-1] of Char;
downloadname: Array[0..MAX_OSPATH-1] of Char;
downloadnumber: Integer;
downloadtype: DLTYPE_T;
downloadpercent: Integer;
{ demo recording info must be here, so it isn't cleared on level change }
demorecording: QBOOLEAN;
demowaiting: QBOOLEAN; { don't record until a non-delta message is received }
demofile: TFileHandle;
end { client_static_t };
Pclient_static_t = ^client_static_t;
TClient_Static_T = client_static_t;
//PClient_Static_T = Pclient_static_t;
{ cdlight_t }
cdlight_p = ^cdlight_t;
cdlight_t = packed record
key: Integer; { so entities can reuse same entry }
color: vec3_t;
origin: vec3_t;
radius: Single;
die: Single; { stop lighting after this time }
decay: Single; { drop this each second }
minlight: Single; { don't add when contributing less }
end { cdlight_t };
TCDLight_T = cdlight_t;
PCDLight_T = cdlight_p;
{ ROGUE }
{ cl_sustain }
cl_sustain_p = ^cl_sustain;
cl_sustain = packed record
id: Integer;
ttype: Integer;
endtime: Integer;
nextthink: Integer;
thinkinterval: Integer;
org: VEC3_T;
dir: VEC3_T;
color: Integer;
count: Integer;
magnitude: Integer;
think: procedure(self: cl_sustain_p); cdecl;
end { cl_sustain };
cl_sustain_t = cl_sustain;
pcl_sustain_t = ^cl_sustain;
TCL_Sustain = cl_sustain_t;
PCL_Sustain = cl_sustain_p;
{ PGM }
{ cparticle_t }
cparticle_p = ^cparticle_s;
cparticle_s = packed record
next: cparticle_p;
time: Single;
org: vec3_t;
vel: vec3_t;
accel: vec3_t;
color: Single;
colorvel: Single;
alpha: Single;
alphavel: Single;
end { particle_s };
pparticle_s = ^cparticle_s;
cparticle_t = cparticle_s;
{/// }
{/// cl_input }
{/// }
{ kbutton_t }
Pkbutton_t = ^kbutton_t;
kbutton_t = packed record
down: Array[0..2-1] of Integer; { key nums holding it down }
downtime: Word; { msec timestamp }
msec: Word; { msec down this frame }
state: Integer;
end { kbutton_t };
TKButton_T = kbutton_t;
//PKButton_T = Pkbutton_t;
{ Variables Moved Together }
var
//cparticle_t: particle_s;
in_mlook, in_klook: kbutton_t;
in_strafe: kbutton_t;
in_speed: kbutton_t;
{/// }
{/// cl_view.c }
{/// }
gun_frame: Integer;
gun_model: Pmodel_s;
implementation
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -