nvs_1_handshake.txt
来自「quake1 dos源代码最新版本」· 文本 代码 · 共 183 行
TXT
183 行
Network Versioning System
=========================
Part I - General And Handshake System
The three different NVS versions
--------------------------------
1. Server SVC version (between the server and the PROGS.DAT (QuakeC code))
The server SVC version is limited by the server executable and the PROGS.DAT,
as the QuakeC code can issue SVC messages just like the server.
This version forces the server and PROGS.DAT to create SVC messages and use
functions of the same version, this is necessary to garanty their
cooperation.
Shortname: SSVC
2. Client SVC version (CSVC, between the server and each client)
The client SVC version is stored for every client on the server and on each
client. It is limited by the server SVC version (SSVC) and the version
supported by the client.
Shortname: CSVC
3. Client CLC version (CCLC, between the server and each client)
The client CLC version is stored for every client on the server and on each
client. It is limited by the server executable and the version supported by
the client.
With this version, even when the PROGS.DAT never heard of the NVS, a NVS-
enhanced client and server can use enhanced messages (e.g. precise aiming).
Shortname: CCLC
To keep compatibility, only the lowest version is used. For example if the
server executable supports version 1.68 and the PROGS.DAT supports version 2.5,
then version 1.68 is used as the server SVC version.
All versions have no more than two decimal numbers.
Handshake
---------
1. Server <-> PROGS.DAT (QuakeC code) (short: SRV<->QC)
SSVC is initialized when a server is spawned in SpawnServer() of SV_MAIN.C
and the cvar NVS_SSVC_VERSION is initialized and made writeable.
The PROGS.DAT can set the cvar NVS_SSVC_VERSION in WorldSpawn() of WORLD.QC
to tell the server which version it supports. The cvar is range-checked by
the server, hence limits the version as described above.
Then the PROGS.DAT must re-read the cvar to get the determined SSVC to use it
for creating its SVC messages. It can also cause an host error if the SSVC is
too low.
On old servers the PROGS.DAT will cause a "cvar not available" warning and
version 0 as SSVC.
After WorldSpawn() the cvar NVS_SSVC_VERSION is made read-only and its value
is transferred to the SSVC.
To test a PROGS.DAT with different NVS versions it is possible to set the
maximum SSVC with the command NVS_MAX_SERVER. Values above the maximum
supported version are denied, a negative value will set it back to the
maximum supported version (default). Changes will take effect on the next
map.
Cvar: NVS_SSVC_VERSION (server, read-only, range-checked)
Command: NVS_MAX_SERVER <version>
2. Server <-> Client (short: SRV<->CL)
Every client initializes its CSVC and CCLC versions on connect in
CL_EstablishConnection() of CL_MAIN.C.
The server initializes CMAX, CSVC and CCLC for the client in
SV_SendServerinfo() of SV_MAIN.C
Then the client issues the CMD command "NVS_VERSION <version>" to the server
on first signon before "prespawn" in CL_SignonReply() of CL_MAIN.C with its
maximum supported version.
The server stores this value as the maximum for this client (CMAX), compares
it with SSVC then sets the result as CSVC and finally compares it with the
maximum supported version then sets the result as CCLC.
The results for CSVC and CCLC plus SSVC are transferred to the client with a
new SVC message. The client stores the data in the cvars NVS_CSVC_VERSION,
NVS_CCLC_VERSION and NVS_SSVC_VERSION (SSVC is helpful for debugging demos).
To let the admin and/or the PROGS.DAT/QuakeC set a required NVS version for
connecting clients the cvar NVS_MIN_VERSION was added. Client's below this
version will be rejected.
To test different client NVS versions it is possible to set the maximum
CSVC/CCLC of the client with the command NVS_MAX_CLIENT. Values above the
maximum supported version are denied, a negative value will set it back to
the maximum supported version (default). Changes will take effect on the next
client connect.
The command just sets the maximum for the NVS_CSVC_VERSION cvar, which is
used as the maximum supported version for the NVS_VERSION command on signon.
You can also issue the NVS_VERSION command during gameplay, which will change
the client's NVS versions at the start of the next server frame, to let you
test different client versions on the fly. Remember that you can be rejected
by doing this, as it is handled like a "reconnection".
Cvar: NVS_CSVC_VERSION (client, read-only)
NVS_CCLC_VERSION (client, read-only)
Command: NVS_VERSION <version>
NVS_MAX_CLIENT <version>
SVC: NVS_VERSION <SSVC> <CSVC> <CCLC>
3. PROGS.DAT (QuakeC code) <-> Client (short: QC<->CL)
The client's CSVC is transferred into an optional entity field called NVS_SVC
before the PROGS.DAT's ClientConnect() is executed.
This way the PROGS.DAT can check new connecting clients too.
Another way is to check/set NVS_MIN_VERSION in WorldSpawn(), but remember
that this interferes with the admin's wishes. So if you do this, read the
cvar first and increase it if it is too low.
As loading games overwrite all entity datas, the current server and client
versions have to be restored every frame. Otherwise the PROGS.DAT/QuakeC may
create messages for the wrong NVS version.
This is also necessary for changing the NVS version during gameplay.
Known Problems
--------------
* NVS_MAX_CLIENT still neccessary despite on the fly changes(?)
* Lots of DPrint in source code for debugging issues
search for REMOVE ME
Hints
-----
* System requires enhanced CVAR handling (read-only, range check)
* To see all the versions just use CVARLIST NVS.
To see the versions of all clients just use the general STATUS command.
To see the version of the server use [CMD] VERSION.
* Remember to inform users that demos recorded with a NVS version enabled
PROGS.DAT will not work on non-NVS executables.
* Client CMD's are executed outside the entity processing in SV_Physics().
* Connecting but not already spawned clients are set to active.
File Changes
------------
* 2000-04-30:
Completly redone handshake system (search for NVS COMMON and NVS HANDSHAKE)
CL_DEMO.C
added initialization of NVS_CSVC_VERSION, NVS_CCLC_VERSION, NVS_SSVC_VERSION in CL_PlayDemo_f()
CL_MAIN.C
added initialization of NVS_CSVC_VERSION, NVS_CCLC_VERSION, NVS_SSVC_VERSION in CL_EstablishConnection()
added NVS_VERSION command to signon reply #1 in CL_SignonReply()
CL_PARSE.C
added SVC_NVSVERSION to SVC
added code for SVC_NVSVERSION to CL_ParseServerMessage()
HOST.C
added call of NVS_Init() in Host_Init()
HOST_CMD.C
enhanced status command to display clients' NVS versions
enhanced version command to display server's NVS versions and NVS_MIN_VERSION
drop clients below NVS_MIN_VERSION in Host_Prespawn_f() (necessary to check non-NVS clients too)
filling client's optional entity field NVS_SVC with client's CSVC version
PROTOCOL.H
added SVC_NVSVERSION #35
NVS.C
added file
added cvars NVS_SSVC_VERSION, NVS_CSVC_VERSION, NVS_CCLC_VERSION, NVS_MIN_VERSION
added commands NVS_MAX_SERVER, NVS_MAX_CLIENT, NVS_VERSION
added NVS_Init() for registering cvars and commands
NVS.H
added file
added definition of MAX_NVS_VERSION
added declarations of cvars and NVS_Init()
QUAKEDEF.H
added include for NVS.H
added declaration for Host_Version_f()
SERVER.H
added NVS_CMAX, NVS_CCLC, NVS_CSVC to server's client structure
SV_MAIN.C
added initialization of NVS_CMAX, NVS_CCLC, NVS_CSVC in SV_ConnectClient() (signon #0)
made NVS_SSVC_VERSION writable before PROGS.DAT loading/WorldSpawn and later read-only again in SV_SpawnServer()
SV_PHYS.C
added setting of NVS_SVC entity field in SV_Physics()
SV_USER.C
allow user remote command NVS_VERSION in SV_ReadClientMessage()
PROGS\DEFS.QC
added NVS_SVC entity field (world = server, client = client)
PROGS\WORLD.QC
added example handshake code for PROGS.DAT
PROGS\CLIENT.QC
added example handshake code for PROGS.DAT
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?