|
OpenBF1942-Plus
Refractor 1, rebuilt from scratch
|
Classes | |
| class | BitReader |
Functions | |
| parse (d) | |
| actions (r) | |
| soldier (r, base) | |
| body (r, base) | |
| engine (r, gears=None) | |
| bundle (r) | |
| firearm (r, mag, mags) | |
| spring (r) | |
| composite (r, base, layout) | |
| vehicle (r, base, end) | |
| control_point (r, base) | |
| kit (r, base) | |
| projectile (r, base) | |
| player (r, base) | |
| score_manager (r, base) | |
| spawn_manager (r, groups) | |
| spawn_groups (data, start, bits) | |
| classify (classes, nid, data, start, bits, base) | |
| ghosts (r, classes=None) | |
| _u (n) | |
| _range_bits (lo, hi) | |
| _create_object (r) | |
| _chat (r) | |
| _game_status (r) | |
| _score (r) | |
| _map (r) | |
| _checksum (r) | |
| _stats (r) | |
| _pb_fragment (r) | |
| event (r) | |
| events (r) | |
| payload (direction, data, classes=None) | |
| load (path) | |
| track_classes (classes, m) | |
| summary (rows) | |
| record (listen_port, server_ip, server_port, path, seconds) | |
| main (argv) | |
Variables | |
| DATA | |
| CONNECT_REPLY | |
| CONNECT_ACK | |
| DISCONNECT | |
| PING | |
| PONG | |
| dict | CVEC_BITS = {1: 20, 2: 16, 3: 12} |
| int | BODY_KIT_BITS = 7 |
| int | ANIM_STATE_BITS = 11 |
| tuple | MANAGERS = ("actions", "events", "ghosts", "downloads") |
| dict | LAYOUTS |
| dict | TEAM_FIELDS = {0: "deaths", 6: "flag_attacks", 7: "teamkills", 8: "score", 9: "tickets", 10: "rounds_won"} |
| dict | GHOST_READERS |
| B | |
| STR | |
| VEC | |
| dict | EVENTS |
Battlefield 1942 game traffic (UDP game port): transport layer reader and a recording relay. Stdlib only.
Spec: docs/formats/network.md
Usage:
bfnet.py record <listen_port> <server_ip> <server_port> <out.jsonl> <seconds>
UDP relay: point the client at this machine (+joinServer <this ip>:<listen_port>); every datagram both
ways is forwarded and logged as one JSON line {t, dir: c2s|s2c, client, hex}. The log holds the player's
name and CD-key hash: keep it out of the repository.
bfnet.py summary <in.jsonl>
packets per direction and type, sequence gaps, acknowledgement mismatches, payload sections (stream manager
mask), how many fully decoded payloads end in their last byte, game events by name, client frame / server tick
range, ghost ids
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Width BitStream::readUnsigned(min, max) uses: the smallest n with 2^n - 1 >= max - min + 1.
|
protected |
|
protected |
|
protected |
| bfnet.actions | ( | r | ) |
PlayerActionManager section: u4 count, then if any a signed 32-bit first frame, then per action six u12 values and a u32 (meaning of the values open).
| bfnet.body | ( | r, | |
| base ) |
SimpleObjectNetworkable update (a vehicle's body): u11 mask, then the fields whose bit is set.
| bfnet.bundle | ( | r | ) |
RotationalBundleNetworkable update: u7 mask, then a 16-bit signed float per set bit (angles x180, speeds, the last x41; raw value kept).
| bfnet.classify | ( | classes, | |
| nid, | |||
| data, | |||
| start, | |||
| bits, | |||
| base ) |
Give an object no event named a class from its update: a LAYOUTS entry that reads it exactly (with the body, if it has a position, within 5 m of the CreateObject position); else a vehicle when it decodes as body and engine near that position; else a control point when it is 7 bits or less and fits.
| bfnet.composite | ( | r, | |
| base, | |||
| layout ) |
Read an object's update as the components of a LAYOUTS entry, in order.
| bfnet.control_point | ( | r, | |
| base ) |
ControlPointNetworkable update: u2 mask; 0x1 a 4-bit signed value, 0x2 a flag.
| bfnet.engine | ( | r, | |
| gears = None ) |
EngineNetworkable update: u10 mask, fields by bit, then a u32 that rises by one per update.
| bfnet.event | ( | r | ) |
One game event: 7-bit id, then its fields. Raises ValueError on an unknown id.
| bfnet.events | ( | r | ) |
GameEventManager section: u8 count, u5 block index, a flag, then the events.
| bfnet.firearm | ( | r, | |
| mag, | |||
| mags ) |
FireArmsNetworkable update: u2 mask; 0x1 range 0..magSize+1, 0x2 range 0..numOfMag+1 (template values).
| bfnet.ghosts | ( | r, | |
| classes = None ) |
GhostManager section: u32 server tick, u8 entry count, a flag, the player's control object state when the flag is set, then the entries. Each entry is a u2 kind and a u16 networkable id; kind 1 carries a flag and an u11 bit length of its update (skipped here), kind 3 removes the ghost, kind 2 is an error.
| bfnet.kit | ( | r, | |
| base ) |
KitNetworkable update: u4 mask; 0x1 position (full vector), 0x2 range 0-256, 0x4 flag, 0x8 range 0-8.
| bfnet.load | ( | path | ) |
| bfnet.main | ( | argv | ) |
| bfnet.parse | ( | d | ) |
One datagram -> dict. Raises ValueError on a malformed packet.
| bfnet.payload | ( | direction, | |
| data, | |||
| classes = None ) |
Data payload -> {"mask", section name: decoded, "end": bit position where decoding stopped, "open": name of
the first section not decodable yet (downloads) or None}. A 6-bit mask names the stream managers that wrote into
the packet; their sections follow in id order. `classes` maps networkable ids to a GHOST_READERS name; their
ghost updates are decoded with it (see `track_classes`).
| bfnet.player | ( | r, | |
| base ) |
BFPlayer update: u24 mask, ranged fields by bit, then always a flag. Names are those matched against the recording's events and server log; the others keep their bit.
| bfnet.projectile | ( | r, | |
| base ) |
ProjectileNetworkable update: u8 mask; position and velocity at scale 0.01, a 12-bit quaternion.
| bfnet.record | ( | listen_port, | |
| server_ip, | |||
| server_port, | |||
| path, | |||
| seconds ) |
| bfnet.score_manager | ( | r, | |
| base ) |
ScoreManager update: u24 mask; bits 0-10 team 1 and 11-21 team 2 (signed 18-bit each), 22 and 23 signed 3-bit round-end values.
| bfnet.soldier | ( | r, | |
| base ) |
BFSoldierNetworkable update: u14 mask, a flag, then the fields whose mask bit is set.
| bfnet.spawn_groups | ( | data, | |
| start, | |||
| bits ) |
The spawn manager's group count, found as the mask width that makes an update end exactly at its length.
| bfnet.spawn_manager | ( | r, | |
| groups ) |
BFSpawnPointManager update: a mask with one bit per spawn group of the level, then per set bit u4 team, a flag (active), and the group's x / 8 and z / 8 as bytes.
| bfnet.spring | ( | r | ) |
SpringNetworkable update: u1; when set, two vectors in the 'high' compression table (widths unknown).
| bfnet.summary | ( | rows | ) |
| bfnet.track_classes | ( | classes, | |
| m ) |
Update `classes` (networkable id -> ghost reader) from a decoded payload's events and ghost entries: CreatePlayer names a player, DataBaseComplete the spawn and score managers, SetDefaultVehicle the player's soldier, SetVehicle a vehicle, HandlePickup a kit, CreateMultipleObjects projectiles; other CreateObject ids are left for `classify`. DestroyObject forgets an id (ids are reused).
| bfnet.vehicle | ( | r, | |
| base, | |||
| end ) |
A vehicle's update: body, engine, then the other components (springs, turrets, weapons; not decoded).
| int bfnet.ANIM_STATE_BITS = 11 |
| bfnet.B |
| int bfnet.BODY_KIT_BITS = 7 |
| bfnet.CONNECT_ACK |
| bfnet.CONNECT_REPLY |
| dict bfnet.CVEC_BITS = {1: 20, 2: 16, 3: 12} |
| bfnet.DATA |
| bfnet.DISCONNECT |
| dict bfnet.EVENTS |
| dict bfnet.GHOST_READERS |
| dict bfnet.LAYOUTS |
| tuple bfnet.MANAGERS = ("actions", "events", "ghosts", "downloads") |
| bfnet.PING |
| bfnet.PONG |
| bfnet.STR |
| dict bfnet.TEAM_FIELDS = {0: "deaths", 6: "flag_attacks", 7: "teamkills", 8: "score", 9: "tickets", 10: "rounds_won"} |
| bfnet.VEC |