OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
prediction_test Namespace Reference

Classes

class  Relay

Functions

 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
dict DEFAULT_CLIENT = {115: 'build/check-linux-10/cod2_linux', 118: 'build/check-linux/cod2_linux'}
dict DEFAULT_SERVER = {115: 'build/check-linux-10/cod2_lnxded', 118: 'build/check-linux/cod2_lnxded'}
str MOVES
int MOVES_SECONDS = 100
str SPOT = '2450 2200 80 90'
int MAX_MISSES = 60
int MAX_ANIM_MISSES = 6

Detailed Description

Counts a real client's prediction misses while it moves, jumps and fires.

    python3 scripts/prediction_test.py /path/to/CoD2 --protocol {115|118} [--binary PATH] [--server PATH] [--max-misses N] [--max-anim-misses N] [--moves CFG] [--spot 'X Y Z YAW'] [--delay MS] [--maxfps N] [--wine CMD]

Runs the dedicated server with scripts/contact_test.py's mod and a minimal
client as its target, and a real client (cod2_linux, held at 20 fps) as the
second player, which the mod puts in front of a ledge (--spot, by rcon) and a
config file drives: it mantles onto the ledge, turns away from the target,
walks forward, crouches and goes prone twice leaning right, walks back and to
both sides, crouches, goes prone, stands, jumps
and fires its rifle, fires, reloads and switches to its thompson and back
during the drop, then aims down its sight and back twice. It keeps away from
the target: the client clips against
other players with a box one unit smaller on each side than the server's (as
the original does), so running into one misses by design.

With each snapshot the client predicts its moves again from the server's
playerstate, with its own bgame, and compares the result with what it had
predicted for the same time; with cg_showmiss 1 it prints, as 1.3,
"Prediction miss: <distance>" when they
differ by more than 0.1. Prints the number of misses and their total and
largest distance, and exits with 0 when the client still runs, walked over
300 units (as the target sees it), left no crash report, and the misses are
at most --max-misses (60). With COD2_TRACE_PREDANIM the client also prints
"Prediction anim miss" when the moves predicted again give other legs or
torso animations than it had predicted (with the origin's miss); those must
be at most --max-anim-misses (6). They come from what the client cannot
predict, not from its animation script (scripts/anim_script_test.py
compares that with the server's): the weapon the mod gives at spawn, and the
MOVETYPE condition the landing event reads, which lives outside the
playerstate and is not set back when the moves are predicted again (3 or 4
per run, all with no origin miss). With COD2_TRACE_PREDDIFF=all the client
prints every playerstate field it predicted otherwise than the server; the
sight's fraction (fWeaponPosFrac) must match it (--max-ads-misses, 0), and so must
the weapon's state (weaponTime, weaponDelay, weapon, weaponstate) through a
fast reload, a shot cut by a reload and a switch to its thompson and back
during the drop, which a Plus server plays by its own rules (--max-weapon-misses,
0, leaving out the weapon the mod gives at spawn), and its lean going prone while leaning
(--max-lean-misses, 0). --delay MS puts a UDP relay between the
client and the server that holds each packet MS milliseconds each way (a
ping of twice that, as online); --maxfps sets the client's com_maxfps
(default 20). --wine CMD runs a Windows client given with --binary, our
cod2_win32.exe or 1.3's CoD2MP_s.exe as a baseline (copy it with its DLLs
off a Windows drive: Wine cannot map mss32.dll from DrvFs), and reads its
console_mp.log. The client opens a window and needs a CD key in
~/.cod2/preferences; without one the test is skipped (exit 0).

Function Documentation

◆ main()

prediction_test.main ( )

Variable Documentation

◆ DEFAULT_CLIENT

dict prediction_test.DEFAULT_CLIENT = {115: 'build/check-linux-10/cod2_linux', 118: 'build/check-linux/cod2_linux'}

◆ DEFAULT_SERVER

dict prediction_test.DEFAULT_SERVER = {115: 'build/check-linux-10/cod2_lnxded', 118: 'build/check-linux/cod2_lnxded'}

◆ MAX_ANIM_MISSES

int prediction_test.MAX_ANIM_MISSES = 6

◆ MAX_MISSES

int prediction_test.MAX_MISSES = 60

◆ MOVES

str prediction_test.MOVES
Initial value:
1= '''wait 300
2+forward; wait 10; +gostand; wait 10; -gostand; wait 40; -forward
3wait 20
4cl_yawspeed 180; +right; wait 20; -right
5+forward; wait 60; -forward
6+leanright; gocrouch; wait 30; goprone; wait 20; gocrouch; wait 6; goprone; wait 20; -leanright; gostand; wait 40
7+back; wait 30; -back
8+moveleft; wait 45; -moveleft
9+moveright; wait 45; -moveright
10+forward; +moveleft; wait 40; -moveleft; -forward
11+forward; wait 60; -forward
12gocrouch; wait 30
13+forward; wait 45; -forward
14goprone; wait 45
15+forward; wait 45; -forward
16gostand; wait 30
17+gostand; wait 5; -gostand; wait 30
18+forward; +gostand; wait 5; -gostand; wait 30; -forward
19+attack; wait 5; -attack; wait 30
20+attack; wait 5; -attack; wait 30
21+attack; wait 2; -attack; wait 2; +reload; wait 2; -reload; wait 13; weapnext; wait 1; weapnext; wait 60
22+moveright; wait 40; -moveright
23toggleads; wait 40; toggleads; wait 40
24toggleads; wait 40; toggleads; wait 40
25wait 30
26'''

◆ MOVES_SECONDS

int prediction_test.MOVES_SECONDS = 100

◆ ROOT

prediction_test.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

◆ SPOT

str prediction_test.SPOT = '2450 2200 80 90'