|
OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
|
Classes | |
| class | Player |
| class | Duel |
Functions | |
| frames_until (player, done, seconds) | |
| settle (player, weapon, seconds=6) | |
| shot_interval (player, script, seconds=6) | |
| check_fast_reload (port, player, other, check) | |
| check_prone_peek (port, player, other, check) | |
| take_turret (port, player) | |
| check_mg_clip (port, player, other, check) | |
| shotgun_pellets (player, index) | |
| check_shotgun_spread (port, player, other, check) | |
| check_mg_rate (port, player, other, check) | |
| snapshots_per_second (player, seconds=3) | |
| check_snapshot_rate (port, player, other, check) | |
| check_archive_time (port, player, other, check) | |
| pump (players, seconds) | |
| check_lean_rewind (port, player, other, check) | |
| check_stance_rewind (port, player, other, check) | |
| check_vote_reconnect (port, player, other, check) | |
| check_error_repeats (port, player, other, check) | |
| check_wait_time (port, player, other, check) | |
| main () | |
Variables | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| str | RCON = 'plusrules' |
| LOG = None | |
| BUTTON_ATTACK | |
| BUTTON_RELOAD | |
| BUTTON_LEANLEFT | |
| BUTTON_LEANRIGHT | |
| PRONE | |
| CROUCH | |
| int | BUTTON_USE = 8 |
| int | BUTTON_ADS = 4096 |
| int | EF_TURRET_ACTIVE = 0x300 |
| dict | STANCE_EVENTS = {140, 141, 142} |
| WEAPON_READY | |
| WEAPON_FIRING | |
| str | OTHER = 'thompson_mp' |
| tuple | RIFLES |
| str | GAMETYPE |
| ET_TURRET | |
| ET_EVENTS | |
| EV_BULLET_HIT_SMALL | |
| EV_SHOTGUN_HIT | |
| list | SPREAD_PATTERNS |
| int | MG42_FIRE_TIME = 50 |
| int | TURRET_RETURN_SPEED = 200 |
| dict | CHECKS |
Checks the rules a Plus server plays by with a Plus client (Plus version 123,
docs/architecture/plus-protocol.md#version-123).
python3 scripts/plus_rules_test.py /path/to/CoD2 [--binary bin/cod2rev_lnxded] [--only NAME,...] [--fps N]
Runs the server with a mod whose dm gametype spawns the player with
thompson_mp and a bolt-action, and a minimal client (cod2client) that sends
scripted usercmds and reads its playerstate from the snapshots:
- fast reload: for each bolt-action (and the shotgun), it fires, presses
reload, switches to the thompson and back while the rifle still drops, at
several times around the bolt, then fires as soon as it can. No time between
the two shots may be shorter than with no switch, give or take a command
(50 ms, how closely the snapshots time a shot). The shotgun gains about
that much on a stock build, so only the rifles show the bug there.
- prone peek: crouched and leaning, it goes prone, crouches and goes prone
again, to each side. The lean, which halves going prone, may come back no
faster than when the lean key is let go (0.5 in 280 ms): it used to halve
in one frame.
- mg clip: it takes a turret from 20 units to its side, which moves it behind
the gun, and leaves it with the use button. It must stay where the turret
held it: the stock game takes it back to where it stood when it took the
turret, behind cover if it stood there. Leaving adds no playerstate event
but the one that restores the stance.
- shotgun spread: turned to a wall the whole spread meets, with
g_shotgun_spread_fix 1, the distances of a shot's 8 impacts from the aim
must be one of the two patterns', whatever the turn, and both must come;
with 0 they must not. This is not a Plus rule: it passes on every build.
- mg rate: on the turret, aimed at the ground, it holds fire: one impact
every 50 ms (mg42's fireTime), timed from the first to the last; left, the
turret turns back at 200 degrees a second. With --fps N the server runs at
that sv_fps, with a snapshot every frame; other builds fail above 20 Hz.
- snapshot rate: with sv_lanForceRate 0, so the test client counts as one on
the internet, it gets a snapshot every frame and a rate of 1,000 bytes a
second per Hz (25,000 at least), and g_forceSnaps 10 set by rcon gives it 10
snapshots a second at once. Other builds have no sv_lanForceRate.
- archive time: a bot moves 100 units a second, and the player follows it a
second back, as a killcam: the bot's origin must be from the newest frame
at least a second old. Stock counted sv_fps frames a second, 960 ms at
sv_fps 60.
- lean rewind: a second client 600 ms behind, down the sights with no
spread, shoots at where the player's head was while it leaned, after it
let go of the lean: the antilag must hit the head, which only the Plus
build's pose rewind does. A shot into the wall over the head first measures
how far the bullet leaves from the view. It sets g_antilag 1, which a game
folder's config can turn off.
- stance rewind: the same client shoots at where the player's head was
before it crouched, went prone or stood up from a crouch, once its head
has left it: the antilag must rewind the animation of the stance, not only its
flags, which only the Plus build does.
Exits with 0 when every check passes. On a build without the rules (any
build but make PLUS=1) the other checks fail: that is how they catch the bugs.
| plus_rules_test.check_archive_time | ( | port, | |
| player, | |||
| other, | |||
| check ) |
Following a bot a second back, as a killcam, the player gets the bot's playerstate from the last frame at least a second old: the bot moves at 100 units a second, so its origin tells how far back that was. The antilag finds its frames the same way. (The archived commandTime is moved to the present, so it cannot tell.)
| plus_rules_test.check_error_repeats | ( | port, | |
| player, | |||
| other, | |||
| check ) |
With logErrors 1 the same runtime error every frame for 11 s prints once, then as a count after 10 s, then the count it left when it stopped, not 220 times.
| plus_rules_test.check_fast_reload | ( | port, | |
| player, | |||
| other, | |||
| check ) |
| plus_rules_test.check_lean_rewind | ( | port, | |
| player, | |||
| other, | |||
| check ) |
The shooter shoots at where the player's head was while it leaned, after the player let go of the lean: the antilag must put the head back where the shooter saw it.
| plus_rules_test.check_mg_clip | ( | port, | |
| player, | |||
| other, | |||
| check ) |
| plus_rules_test.check_mg_rate | ( | port, | |
| player, | |||
| other, | |||
| check ) |
Manned, the MG fires once a fireTime at any sv_fps; left, it turns back to its rest at the same speed.
| plus_rules_test.check_prone_peek | ( | port, | |
| player, | |||
| other, | |||
| check ) |
| plus_rules_test.check_shotgun_spread | ( | port, | |
| player, | |||
| other, | |||
| check ) |
| plus_rules_test.check_snapshot_rate | ( | port, | |
| player, | |||
| other, | |||
| check ) |
With sv_lanForceRate 0 the test client gets an internet client's rate: on a Plus server, a snapshot every frame and 1,000 bytes a second per Hz (25,000 at least), whatever its snaps and rate; g_forceSnaps and g_forceRate set by rcon take effect at once.
| plus_rules_test.check_stance_rewind | ( | port, | |
| player, | |||
| other, | |||
| check ) |
The shooter shoots at where the player's head was before it changed stance, once the player's head has left it: the antilag must rewind the stance's animation too, not only its flags. On the server going down holds the head a little over standing for about 450 ms (crouch) or 700 ms (prone) before it drops, and standing up raises it at once, so each shot comes when the 600 ms ago it rewinds to still has the head there.
| plus_rules_test.check_vote_reconnect | ( | port, | |
| player, | |||
| other, | |||
| check ) |
A player who voted and reconnects in the same vote cannot vote again (ClientConnect clears the whole client). With two more clients the vote neither passes nor fails while the voter is away.
| plus_rules_test.check_wait_time | ( | port, | |
| player, | |||
| other, | |||
| check ) |
40 x wait 0.05 take 2 s and 4 x wait 1 take 4 s, to a frame, at any sv_fps: the fraction of a frame a wait leaves carries to the next.
| plus_rules_test.frames_until | ( | player, | |
| done, | |||
| seconds ) |
Snapshots' playerstates until done(playerstates) or seconds pass.
| plus_rules_test.main | ( | ) |
| plus_rules_test.pump | ( | players, | |
| seconds ) |
Keeps every client sending commands for that long.
| plus_rules_test.settle | ( | player, | |
| weapon, | |||
| seconds = 6 ) |
Holds weapon until it is ready and stays so for half a second.
| plus_rules_test.shot_interval | ( | player, | |
| script, | |||
| seconds = 6 ) |
Runs script from a ready weapon; the time from its first shot to the next one, in ms, or None.
| plus_rules_test.shotgun_pellets | ( | player, | |
| index ) |
Fires the shotgun once; its pellets' distances from the aim, as above, from the impacts the server sends, or the count of impacts if not 8.
| plus_rules_test.snapshots_per_second | ( | player, | |
| seconds = 3 ) |
| plus_rules_test.take_turret | ( | port, | |
| player ) |
Has the player take the turret, twice if the first useTurret did not take (now and then it does not); the playerstates until it is on.
| int plus_rules_test.BUTTON_ADS = 4096 |
| plus_rules_test.BUTTON_ATTACK |
| plus_rules_test.BUTTON_LEANLEFT |
| plus_rules_test.BUTTON_LEANRIGHT |
| plus_rules_test.BUTTON_RELOAD |
| int plus_rules_test.BUTTON_USE = 8 |
| dict plus_rules_test.CHECKS |
| plus_rules_test.CROUCH |
| int plus_rules_test.EF_TURRET_ACTIVE = 0x300 |
| plus_rules_test.ET_EVENTS |
| plus_rules_test.ET_TURRET |
| plus_rules_test.EV_BULLET_HIT_SMALL |
| plus_rules_test.EV_SHOTGUN_HIT |
| str plus_rules_test.GAMETYPE |
| plus_rules_test.LOG = None |
| int plus_rules_test.MG42_FIRE_TIME = 50 |
| str plus_rules_test.OTHER = 'thompson_mp' |
| plus_rules_test.PRONE |
| str plus_rules_test.RCON = 'plusrules' |
| tuple plus_rules_test.RIFLES |
| plus_rules_test.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| list plus_rules_test.SPREAD_PATTERNS |
| dict plus_rules_test.STANCE_EVENTS = {140, 141, 142} |
| int plus_rules_test.TURRET_RETURN_SPEED = 200 |
| plus_rules_test.WEAPON_FIRING |
| plus_rules_test.WEAPON_READY |