Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1929702f5b | ||
|
|
9d6b980ba6 | ||
|
|
9e4f8a2dcb | ||
|
|
53c268b8a6 | ||
|
|
592be6270a | ||
|
|
8817c37470 | ||
|
|
d635d83725 | ||
|
|
2a6dc2b738 | ||
|
|
6112dcfc5a | ||
|
|
62fa7e13ef | ||
|
|
9a12828762 | ||
|
|
7e82e7128e | ||
|
|
94882796b7 | ||
|
|
3dba558e4f | ||
|
|
1dc533fe18 | ||
|
|
8a8e70599f | ||
|
|
b115a41263 | ||
|
|
320464258a | ||
|
|
f5bb75c27c | ||
|
|
5cd1daff77 | ||
|
|
6329be8aa1 | ||
|
|
7a2f4caa50 | ||
|
|
938c37a669 | ||
|
|
fae3fbad69 | ||
|
|
5a35ea2b20 | ||
|
|
2e179ea90f | ||
|
|
9b517e554c | ||
|
|
595bbc5611 | ||
|
|
761210d405 | ||
|
|
7ba780ef59 | ||
|
|
d9c43e3478 | ||
|
|
c04ce7fd00 | ||
|
|
3f06b1b9d8 | ||
|
|
1b2d058a04 | ||
|
|
b5fa53ed95 | ||
|
|
1f2c10a3ca | ||
|
|
12f1155752 | ||
|
|
2b0327bc80 | ||
|
|
58aa352705 | ||
|
|
59c4b2160e | ||
|
|
1cf336f0ff | ||
|
|
d10969dc83 | ||
|
|
fe1d51dd58 | ||
|
|
24e4123882 | ||
|
|
197c199473 | ||
|
|
0acc3b1381 | ||
|
|
1e74e9b03e | ||
|
|
5d108579ed | ||
|
|
7a1ffca28b | ||
|
|
b843156fe8 | ||
|
|
99a31ca82d | ||
|
|
9666575b39 | ||
|
|
8466846d45 | ||
|
|
bc580cf1cf | ||
|
|
8e6b9a211e | ||
|
|
d0016bca89 | ||
|
|
3d575f32ed | ||
|
|
727b9ca80d | ||
|
|
99d7c924db | ||
|
|
57d96e4681 | ||
|
|
177ad4d40d | ||
|
|
bfb668d498 | ||
|
|
fc2b6551ca | ||
|
|
5316a6b145 | ||
|
|
59b1fb422b | ||
|
|
dc383d10da | ||
|
|
a143d9490d | ||
|
|
e55c29a97e | ||
|
|
16361bdef1 | ||
|
|
5ecd3075a0 | ||
|
|
13c14df95c | ||
|
|
b525bf8514 | ||
|
|
087ca8a875 | ||
|
|
24957ff6a0 | ||
|
|
402d4b8351 | ||
|
|
d1825ab08d | ||
|
|
268ec84b74 | ||
|
|
8dc796028e | ||
|
|
8aa381ed14 | ||
|
|
c3f82fa9b2 | ||
|
|
5ff4b6ee8d | ||
|
|
91e838e2f6 | ||
|
|
520b8401db | ||
|
|
2ed4a7b49d | ||
|
|
503992d544 | ||
|
|
ccc7df6611 | ||
|
|
ddcbe79283 | ||
|
|
862d88737e | ||
|
|
8610b28376 | ||
|
|
9e6247e0cb | ||
|
|
dea5fe3b1e | ||
|
|
f0804aa587 | ||
|
|
16ad4cc900 | ||
|
|
a38ede078a | ||
|
|
fa85aa53f5 | ||
|
|
8be9a038a1 | ||
|
|
783b591a6a | ||
|
|
e82d880060 | ||
|
|
7d0e587c51 | ||
|
|
01586cfebf | ||
|
|
de52060644 | ||
|
|
ab7c507a29 | ||
|
|
ba6fe0a826 | ||
|
|
3f6c0c37a4 | ||
|
|
606109551d | ||
|
|
8194c5a00b | ||
|
|
737551fd51 | ||
|
|
7a56c624f5 | ||
|
|
3ae09c3d2c | ||
|
|
3a22816c2f | ||
|
|
2853a42253 | ||
|
|
39ece781ee | ||
|
|
cf17201ec8 | ||
|
|
45de17116b | ||
|
|
7d56f34b83 | ||
|
|
3c7ba95ff5 | ||
|
|
092505224a | ||
|
|
079883d640 | ||
|
|
54faa1dab6 | ||
|
|
273152cc25 | ||
|
|
9bdd7f30c0 | ||
|
|
685bf260a0 | ||
|
|
933ed2b7b8 | ||
|
|
c115f5292d | ||
|
|
0f22c1d592 | ||
|
|
fb1abedd8b | ||
|
|
cd345aac7c | ||
|
|
7e00135d31 | ||
|
|
95416b2cfc | ||
|
|
ffc1512dcb | ||
|
|
88a7c07ec7 | ||
|
|
8e8713681d | ||
|
|
d7099f3e40 | ||
|
|
4ba36d7305 | ||
|
|
e3389991ac | ||
|
|
855f083117 | ||
|
|
6f3786de91 | ||
|
|
493713b0a6 | ||
|
|
bf356fc58a | ||
|
|
6a7b919522 | ||
|
|
20861c06d2 | ||
|
|
fc7271fd52 | ||
|
|
c1305fa94f | ||
|
|
3d2c04d675 | ||
|
|
0fc85d6c67 | ||
|
|
c0a08f395e | ||
|
|
06cb70fb58 | ||
|
|
1709698053 | ||
|
|
cb72dca40f | ||
|
|
bbea2a2bff | ||
|
|
57cdbd8f80 | ||
|
|
c5c5a8eaeb | ||
|
|
a3ee36b5ef | ||
|
|
30a1e0f40e | ||
|
|
327cf96d6f | ||
|
|
867855d388 | ||
|
|
9e7fd75f57 | ||
|
|
6754403d68 | ||
|
|
aedf5ff9bc | ||
|
|
193cbf59c7 | ||
|
|
fe160e9dbe | ||
|
|
d578f88bd0 | ||
|
|
d3fc997fdc | ||
|
|
a227872ccb | ||
|
|
812ffeea33 | ||
|
|
c05864b3fc | ||
|
|
ce77db8404 | ||
|
|
39350fb81f | ||
|
|
1a15a171ac | ||
|
|
2e3841ff7d | ||
|
|
46edf53657 | ||
|
|
cd747c23c5 | ||
|
|
f148dbd6d9 | ||
|
|
c3adcfe5bf | ||
|
|
3304965653 | ||
|
|
c04765d7f4 | ||
|
|
933aac6175 | ||
|
|
809408c663 | ||
|
|
601a4c1f50 | ||
|
|
133d6a5dc1 | ||
|
|
12c97ffa85 | ||
|
|
61623e68d5 | ||
|
|
23b542601f | ||
|
|
62b630a261 | ||
|
|
0e6327cadf | ||
|
|
5f82df71f0 | ||
|
|
e8e0c2215a | ||
|
|
383355381c | ||
|
|
2b0103a0ef | ||
|
|
e44619818b | ||
|
|
b449c43e22 | ||
|
|
991ab41016 | ||
|
|
5f9748d736 | ||
|
|
56b2a0e8e3 | ||
|
|
5f388f7818 | ||
|
|
557c0b486c |
No files matched your search
@@ -67,7 +67,9 @@ jobs:
|
||||
run: python tools/ci_build.py linux release
|
||||
|
||||
- name: Test
|
||||
run: python -m pytest -q tools/test_linux_port.py
|
||||
run: |
|
||||
python -m pytest -q tools/test_linux_port.py
|
||||
python tools/test_light_storage.py
|
||||
|
||||
- name: Compile cache
|
||||
run: ccache --show-stats
|
||||
@@ -200,6 +202,9 @@ jobs:
|
||||
- name: Release
|
||||
run: python tools/ci_build.py windows release
|
||||
|
||||
- name: Test light storage
|
||||
run: python tools/test_light_storage.py
|
||||
|
||||
- name: Compile cache
|
||||
run: ccache --show-stats
|
||||
|
||||
@@ -242,10 +247,7 @@ jobs:
|
||||
mkdir release
|
||||
for build in artifacts/*/; do
|
||||
name="$(basename "$build")"
|
||||
# stored, not deflated: the updater in builds up to 57 waits for
|
||||
# an end of stream the game's zlib 1.1 does not always report,
|
||||
# and fails on a deflated entry that unpacked correctly
|
||||
(cd "$build" && zip -0 -qr "$GITHUB_WORKSPACE/release/$name.zip" .)
|
||||
(cd "$build" && zip -qr "$GITHUB_WORKSPACE/release/$name.zip" .)
|
||||
done
|
||||
ls -l release
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ builds of the latest release:
|
||||
|
||||
| Platform | Release | Debug |
|
||||
| --- | --- | --- |
|
||||
| Linux | [halo-linux-release.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-linux-release.zip) | [halo-linux-debug.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-linux-debug.zip) |
|
||||
| Windows | [halo-windows-release.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-windows-release.zip) | [halo-windows-debug.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-windows-debug.zip) |
|
||||
| Android | [halo-android-release.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-android-release.zip) | [halo-android-debug.zip](https://github.com/cybersecurity/halo-ce-universal/releases/latest/download/halo-android-debug.zip) |
|
||||
| Linux | [halo-linux-release.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-linux-release.zip) | [halo-linux-debug.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-linux-debug.zip) |
|
||||
| Windows | [halo-windows-release.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-windows-release.zip) | [halo-windows-debug.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-windows-debug.zip) |
|
||||
| Android | [halo-android-release.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-android-release.zip) | [halo-android-debug.zip](https://github.com/OpenCommunityEdition/OpenCE/releases/latest/download/halo-android-debug.zip) |
|
||||
|
||||
Use the release build to play. The debug build stops at the first failed
|
||||
assertion and writes it to the log. Use the debug build to find and report
|
||||
@@ -32,7 +32,7 @@ if you want to install it. Refer to "Updates" in
|
||||
[port/linux/README.md](port/linux/README.md#updates).
|
||||
|
||||
Each build of the `main` branch that passes on all three platforms is a new
|
||||
release. The [Releases](https://github.com/cybersecurity/halo-ce-universal/releases)
|
||||
release. The [Releases](https://github.com/OpenCommunityEdition/OpenCE/releases)
|
||||
page keeps the last five releases. If the latest build has a problem, get
|
||||
an older build from that page.
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
# Steam Frame
|
||||
|
||||
The same APK as for the Quest runs on the Steam Frame, in Lepton (SteamOS's
|
||||
Android, a Waydroid fork: Android 11, arm64), with SteamVR's OpenXR runtime.
|
||||
What differs is found at run time, not by a build of its own.
|
||||
|
||||
## The device
|
||||
|
||||
- Steam Settings > System > Enable Developer Mode; then start "Lepton
|
||||
Development" from the library. While the headset sleeps Lepton stops, and
|
||||
adb with it.
|
||||
- adb over the network: `adb connect <frame-ip>:5555`; over USB:
|
||||
`adb forward tcp:5555 tcp:5555` then `adb connect localhost:5555`.
|
||||
Always name the device (`adb -s <frame-ip>:5555 ...`): a Quest may be
|
||||
connected as well.
|
||||
- Install with `adb install -r --no-streaming`. It prints "Lepton post
|
||||
installation failed due to APP_PATH being unset", but installs. Start the
|
||||
game with `am start -n com.halo.decomp/.LauncherActivity`.
|
||||
- Lepton empties `/sdcard/Android/data` whenever it starts again: the game's
|
||||
data must live elsewhere (stage 2). `/sdcard/Documents` and
|
||||
`/sdcard/Download` are the SteamOS user's folders and are kept.
|
||||
|
||||
## What the port does for it
|
||||
|
||||
- SDL3's clipboard handler takes a clipboard service for granted, which
|
||||
Lepton has not: `tools/android_build.py` patches it to do without.
|
||||
- SteamVR lists an implicit OpenXR layer for Vulkan apps whose library an
|
||||
app cannot load: the APK carries a pass-through layer under its name
|
||||
(`port/android/xr_layer/fdm_injection_stub.c`).
|
||||
|
||||
## Stages
|
||||
|
||||
| # | Stage | State |
|
||||
| --- | --- | --- |
|
||||
| 1 | Base: the fixes above on the current main | done |
|
||||
| 2 | The game's data where Lepton keeps it | done: `/home/steamos/Documents/HaloCE` |
|
||||
| 3 | Menus, HUD and text visible (quad layers) | done: their alpha from their colour |
|
||||
| 4 | The freeze at the cryo bay's calibration | not seen again (2026-10-04) |
|
||||
| 5 | The Frame's controllers | done: their own profile, the Xbox's layout |
|
||||
| 6 | Frame rate, resolution | done: 72 Hz steady, multiview on |
|
||||
| 7 | Multiplayer, voice, cross-play with the Quest | |
|
||||
| 8 | A button in the Steam library | done: `steam_frame_launch.sh` |
|
||||
|
||||
## Starting it on the Frame
|
||||
|
||||
A button in the Steam library ("Halo VR", a non-Steam game) runs
|
||||
`~/Documents/HaloCE/halo-vr.sh` (`port/android/steam_frame_launch.sh`),
|
||||
which starts the game as Steam starts an Android title of its own:
|
||||
`lepton waitforexitandrun -- ~/Documents/HaloCE/HaloVR.apk`, in a container
|
||||
of its own (`steamlaunch-4290000001`) that Lepton installs the APK into
|
||||
anew whenever the file is newer. Updating the game is replacing that APK.
|
||||
|
||||
What the script does that Steam would for an Android title:
|
||||
- a compat data path (`steamapps/compatdata/4290000001/internal`): after an
|
||||
install Lepton links the app's data to it, a dangling link without it;
|
||||
and the shader path, which Lepton reads Steam's shader dump path against;
|
||||
- a container id of its own: with the shortcut's id, SteamVR's client in the
|
||||
container stalled in xrCreateInstance;
|
||||
- a few starts: a new APK's first start only installs it, and a start that
|
||||
ends within 30 s is tried again (up to three times), unless the game was
|
||||
quit (it writes `quit_requested.txt`).
|
||||
|
||||
Steam's "Exit game" does not reach the game (its process is the container's,
|
||||
not Steam's): quit it with the VR options' "Quit Halo" (Y in the main or
|
||||
pause menu, twice). A container ended within 30 s of its start makes
|
||||
Lepton drop the app's install, so the next start installs it again.
|
||||
|
||||
The shortcut is in `userdata/<id>/config/shortcuts.vdf` (Steam reads it when
|
||||
it starts; appid 3151454348 for this name and path), its pictures in
|
||||
`userdata/<id>/config/grid/` (from `port/android/steam_frame_grid/`). From
|
||||
the Mac, over USB the Frame's SteamOS is an adb device of its own, `frame`,
|
||||
beside Lepton's `<frame-ip>:5555`.
|
||||
|
||||
## The game's data
|
||||
|
||||
Lepton uninstalls the app and empties its folders whenever it starts again.
|
||||
The game's data lives in the SteamOS user's Documents instead: when
|
||||
`/home/steamos/Documents/HaloCE` holds `maps/ui.map` and is writable, the
|
||||
launcher and the game take it as their data folder (config.toml, saves and
|
||||
debug.txt go there too). Once:
|
||||
|
||||
adb -s <frame-ip>:5555 shell mkdir -p /home/steamos/Documents/HaloCE/maps
|
||||
adb -s <frame-ip>:5555 push assets/maps/. /home/steamos/Documents/HaloCE/maps/
|
||||
adb -s <frame-ip>:5555 shell chmod -R 777 /home/steamos/Documents/HaloCE
|
||||
|
||||
After a Lepton restart only the APK is installed again. (Use the path under
|
||||
/home, not /sdcard/Documents: Android 11's scoped storage stands between the
|
||||
app and the latter.)
|
||||
|
||||
## The controllers
|
||||
|
||||
SteamVR offers the Frame's controllers as themselves
|
||||
(`XR_VALVE_frame_controller_interaction`,
|
||||
`/interaction_profiles/valve/frame_controller_valve`; Valve's "Steam Frame
|
||||
Input" page). Without bindings for it, SteamVR maps the Quest's onto them,
|
||||
and the left Touch controller's X and Y land on the D-pad. With them the
|
||||
game gets the Xbox's layout, as the right controller has it: A jump, B
|
||||
flashlight (held: switch grenades), X action and reload, Y switch weapon,
|
||||
menu pause; the left one's View is Back (scores), its D-pad the D-pad, the
|
||||
bumpers switch grenades (left) and the flashlight (right). The VR options'
|
||||
page of buttons shows this layout on the Frame.
|
||||
|
||||
## Findings
|
||||
|
||||
- 2026-10-02: runs flat and in VR (GLES 3.2 by Mesa zink on Turnip, eyes
|
||||
1728x1728, 72 Hz, XR_FB_display_refresh_rate absent). Quad layers
|
||||
(menus, HUD, instructions) are not shown; the projection layer is. Froze
|
||||
at the cryo bay's look calibration; its log was lost to Lepton's wipe.
|
||||
- 2026-10-04: SteamVR draws a quad's texels by their alpha alone; the
|
||||
game's menus and HUD have none in their additive parts, so nothing showed.
|
||||
On SteamVR (by the runtime's name) the overlays' alpha now comes from their
|
||||
colour (host_xr.c; `HALO_XR_QUAD_ALPHA=colour|keep` overrides). With it,
|
||||
menus, HUD and the campaign ran well (the user: "lief 1a"); no freeze.
|
||||
- 2026-10-04: no online games found: the public MQTT brokers had banned the
|
||||
home connection for a while (too many connections from tests that day);
|
||||
broker.emqx.io came back within minutes. Lepton's network is the Frame's
|
||||
own (same IP), DNS works.
|
||||
- 2026-10-04: the refresh rate is SteamOS's setting; the runtime offers
|
||||
only that one (the game asks for the highest at or below
|
||||
`vr.refresh_rate`, and logs the rates offered). At 72 Hz the game holds
|
||||
72 fps (about 11.6 ms a frame with multiview, eyes 7.6 ms; without it
|
||||
eyes about 9 ms). At 90 Hz it cannot (11.1 ms a frame), and SteamVR's
|
||||
making up of the missed frames showed as a doubled picture when turning
|
||||
the head. Keep the Frame at 72 Hz, or lower `vr.resolution_scale` (about
|
||||
0.85) for 90.
|
||||
- 2026-10-05: doubled pictures when turning at 72 Hz too, the game at the
|
||||
edge of its frame (12.5 of 13.9 ms; SteamVR reprojecting 2-8% of the
|
||||
frames). The time was not the drawing's but waits: the layer copies read
|
||||
the GL state back (glGet*) and released each image at once, and with
|
||||
Mesa's GL thread (zink) every read waits for the thread to run all that
|
||||
is queued, every release for the GPU (the left eye's copy took 4.5-7 ms
|
||||
of the frame, the right one's, just after it, 0.7). On SteamVR the copies
|
||||
are now deferred (host_xr.c): no state read back (the game sets its own
|
||||
again), the images released together as the frame ends, and the eyes'
|
||||
work flushed to the GPU as soon as they are copied.
|
||||
`debug.xr_deferred_copies` = 0 brings back the old copies for comparing,
|
||||
1 defers them on any runtime; `vr.log_performance` logs the frame's parts
|
||||
and, with the compositor's counters, each copy's time.
|
||||
@@ -0,0 +1,52 @@
|
||||
# VR roadmap
|
||||
|
||||
What the VR port (Quest 3, Steam Frame) has, and what comes next, in the
|
||||
agreed order. Updated with every step: a step is **done** once the user has
|
||||
tried it in the headset and it is merged into `main`; **built** means in a
|
||||
branch, not yet tried in the headset.
|
||||
|
||||
Several of the next steps follow
|
||||
[HaloCE-Quest-VR](https://github.com/moistman42069/HaloCE-Quest-VR) and the
|
||||
Steam Frame work it grew from,
|
||||
[astromaddie/HaloCE-VR](https://github.com/astromaddie/HaloCE-VR) (both
|
||||
CC0): their ideas, rebuilt into this port's own structure, with the source
|
||||
named where code is taken over.
|
||||
|
||||
## Done (in `main`)
|
||||
|
||||
| Area | What |
|
||||
| --- | --- |
|
||||
| Headsets | Quest 3; Steam Frame (Lepton): its controllers' layout, a Steam library tile that installs, starts, updates and quits the game, data kept in `~/Documents/HaloCE` |
|
||||
| Rendering | Both eyes in one pass (multiview) on the Quest; one by one on SteamVR, where multiview's eyes did not fuse; lens flares at their depth in stereo; HUD, menus, scope, crosshair and names as layers of their own |
|
||||
| Aiming | The weapon in the hand, its shots from the muzzle, laser and crosshair options |
|
||||
| Body | Physical crouch (`vr.crouch_limit`) beside the crouch button, leaning (`vr.lean_limit`), melee by swinging, grenades thrown with the left hand, two-handed weapons |
|
||||
| Vehicles | The Warthog's wheel turned with the hands, right trigger throttle, left brake; first-person seats; turrets with handles |
|
||||
| Comfort | Snap or smooth turning, a comfort vignette in vehicles, VR options in the main and pause menus (Y), a page of every controller button |
|
||||
| Menus | The PC version's menus in VR (`vr.menus`), clicked with a laser; text typed on the on-screen keyboard |
|
||||
| Multiplayer | Up to date with OpenCE (network version 20): cross-play, its server browser, co-op campaign, password lobbies; join codes and the VR online list |
|
||||
| Bots | Bots in multiplayer: on foot (paths, items, objectives), in vehicles and at turrets; they make room for a joining person |
|
||||
|
||||
## Next, in order
|
||||
|
||||
| # | Step | State |
|
||||
| --- | --- | --- |
|
||||
| 1 | Steam Frame CPU time: Mesa's trace markers off (after astromaddie/HaloCE-VR), no `glGet` stalls in the visibility counters' copies; then measured in the headset | built (branch `frame/performance-2`) |
|
||||
| 3a | Visible arms and hands: the arms by IK to the controllers, fingers by trigger and grip | |
|
||||
| 2 | Controls and comfort: left-handed mode, buttons remapped, flashlight by tapping the head, finer turning and vignette choices, graphics presets and refresh rate in the VR options | |
|
||||
| 3b | The whole body: torso from head and hands, legs and feet following in the room; full / arms only / hands only | |
|
||||
| 3c | Weapons held physically, holsters at shoulder and hip (the buttons stay) | |
|
||||
| 3d | Other VR players shown with their heads, hands and bodies (today their bodies move as flat players' do: only their aim and throws come from their hands) | |
|
||||
| 4 | Later: disc image import in the launcher, sprint by arm swing (offline) | |
|
||||
|
||||
## Open points outside the order
|
||||
|
||||
- Multiview on the Steam Frame: why the eyes do not fuse there (suspected
|
||||
Mesa zink/Turnip); tools in branch `frame/doubled-images` (86335828),
|
||||
not merged.
|
||||
- Transparent geometry groups: the Xbox's 384 a window overflow in games
|
||||
of 30 and more players.
|
||||
- The VR on-screen keyboard shows a password in the clear while it is
|
||||
typed.
|
||||
- Headset tests of the latest merge (`merge/upstream-2026-10-06`): menus,
|
||||
bots, co-op, a password game between Frame and Quest, a bot making room
|
||||
for a joining person.
|
||||
@@ -35,6 +35,7 @@ import java.nio.channels.FileChannel;
|
||||
*/
|
||||
public class LauncherActivity extends Activity {
|
||||
private static final int PICK_IMAGE = 1;
|
||||
private static final String SHARED_DATA_ROOT = "/home/steamos/Documents/HaloCE";
|
||||
|
||||
private File dataRoot;
|
||||
private TextView status;
|
||||
@@ -46,6 +47,12 @@ public class LauncherActivity extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
dataRoot = getExternalFilesDir(null);
|
||||
// the Steam Frame: Lepton empties the app's own folders whenever it
|
||||
// starts again; the game's data lives in the SteamOS user's
|
||||
// Documents instead, when it is there (port/android/STEAM_FRAME.md;
|
||||
// the same choice as host_main.c's)
|
||||
if (new File(SHARED_DATA_ROOT, "maps/ui.map").isFile() && new File(SHARED_DATA_ROOT).canWrite())
|
||||
dataRoot = new File(SHARED_DATA_ROOT);
|
||||
// created by the app, so that files pushed into it with adb stay
|
||||
// readable (a directory adb creates there belongs to the shell user)
|
||||
if (dataRoot != null)
|
||||
|
||||
@@ -119,7 +119,9 @@ headset before the game started, and set HALO_VR); 0 on failure */
|
||||
int host_xr_initialize(struct halo_xr_info *info, float wanted_refresh_rate);
|
||||
/* waits for the next frame and reports the predicted poses */
|
||||
int host_xr_begin_frame(struct halo_xr_frame *frame);
|
||||
/* copies a render target texture (0: clears) into a layer's image */
|
||||
/* copies a render target texture (0: clears) into a layer's image: 0 not
|
||||
copied, 1 copied with the GL state put back, 2 copied with the copy's GL
|
||||
state left (the deferred copies, host_xr.c), which the game sets again */
|
||||
int host_xr_copy_layer(int layer, unsigned int texture, int clear_alpha);
|
||||
/* the same for part of the texture: left, top, right, bottom, 0..1 from its
|
||||
top left */
|
||||
|
||||
@@ -92,6 +92,7 @@ void *host_resolve_import(const char *name);
|
||||
/* ---------- SDL / GL (host_sdl.c, host_gl.c) */
|
||||
|
||||
void *host_gl_resolve(const char *name);
|
||||
int host_gl_quiet_trace_markers(void);
|
||||
|
||||
/* ---------- VR (host_xr.c) */
|
||||
|
||||
|
||||
@@ -11,8 +11,52 @@ already have host types by then. Only strings need copying back.
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES3/gl32.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Valve's Mesa (the Steam Frame's Lepton) writes a marker to the kernel's
|
||||
trace_marker around every flush and context switch, a couple of hundred a
|
||||
frame, whether or not anything traces. The descriptors it holds open on that
|
||||
file are pointed at /dev/null instead (not closed: a reused descriptor would
|
||||
take the markers elsewhere). After astromaddie/HaloCE-VR (CC0). Returns how
|
||||
many were. */
|
||||
int host_gl_quiet_trace_markers(void)
|
||||
{
|
||||
DIR *directory = opendir("/proc/self/fd");
|
||||
struct dirent *entry;
|
||||
int quieted = 0, null_fd;
|
||||
|
||||
if (!directory)
|
||||
return 0;
|
||||
null_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
|
||||
while (null_fd >= 0 && (entry = readdir(directory)) != NULL)
|
||||
{
|
||||
char link[64], target[256];
|
||||
ssize_t length;
|
||||
int fd = atoi(entry->d_name);
|
||||
|
||||
if (entry->d_name[0] < '0' || entry->d_name[0] > '9' || fd == null_fd)
|
||||
continue;
|
||||
snprintf(link, sizeof(link), "/proc/self/fd/%d", fd);
|
||||
length = readlink(link, target, sizeof(target) - 1);
|
||||
if (length <= 0)
|
||||
continue;
|
||||
target[length] = 0;
|
||||
if (strstr(target, "tracing/trace_marker") && dup3(null_fd, fd, O_CLOEXEC) == fd)
|
||||
quieted++;
|
||||
}
|
||||
if (null_fd >= 0)
|
||||
close(null_fd);
|
||||
closedir(directory);
|
||||
if (quieted)
|
||||
host_logf(HOST_LOG_INFO, "trace markers: %d descriptors to /dev/null", quieted);
|
||||
return quieted;
|
||||
}
|
||||
|
||||
void *host_gl_resolve(const char *name)
|
||||
{
|
||||
@@ -88,14 +132,13 @@ half-drawn targets out of tile memory, for every lens flare. */
|
||||
static GLuint counter_snapshots[COUNTER_SNAPSHOTS];
|
||||
static uint32_t counter_snapshot_sizes[COUNTER_SNAPSHOTS];
|
||||
|
||||
/* (the copy bindings are left unbound after: the renderer binds them itself
|
||||
for each copy. Asking GL what they were would wait for Mesa's GL thread, on
|
||||
the Frame, to run everything queued) */
|
||||
void host_gl_counters_snapshot(uint32_t buffer, uint32_t size, uint32_t slot)
|
||||
{
|
||||
GLint read_binding = 0, write_binding = 0;
|
||||
|
||||
if (slot >= COUNTER_SNAPSHOTS || !buffer || !size)
|
||||
return;
|
||||
glGetIntegerv(GL_COPY_READ_BUFFER_BINDING, &read_binding);
|
||||
glGetIntegerv(GL_COPY_WRITE_BUFFER_BINDING, &write_binding);
|
||||
if (!counter_snapshots[slot])
|
||||
glGenBuffers(1, &counter_snapshots[slot]);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, counter_snapshots[slot]);
|
||||
@@ -108,19 +151,17 @@ void host_gl_counters_snapshot(uint32_t buffer, uint32_t size, uint32_t slot)
|
||||
glMemoryBarrier(GL_ATOMIC_COUNTER_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, buffer);
|
||||
glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, size);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, (GLuint)read_binding);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, (GLuint)write_binding);
|
||||
glBindBuffer(GL_COPY_READ_BUFFER, 0);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
|
||||
}
|
||||
|
||||
/* copies a snapshot out; its frame must be finished (host_gl_wait_frame) */
|
||||
int host_gl_counters_read(uint32_t slot, void *out, uint32_t size)
|
||||
{
|
||||
GLint write_binding = 0;
|
||||
const void *mapping;
|
||||
|
||||
if (slot >= COUNTER_SNAPSHOTS || !counter_snapshots[slot] || size > counter_snapshot_sizes[slot])
|
||||
return 0;
|
||||
glGetIntegerv(GL_COPY_WRITE_BUFFER_BINDING, &write_binding);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, counter_snapshots[slot]);
|
||||
mapping = glMapBufferRange(GL_COPY_WRITE_BUFFER, 0, size, GL_MAP_READ_BIT);
|
||||
if (mapping)
|
||||
@@ -128,7 +169,7 @@ int host_gl_counters_read(uint32_t slot, void *out, uint32_t size)
|
||||
memcpy(out, mapping, size);
|
||||
glUnmapBuffer(GL_COPY_WRITE_BUFFER);
|
||||
}
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, (GLuint)write_binding);
|
||||
glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
|
||||
return mapping != NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ int host_errno(void)
|
||||
|
||||
static char data_root[512];
|
||||
static char save_root[512];
|
||||
/* where a device that empties the app's folders keeps the game's data */
|
||||
#define SHARED_DATA_ROOT "/home/steamos/Documents/HaloCE"
|
||||
|
||||
void host_android_path(int which, char *buffer, uint32_t size)
|
||||
{
|
||||
@@ -269,6 +271,12 @@ static void *game_main(void *unused)
|
||||
external = SDL_GetAndroidExternalStoragePath();
|
||||
if (!external)
|
||||
host_fatal("Android storage is unavailable: %s", SDL_GetError());
|
||||
/* the Steam Frame: Lepton empties the app's own folders whenever it
|
||||
starts again; the game's data lives in the SteamOS user's Documents
|
||||
instead, when it is there (port/android/STEAM_FRAME.md; the same choice
|
||||
as LauncherActivity's) */
|
||||
if (directory_has_maps(SHARED_DATA_ROOT) && access(SHARED_DATA_ROOT, W_OK) == 0)
|
||||
external = SHARED_DATA_ROOT;
|
||||
snprintf(data_root, sizeof(data_root), "%s", external);
|
||||
snprintf(save_root, sizeof(save_root), "%s/save", external);
|
||||
/* readable by adb (the shell user), for managing saves */
|
||||
@@ -293,6 +301,19 @@ static void *game_main(void *unused)
|
||||
environment_set(&environment, "HALO_SAVE_ROOT", save_root);
|
||||
time_zone(zone, sizeof(zone));
|
||||
environment_set(&environment, "TZ", zone);
|
||||
/* internet play's MQTT brokers (network.brokers_file): the APK's list,
|
||||
written beside config.toml at each start, as a desktop update replaces
|
||||
the file beside its game */
|
||||
{
|
||||
size_t brokers_size = 0;
|
||||
void *brokers = SDL_LoadFile("brokers.txt", &brokers_size);
|
||||
|
||||
snprintf(path, sizeof(path), "%s/brokers.txt", data_root);
|
||||
if (!brokers || !SDL_SaveFile(path, brokers, brokers_size))
|
||||
host_logf(HOST_LOG_ERROR, "cannot write %s: %s", path, SDL_GetError());
|
||||
SDL_free(brokers);
|
||||
}
|
||||
snprintf(path, sizeof(path), "%s/config.toml", data_root);
|
||||
|
||||
image = SDL_LoadFile("halo_guest.elf", &image_size);
|
||||
if (!image)
|
||||
@@ -305,6 +326,26 @@ static void *game_main(void *unused)
|
||||
ranges: the headset's runtime, loaded by the probe, maps its libraries
|
||||
wherever there is room, the Xbox window at 0x80000000 included */
|
||||
snprintf(path, sizeof(path), "%s/config.toml", data_root);
|
||||
{
|
||||
/* (debug.gl_thread: Mesa's GL thread on or off, as the driver's
|
||||
mesa_glthread, before the GL context is made; -1 leaves it be) */
|
||||
double gl_thread = config_number(path, "debug.gl_thread", -1.0);
|
||||
|
||||
if (gl_thread >= 0.0)
|
||||
{
|
||||
setenv("mesa_glthread", gl_thread != 0.0 ? "true" : "false", 1);
|
||||
host_logf(HOST_LOG_INFO, "Mesa's GL thread %s (debug.gl_thread)", gl_thread != 0.0 ? "on" : "off");
|
||||
}
|
||||
}
|
||||
{
|
||||
/* (debug.xr_deferred_copies: the headset's layer copies deferred,
|
||||
host_xr.c, or one by one; -1 as the runtime has it, deferred on
|
||||
SteamVR) */
|
||||
double deferred = config_number(path, "debug.xr_deferred_copies", -1.0);
|
||||
|
||||
if (deferred >= 0.0)
|
||||
setenv("HALO_XR_DEFERRED", deferred != 0.0 ? "1" : "0", 1);
|
||||
}
|
||||
{
|
||||
int eye_width, eye_height;
|
||||
|
||||
|
||||
@@ -151,7 +151,11 @@ uint32_t host_sdl_gl_create_context(uint32_t window)
|
||||
{
|
||||
SDL_Window *object = handle_get(window, _handle_window);
|
||||
|
||||
return object ? handle_new(_handle_context, SDL_GL_CreateContext(object)) : 0;
|
||||
uint32_t context = object ? handle_new(_handle_context, SDL_GL_CreateContext(object)) : 0;
|
||||
|
||||
/* (the driver opens its trace markers with the context) */
|
||||
host_gl_quiet_trace_markers();
|
||||
return context;
|
||||
}
|
||||
|
||||
int host_sdl_gl_make_current(uint32_t window, uint32_t context)
|
||||
|
||||
@@ -38,6 +38,8 @@ picture; the copy flips them to GL's bottom-up images.
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define XR_USE_PLATFORM_ANDROID
|
||||
#define XR_USE_GRAPHICS_API_OPENGL_ES
|
||||
@@ -56,6 +58,7 @@ struct xr_swapchain
|
||||
GLuint framebuffers[MAXIMUM_SWAPCHAIN_IMAGES];
|
||||
uint32_t acquired_index;
|
||||
int filled; /* this frame */
|
||||
int held; /* acquired, released only as the frame ends (xr.deferred) */
|
||||
};
|
||||
|
||||
struct xr_hand_actions
|
||||
@@ -102,6 +105,14 @@ static struct
|
||||
XrAction button_b; /* B on the right controller, Y on the left */
|
||||
XrAction menu;
|
||||
XrAction thumbrest;
|
||||
/* the Steam Frame's controllers' own (XR_VALVE_frame_controller_interaction) */
|
||||
int has_frame_controller;
|
||||
int frame_layout;
|
||||
XrAction button_x;
|
||||
XrAction button_y;
|
||||
XrAction view;
|
||||
XrAction bumper;
|
||||
XrAction dpad[4];
|
||||
XrAction haptic;
|
||||
struct xr_hand_actions hands[HALO_XR_HAND_COUNT];
|
||||
|
||||
@@ -111,6 +122,33 @@ static struct
|
||||
int left_grip_valid;
|
||||
|
||||
int has_performance_settings;
|
||||
/* (XR_META_performance_metrics: the compositor's counts, in the log,
|
||||
for telling frames shown late from the game's own pace) */
|
||||
int has_metrics;
|
||||
PFN_xrQueryPerformanceMetricsCounterMETA query_metric;
|
||||
XrPath metric_paths[16];
|
||||
uint32_t metric_count;
|
||||
struct timespec metrics_logged;
|
||||
/* (SteamVR: the frames' thread kept on the fast cores, xr_fast_cores) */
|
||||
int steamvr;
|
||||
int cores_pinned;
|
||||
/* (with the metrics: the time the copies into the layers' images and
|
||||
xrEndFrame took, since the last line, and the frames) */
|
||||
double copy_seconds[HALO_XR_LAYER_COUNT];
|
||||
double end_seconds;
|
||||
double acquire_seconds;
|
||||
double release_seconds;
|
||||
int timed_frames;
|
||||
/* The copies without waits in the frame (SteamVR: HALO_XR_DEFERRED,
|
||||
debug.xr_deferred_copies). Each copy otherwise reads the GL state back
|
||||
to restore it (glGet*), and releases its image at once: with Mesa's GL
|
||||
thread (the Steam Frame's zink) each read waits for the thread to run
|
||||
everything queued, and each release for the GPU to finish it, so the
|
||||
game's one thread stood still for the eyes' whole drawing in the middle
|
||||
of every frame. Deferred, a copy leaves its GL state for the game to set
|
||||
again (host_xr_copy_layer's 2) and keeps its image until the frame ends,
|
||||
where all are released at once. */
|
||||
int deferred;
|
||||
int has_refresh_rate;
|
||||
PFN_xrRequestDisplayRefreshRateFB request_refresh_rate;
|
||||
PFN_xrGetDisplayRefreshRateFB get_refresh_rate;
|
||||
@@ -122,6 +160,11 @@ static struct
|
||||
GLint rect_uniform;
|
||||
GLint cut_disc_uniform;
|
||||
GLint vignette_uniform;
|
||||
GLint alpha_from_colour_uniform;
|
||||
/* the runtime draws a quad's texels by their alpha alone, ignoring the
|
||||
colour of those with none (SteamVR on the Steam Frame): the game's
|
||||
overlays, whose additive parts have none, get alpha from their colour */
|
||||
int quad_alpha_from_colour;
|
||||
GLint tangents_uniform;
|
||||
float vignette;
|
||||
/* the same copy from a layer of a texture array (the eyes drawn at
|
||||
@@ -223,6 +266,7 @@ static const char copy_fragment_shader[] =
|
||||
"precision highp float;\n"
|
||||
"uniform sampler2D source;\n"
|
||||
"uniform float cut_disc;\n"
|
||||
"uniform float alpha_from_colour; /* 1: as opaque as it is bright (a quad's, SteamVR) */\n"
|
||||
"uniform float vignette; /* 0..1: the eye images darken from their edges */\n"
|
||||
"uniform vec4 tangents; /* the eye's edges: left, right, down, up */\n"
|
||||
"in vec2 coordinate;\n"
|
||||
@@ -236,6 +280,8 @@ static const char copy_fragment_shader[] =
|
||||
"{\n"
|
||||
" vec4 texel = texture(source, coordinate);\n"
|
||||
" color = vec4(to_linear(texel.rgb), texel.a);\n"
|
||||
" if (alpha_from_colour > 0.5)\n"
|
||||
" color.a = max(color.a, max(color.r, max(color.g, color.b)));\n"
|
||||
" if (cut_disc > 0.5)\n"
|
||||
" {\n"
|
||||
" float inside = 1.0 - smoothstep(0.95, 1.0, length(disc));\n"
|
||||
@@ -326,6 +372,7 @@ static int copy_initialize(void)
|
||||
xr.rect_uniform = glGetUniformLocation(xr.program, "rect");
|
||||
xr.cut_disc_uniform = glGetUniformLocation(xr.program, "cut_disc");
|
||||
xr.vignette_uniform = glGetUniformLocation(xr.program, "vignette");
|
||||
xr.alpha_from_colour_uniform = glGetUniformLocation(xr.program, "alpha_from_colour");
|
||||
xr.tangents_uniform = glGetUniformLocation(xr.program, "tangents");
|
||||
xr.copy_array_layer = -1;
|
||||
{
|
||||
@@ -580,6 +627,14 @@ static int actions_initialize(void)
|
||||
xr.button_b = action_create("button_upper", "B / Y", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.menu = action_create("menu", "Menu", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.thumbrest = action_create("thumbrest", "Thumb rest", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.button_x = action_create("button_x", "X", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.button_y = action_create("button_y", "Y", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.view = action_create("view", "View", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.bumper = action_create("bumper", "Bumper", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.dpad[0] = action_create("dpad_up", "D-pad up", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.dpad[1] = action_create("dpad_down", "D-pad down", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.dpad[2] = action_create("dpad_left", "D-pad left", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.dpad[3] = action_create("dpad_right", "D-pad right", XR_ACTION_TYPE_BOOLEAN_INPUT);
|
||||
xr.haptic = action_create("haptic", "Rumble", XR_ACTION_TYPE_VIBRATION_OUTPUT);
|
||||
|
||||
{
|
||||
@@ -644,6 +699,44 @@ static int actions_initialize(void)
|
||||
{ &xr.haptic, "/user/hand/right/output/haptic" },
|
||||
};
|
||||
|
||||
/* the Steam Frame's controllers, as themselves: the right one has
|
||||
A, B, X, Y and a menu button, the left one a D-pad and a View button
|
||||
(port/android/STEAM_FRAME.md) */
|
||||
static const struct binding frame_controller[] =
|
||||
{
|
||||
{ &xr.grip_pose, "/user/hand/left/input/grip/pose" },
|
||||
{ &xr.grip_pose, "/user/hand/right/input/grip/pose" },
|
||||
{ &xr.aim_pose, "/user/hand/left/input/aim/pose" },
|
||||
{ &xr.aim_pose, "/user/hand/right/input/aim/pose" },
|
||||
{ &xr.trigger, "/user/hand/left/input/trigger/value" },
|
||||
{ &xr.trigger, "/user/hand/right/input/trigger/value" },
|
||||
{ &xr.squeeze, "/user/hand/left/input/squeeze/value" },
|
||||
{ &xr.squeeze, "/user/hand/right/input/squeeze/value" },
|
||||
{ &xr.thumbstick, "/user/hand/left/input/thumbstick" },
|
||||
{ &xr.thumbstick, "/user/hand/right/input/thumbstick" },
|
||||
{ &xr.thumbstick_click, "/user/hand/left/input/thumbstick/click" },
|
||||
{ &xr.thumbstick_click, "/user/hand/right/input/thumbstick/click" },
|
||||
{ &xr.button_a, "/user/hand/right/input/a/click" },
|
||||
{ &xr.button_b, "/user/hand/right/input/b/click" },
|
||||
{ &xr.button_x, "/user/hand/right/input/x/click" },
|
||||
{ &xr.button_y, "/user/hand/right/input/y/click" },
|
||||
{ &xr.menu, "/user/hand/right/input/menu/click" },
|
||||
{ &xr.view, "/user/hand/left/input/view/click" },
|
||||
{ &xr.bumper, "/user/hand/left/input/bumper/click" },
|
||||
{ &xr.bumper, "/user/hand/right/input/bumper/click" },
|
||||
{ &xr.dpad[0], "/user/hand/left/input/dpad_up/click" },
|
||||
{ &xr.dpad[1], "/user/hand/left/input/dpad_down/click" },
|
||||
{ &xr.dpad[2], "/user/hand/left/input/dpad_left/click" },
|
||||
{ &xr.dpad[3], "/user/hand/left/input/dpad_right/click" },
|
||||
{ &xr.haptic, "/user/hand/left/output/haptic" },
|
||||
{ &xr.haptic, "/user/hand/right/output/haptic" },
|
||||
};
|
||||
|
||||
if (xr.has_frame_controller)
|
||||
{
|
||||
suggest("/interaction_profiles/valve/frame_controller_valve", frame_controller,
|
||||
sizeof(frame_controller) / sizeof(frame_controller[0]));
|
||||
}
|
||||
suggest("/interaction_profiles/oculus/touch_controller", touch, sizeof(touch) / sizeof(touch[0]));
|
||||
suggest("/interaction_profiles/valve/index_controller", index, sizeof(index) / sizeof(index[0]));
|
||||
suggest("/interaction_profiles/khr/simple_controller", simple, sizeof(simple) / sizeof(simple[0]));
|
||||
@@ -713,6 +806,30 @@ static void hands_read(struct halo_xr_frame *frame)
|
||||
sync.activeActionSets = &active;
|
||||
if (!XR_SUCCEEDED(xrSyncActions(xr.session, &sync)))
|
||||
return;
|
||||
{
|
||||
/* (the controllers' profile the runtime chose, in the log as it
|
||||
changes) */
|
||||
static XrPath logged[HALO_XR_HAND_COUNT];
|
||||
|
||||
for (hand = 0; hand < HALO_XR_HAND_COUNT; hand++)
|
||||
{
|
||||
XrInteractionProfileState state = { XR_TYPE_INTERACTION_PROFILE_STATE };
|
||||
|
||||
if (XR_SUCCEEDED(xrGetCurrentInteractionProfile(xr.session, xr.hands[hand].path, &state)) &&
|
||||
state.interactionProfile != logged[hand])
|
||||
{
|
||||
char name[XR_MAX_PATH_LENGTH] = "none";
|
||||
uint32_t length = 0;
|
||||
|
||||
logged[hand] = state.interactionProfile;
|
||||
if (state.interactionProfile != XR_NULL_PATH)
|
||||
xrPathToString(xr.instance, state.interactionProfile, sizeof(name), &length, name);
|
||||
if (hand == HALO_XR_HAND_RIGHT)
|
||||
xr.frame_layout = strstr(name, "frame_controller") != NULL;
|
||||
host_logf(HOST_LOG_INFO, "xr: the %s hand's controller: %s", hand ? "right" : "left", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (hand = 0; hand < HALO_XR_HAND_COUNT; hand++)
|
||||
{
|
||||
struct halo_xr_hand *out = &frame->hands[hand];
|
||||
@@ -757,7 +874,31 @@ static void hands_read(struct halo_xr_frame *frame)
|
||||
(action_boolean(xr.menu, hand) ? HALO_XR_BUTTON_MENU : 0) |
|
||||
(action_boolean(xr.thumbrest, hand) ? HALO_XR_BUTTON_THUMBREST : 0) |
|
||||
(out->trigger > 0.5f ? HALO_XR_BUTTON_TRIGGER : 0) |
|
||||
(out->squeeze > 0.5f ? HALO_XR_BUTTON_SQUEEZE : 0);
|
||||
(out->squeeze > 0.5f ? HALO_XR_BUTTON_SQUEEZE : 0) |
|
||||
(action_boolean(xr.view, hand) ? HALO_XR_BUTTON_VIEW : 0) |
|
||||
(action_boolean(xr.bumper, hand) ? HALO_XR_BUTTON_BUMPER : 0) |
|
||||
(action_boolean(xr.dpad[0], hand) ? HALO_XR_BUTTON_DPAD_UP : 0) |
|
||||
(action_boolean(xr.dpad[1], hand) ? HALO_XR_BUTTON_DPAD_DOWN : 0) |
|
||||
(action_boolean(xr.dpad[2], hand) ? HALO_XR_BUTTON_DPAD_LEFT : 0) |
|
||||
(action_boolean(xr.dpad[3], hand) ? HALO_XR_BUTTON_DPAD_RIGHT : 0);
|
||||
}
|
||||
frame->controller_layout = xr.frame_layout ? HALO_XR_LAYOUT_FRAME : HALO_XR_LAYOUT_TOUCH;
|
||||
if (xr.frame_layout)
|
||||
{
|
||||
/* (the Frame's right X, Y and menu button: the game's X, Y and Start,
|
||||
which the Quest has on the left) */
|
||||
struct halo_xr_hand *left = &frame->hands[HALO_XR_HAND_LEFT];
|
||||
struct halo_xr_hand *right = &frame->hands[HALO_XR_HAND_RIGHT];
|
||||
|
||||
if (action_boolean(xr.button_x, HALO_XR_HAND_RIGHT))
|
||||
left->buttons |= HALO_XR_BUTTON_A;
|
||||
if (action_boolean(xr.button_y, HALO_XR_HAND_RIGHT))
|
||||
left->buttons |= HALO_XR_BUTTON_B;
|
||||
if (right->buttons & HALO_XR_BUTTON_MENU)
|
||||
{
|
||||
right->buttons &= ~HALO_XR_BUTTON_MENU;
|
||||
left->buttons |= HALO_XR_BUTTON_MENU;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -774,6 +915,13 @@ static void refresh_rate_choose(float wanted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
{
|
||||
char line[128] = "";
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
snprintf(line + strlen(line), sizeof(line) - strlen(line), " %.0f", rates[index]);
|
||||
host_logf(HOST_LOG_INFO, "xr: refresh rates offered:%s Hz", line);
|
||||
}
|
||||
/* the highest rate not above the one wanted (0: the highest) */
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
@@ -895,6 +1043,12 @@ int host_xr_probe(float resolution_scale, int *eye_width, int *eye_height)
|
||||
/* the loader and the runtime keep the activity */
|
||||
activity = (*environment)->NewGlobalRef(environment, activity);
|
||||
|
||||
/* (The Steam Frame lists an implicit API layer of its own for Vulkan
|
||||
apps, XR_APILAYER_VALVE_fdm_injection, whose library an app cannot load
|
||||
from its namespace, failing xrCreateInstance; the Android loader reads
|
||||
no variable to turn it off, so the app carries a pass-through layer
|
||||
under that library's name: port/android/xr_layer/fdm_injection_stub.c) */
|
||||
|
||||
if (!XR_SUCCEEDED(xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR",
|
||||
(PFN_xrVoidFunction *)&initialize_loader)) || !initialize_loader)
|
||||
{
|
||||
@@ -922,6 +1076,23 @@ int host_xr_probe(float resolution_scale, int *eye_width, int *eye_height)
|
||||
extensions[index].next = NULL;
|
||||
}
|
||||
xrEnumerateInstanceExtensionProperties(NULL, extension_count, &extension_count, extensions);
|
||||
{
|
||||
/* (the runtime's extensions, in the log: what a headset offers) */
|
||||
char line[512] = "";
|
||||
|
||||
for (index = 0; index < extension_count; index++)
|
||||
{
|
||||
if (strlen(line) + strlen(extensions[index].extensionName) + 2 >= sizeof(line))
|
||||
{
|
||||
host_logf(HOST_LOG_INFO, "xr: extensions %s", line);
|
||||
line[0] = 0;
|
||||
}
|
||||
strcat(line, " ");
|
||||
strcat(line, extensions[index].extensionName);
|
||||
}
|
||||
if (line[0])
|
||||
host_logf(HOST_LOG_INFO, "xr: extensions %s", line);
|
||||
}
|
||||
if (!has_extension(extensions, extension_count, XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME))
|
||||
{
|
||||
host_logf(HOST_LOG_ERROR, "xr: the runtime has no OpenGL ES support");
|
||||
@@ -933,9 +1104,15 @@ int host_xr_probe(float resolution_scale, int *eye_width, int *eye_height)
|
||||
xr.has_performance_settings = has_extension(extensions, extension_count, XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME);
|
||||
if (xr.has_performance_settings)
|
||||
enabled[enabled_count++] = XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME;
|
||||
xr.has_frame_controller = has_extension(extensions, extension_count, "XR_VALVE_frame_controller_interaction");
|
||||
if (xr.has_frame_controller)
|
||||
enabled[enabled_count++] = "XR_VALVE_frame_controller_interaction";
|
||||
xr.has_refresh_rate = has_extension(extensions, extension_count, XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME);
|
||||
if (xr.has_refresh_rate)
|
||||
enabled[enabled_count++] = XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME;
|
||||
xr.has_metrics = has_extension(extensions, extension_count, XR_META_PERFORMANCE_METRICS_EXTENSION_NAME);
|
||||
if (xr.has_metrics)
|
||||
enabled[enabled_count++] = XR_META_PERFORMANCE_METRICS_EXTENSION_NAME;
|
||||
|
||||
android.applicationVM = machine;
|
||||
android.applicationActivity = activity;
|
||||
@@ -960,6 +1137,23 @@ int host_xr_probe(float resolution_scale, int *eye_width, int *eye_height)
|
||||
}
|
||||
xrGetSystemProperties(xr.instance, xr.system, &properties);
|
||||
strncpy(xr.system_name, properties.systemName, sizeof(xr.system_name) - 1);
|
||||
{
|
||||
/* (SteamVR: the quads' alpha from their colour; HALO_XR_QUAD_ALPHA
|
||||
"colour" or "keep" says otherwise, for trying) */
|
||||
XrInstanceProperties instance = { XR_TYPE_INSTANCE_PROPERTIES };
|
||||
const char *choice = getenv("HALO_XR_QUAD_ALPHA");
|
||||
|
||||
if (XR_SUCCEEDED(xrGetInstanceProperties(xr.instance, &instance)))
|
||||
{
|
||||
xr.quad_alpha_from_colour = strstr(instance.runtimeName, "SteamVR") != NULL;
|
||||
xr.steamvr = xr.quad_alpha_from_colour;
|
||||
host_logf(HOST_LOG_INFO, "xr: runtime %s", instance.runtimeName);
|
||||
}
|
||||
if (choice)
|
||||
xr.quad_alpha_from_colour = !strcmp(choice, "colour");
|
||||
if (xr.quad_alpha_from_colour)
|
||||
host_logf(HOST_LOG_INFO, "xr: the overlays' alpha from their colour");
|
||||
}
|
||||
|
||||
views[0].type = views[1].type = XR_TYPE_VIEW_CONFIGURATION_VIEW;
|
||||
views[0].next = views[1].next = NULL;
|
||||
@@ -1066,6 +1260,29 @@ int host_xr_initialize(struct halo_xr_info *info, float wanted_refresh_rate)
|
||||
xr.get_refresh_rate(xr.session, &info->refresh_rate);
|
||||
}
|
||||
|
||||
/* (the runtime's GL binding brings contexts of its own, with their own
|
||||
trace markers: host_gl.c) */
|
||||
host_gl_quiet_trace_markers();
|
||||
|
||||
if (xr.has_metrics)
|
||||
{
|
||||
PFN_xrEnumeratePerformanceMetricsCounterPathsMETA enumerate = NULL;
|
||||
PFN_xrSetPerformanceMetricsStateMETA set_state = NULL;
|
||||
XrPerformanceMetricsStateMETA state = { XR_TYPE_PERFORMANCE_METRICS_STATE_META };
|
||||
|
||||
xrGetInstanceProcAddr(xr.instance, "xrEnumeratePerformanceMetricsCounterPathsMETA",
|
||||
(PFN_xrVoidFunction *)&enumerate);
|
||||
xrGetInstanceProcAddr(xr.instance, "xrSetPerformanceMetricsStateMETA", (PFN_xrVoidFunction *)&set_state);
|
||||
xrGetInstanceProcAddr(xr.instance, "xrQueryPerformanceMetricsCounterMETA",
|
||||
(PFN_xrVoidFunction *)&xr.query_metric);
|
||||
state.enabled = XR_TRUE;
|
||||
xr.has_metrics = enumerate && set_state && xr.query_metric &&
|
||||
XR_SUCCEEDED(enumerate(xr.instance, 16, &xr.metric_count, xr.metric_paths)) &&
|
||||
XR_SUCCEEDED(set_state(xr.session, &state));
|
||||
host_logf(HOST_LOG_INFO, "xr: performance metrics %s (%u counters)", xr.has_metrics ? "on" : "off",
|
||||
xr.has_metrics ? xr.metric_count : 0);
|
||||
}
|
||||
|
||||
if (xr.has_performance_settings)
|
||||
{
|
||||
/* the game's one busy thread and its GPU work both need the clocks
|
||||
@@ -1082,6 +1299,16 @@ int host_xr_initialize(struct halo_xr_info *info, float wanted_refresh_rate)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* (deferred on SteamVR; HALO_XR_DEFERRED "1" or "0" says otherwise:
|
||||
debug.xr_deferred_copies, host_main.c) */
|
||||
const char *choice = getenv("HALO_XR_DEFERRED");
|
||||
|
||||
xr.deferred = choice && *choice ? atoi(choice) != 0 : xr.steamvr;
|
||||
host_logf(HOST_LOG_INFO, "xr: layer copies %s", xr.deferred ?
|
||||
"deferred (no waits for the GL thread or the GPU in the frame)" : "restored and released one by one");
|
||||
}
|
||||
|
||||
info->eye_width = xr.eye_width;
|
||||
info->eye_height = xr.eye_height;
|
||||
info->overlay_width = xr.eye_width;
|
||||
@@ -1245,8 +1472,30 @@ int host_xr_copy_layer_array(int layer, uint32_t texture, int array_layer)
|
||||
|
||||
/* copies part of a render target (left, top, right, bottom, 0..1 from its
|
||||
top left) into a layer's image */
|
||||
static double seconds_now(void)
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
return (double)now.tv_sec + (double)now.tv_nsec * 1e-9;
|
||||
}
|
||||
|
||||
static int copy_layer_region(int layer, uint32_t texture, int clear_alpha, float left, float top, float right,
|
||||
float bottom);
|
||||
|
||||
int host_xr_copy_layer_region(int layer, uint32_t texture, int clear_alpha, float left, float top, float right,
|
||||
float bottom)
|
||||
{
|
||||
double start = xr.has_metrics ? seconds_now() : 0.0;
|
||||
int copied = copy_layer_region(layer, texture, clear_alpha, left, top, right, bottom);
|
||||
|
||||
if (xr.has_metrics && layer >= 0 && layer < HALO_XR_LAYER_COUNT)
|
||||
xr.copy_seconds[layer] += seconds_now() - start;
|
||||
return copied;
|
||||
}
|
||||
|
||||
static int copy_layer_region(int layer, uint32_t texture, int clear_alpha, float left, float top, float right,
|
||||
float bottom)
|
||||
{
|
||||
struct xr_swapchain *swapchain;
|
||||
XrSwapchainImageAcquireInfo acquire = { XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO };
|
||||
@@ -1258,17 +1507,27 @@ int host_xr_copy_layer_region(int layer, uint32_t texture, int clear_alpha, floa
|
||||
return 0;
|
||||
swapchain = &xr.swapchains[layer];
|
||||
if (swapchain->filled)
|
||||
return 1;
|
||||
if (!xr_ok(xrAcquireSwapchainImage(swapchain->handle, &acquire, &swapchain->acquired_index),
|
||||
"xrAcquireSwapchainImage"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return xr.deferred ? 2 : 1;
|
||||
wait.timeout = XR_INFINITE_DURATION;
|
||||
if (!xr_ok(xrWaitSwapchainImage(swapchain->handle, &wait), "xrWaitSwapchainImage"))
|
||||
return 0;
|
||||
{
|
||||
double start = xr.has_metrics ? seconds_now() : 0.0;
|
||||
|
||||
gl_save(&saved);
|
||||
if (!xr_ok(xrAcquireSwapchainImage(swapchain->handle, &acquire, &swapchain->acquired_index),
|
||||
"xrAcquireSwapchainImage"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!xr_ok(xrWaitSwapchainImage(swapchain->handle, &wait), "xrWaitSwapchainImage"))
|
||||
return 0;
|
||||
if (xr.has_metrics)
|
||||
xr.acquire_seconds += seconds_now() - start;
|
||||
}
|
||||
|
||||
/* (deferred: nothing read back; the game sets its state again) */
|
||||
if (xr.deferred)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
else
|
||||
gl_save(&saved);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, swapchain->framebuffers[swapchain->acquired_index]);
|
||||
glViewport(0, 0, swapchain->width, swapchain->height);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
@@ -1316,6 +1575,8 @@ int host_xr_copy_layer_region(int layer, uint32_t texture, int clear_alpha, floa
|
||||
glUniform1i(xr.source_uniform, 0);
|
||||
glUniform4f(xr.rect_uniform, left, top, right, bottom);
|
||||
glUniform1f(xr.cut_disc_uniform, clear_alpha == HALO_XR_COPY_DISC ? 1.0f : 0.0f);
|
||||
glUniform1f(xr.alpha_from_colour_uniform, xr.quad_alpha_from_colour && clear_alpha == HALO_XR_COPY_ALPHA &&
|
||||
layer != HALO_XR_LAYER_EYE_LEFT && layer != HALO_XR_LAYER_EYE_RIGHT ? 1.0f : 0.0f);
|
||||
if ((layer == HALO_XR_LAYER_EYE_LEFT || layer == HALO_XR_LAYER_EYE_RIGHT) && xr.vignette > 0.001f)
|
||||
{
|
||||
const XrFovf *fov = &xr.views[layer - HALO_XR_LAYER_EYE_LEFT].fov;
|
||||
@@ -1331,13 +1592,22 @@ int host_xr_copy_layer_region(int layer, uint32_t texture, int clear_alpha, floa
|
||||
glBindVertexArray(xr.vertex_array);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glBindSampler(0, xr.sampler);
|
||||
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, &swizzle_r);
|
||||
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, &swizzle_b);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, swizzle_r);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, swizzle_b);
|
||||
if (xr.deferred)
|
||||
{
|
||||
/* (the game's render targets, all a copy reads, have no
|
||||
swizzle: only its uploaded textures get one, xbox_textures.c) */
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, &swizzle_r);
|
||||
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, &swizzle_b);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, swizzle_r);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, swizzle_b);
|
||||
}
|
||||
if (clear_alpha == HALO_XR_COPY_OPAQUE)
|
||||
{
|
||||
/* an opaque layer: the game's alpha channel holds other things */
|
||||
@@ -1351,13 +1621,95 @@ int host_xr_copy_layer_region(int layer, uint32_t texture, int clear_alpha, floa
|
||||
glClearColor(0.0f, 0.0f, 0.0f, clear_alpha ? 1.0f : 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
swapchain->filled = 1;
|
||||
if (xr.deferred)
|
||||
{
|
||||
swapchain->held = 1;
|
||||
/* (the eyes, most of the frame's work, on to the GPU while the
|
||||
game draws the rest) */
|
||||
if (layer == HALO_XR_LAYER_EYE_RIGHT)
|
||||
glFlush();
|
||||
return 2;
|
||||
}
|
||||
gl_restore(&saved);
|
||||
|
||||
xrReleaseSwapchainImage(swapchain->handle, &release);
|
||||
swapchain->filled = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* deferred: the images the frame's copies kept, released before it ends */
|
||||
static void release_held(void)
|
||||
{
|
||||
double start = xr.has_metrics ? seconds_now() : 0.0;
|
||||
int layer;
|
||||
|
||||
for (layer = 0; layer < HALO_XR_LAYER_COUNT; layer++)
|
||||
{
|
||||
XrSwapchainImageReleaseInfo release = { XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO };
|
||||
struct xr_swapchain *swapchain = &xr.swapchains[layer];
|
||||
|
||||
if (!swapchain->held)
|
||||
continue;
|
||||
swapchain->held = 0;
|
||||
xr_ok(xrReleaseSwapchainImage(swapchain->handle, &release), "xrReleaseSwapchainImage");
|
||||
}
|
||||
if (xr.has_metrics)
|
||||
xr.release_seconds += seconds_now() - start;
|
||||
}
|
||||
|
||||
/* The Steam Frame: Android in a container, without XR_EXT_performance_settings
|
||||
to ask for the clocks, and the scheduler free to put the game's one busy
|
||||
thread, which simulates and draws each frame, on a slow core (its two
|
||||
2.3 GHz ones) now and then: frames late to the compositor, shown twice,
|
||||
the picture doubled as the head turns. The thread that ends the frames is
|
||||
kept on the cores no slower than nine tenths of the fastest. */
|
||||
static void xr_fast_cores(void)
|
||||
{
|
||||
cpu_set_t set;
|
||||
long fastest = 0, speeds[CPU_SETSIZE];
|
||||
int cpu, count = 0;
|
||||
char line[128] = "";
|
||||
|
||||
for (cpu = 0; cpu < CPU_SETSIZE && cpu < 64; cpu++)
|
||||
{
|
||||
char path[96];
|
||||
FILE *file;
|
||||
|
||||
speeds[cpu] = 0;
|
||||
snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu);
|
||||
file = fopen(path, "r");
|
||||
if (!file)
|
||||
continue;
|
||||
if (fscanf(file, "%ld", &speeds[cpu]) != 1)
|
||||
speeds[cpu] = 0;
|
||||
fclose(file);
|
||||
if (speeds[cpu] > fastest)
|
||||
fastest = speeds[cpu];
|
||||
}
|
||||
if (!fastest)
|
||||
{
|
||||
host_logf(HOST_LOG_INFO, "xr: the cores' speeds unknown: the frames' thread left where it runs");
|
||||
return;
|
||||
}
|
||||
CPU_ZERO(&set);
|
||||
for (cpu = 0; cpu < CPU_SETSIZE && cpu < 64; cpu++)
|
||||
{
|
||||
if (speeds[cpu] && speeds[cpu] * 10 >= fastest * 9)
|
||||
{
|
||||
char item[8];
|
||||
|
||||
CPU_SET(cpu, &set);
|
||||
count++;
|
||||
snprintf(item, sizeof(item), " %d", cpu);
|
||||
strcat(line, item);
|
||||
}
|
||||
}
|
||||
if (count && sched_setaffinity(0, sizeof(set), &set) == 0)
|
||||
host_logf(HOST_LOG_INFO, "xr: the frames' thread on the fast cores:%s (fastest %ld MHz)", line, fastest / 1000);
|
||||
else
|
||||
host_logf(HOST_LOG_INFO, "xr: the frames' thread could not be kept on the fast cores");
|
||||
}
|
||||
|
||||
int host_xr_end_frame(const struct halo_xr_submit *submit)
|
||||
{
|
||||
XrFrameEndInfo end = { XR_TYPE_FRAME_END_INFO };
|
||||
@@ -1375,6 +1727,7 @@ int host_xr_end_frame(const struct halo_xr_submit *submit)
|
||||
if (!xr.frame_begun)
|
||||
return 0;
|
||||
xr.frame_begun = 0;
|
||||
release_held();
|
||||
|
||||
if (xr.frame_state.shouldRender && submit->eyes && xr.views_valid &&
|
||||
xr.swapchains[HALO_XR_LAYER_EYE_LEFT].filled && xr.swapchains[HALO_XR_LAYER_EYE_RIGHT].filled)
|
||||
@@ -1500,11 +1853,83 @@ int host_xr_end_frame(const struct halo_xr_submit *submit)
|
||||
}
|
||||
}
|
||||
|
||||
if (xr.steamvr && !xr.cores_pinned)
|
||||
{
|
||||
xr.cores_pinned = 1;
|
||||
if (!getenv("HALO_XR_ANY_CORE"))
|
||||
xr_fast_cores();
|
||||
}
|
||||
/* (every five seconds, the compositor's counters, and the core the
|
||||
frames' thread is on) */
|
||||
if (xr.has_metrics)
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
if (now.tv_sec - xr.metrics_logged.tv_sec >= 5)
|
||||
{
|
||||
char line[768] = "";
|
||||
uint32_t counter;
|
||||
|
||||
xr.metrics_logged = now;
|
||||
for (counter = 0; counter < xr.metric_count && counter < 16; counter++)
|
||||
{
|
||||
XrPerformanceMetricsCounterMETA value = { XR_TYPE_PERFORMANCE_METRICS_COUNTER_META };
|
||||
char name[XR_MAX_PATH_LENGTH];
|
||||
uint32_t length = 0;
|
||||
char item[96];
|
||||
|
||||
if (!XR_SUCCEEDED(xr.query_metric(xr.session, xr.metric_paths[counter], &value)) ||
|
||||
!XR_SUCCEEDED(xrPathToString(xr.instance, xr.metric_paths[counter], sizeof(name), &length, name)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
snprintf(item, sizeof(item), " %s=%g", strrchr(name, '/') ? strrchr(name, '/') + 1 : name,
|
||||
(value.counterFlags & XR_PERFORMANCE_METRICS_COUNTER_FLOAT_VALUE_VALID_BIT_META) ?
|
||||
(double)value.floatValue : (double)value.uintValue);
|
||||
if (strlen(line) + strlen(item) < sizeof(line))
|
||||
strcat(line, item);
|
||||
}
|
||||
host_logf(HOST_LOG_INFO, "xr: metrics%s, on core %d", line, sched_getcpu());
|
||||
if (xr.timed_frames)
|
||||
{
|
||||
double frames = (double)xr.timed_frames;
|
||||
char copies[256] = "";
|
||||
int timed;
|
||||
|
||||
for (timed = 0; timed < HALO_XR_LAYER_COUNT; timed++)
|
||||
{
|
||||
char item[24];
|
||||
|
||||
snprintf(item, sizeof(item), " %d:%.2f", timed, xr.copy_seconds[timed] * 1e3 / frames);
|
||||
strcat(copies, item);
|
||||
xr.copy_seconds[timed] = 0.0;
|
||||
}
|
||||
host_logf(HOST_LOG_INFO, "xr: per frame ms: copies (layer:ms)%s; of them acquiring images %.2f; "
|
||||
"releasing them at the end %.2f; xrEndFrame %.2f (copies %s)", copies,
|
||||
xr.acquire_seconds * 1e3 / frames, xr.release_seconds * 1e3 / frames, xr.end_seconds * 1e3 / frames,
|
||||
xr.deferred ? "deferred" : "one by one");
|
||||
xr.acquire_seconds = xr.release_seconds = xr.end_seconds = 0.0;
|
||||
xr.timed_frames = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end.displayTime = xr.frame_state.predictedDisplayTime;
|
||||
end.environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;
|
||||
end.layerCount = layer_count;
|
||||
end.layers = layers;
|
||||
return xr_ok(xrEndFrame(xr.session, &end), "xrEndFrame");
|
||||
{
|
||||
double start = xr.has_metrics ? seconds_now() : 0.0;
|
||||
int ended = xr_ok(xrEndFrame(xr.session, &end), "xrEndFrame");
|
||||
|
||||
if (xr.has_metrics)
|
||||
{
|
||||
xr.end_seconds += seconds_now() - start;
|
||||
xr.timed_frames++;
|
||||
}
|
||||
return ended;
|
||||
}
|
||||
}
|
||||
|
||||
void host_xr_set_vignette(float strength)
|
||||
|
||||
@@ -53,6 +53,23 @@ enum
|
||||
HALO_XR_BUTTON_TRIGGER = 1 << 4, /* trigger past its click point */
|
||||
HALO_XR_BUTTON_SQUEEZE = 1 << 5, /* grip past its click point */
|
||||
HALO_XR_BUTTON_THUMBREST = 1 << 6, /* thumb resting (touch) */
|
||||
/* the Steam Frame's controllers' (HALO_XR_LAYOUT_FRAME): the left one's
|
||||
View button and D-pad, either one's bumper (their right one's X, Y and
|
||||
menu button come as the left hand's A, B and MENU: the game's X, Y and
|
||||
Start, as on the Quest) */
|
||||
HALO_XR_BUTTON_VIEW = 1 << 7,
|
||||
HALO_XR_BUTTON_BUMPER = 1 << 8,
|
||||
HALO_XR_BUTTON_DPAD_UP = 1 << 9,
|
||||
HALO_XR_BUTTON_DPAD_DOWN = 1 << 10,
|
||||
HALO_XR_BUTTON_DPAD_LEFT = 1 << 11,
|
||||
HALO_XR_BUTTON_DPAD_RIGHT = 1 << 12,
|
||||
};
|
||||
|
||||
/* the controllers' layout, for what the game tells the player */
|
||||
enum
|
||||
{
|
||||
HALO_XR_LAYOUT_TOUCH = 0, /* the Quest's: X, Y and menu on the left */
|
||||
HALO_XR_LAYOUT_FRAME = 1, /* the Steam Frame's: A, B, X, Y and menu on the right, a D-pad on the left */
|
||||
};
|
||||
|
||||
/* halo_xr_hand.flags, halo_xr_view.flags, halo_xr_frame.head_flags */
|
||||
@@ -112,6 +129,7 @@ struct halo_xr_frame
|
||||
struct halo_xr_pose head;
|
||||
struct halo_xr_view views[HALO_XR_EYE_COUNT];
|
||||
struct halo_xr_hand hands[HALO_XR_HAND_COUNT];
|
||||
int controller_layout; /* HALO_XR_LAYOUT_* */
|
||||
};
|
||||
|
||||
/* halo_xr_submit.overlay_mode */
|
||||
|
||||
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
# Halo VR on the Steam Frame: Lepton runs the APK in a container of its own,
|
||||
# and installs it anew whenever the APK is newer than the installed one
|
||||
# (port/android/STEAM_FRAME.md). The game's data: ~/Documents/HaloCE.
|
||||
# (a container of its own, not the shortcut's id: with that, SteamVR's
|
||||
# client in the container waited on xrCreateInstance)
|
||||
export SteamAppId="${HALO_LEPTON_APP_ID:-4290000001}"
|
||||
# (what Steam gives an Android title of its own, and a non-Steam game not:
|
||||
# the app's data in the container links to the compat data path's
|
||||
# internal/, a dangling link without it; and the shader paths: Lepton reads
|
||||
# the dump path against the other)
|
||||
export STEAM_COMPAT_DATA_PATH="$HOME/.local/share/Steam/steamapps/compatdata/$SteamAppId"
|
||||
export STEAM_COMPAT_SHADER_PATH="$HOME/.local/share/Steam/steamapps/shadercache/$SteamAppId"
|
||||
mkdir -p "$STEAM_COMPAT_DATA_PATH/internal" "$STEAM_COMPAT_SHADER_PATH"
|
||||
unset STEAM_FOSSILIZE_DUMP_PATH LD_PRELOAD
|
||||
LEPTON="$HOME/.local/share/Steam/steamapps/common/Lepton/lepton"
|
||||
APK="$HOME/Documents/HaloCE/HaloVR.apk"
|
||||
LOG="$HOME/Documents/HaloCE/launcher.log"
|
||||
# (written by the game when the player quits it: no start again)
|
||||
QUIT="$HOME/Documents/HaloCE/quit_requested.txt"
|
||||
rm -f "$QUIT"
|
||||
CONTEXT="steamlaunch-$SteamAppId"
|
||||
|
||||
log() { echo "$(date '+%F %T') $*" >> "$LOG"; }
|
||||
log "start (pid $$, parent $PPID)"
|
||||
|
||||
# Steam's "Exit game" ends the game's processes as Steam knows them (this
|
||||
# script, under Steam's reaper), not the container, which podman runs: a
|
||||
# signal here is passed on to Lepton, and a watcher of its own takes the
|
||||
# container down once this script is gone (killed)
|
||||
stopping=0
|
||||
child=0
|
||||
stop()
|
||||
{
|
||||
log "signal $1"
|
||||
stopping=1
|
||||
[ "$child" -gt 0 ] && kill -TERM "$child" 2>/dev/null
|
||||
}
|
||||
trap 'stop TERM' TERM
|
||||
trap 'stop INT' INT
|
||||
trap 'stop HUP' HUP
|
||||
|
||||
script=$$
|
||||
setsid bash -c '
|
||||
while kill -0 '"$script"' 2>/dev/null; do sleep 1; done
|
||||
echo "$(date "+%F %T") watcher: the game was ended, so its container" >> "'"$LOG"'"
|
||||
"'"$LEPTON"'" kill "'"$CONTEXT"'" >/dev/null 2>&1
|
||||
' </dev/null >/dev/null 2>&1 &
|
||||
|
||||
# the game's log while it runs (Lepton's logcat of its container), for
|
||||
# looking into problems: logcat.txt, anew each start
|
||||
LOGCAT="$HOME/Documents/HaloCE/logcat.txt"
|
||||
: > "$LOGCAT"
|
||||
setsid bash -c '
|
||||
while kill -0 '"$script"' 2>/dev/null; do
|
||||
"'"$LEPTON"'" logcat "'"$CONTEXT"'" 2>/dev/null | grep -v "^ERROR: \|^steamlaunch-\|^$" >> "'"$LOGCAT"'"
|
||||
sleep 3
|
||||
done
|
||||
' </dev/null >/dev/null 2>&1 &
|
||||
|
||||
run()
|
||||
{
|
||||
"$LEPTON" waitforexitandrun -- "$APK" &
|
||||
child=$!
|
||||
# (wait returns early when a signal comes: until Lepton is gone)
|
||||
while kill -0 "$child" 2>/dev/null; do
|
||||
wait "$child"
|
||||
done
|
||||
child=0
|
||||
}
|
||||
|
||||
# (a new APK is only installed on its first start, not started; and a start
|
||||
# right after a game that was ended hard can fail in SteamVR, which then
|
||||
# needs a moment: again, up to three times, while it ends within 30 s)
|
||||
for attempt in 1 2 3; do
|
||||
started=$SECONDS
|
||||
run
|
||||
if (( stopping || SECONDS - started >= 30 )) || [ -e "$QUIT" ]; then
|
||||
break
|
||||
fi
|
||||
log "ended within $((SECONDS - started)) s: again"
|
||||
sleep 5
|
||||
done
|
||||
rm -f "$QUIT"
|
||||
log "end"
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
FDM_INJECTION_STUB.C
|
||||
|
||||
An OpenXR API layer that does nothing, named as the Steam Frame's
|
||||
XR_APILAYER_VALVE_fdm_injection names its library
|
||||
(libVkLayer_VALVE_fdm_injection.so). The Frame lists that layer as implicit
|
||||
for every OpenXR app (/vendor/etc/openxr/1/api_layers/implicit.d), but an
|
||||
Android app (in Lepton) cannot load the system's library from its own
|
||||
namespace, and the Khronos loader then fails xrCreateInstance altogether;
|
||||
nor does the Android loader read the variable that would turn the layer
|
||||
off. With this one in the app's libraries the loader finds a layer of that
|
||||
name, which hands every call on to the next. (The real layer adds fragment
|
||||
density maps to Vulkan apps; this game draws with OpenGL ES.) On a Quest no
|
||||
manifest names it and it is never loaded.
|
||||
*/
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_loader_negotiation.h>
|
||||
#include <stddef.h>
|
||||
|
||||
static PFN_xrGetInstanceProcAddr next_get_instance_proc_addr;
|
||||
|
||||
static XRAPI_ATTR XrResult XRAPI_CALL layer_get_instance_proc_addr(XrInstance instance, const char *name,
|
||||
PFN_xrVoidFunction *function)
|
||||
{
|
||||
if (!next_get_instance_proc_addr)
|
||||
return XR_ERROR_HANDLE_INVALID;
|
||||
return next_get_instance_proc_addr(instance, name, function);
|
||||
}
|
||||
|
||||
static XRAPI_ATTR XrResult XRAPI_CALL layer_create_api_layer_instance(const XrInstanceCreateInfo *info,
|
||||
const XrApiLayerCreateInfo *layer_info, XrInstance *instance)
|
||||
{
|
||||
XrApiLayerCreateInfo next_layer_info;
|
||||
|
||||
if (!layer_info || !layer_info->nextInfo)
|
||||
return XR_ERROR_INITIALIZATION_FAILED;
|
||||
next_get_instance_proc_addr = layer_info->nextInfo->nextGetInstanceProcAddr;
|
||||
next_layer_info = *layer_info;
|
||||
next_layer_info.nextInfo = layer_info->nextInfo->next;
|
||||
return layer_info->nextInfo->nextCreateApiLayerInstance(info, &next_layer_info, instance);
|
||||
}
|
||||
|
||||
__attribute__((visibility("default")))
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrNegotiateLoaderApiLayerInterface(const XrNegotiateLoaderInfo *loader_info,
|
||||
const char *layer_name, XrNegotiateApiLayerRequest *request)
|
||||
{
|
||||
(void)layer_name;
|
||||
if (!loader_info || !request || loader_info->structType != XR_LOADER_INTERFACE_STRUCT_LOADER_INFO ||
|
||||
request->structType != XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST ||
|
||||
loader_info->minInterfaceVersion > XR_CURRENT_LOADER_API_LAYER_VERSION ||
|
||||
loader_info->maxInterfaceVersion < XR_CURRENT_LOADER_API_LAYER_VERSION)
|
||||
{
|
||||
return XR_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
request->layerInterfaceVersion = XR_CURRENT_LOADER_API_LAYER_VERSION;
|
||||
request->layerApiVersion = loader_info->maxApiVersion < XR_CURRENT_API_VERSION ? loader_info->maxApiVersion :
|
||||
XR_CURRENT_API_VERSION;
|
||||
request->getInstanceProcAddr = layer_get_instance_proc_addr;
|
||||
request->createApiLayerInstance = layer_create_api_layer_instance;
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 369 KiB After Width: | Height: | Size: 369 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
@@ -314,7 +314,7 @@
|
||||
"svg": "hud_xbox_order__bitmaps__combined__hud_ammo_meters.svg",
|
||||
"source_scale": 4,
|
||||
"source": [
|
||||
-34,
|
||||
-2,
|
||||
108
|
||||
],
|
||||
"clip": [
|
||||
@@ -380,7 +380,7 @@
|
||||
"svg": "hud_xbox_order__bitmaps__combined__hud_ammo_meters.svg",
|
||||
"source_scale": 4,
|
||||
"source": [
|
||||
-25,
|
||||
-5,
|
||||
312
|
||||
],
|
||||
"clip": [
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<defs>
|
||||
<radialGradient id="cone" gradientUnits="userSpaceOnUse" cx="167.994" cy="346.437" r="165.922"><stop offset="0" stop-color="#fff"/><stop offset="1" stop-color="#000"/></radialGradient><radialGradient id="coned" gradientUnits="userSpaceOnUse" cx="167.994" cy="346.437" r="165.922"><stop offset="0" stop-color="#fff"/><stop offset="1" stop-color="#878787"/></radialGradient>
|
||||
<g id="art">
|
||||
<path d="M167.994,346.437 L69.695,202.598 L266.292,202.598 Z" fill="url(#cone)"/>
|
||||
<path d="M167.994,346.437 L54.604,180.515 L281.384,180.515 Z" fill="url(#cone)"/>
|
||||
<circle cx="167.994" cy="345.987" r="53.201" fill="#878787"/>
|
||||
<path d="M167.994,346.437 L137.767,302.207 A53.201,53.201 0 0 1 198.220,302.207 Z" fill="url(#coned)"/>
|
||||
<!-- "15m" pixel label -->
|
||||
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
@@ -2,7 +2,7 @@
|
||||
<defs>
|
||||
<radialGradient id="cone" gradientUnits="userSpaceOnUse" cx="126.000" cy="130.342" r="128.840"><stop offset="0" stop-color="#fff"/><stop offset="1" stop-color="#000"/></radialGradient><radialGradient id="coned" gradientUnits="userSpaceOnUse" cx="126.000" cy="130.342" r="128.840"><stop offset="0" stop-color="#fff"/><stop offset="1" stop-color="#878787"/></radialGradient>
|
||||
<g id="art">
|
||||
<path d="M126.000,130.342 L49.632,18.677 L202.368,18.677 Z" fill="url(#cone)"/>
|
||||
<path d="M126.000,130.342 L37.886,1.502 L214.114,1.502 Z" fill="url(#cone)"/>
|
||||
<circle cx="126.000" cy="129.985" r="41.776" fill="#878787"/>
|
||||
<path d="M126.000,130.342 L102.251,95.616 A41.776,41.776 0 0 1 149.749,95.616 Z" fill="url(#coned)"/>
|
||||
<!-- "15m" pixel label -->
|
||||
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
@@ -51,7 +51,7 @@ until it is redrawn.
|
||||
| `ce/shell/main_menu/settings_select/player_setup/player_profile_edit/profile_options__6.png` | 512x256 | `shell/main_menu/settings_select/player_setup/player_profile_edit/profile_options__6.png` |
|
||||
| `ce/shell/main_menu/settings_select/player_setup/player_profile_edit/profile_options__8.png` | 512x256 | `shell/main_menu/settings_select/player_setup/player_profile_edit/profile_options__8.png` |
|
||||
|
||||
13 of 147 frames are placeholders.
|
||||
13 of 156 frames are placeholders.
|
||||
|
||||
The PC version's `ui\gamespy` and `ui\ticker` fonts are drawn with `ui\small_ui`, which
|
||||
the Xbox's map has.
|
||||
@@ -10,11 +10,10 @@ do (save a setting, join a game) does not happen; the screens open and close as
|
||||
|
||||
| Function | Uses | |
|
||||
| --- | --- | --- |
|
||||
| `common button bar update` | 24 | PC function |
|
||||
| `common button bar update` | 25 | PC function |
|
||||
| `direct ip connect init` | 1 | PC function |
|
||||
| `direct ip connect update` | 1 | PC function |
|
||||
| `direct ip edit field` | 4 | PC function |
|
||||
| `gamespy screen dispose` | 1 | PC function |
|
||||
| `gamespy screen update` | 1 | PC function |
|
||||
| `gamespy select button` | 8 | PC function |
|
||||
| `gamespy select header` | 22 | PC function |
|
||||
@@ -22,7 +21,7 @@ do (save a setting, join a game) does not happen; the screens open and close as
|
||||
| `gamespy update filter settings` | 2 | PC function |
|
||||
| `gt edit list update` | 1 | PC function |
|
||||
| `gt select list update` | 1 | PC function |
|
||||
| `mouse spinner 1wide click` | 64 | PC function |
|
||||
| `mouse spinner 1wide click` | 66 | PC function |
|
||||
| `mp map list update` | 1 | PC function |
|
||||
| `mp prof init teamplay options` | 1 | PC function |
|
||||
| `mp prof init vehicle options` | 1 | PC function |
|
||||
@@ -34,4 +33,4 @@ do (save a setting, join a game) does not happen; the screens open and close as
|
||||
| `ss edit server name` | 2 | PC function |
|
||||
| `ss start game` | 2 | PC function |
|
||||
|
||||
Wired: `campaign menu continue`, `campaign menu init`, `controls back handler`, `controls begin binding`, `controls screen change set`, `controls screen defaults`, `controls screen init`, `controls update menu`, `difficulty item select`, `direct ip connect go`, `emit custom activation event`, `gamespy back handler`, `gamespy dismiss error`, `gamespy dismiss filters`, `gamespy screen init`, `load game list update`, `load game menu activated`, `load game menu delete finish`, `load game menu delete request`, `load game menu dispose`, `load game menu init`, `main menu quit game`, `mouse emit accept event`, `mouse emit back event`, `mouse emit x event`, `mp type set mode`, `profile manager select`, `profile set edit begin`, `single prev cl item activated`, `solo map list update`.
|
||||
Wired: `campaign menu continue`, `campaign menu init`, `controls back handler`, `controls begin binding`, `controls screen change set`, `controls screen defaults`, `controls screen init`, `controls update menu`, `difficulty item select`, `direct ip connect go`, `emit custom activation event`, `gamespy back handler`, `gamespy dismiss error`, `gamespy dismiss filters`, `gamespy screen dispose`, `gamespy screen init`, `load game list update`, `load game menu activated`, `load game menu delete finish`, `load game menu delete request`, `load game menu dispose`, `load game menu init`, `main menu quit game`, `mouse emit accept event`, `mouse emit back event`, `mouse emit x event`, `mp type set mode`, `profile manager select`, `profile set edit begin`, `single prev cl item activated`, `solo map list update`.
|
||||
@@ -309,13 +309,37 @@
|
||||
<bitmap name="main_menu/solo_level_select/header_load_level">
|
||||
<frame png="ce/shell/main_menu/solo_level_select/header_load_level__0.png" width="512" height="64"/>
|
||||
</bitmap>
|
||||
<bitmap name="main_menu/multiplayer_type_select/coop/header_player_2">
|
||||
<frame png="ce/port/main_menu/multiplayer_type_select/coop/header_player_2.png" width="512" height="64"/>
|
||||
</bitmap>
|
||||
<bitmap name="main_menu/multiplayer_type_select/join_game/header_direct_link">
|
||||
<frame png="ce/port/main_menu/multiplayer_type_select/join_game/header_direct_link.png" width="512" height="64"/>
|
||||
</bitmap>
|
||||
<bitmap name="main_menu/multiplayer_type_select/join_game/header_password">
|
||||
<frame png="ce/port/main_menu/multiplayer_type_select/join_game/header_password.png" width="512" height="64"/>
|
||||
</bitmap>
|
||||
<bitmap name="main_menu/multiplayer_type_select/join_game/header_server_browser">
|
||||
<frame png="ce/port/main_menu/multiplayer_type_select/join_game/header_server_browser.png" width="512" height="64"/>
|
||||
</bitmap>
|
||||
<bitmap name="main_menu/multiplayer_type_select/lobby/header_add_player">
|
||||
<frame png="ce/port/main_menu/multiplayer_type_select/lobby/header_add_player.png" width="512" height="64"/>
|
||||
</bitmap>
|
||||
<bitmap name="main_menu/multiplayer_type_select/lobby/header_lobby">
|
||||
<frame png="ce/port/main_menu/multiplayer_type_select/lobby/header_lobby.png" width="512" height="64"/>
|
||||
</bitmap>
|
||||
<bitmap name="pause/pausebox_left">
|
||||
<frame png="ce/port/pause/pausebox_left__0.png" width="16" height="256"/>
|
||||
<frame png="ce/port/pause/pausebox_left__1.png" width="16" height="256"/>
|
||||
</bitmap>
|
||||
<bitmap name="pause/pausebox_center">
|
||||
<frame png="ce/port/pause/pausebox_center__0.png" width="4" height="256"/>
|
||||
<frame png="ce/port/pause/pausebox_center__1.png" width="4" height="256"/>
|
||||
</bitmap>
|
||||
<bitmap name="pause/pausebox_right">
|
||||
<frame png="ce/port/pause/pausebox_right__0.png" width="16" height="256"/>
|
||||
<frame png="ce/port/pause/pausebox_right__1.png" width="16" height="256"/>
|
||||
</bitmap>
|
||||
<bitmap name="blank">
|
||||
<frame png="ce/port/blank__0.png" width="4" height="4"/>
|
||||
</bitmap>
|
||||
</menus>
|
||||
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- The port's multiplayer screens, in the PC version's style (tools/port_settings.py) -->
|
||||
<menus>
|
||||
<widget name="main_menu/multiplayer_type_select/multiplayer_type_coop_item" type="text" left="51" width="232" height="32" bitmap="bitmaps/list_item_bkd" string_list="main_menu/multiplayer_type_select/multiplayer_options" string_index="7" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="5">
|
||||
<on event="a" run="port coop begin" open="main_menu/multiplayer_type_select/coop/player_2_profile_screen" branch="true"/>
|
||||
<on event="start" run="port coop begin" open="main_menu/multiplayer_type_select/coop/player_2_profile_screen" branch="true"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/player_2_profile_screen" width="640" height="480" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/gradient">
|
||||
<child widget="main_menu/new_select/sel_list_desc_bkd"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/player_2_profile_list"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/header_player_2"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/player_2_help" x="20" y="416"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/header_player_2" controller="1" left="35" top="11" width="363" height="59" bitmap="main_menu/multiplayer_type_select/coop/header_player_2">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/player_2_profile_list" type="column_list" width="640" height="480" flags="pass_unhandled_to_focused_child up_down_tabs_children" description="main_menu/profile_manager/player_profile_extended_desc">
|
||||
<data input="3wide player profile list update"/>
|
||||
<on event="created" run="port coop player 2 list initialize"/>
|
||||
<on event="deleted" run="player profile list dispose"/>
|
||||
<on event="custom_activation" run="port coop player 2" open="main_menu/solo_level_select/solo_level_select_screen" branch="true"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_0" x="20" y="73"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_1" x="20" y="103"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_2" x="20" y="133"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_3" x="20" y="163"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_4" x="20" y="193"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_5" x="20" y="223"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_6" x="20" y="253"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_7" x="20" y="283"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_8" x="20" y="313"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_9" x="20" y="343"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_10" x="20" y="373"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/player_2_button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_0" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd_top" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_1" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_2" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_3" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_4" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_5" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_6" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_7" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_8" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_9" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/list_item_10" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="a" run="single prev cl item activated"/>
|
||||
<on event="start" run="single prev cl item activated"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/player_2_help" type="text" width="350" height="24" text="Player 2: choose with your controller." font="ui\small_ui" color="#FF2896FF" text_y="5" text_flags="no_focus_test">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/coop/player_2_button_bar" type="column_list" width="640" height="28" flags="pass_unhandled_to_focused_child left_right_tabs_items">
|
||||
<data input="common button bar update"/>
|
||||
<child widget="main_menu/profile_manager/profile_manager_button_ok" x="380" y="1"/>
|
||||
<child widget="common_button_back" x="510" y="1"/>
|
||||
</widget>
|
||||
</menus>
|
||||
@@ -1,6 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- The port's multiplayer screens, in the PC version's style (tools/port_settings.py) -->
|
||||
<menus>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/password_screen" width="640" height="480" flags="pass_unhandled_to_focused_child pause_game" bitmap="bitmaps/gradient">
|
||||
<on event="b" run="port password back"/>
|
||||
<on event="back" run="port password back"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/password/header_password"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/password/options_menu"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/header_password" controller="1" left="35" top="11" width="605" height="59" bitmap="main_menu/multiplayer_type_select/join_game/header_password">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/help" type="text" controller="1" left="68" top="120" width="482" height="60" string_list="main_menu/multiplayer_type_select/join_game/password/help_strings" font="ui\large_ui" color="#FFFFFFFF">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/options_menu" type="column_list" width="640" height="480" flags="pass_unhandled_to_focused_child up_down_tabs_children" description="main_menu/multiplayer_type_select/join_game/password/help">
|
||||
<data input="port password update"/>
|
||||
<on event="created" run="port password init"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/password/op_password" x="54" y="73"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/password/button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/button_bar" type="column_list" width="640" height="28" flags="pass_unhandled_to_focused_child left_right_tabs_items">
|
||||
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/password/button_ok" x="380" y="1"/>
|
||||
<child widget="common_button_cancel" x="510" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/op_password" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<on event="a" run="port password edit"/>
|
||||
<on event="start" run="port password edit"/>
|
||||
<on event="b"/>
|
||||
<on event="back"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/password/password_label"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/password/password_value" x="230" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/password_label" type="text" controller="1" width="230" height="22" string_list="main_menu/multiplayer_type_select/join_game/password/labels" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/password_value" type="text" controller="1" width="280" height="22" font="ui\small_ui" color="#FF2896FF" align="center" text_y="5" text_flags="no_focus_test">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/button_defaults" type="text" width="128" height="24" bitmap="bitmaps/text_button_background" string_list="strings/common_button_captions" string_index="3" font="ui\small_ui" color="#FFFFFFFF" align="center" text_y="2">
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/password/button_ok" type="text" width="128" height="24" bitmap="bitmaps/text_button_background" text="JOIN GAME" font="ui\small_ui" color="#FFFFFFFF" align="center" text_y="2">
|
||||
<on event="a" run="port password join"/>
|
||||
<on event="start" run="port password join"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
</widget>
|
||||
<strings name="main_menu/multiplayer_type_select/join_game/password/labels">
|
||||
<string text="PASSWORD:"/>
|
||||
</strings>
|
||||
<strings name="main_menu/multiplayer_type_select/join_game/password/help_strings">
|
||||
<string text=""/>
|
||||
<string text="This game has a password. Type it, then press\nEnter to join."/>
|
||||
<string text="That is not the game's password. Try again."/>
|
||||
<string text="Could not join the game."/>
|
||||
</strings>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/header_server_browser" controller="1" left="35" top="11" width="363" height="59" bitmap="main_menu/multiplayer_type_select/join_game/header_server_browser">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/header_direct_link" controller="1" left="35" top="11" width="363" height="59" bitmap="main_menu/multiplayer_type_select/join_game/header_direct_link">
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/ticker_rules_info" x="80"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/join_game/join_game_button_bar" type="column_list" width="640" height="28" flags="pass_unhandled_to_focused_child left_right_tabs_items">
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/join_game_button_update" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/join_game_button_refresh" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/button_clipboard" x="128" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/join_game_button_filters" x="256" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/join_game/join_game_button_join" x="384" y="1"/>
|
||||
|
||||
@@ -1,34 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- The port's multiplayer screens, in the PC version's style (tools/port_settings.py) -->
|
||||
<menus>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_screen" width="640" height="480" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/gradient">
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_screen" width="640" height="480" flags="pass_unhandled_to_focused_child main_menu_if_no_history" bitmap="bitmaps/gradient">
|
||||
<on event="created" run="port lobby open"/>
|
||||
<on event="created" run="net server accept conx"/>
|
||||
<on event="created" run="net server allow start"/>
|
||||
<on event="b" run="net game unjoin player" back="true"/>
|
||||
<on event="back" run="net game unjoin player" back="true"/>
|
||||
<on event="b" run="port lobby leave" back="true"/>
|
||||
<on event="back" run="port lobby leave" back="true"/>
|
||||
<on event="start" run="port lobby join" open="main_menu/multiplayer_type_select/lobby/player_profile_screen" branch="true"/>
|
||||
<child widget="main_menu/new_select/sel_list_desc_bkd"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_list"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/header_lobby"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_join_help"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/header_lobby" controller="1" left="35" top="11" width="363" height="59" bitmap="main_menu/multiplayer_type_select/lobby/header_lobby">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_join_help" type="text" controller="1" left="355" top="446" width="275" height="24" font="ui\small_ui" color="#FF2896FF" align="right" text_y="5" text_flags="no_focus_test">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_list" type="column_list" width="640" height="480" flags="pass_unhandled_to_focused_child up_down_tabs_children" description="main_menu/multiplayer_type_select/lobby/lobby_desc">
|
||||
<data input="net splitscreen prejoin players"/>
|
||||
<data input="port lobby update"/>
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_0" x="20" y="73"/>
|
||||
<child widget="main_menu/new_select/list_item_1" x="20" y="103"/>
|
||||
<child widget="main_menu/new_select/list_item_2" x="20" y="133"/>
|
||||
<child widget="main_menu/new_select/list_item_3" x="20" y="163"/>
|
||||
<child widget="main_menu/new_select/list_item_4" x="20" y="193"/>
|
||||
<child widget="main_menu/new_select/list_item_5" x="20" y="223"/>
|
||||
<child widget="main_menu/new_select/list_item_6" x="20" y="253"/>
|
||||
<child widget="main_menu/new_select/list_item_7" x="20" y="283"/>
|
||||
<child widget="main_menu/new_select/list_item_8" x="20" y="313"/>
|
||||
<child widget="main_menu/new_select/list_item_9" x="20" y="343"/>
|
||||
<child widget="main_menu/new_select/list_item_10" x="20" y="373"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_0" x="20" y="73"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_1" x="20" y="103"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_2" x="20" y="133"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_3" x="20" y="163"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_4" x="20" y="193"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_5" x="20" y="223"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_6" x="20" y="253"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_7" x="20" y="283"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_8" x="20" y="313"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_9" x="20" y="343"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/list_item_10" x="20" y="373"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_0" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd_top" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_1" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_2" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_3" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_4" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_5" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_6" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_7" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_8" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_9" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/list_item_10" width="390" height="28" bitmap="bitmaps/sel_list_item_bkd" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<on event="left right" run="swap player team"/>
|
||||
<child widget="main_menu/new_select/list_item_text" x="25"/>
|
||||
<child widget="main_menu/new_select/list_item_arrows"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_desc" width="640" height="480">
|
||||
<child widget="main_menu/current_profile_name"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_right_item" x="22" y="2"/>
|
||||
@@ -36,6 +95,8 @@
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_right_item" controller="1" left="406" top="75" width="162" height="326" bitmap="bitmaps/spinner_list_3_wide_item_background">
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_map_pic"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_map_name"/>
|
||||
<child widget="main_menu/solo_level_select/replay_level_right_pic"/>
|
||||
<child widget="main_menu/solo_level_select/replay_level_right_name"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_game_data"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_map_pic" controller="1" left="419" top="87" width="140" height="114" bitmap="ui\shell\bitmaps\mp_map_grafix">
|
||||
@@ -45,10 +106,16 @@
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_game_data" type="text" controller="1" left="417" top="250" width="146" height="144" font="ui\small_ui" color="#FF2896FF">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_button_bar" type="column_list" width="640" height="28" flags="pass_unhandled_to_focused_child left_right_tabs_items">
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_button_team" x="250" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_button_start" x="380" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_button_team" x="120" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_button_start" x="250" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_button_add" x="380" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_button_leave" x="510" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_button_add" type="text" width="128" height="24" bitmap="bitmaps/text_button_background" text="ADD PLAYER" font="ui\small_ui" color="#FFFFFFFF" align="center" text_y="2">
|
||||
<on event="a" run="port lobby add player"/>
|
||||
<on event="start" run="port lobby add player"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/lobby_button_team" type="text" width="128" height="24" bitmap="bitmaps/text_button_background" text="SWITCH TEAM" font="ui\small_ui" color="#FFFFFFFF" align="center" text_y="2">
|
||||
<on event="a" run="swap player team"/>
|
||||
<on event="start" run="swap player team"/>
|
||||
@@ -64,14 +131,46 @@
|
||||
<on event="start" run="mouse emit back event"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/player_profile_screen" width="640" height="480" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/gradient">
|
||||
<on event="created" run="net server defer start"/>
|
||||
<child widget="main_menu/new_select/sel_list_desc_bkd"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/player_profile_list"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/header_add_player"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/player_profile_help" x="20" y="416"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/header_add_player" controller="1" left="35" top="11" width="363" height="59" bitmap="main_menu/multiplayer_type_select/lobby/header_add_player">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/player_profile_list" type="column_list" width="640" height="480" flags="pass_unhandled_to_focused_child up_down_tabs_children" description="main_menu/profile_manager/player_profile_extended_desc">
|
||||
<data input="3wide player profile list update"/>
|
||||
<on event="created" run="port lobby player list initialize"/>
|
||||
<on event="deleted" run="player profile list dispose"/>
|
||||
<on event="custom_activation" run="port lobby player choose" back="true" branch="true"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_0" x="20" y="73"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_1" x="20" y="103"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_2" x="20" y="133"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_3" x="20" y="163"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_4" x="20" y="193"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_5" x="20" y="223"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_6" x="20" y="253"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_7" x="20" y="283"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_8" x="20" y="313"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_9" x="20" y="343"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/list_item_10" x="20" y="373"/>
|
||||
<child widget="main_menu/multiplayer_type_select/coop/player_2_button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/player_profile_help" type="text" width="350" height="24" text="The new player's profile." font="ui\small_ui" color="#FF2896FF" text_y="5" text_flags="no_focus_test">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/preview_screen" width="640" height="480" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/gradient">
|
||||
<on event="b" back="true"/>
|
||||
<on event="back" back="true"/>
|
||||
<on event="created" run="port lobby open"/>
|
||||
<on event="b" run="port lobby preview leave" back="true"/>
|
||||
<on event="back" run="port lobby preview leave" back="true"/>
|
||||
<on event="start" run="port lobby preview add" open="main_menu/multiplayer_type_select/lobby/player_profile_screen" branch="true"/>
|
||||
<child widget="main_menu/new_select/sel_list_desc_bkd"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/preview_list"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/header_lobby"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/lobby_join_help"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/preview_list" type="column_list" width="640" height="480" flags="pass_unhandled_to_focused_child left_right_tabs_items" description="main_menu/multiplayer_type_select/lobby/lobby_desc">
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/preview_list" type="column_list" width="640" height="480" flags="pass_unhandled_to_focused_child up_down_tabs_children" description="main_menu/multiplayer_type_select/lobby/lobby_desc">
|
||||
<data input="port lobby preview update"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/preview_status" x="30" y="75"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/preview_button_bar" y="414"/>
|
||||
@@ -79,7 +178,8 @@
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/preview_status" type="text" controller="1" width="360" height="300" font="ui\large_ui" color="#FF2896FF">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/preview_button_bar" type="column_list" width="640" height="28" flags="pass_unhandled_to_focused_child left_right_tabs_items">
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/preview_button_join" x="380" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/preview_button_join" x="250" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/preview_button_add" x="380" y="1"/>
|
||||
<child widget="main_menu/multiplayer_type_select/lobby/preview_button_back" x="510" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/preview_button_join" type="text" width="128" height="24" bitmap="bitmaps/text_button_background" text="JOIN GAME" font="ui\small_ui" color="#FFFFFFFF" align="center" text_y="2">
|
||||
@@ -87,6 +187,11 @@
|
||||
<on event="start" run="port lobby preview join"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/preview_button_add" type="text" width="128" height="24" bitmap="bitmaps/text_button_background" text="ADD PLAYER" font="ui\small_ui" color="#FFFFFFFF" align="center" text_y="2">
|
||||
<on event="a" run="port lobby add player"/>
|
||||
<on event="start" run="port lobby add player"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/lobby/preview_button_back" type="text" width="128" height="24" bitmap="bitmaps/text_button_background" text="BACK" font="ui\small_ui" color="#FFFFFFFF" align="center" text_y="2">
|
||||
<on event="a" run="mouse emit back event"/>
|
||||
<on event="start" run="mouse emit back event"/>
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
<child widget="main_menu/multiplayer_type_select/mp_map_select/mp_map_right_name"/>
|
||||
<child widget="main_menu/multiplayer_type_select/mp_map_select/mp_map_right_pic"/>
|
||||
<child widget="main_menu/multiplayer_type_select/mp_map_select/mp_map_right_data"/>
|
||||
<child widget="main_menu/solo_level_select/replay_level_right_name"/>
|
||||
<child widget="main_menu/solo_level_select/replay_level_right_pic"/>
|
||||
<child widget="main_menu/solo_level_select/replay_level_right_data"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/mp_map_select/mp_map_right_name" type="text" controller="1" left="417" top="204" width="146" height="43" string_list="main_menu/mp_map_list" string_index="2" font="ui\large_ui" color="#FF2896FF">
|
||||
</widget>
|
||||
@@ -33,7 +36,9 @@
|
||||
<on event="created" run="mp level list initialize"/>
|
||||
<on event="deleted" run="mp level list dispose"/>
|
||||
<on event="custom_activation" run="mp level select" open="main_menu/multiplayer_type_select/connected/gametype_select_screen_wrapper"/>
|
||||
<child widget="main_menu/new_select/list_item_0" x="20" y="73"/>
|
||||
<on event="b" run="port map list back"/>
|
||||
<on event="back" run="port map list back"/>
|
||||
<child widget="main_menu/new_select/list_item_0_map_kind" x="82" y="73"/>
|
||||
<child widget="main_menu/new_select/list_item_1" x="20" y="103"/>
|
||||
<child widget="main_menu/new_select/list_item_2" x="20" y="133"/>
|
||||
<child widget="main_menu/new_select/list_item_3" x="20" y="163"/>
|
||||
|
||||
@@ -9,20 +9,27 @@
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/header_server_settings" controller="1" left="35" top="11" width="605" height="59" bitmap="main_menu/multiplayer_type_select/server_settings/header_server_settings">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/help" type="text" controller="1" left="68" top="350" width="482" height="60" string_list="main_menu/multiplayer_type_select/server_settings/help_strings" font="ui\large_ui" color="#FFFFFFFF">
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/help" type="text" controller="1" left="68" top="366" width="482" height="60" string_list="main_menu/multiplayer_type_select/server_settings/help_strings" font="ui\large_ui" color="#FFFFFFFF">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/options_menu" type="column_list" width="640" height="480" flags="pass_unhandled_to_focused_child up_down_tabs_children" description="main_menu/multiplayer_type_select/server_settings/help">
|
||||
<data input="server settings update"/>
|
||||
<on event="created" run="server settings init"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_server_name" x="54" y="73"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_max_players" x="54" y="103"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_invite" x="54" y="133"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_game_type" x="54" y="163"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_player_options" x="54" y="193"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_item_options" x="54" y="223"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_vehicle_options" x="54" y="253"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_indicator_options" x="54" y="283"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_team_options" x="54" y="313"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_max_players" x="54" y="99"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_invite" x="54" y="125"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_listing" x="54" y="151"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_password" x="54" y="177"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_friendly_fire" x="54" y="203"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_extra_enemies" x="54" y="229"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_enemies_per_player" x="54" y="255"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_enemies_multiplier" x="54" y="255"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_player_collisions" x="54" y="281"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_game_type" x="54" y="203"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_player_options" x="54" y="229"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_item_options" x="54" y="255"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_vehicle_options" x="54" y="281"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_indicator_options" x="54" y="307"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_team_options" x="54" y="333"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/button_bar" type="column_list" width="640" height="28" flags="pass_unhandled_to_focused_child left_right_tabs_items">
|
||||
@@ -64,6 +71,83 @@
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/invite_value" type="text" controller="1" width="280" height="22" font="ui\small_ui" color="#FF2896FF" align="center" text_y="5" text_flags="no_focus_test">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/op_listing" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/listing_label"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/listing_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/listing_label" type="text" controller="1" width="300" height="22" string_list="main_menu/multiplayer_type_select/server_settings/labels" string_index="9" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/listing_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="PUBLIC|PRIVATE" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/op_password" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<on event="a" run="ss edit server password"/>
|
||||
<on event="start" run="ss edit server password"/>
|
||||
<on event="b"/>
|
||||
<on event="back"/>
|
||||
<on event="left_mouse" run="mouse emit accept event"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/password_label"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/password_value" x="230" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/password_label" type="text" controller="1" width="230" height="22" string_list="main_menu/multiplayer_type_select/server_settings/labels" string_index="15" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/password_value" type="text" controller="1" width="280" height="22" font="ui\small_ui" color="#FF2896FF" align="center" text_y="5" text_flags="no_focus_test">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/op_friendly_fire" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/friendly_fire_label"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/friendly_fire_spinner" x="286" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/friendly_fire_label" type="text" controller="1" width="300" height="22" string_list="main_menu/multiplayer_type_select/server_settings/labels" string_index="10" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/friendly_fire_spinner" type="spinner" top="2" width="206" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="OFF|ON|SHIELD ONLY|EXPLOSIVES ONLY" setting="network.coop_friendly_fire" values="off|on|shields_only|explosives_only" font="ui\large_ui" color="#FF2896FF" align="center" text_y="4" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -13 19 -7" footer_bounds="7 208 19 214">
|
||||
<on event="created" run="port setting load"/>
|
||||
<on event="deleted" run="port setting save"/>
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/op_extra_enemies" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/extra_enemies_label"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/extra_enemies_spinner" x="286" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/extra_enemies_label" type="text" controller="1" width="300" height="22" string_list="main_menu/multiplayer_type_select/server_settings/labels" string_index="11" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/extra_enemies_spinner" type="spinner" top="2" width="206" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="NONE|PER PLAYER|STATIC MULTIPLIER" setting="network.coop_enemies_mode" values="none|per_player|multiplier" font="ui\large_ui" color="#FF2896FF" align="center" text_y="4" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -13 19 -7" footer_bounds="7 208 19 214">
|
||||
<on event="created" run="port setting load"/>
|
||||
<on event="deleted" run="port setting save"/>
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/op_enemies_per_player" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/enemies_per_player_label"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/enemies_per_player_spinner" x="286" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/enemies_per_player_label" type="text" controller="1" width="300" height="22" string_list="main_menu/multiplayer_type_select/server_settings/labels" string_index="12" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/enemies_per_player_spinner" type="spinner" top="2" width="206" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="25%|50%|100%|150%|200%" setting="network.coop_enemies" values="25|50|100|150|200" font="ui\large_ui" color="#FF2896FF" align="center" text_y="4" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -13 19 -7" footer_bounds="7 208 19 214">
|
||||
<on event="created" run="port setting load"/>
|
||||
<on event="deleted" run="port setting save"/>
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/op_enemies_multiplier" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/enemies_multiplier_label"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/enemies_multiplier_spinner" x="286" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/enemies_multiplier_label" type="text" controller="1" width="300" height="22" string_list="main_menu/multiplayer_type_select/server_settings/labels" string_index="13" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/enemies_multiplier_spinner" type="spinner" top="2" width="206" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="2X|4X|8X|16X|32X" setting="network.coop_enemies_multiplier" values="2|4|8|16|32" font="ui\large_ui" color="#FF2896FF" align="center" text_y="4" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -13 19 -7" footer_bounds="7 208 19 214">
|
||||
<on event="created" run="port setting load"/>
|
||||
<on event="deleted" run="port setting save"/>
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/op_player_collisions" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/player_collisions_label"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/player_collisions_spinner" x="286" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/player_collisions_label" type="text" controller="1" width="300" height="22" string_list="main_menu/multiplayer_type_select/server_settings/labels" string_index="14" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/player_collisions_spinner" type="spinner" top="2" width="206" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="network.coop_player_collisions" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="4" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -13 19 -7" footer_bounds="7 208 19 214">
|
||||
<on event="created" run="port setting load"/>
|
||||
<on event="deleted" run="port setting save"/>
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/server_settings/op_game_type" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<on event="a" run="port setup edit" open="main_menu/settings_select/multiplayer_setup/playlist_edit/game_type_select/gametype_select_screen"/>
|
||||
<on event="start" run="port setup edit" open="main_menu/settings_select/multiplayer_setup/playlist_edit/game_type_select/gametype_select_screen"/>
|
||||
@@ -148,6 +232,13 @@
|
||||
<string text="VEHICLE OPTIONS:"/>
|
||||
<string text="INDICATOR OPTIONS:"/>
|
||||
<string text="TEAMPLAY OPTIONS:"/>
|
||||
<string text="LISTING:"/>
|
||||
<string text="FRIENDLY FIRE:"/>
|
||||
<string text="EXTRA ENEMIES:"/>
|
||||
<string text="PER PLAYER:"/>
|
||||
<string text="MULTIPLIER:"/>
|
||||
<string text="PLAYER COLLISIONS:"/>
|
||||
<string text="PASSWORD:"/>
|
||||
</strings>
|
||||
<strings name="main_menu/multiplayer_type_select/server_settings/help_strings">
|
||||
<string text=""/>
|
||||
@@ -160,5 +251,19 @@
|
||||
<string text="Each team's vehicles and their respawn time, for\nthis game."/>
|
||||
<string text="The motion tracker and nav points, for this game."/>
|
||||
<string text="Friendly fire and team balance, for this game."/>
|
||||
<string text="Anyone can see and join your game: it is listed\nin everyone's Server Browser."/>
|
||||
<string text="Only players with your invite link can join."/>
|
||||
<string text="Players can not be hurt by weapons and explosives\nfired by the other players."/>
|
||||
<string text="Players can be hurt by weapons or explosives\nfired by the other players."/>
|
||||
<string text="Damage from the other players will only reduce\nshields. Health will be unaffected."/>
|
||||
<string text="Players can be hurt by damage from explosives\nfired by the other players."/>
|
||||
<string text="Enemy squads are as the campaign has them."/>
|
||||
<string text="Enemy squads grow with the players: by the amount\nbelow for each player past the first."/>
|
||||
<string text="Enemy squads are the amount below times as large,\nhowever many players there are."/>
|
||||
<string text="For each player past the first, enemy squads get\nthis much more of themselves (100%: as many again)."/>
|
||||
<string text="Each enemy squad is this many times as large."/>
|
||||
<string text="Players bump into each other, as in the campaign."/>
|
||||
<string text="Players walk through each other, so that no one\nblocks a doorway. The AI's characters still block."/>
|
||||
<string text="Players from the Server Browser must type it to\njoin (an invite link needs none). Enter sets it."/>
|
||||
</strings>
|
||||
</menus>
|
||||
@@ -59,13 +59,14 @@
|
||||
<child widget="main_menu/multiplayer_type_select/multiplayer_type_create_item" x="-32" y="210"/>
|
||||
<child widget="main_menu/multiplayer_type_select/multiplayer_type_create_internet_item" y="243"/>
|
||||
<child widget="main_menu/multiplayer_type_select/multiplayer_type_create_lan_item" y="276"/>
|
||||
<child widget="main_menu/multiplayer_type_select/multiplayer_type_gametypes_item" y="342"/>
|
||||
<child widget="main_menu/multiplayer_type_select/multiplayer_type_coop_item" y="309"/>
|
||||
<child widget="main_menu/multiplayer_type_select/multiplayer_type_gametypes_item" y="375"/>
|
||||
<child widget="main_menu/multiplayer_type_select/multiplayer_type_button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/multiplayer_type_select/multiplayer_type_select_screen" width="640" height="480" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/gradient">
|
||||
<on event="created" run="mp type menu initialize"/>
|
||||
<child widget="main_menu/multiplayer_type_select/header_multiplayer"/>
|
||||
<child widget="main_menu/multiplayer_type_select/multiplayer_type_select_list"/>
|
||||
<child widget="main_menu/blueline" x="64" y="325"/>
|
||||
<child widget="main_menu/blueline" x="64" y="358"/>
|
||||
</widget>
|
||||
</menus>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- The port's multiplayer screens, in the PC version's style (tools/port_settings.py) -->
|
||||
<menus>
|
||||
<widget name="main_menu/new_select/list_item_0_map_kind" width="256" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds_sm" font="ui\large_ui" color="#FF2896FF" align="center" text_y="3">
|
||||
<child widget="main_menu/new_select/list_item_0_map_kind_spinner" x="15" y="2"/>
|
||||
</widget>
|
||||
<widget name="main_menu/new_select/list_item_0_map_kind_spinner" type="spinner" width="226" height="22" flags="left_right_tabs_items" string_list="main_menu/new_select/var_map_kinds" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" list_flags="items_from_strings" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 226 19 232">
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<strings name="main_menu/new_select/var_map_kinds">
|
||||
<string text="SINGLEPLAYER"/>
|
||||
<string text="MULTIPLAYER"/>
|
||||
</strings>
|
||||
</menus>
|
||||
@@ -1,6 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- The port's multiplayer screens, in the PC version's style (tools/port_settings.py) -->
|
||||
<menus>
|
||||
<widget name="main_menu/settings_select/multiplayer_setup/item_options_edit/op_map_weapons" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/map_weapons_label"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/map_weapons_spinner" x="286" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/multiplayer_setup/item_options_edit/map_weapons_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/multiplayer_setup/item_options_edit/item_options_labels" string_index="8" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/multiplayer_setup/item_options_edit/map_weapons_spinner" type="spinner" top="2" width="206" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" string_list="main_menu/settings_select/multiplayer_setup/item_options_edit/var_map_weapons" font="ui\large_ui" color="#FF2896FF" align="center" text_y="4" list_flags="items_from_strings" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -13 19 -7" footer_bounds="7 208 19 214">
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/multiplayer_setup/item_options_edit/op_loadout" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/loadout_label"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/loadout_spinner" x="286" y="1"/>
|
||||
@@ -28,6 +37,10 @@
|
||||
<widget name="main_menu/settings_select/multiplayer_setup/item_options_edit/secondary_weapon_spinner" type="spinner" top="2" width="206" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" string_list="main_menu/settings_select/multiplayer_setup/item_options_edit/var_loadout_weapon" font="ui\large_ui" color="#FF2896FF" align="center" text_y="4" list_flags="items_from_strings" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -13 19 -7" footer_bounds="7 208 19 214">
|
||||
<on event="left_mouse" run="mouse spinner 1wide click"/>
|
||||
</widget>
|
||||
<strings name="main_menu/settings_select/multiplayer_setup/item_options_edit/var_map_weapons">
|
||||
<string text="YES"/>
|
||||
<string text="NO"/>
|
||||
</strings>
|
||||
<strings name="main_menu/settings_select/multiplayer_setup/item_options_edit/var_loadout">
|
||||
<string text="CATEGORY"/>
|
||||
<string text="CUSTOM"/>
|
||||
@@ -43,7 +56,5 @@
|
||||
<string text="PLASMA PISTOL"/>
|
||||
<string text="PLASMA RIFLE"/>
|
||||
<string text="NEEDLER"/>
|
||||
<string text="FUEL ROD"/>
|
||||
<string text="FLAMETHROWER"/>
|
||||
</strings>
|
||||
</menus>
|
||||
@@ -26,9 +26,10 @@
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_infinite_grenades" x="54" y="73"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_weapon_set" x="54" y="103"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_starting_equipment" x="54" y="133"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_loadout" x="54" y="163"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_primary_weapon" x="54" y="193"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_secondary_weapon" x="54" y="223"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_map_weapons" x="54" y="163"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_loadout" x="54" y="193"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_primary_weapon" x="54" y="223"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/op_secondary_weapon" x="54" y="253"/>
|
||||
<child widget="main_menu/settings_select/multiplayer_setup/item_options_edit/item_button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/multiplayer_setup/item_options_edit/item_options_screen" width="640" height="480" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/gradient">
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/op_volume" x="54" y="73"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/op_music_volume" x="54" y="103"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/op_effects_volume" x="54" y="133"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/op_enabled" x="54" y="163"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/op_reverb" x="54" y="163"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/op_enabled" x="54" y="193"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/button_bar" type="column_list" width="640" height="28" flags="pass_unhandled_to_focused_child left_right_tabs_items">
|
||||
@@ -51,11 +52,20 @@
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/effects_volume_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="0|1|2|3|4|5|6|7|8|9|10" setting="audio.effects_volume" values="0|0.1|0.2|0.3|0.4|0.5|0.6|0.7|0.8|0.9|1" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/op_reverb" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/reverb_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/reverb_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/reverb_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/labels" string_index="3" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/reverb_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="audio.reverb" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/op_enabled" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/enabled_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/enabled_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/enabled_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/labels" string_index="3" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/enabled_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/labels" string_index="4" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/enabled_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="audio.enabled" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
@@ -74,6 +84,7 @@
|
||||
<string text="MASTER VOLUME:"/>
|
||||
<string text="MUSIC VOLUME:"/>
|
||||
<string text="EFFECTS VOLUME:"/>
|
||||
<string text="REVERB:"/>
|
||||
<string text="SOUND:"/>
|
||||
</strings>
|
||||
<strings name="main_menu/settings_select/player_setup/player_profile_edit/audio_settings/help_strings">
|
||||
@@ -81,6 +92,7 @@
|
||||
<string text="The volume of everything."/>
|
||||
<string text="The music's volume."/>
|
||||
<string text="The volume of every other sound: effects and\nspeech."/>
|
||||
<string text="Echo sounds as the place you are in does, and\nmuffle those behind walls, as the Xbox did."/>
|
||||
<string text="Play sound at all; from the next time the game\nstarts."/>
|
||||
</strings>
|
||||
</menus>
|
||||
@@ -9,18 +9,24 @@
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/header_profile_video_settings" controller="1" left="35" top="11" width="605" height="59" bitmap="main_menu/settings_select/player_setup/player_profile_edit/video_settings/header_profile_video_settings">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/help" type="text" controller="1" left="68" top="350" width="482" height="60" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/help_strings" font="ui\large_ui" color="#FFFFFFFF">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/help" type="text" controller="1" left="68" top="364" width="482" height="60" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/help_strings" font="ui\large_ui" color="#FFFFFFFF">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/options_menu" type="column_list" width="640" height="480" flags="pass_unhandled_to_focused_child up_down_tabs_children" description="main_menu/settings_select/player_setup/player_profile_edit/video_settings/help">
|
||||
<data input="port settings help"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_mode" x="54" y="73" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_window_scale" x="54" y="99" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_vsync" x="54" y="125"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_max_fps" x="54" y="151" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_interpolation" x="54" y="177"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_direct_camera" x="54" y="203" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_high_res_hud" x="54" y="229"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_high_res_text" x="54" y="255"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_resolution" x="54" y="97" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_window_size" x="54" y="97" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_resolution_scaling" x="54" y="121" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_vsync" x="54" y="145"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_max_fps" x="54" y="169" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_interpolation" x="54" y="193"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_direct_camera" x="54" y="217" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_high_res_hud" x="54" y="241"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_high_res_text" x="54" y="265"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_anti_aliasing" x="54" y="289" platform="desktop"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_anti_aliasing_android" x="54" y="289" platform="android"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_shadow_resolution" x="54" y="313"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_per_pixel_lighting" x="54" y="337"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/button_bar" y="414"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/button_bar" type="column_list" width="640" height="28" flags="pass_unhandled_to_focused_child left_right_tabs_items">
|
||||
@@ -37,20 +43,38 @@
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/mode_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="FULLSCREEN|BORDERLESS|WINDOWED" setting="display.mode" values="fullscreen|borderless|windowed" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_window_scale" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF" platform="desktop">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/window_scale_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/window_scale_spinner" x="320" y="1"/>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_resolution" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF" platform="desktop">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/resolution_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/resolution_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/window_scale_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="1" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/resolution_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="1" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/window_scale_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="640 x 480|1280 x 960|1920 x 1440|2560 x 1920" setting="display.window_scale" values="1|2|3|4" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/resolution_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="NATIVE" setting="display.resolution" values="native" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_window_size" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF" platform="desktop">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/window_size_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/window_size_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/window_size_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="2" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/window_size_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="1280 x 960" setting="display.window_size" values="1280x960" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_resolution_scaling" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF" platform="desktop">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/resolution_scaling_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/resolution_scaling_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/resolution_scaling_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="3" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/resolution_scaling_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="NATIVE|ORIGINAL" setting="display.resolution_scaling" values="native|original" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_vsync" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/vsync_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/vsync_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/vsync_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="2" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/vsync_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="4" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/vsync_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="display.vsync" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
@@ -59,7 +83,7 @@
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/max_fps_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/max_fps_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/max_fps_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="3" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/max_fps_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="5" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/max_fps_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="AUTO|30|60|120|144|165|240|NONE" setting="display.max_fps" values="0|30|60|120|144|165|240|-1" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
@@ -68,7 +92,7 @@
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/interpolation_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/interpolation_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/interpolation_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="4" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/interpolation_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="6" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/interpolation_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="display.interpolation" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
@@ -77,7 +101,7 @@
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/direct_camera_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/direct_camera_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/direct_camera_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="5" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/direct_camera_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="7" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/direct_camera_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="display.direct_camera" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
@@ -86,7 +110,7 @@
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_hud_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_hud_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_hud_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="6" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_hud_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="8" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_hud_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="display.high_res_hud" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
@@ -95,11 +119,47 @@
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_text_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_text_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_text_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="7" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_text_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="9" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/high_res_text_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="display.high_res_text" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_anti_aliasing" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF" platform="desktop">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/anti_aliasing_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/anti_aliasing_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/anti_aliasing_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="10" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/anti_aliasing_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="OFF|FXAA|SMAA|SSAA 2X|MSAA 2X|MSAA 4X|MSAA 8X" setting="display.anti_aliasing" values="off|fxaa|smaa|ssaa2x|msaa2x|msaa4x|msaa8x" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_anti_aliasing_android" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF" platform="android">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/anti_aliasing_android_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/anti_aliasing_android_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/anti_aliasing_android_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="11" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/anti_aliasing_android_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="OFF|FXAA|MSAA 2X|MSAA 4X" setting="display.anti_aliasing" values="off|fxaa|msaa2x|msaa4x" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_shadow_resolution" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/shadow_resolution_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/shadow_resolution_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/shadow_resolution_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="12" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/shadow_resolution_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="128|256|512|1024" setting="display.shadow_resolution" values="128|256|512|1024" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/op_per_pixel_lighting" width="512" height="28" flags="pass_unhandled_to_focused_child" bitmap="bitmaps/option_bkds" color="#FF2896FF">
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/per_pixel_lighting_label"/>
|
||||
<child widget="main_menu/settings_select/player_setup/player_profile_edit/video_settings/per_pixel_lighting_spinner" x="320" y="1"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/per_pixel_lighting_label" type="text" controller="1" width="300" height="22" string_list="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels" string_index="13" font="ui\large_ui" color="#FF2896FF" text_x="13" text_y="4">
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/per_pixel_lighting_spinner" type="spinner" left="3" top="2" width="147" height="20" flags="pass_unhandled_to_focused_child left_right_tabs_items" strings="ON|OFF" setting="display.per_pixel_lighting" values="true|false" font="ui\large_ui" color="#FF2896FF" align="center" text_y="1" header_bitmap="bitmaps/arrow_sm_left" footer_bitmap="bitmaps/arrow_sm_right" header_bounds="7 -6 19 0" footer_bounds="7 150 19 156">
|
||||
<on event="created" run="port setting load"/>
|
||||
</widget>
|
||||
<widget name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/button_defaults" type="text" width="128" height="24" bitmap="bitmaps/text_button_background" string_list="strings/common_button_captions" string_index="3" font="ui\small_ui" color="#FFFFFFFF" align="center" text_y="2">
|
||||
<on event="a" run="port settings defaults"/>
|
||||
<on event="start" run="port settings defaults"/>
|
||||
@@ -112,23 +172,35 @@
|
||||
</widget>
|
||||
<strings name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/labels">
|
||||
<string text="DISPLAY MODE:"/>
|
||||
<string text="RESOLUTION:"/>
|
||||
<string text="WINDOW SIZE:"/>
|
||||
<string text="RESOLUTION SCALING:"/>
|
||||
<string text="V-SYNC:"/>
|
||||
<string text="FRAME RATE LIMIT:"/>
|
||||
<string text="SMOOTH MOTION:"/>
|
||||
<string text="INSTANT AIM:"/>
|
||||
<string text="HIGH-RES HUD:"/>
|
||||
<string text="HIGH-RES TEXT:"/>
|
||||
<string text="ANTI-ALIASING:"/>
|
||||
<string text="ANTI-ALIASING:"/>
|
||||
<string text="SHADOW RESOLUTION:"/>
|
||||
<string text="PER-PIXEL LIGHTING:"/>
|
||||
</strings>
|
||||
<strings name="main_menu/settings_select/player_setup/player_profile_edit/video_settings/help_strings">
|
||||
<string text=""/>
|
||||
<string text="Fullscreen and borderless draw at the display's\nresolution; windowed, 640x480 scaled. F11: window."/>
|
||||
<string text="The window's size when windowed (its edges can\nalso be dragged)."/>
|
||||
<string text="Fullscreen takes the display; borderless covers it\nwith a window. F11 switches to the window."/>
|
||||
<string text="What fullscreen and borderless draw at. Fullscreen\nsets the display to it; borderless scales it."/>
|
||||
<string text="The window's size: 4:3, then 16:10, 16:9 and 21:9\n(its edges can also be dragged)."/>
|
||||
<string text="Native draws at the resolution; Original draws\nthe Xbox's 640x480 and scales it up."/>
|
||||
<string text="Wait for the display between frames, so that the\npicture never tears."/>
|
||||
<string text="With V-Sync off, the most frames a second. Auto:\ntwice the display's refresh rate."/>
|
||||
<string text="Draw a frame for every display refresh, blending\nbetween the game's 30 ticks a second."/>
|
||||
<string text="In first person, turn the view the moment the\nmouse moves, not up to two ticks later."/>
|
||||
<string text="Draw the HUD from the high-res redraws; off\ndraws the game's own pictures."/>
|
||||
<string text="Draw text and titles with high-res fonts; off\ndraws the game's own."/>
|
||||
<string text="Smooth jagged edges, which the Xbox did not. FXAA\nand SMAA are cheap; SSAA and MSAA are sharper."/>
|
||||
<string text="Smooth jagged edges, which the Xbox did not. FXAA\nis cheap; MSAA is sharper."/>
|
||||
<string text="The size objects' shadows are drawn at: 128 as on\nthe Xbox; larger for smoother, as soft, edges."/>
|
||||
<string text="Light models for each pixel, without the facets\nof the Xbox's lighting for each vertex."/>
|
||||
</strings>
|
||||
</menus>
|
||||
@@ -14,6 +14,9 @@
|
||||
<child widget="main_menu/solo_level_select/difficulty_indicator" x="416" y="343"/>
|
||||
<child widget="main_menu/solo_level_select/difficulty_indicator" x="466" y="343"/>
|
||||
<child widget="main_menu/solo_level_select/difficulty_indicator" x="516" y="343"/>
|
||||
<child widget="main_menu/multiplayer_type_select/mp_map_select/mp_map_right_name"/>
|
||||
<child widget="main_menu/multiplayer_type_select/mp_map_select/mp_map_right_pic"/>
|
||||
<child widget="main_menu/multiplayer_type_select/mp_map_select/mp_map_right_data"/>
|
||||
</widget>
|
||||
<widget name="main_menu/solo_level_select/replay_level_right_name" type="text" controller="1" left="417" top="204" width="146" height="43" string_list="main_menu/map_list" string_index="2" font="ui\large_ui" color="#FF2896FF">
|
||||
</widget>
|
||||
@@ -38,7 +41,7 @@
|
||||
<on event="created" run="initialize sp level list solo"/>
|
||||
<on event="deleted" run="dispose sp level list"/>
|
||||
<on event="custom_activation" run="solo level set map" open="main_menu/difficulty_select/difficulty_select_list_screen"/>
|
||||
<child widget="main_menu/new_select/list_item_0" x="20" y="73"/>
|
||||
<child widget="main_menu/new_select/list_item_0_map_kind" x="82" y="73"/>
|
||||
<child widget="main_menu/new_select/list_item_1" x="20" y="103"/>
|
||||
<child widget="main_menu/new_select/list_item_2" x="20" y="133"/>
|
||||
<child widget="main_menu/new_select/list_item_3" x="20" y="163"/>
|
||||
|
||||
|
After Width: | Height: | Size: 75 B |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 305 B |
|
After Width: | Height: | Size: 323 B |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
@@ -374,6 +374,7 @@
|
||||
<string text="Join a game by its invite link,\nor one a Discord invite\nreached."/>
|
||||
<string text="Host a game on the Internet:\nplayers join by its invite\nlink or Discord."/>
|
||||
<string text="Host a game on your LAN\nonly."/>
|
||||
<string text="Play the campaign with a\nfriend in split screen:\nplayer 2 on a gamepad."/>
|
||||
<string text="Set all the attributes for your \nmultiplayer gametypes and\nkeep them for future use."/>
|
||||
</strings>
|
||||
<strings name="main_menu/multiplayer_type_select/multiplayer_options">
|
||||
@@ -384,6 +385,7 @@
|
||||
<string text="DIRECT LINK"/>
|
||||
<string text="EDIT GAMETYPES"/>
|
||||
<string text="SERVER BROWSER"/>
|
||||
<string text="CO-OP CAMPAIGN"/>
|
||||
</strings>
|
||||
<strings name="main_menu/multiplayer_type_select/server_settings/cap_server_settings_options">
|
||||
<string text="Enter a name for your server."/>
|
||||
@@ -498,6 +500,8 @@
|
||||
<string text="The map's weapons, without any grenades."/>
|
||||
<string text="You will start the game with the weapon set that the \nmap designers custom tailored for it."/>
|
||||
<string text="Use the generic starting weapons across all maps."/>
|
||||
<string text="The map's weapons appear where its designers\nplaced them."/>
|
||||
<string text="No weapons appear on the map: with a loadout of\nNONE and NONE, melee and grenades only."/>
|
||||
<string text="The weapons follow the weapon set above."/>
|
||||
<string text="Everyone starts with the primary and secondary\nweapons below; the map's weapons are its own."/>
|
||||
<string text="No primary weapon."/>
|
||||
@@ -510,8 +514,6 @@
|
||||
<string text="Everyone spawns with a plasma pistol as their primary\nweapon (where the map has one)."/>
|
||||
<string text="Everyone spawns with a plasma rifle as their primary\nweapon (where the map has one)."/>
|
||||
<string text="Everyone spawns with a needler as their primary\nweapon (where the map has one)."/>
|
||||
<string text="Everyone spawns with a fuel rod as their primary\nweapon (where the map has one)."/>
|
||||
<string text="Everyone spawns with a flamethrower as their primary\nweapon (where the map has one)."/>
|
||||
<string text="No secondary weapon."/>
|
||||
<string text="A random secondary weapon, of those the map has,\neach time you spawn."/>
|
||||
<string text="Everyone spawns with a assault rifle as their secondary\nweapon (where the map has one)."/>
|
||||
@@ -522,8 +524,6 @@
|
||||
<string text="Everyone spawns with a plasma pistol as their secondary\nweapon (where the map has one)."/>
|
||||
<string text="Everyone spawns with a plasma rifle as their secondary\nweapon (where the map has one)."/>
|
||||
<string text="Everyone spawns with a needler as their secondary\nweapon (where the map has one)."/>
|
||||
<string text="Everyone spawns with a fuel rod as their secondary\nweapon (where the map has one)."/>
|
||||
<string text="Everyone spawns with a flamethrower as their secondary\nweapon (where the map has one)."/>
|
||||
</strings>
|
||||
<strings name="main_menu/settings_select/multiplayer_setup/item_options_edit/item_options_labels">
|
||||
<string text="INFINITE GRENADES:"/>
|
||||
@@ -534,6 +534,7 @@
|
||||
<string text="LOADOUT:"/>
|
||||
<string text="PRIMARY WEAPON:"/>
|
||||
<string text="SECONDARY WEAPON:"/>
|
||||
<string text="MAP WEAPONS:"/>
|
||||
</strings>
|
||||
<strings name="main_menu/settings_select/multiplayer_setup/item_options_edit/var_infinite_grenades">
|
||||
<string text="YES"/>
|
||||
@@ -963,6 +964,12 @@
|
||||
<string text="At the end of this game there will be fifteen angry\nmen. Angry because the winning player killed them."/>
|
||||
<string text="You'll need to secure twenty-five kills in order to\nwin the game."/>
|
||||
<string text="We hope you've got plenty of time, because you'll\nneed to make a full fifty kills to win this one."/>
|
||||
<string text="Seventy-five kills to win. Settle in for a long\nfight."/>
|
||||
<string text="A hundred kills to win. Made for big games."/>
|
||||
<string text="A hundred and fifty kills to win. Only a crowded\nserver gets there."/>
|
||||
<string text="Two hundred kills to win. Bring friends. Lots of\nthem."/>
|
||||
<string text="Two hundred and fifty kills to win."/>
|
||||
<string text="Five hundred kills to win. You'll be here a while."/>
|
||||
<string text="This is a team game."/>
|
||||
<string text="It's every man for himself."/>
|
||||
<string text="The game will have no time limit. It will only end\nwhen someone wins."/>
|
||||
@@ -994,6 +1001,12 @@
|
||||
<string text="15"/>
|
||||
<string text="25"/>
|
||||
<string text="50"/>
|
||||
<string text="75"/>
|
||||
<string text="100"/>
|
||||
<string text="150"/>
|
||||
<string text="200"/>
|
||||
<string text="250"/>
|
||||
<string text="500"/>
|
||||
</strings>
|
||||
<strings name="main_menu/settings_select/multiplayer_setup/playlist_edit/slayer_edit/var_team_play">
|
||||
<string text="YES"/>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"ce/main_menu.gametype_select.xml",
|
||||
"ce/main_menu.multiplayer_type_select.connected.4way_profile_select.xml",
|
||||
"ce/main_menu.multiplayer_type_select.connected.xml",
|
||||
"ce/main_menu.multiplayer_type_select.coop.xml",
|
||||
"ce/main_menu.multiplayer_type_select.direct_ip.xml",
|
||||
"ce/main_menu.multiplayer_type_select.join_game.filters.xml",
|
||||
"ce/main_menu.multiplayer_type_select.join_game.port.xml",
|
||||
@@ -16,6 +17,7 @@
|
||||
"ce/main_menu.multiplayer_type_select.mp_map_select.xml",
|
||||
"ce/main_menu.multiplayer_type_select.server_settings.xml",
|
||||
"ce/main_menu.multiplayer_type_select.xml",
|
||||
"ce/main_menu.new_select.port.xml",
|
||||
"ce/main_menu.new_select.xml",
|
||||
"ce/main_menu.player_profiles_select.xml",
|
||||
"ce/main_menu.profile_manager.xml",
|
||||
@@ -49,9 +51,19 @@
|
||||
"ce/main_menu.xml",
|
||||
"ce/shell.xml",
|
||||
"ce/strings.xml",
|
||||
"ce/port/blank__0.png",
|
||||
"ce/port/main_menu/multiplayer_type_select/coop/header_player_2.png",
|
||||
"ce/port/main_menu/multiplayer_type_select/join_game/header_direct_link.png",
|
||||
"ce/port/main_menu/multiplayer_type_select/join_game/header_password.png",
|
||||
"ce/port/main_menu/multiplayer_type_select/join_game/header_server_browser.png",
|
||||
"ce/port/main_menu/multiplayer_type_select/lobby/header_add_player.png",
|
||||
"ce/port/main_menu/multiplayer_type_select/lobby/header_lobby.png",
|
||||
"ce/port/pause/pausebox_center__0.png",
|
||||
"ce/port/pause/pausebox_center__1.png",
|
||||
"ce/port/pause/pausebox_left__0.png",
|
||||
"ce/port/pause/pausebox_left__1.png",
|
||||
"ce/port/pause/pausebox_right__0.png",
|
||||
"ce/port/pause/pausebox_right__1.png",
|
||||
"ce/shell/bitmaps/alert_bkd__0.png",
|
||||
"ce/shell/bitmaps/arrow_sm_down__0.png",
|
||||
"ce/shell/bitmaps/arrow_sm_down__1.png",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4"/>
|
||||
|
After Width: | Height: | Size: 81 B |
@@ -0,0 +1,13 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="64" viewBox="0 0 512 64">
|
||||
<defs>
|
||||
<filter id="soft" filterUnits="userSpaceOnUse" x="-60" y="-60" width="632" height="184">
|
||||
<feGaussianBlur stdDeviation="14.23 13.06"/>
|
||||
</filter>
|
||||
<mask id="cut" maskUnits="userSpaceOnUse" x="0" y="0" width="512" height="64">
|
||||
<rect width="512" height="59" fill="#fff"/>
|
||||
</mask>
|
||||
</defs>
|
||||
<g mask="url(#cut)">
|
||||
<rect x="29.08" y="28.05" width="323.93" height="40.95" fill="#021931" fill-opacity="0.893" filter="url(#soft)"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 563 B |
@@ -0,0 +1,13 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="64" viewBox="0 0 512 64">
|
||||
<defs>
|
||||
<filter id="soft" filterUnits="userSpaceOnUse" x="-60" y="-60" width="632" height="184">
|
||||
<feGaussianBlur stdDeviation="14.23 13.06"/>
|
||||
</filter>
|
||||
<mask id="cut" maskUnits="userSpaceOnUse" x="0" y="0" width="512" height="64">
|
||||
<rect width="512" height="59" fill="#fff"/>
|
||||
</mask>
|
||||
</defs>
|
||||
<g mask="url(#cut)">
|
||||
<rect x="29.08" y="28.05" width="216.45" height="40.95" fill="#021931" fill-opacity="0.893" filter="url(#soft)"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 563 B |
@@ -0,0 +1,13 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="64" viewBox="0 0 512 64">
|
||||
<defs>
|
||||
<filter id="soft" filterUnits="userSpaceOnUse" x="-60" y="-60" width="632" height="184">
|
||||
<feGaussianBlur stdDeviation="14.23 13.06"/>
|
||||
</filter>
|
||||
<mask id="cut" maskUnits="userSpaceOnUse" x="0" y="0" width="512" height="64">
|
||||
<rect width="512" height="59" fill="#fff"/>
|
||||
</mask>
|
||||
</defs>
|
||||
<g mask="url(#cut)">
|
||||
<rect x="29.08" y="28.05" width="226.48" height="40.95" fill="#021931" fill-opacity="0.893" filter="url(#soft)"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 563 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="256" viewBox="0 0 4 256">
|
||||
<rect x="0" y="2" width="4" height="190" fill="#0a2649" fill-opacity="0.75"/>
|
||||
<rect x="0" y="0" width="4" height="2" fill="#2896ff"/>
|
||||
<rect x="0" y="192" width="4" height="2" fill="#2896ff"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 289 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="256" viewBox="0 0 4 256">
|
||||
<rect x="0" y="2" width="4" height="225" fill="#0a2649" fill-opacity="0.75"/>
|
||||
<rect x="0" y="0" width="4" height="2" fill="#2896ff"/>
|
||||
<rect x="0" y="227" width="4" height="2" fill="#2896ff"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 289 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="256" viewBox="0 0 16 256">
|
||||
<path d="M9.5,1 H17 V193 H9.5 A8.5,8.5 0 0 1 1,184.5 V9.5 A8.5,8.5 0 0 1 9.5,1 Z" fill="#0a2649" fill-opacity="0.75" fill-rule="evenodd"/>
|
||||
<path d="M17,1 H9.5 A8.5,8.5 0 0 0 1,9.5 V184.5 A8.5,8.5 0 0 0 9.5,193 H17" fill="none" stroke="#2896ff" stroke-width="2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 360 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="256" viewBox="0 0 16 256">
|
||||
<path d="M9.5,1 H17 V228 H9.5 A8.5,8.5 0 0 1 1,219.5 V9.5 A8.5,8.5 0 0 1 9.5,1 Z" fill="#0a2649" fill-opacity="0.75" fill-rule="evenodd"/>
|
||||
<path d="M17,1 H9.5 A8.5,8.5 0 0 0 1,9.5 V219.5 A8.5,8.5 0 0 0 9.5,228 H17" fill="none" stroke="#2896ff" stroke-width="2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 360 B |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="256" viewBox="0 0 16 256">
|
||||
<g transform="matrix(-1 0 0 1 16 0)">
|
||||
<path d="M9.5,1 H17 V193 H9.5 A8.5,8.5 0 0 1 1,184.5 V9.5 A8.5,8.5 0 0 1 9.5,1 Z" fill="#0a2649" fill-opacity="0.75" fill-rule="evenodd"/>
|
||||
<path d="M17,1 H9.5 A8.5,8.5 0 0 0 1,9.5 V184.5 A8.5,8.5 0 0 0 9.5,193 H17" fill="none" stroke="#2896ff" stroke-width="2"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 411 B |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="256" viewBox="0 0 16 256">
|
||||
<g transform="matrix(-1 0 0 1 16 0)">
|
||||
<path d="M9.5,1 H17 V228 H9.5 A8.5,8.5 0 0 1 1,219.5 V9.5 A8.5,8.5 0 0 1 9.5,1 Z" fill="#0a2649" fill-opacity="0.75" fill-rule="evenodd"/>
|
||||
<path d="M17,1 H9.5 A8.5,8.5 0 0 0 1,9.5 V219.5 A8.5,8.5 0 0 0 9.5,228 H17" fill="none" stroke="#2896ff" stroke-width="2"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 411 B |
@@ -0,0 +1,10 @@
|
||||
# The public MQTT brokers of internet play: the machines of an invite find
|
||||
# each other through them, and the server browser's listings go through
|
||||
# them. The game uses every one at once (up to 4), so any one working is
|
||||
# enough. One host:port on each line; "#" starts a comment.
|
||||
# (The game reads this file beside config.toml: network.brokers_file. An
|
||||
# update replaces it; keep a list of your own under another name.)
|
||||
opence.milenko.org:1883
|
||||
broker.emqx.io:1883
|
||||
broker.hivemq.com:1883
|
||||
test.mosquitto.org:1883
|
||||
@@ -21,6 +21,69 @@ with ideas from VALORANT's netcode articles, keeping the 30 Hz tick:
|
||||
vehicle it drives) from its local input at once. Remote players are
|
||||
driven by the inputs the host relays every tick, the latest one held
|
||||
until a newer arrives.
|
||||
- **Actors driven.** Only the host runs the AI. Each tick it sends its
|
||||
clients the control its actors gave their units (how they move, where
|
||||
they face, aim and look, their trigger and buttons, their animation
|
||||
impulses) with the units' state, those near a client's players every
|
||||
tick and others less often; a client drives each unit with the latest
|
||||
it has, as it drives a remote player's, until it hears nothing of it for
|
||||
two seconds (`port/linux/game/network_actors.c`).
|
||||
- **Co-op.** A network game on a campaign level with no game engine
|
||||
(Create Game's Map screen, its SINGLEPLAYER maps, over LAN and the
|
||||
internet) is co-op. Only the host runs the
|
||||
level's scripts and spawns players. `network_coop.c` sends the clients
|
||||
everything the scripts do that they would otherwise miss:
|
||||
- every tick: the cinematic, camera, screen fade, the HUD settings the
|
||||
scripts control (what is shown, the mission timer), the skip vote, and
|
||||
which teams are allies and friends (the scripts' allegiances, so the
|
||||
marines are the players' allies on every machine);
|
||||
- once each, numbered so nothing is applied twice: script sounds,
|
||||
chapter titles, help and objective text, "Checkpoint" messages, screen
|
||||
shake, nav points, custom animations on units and scenery, and units
|
||||
opening and closing (dropships' doors);
|
||||
- device groups (doors, elevators, switches; a client sets none itself,
|
||||
and its player's use of one is relayed to the host), and each device's
|
||||
position and power as it changes: a client puts its device where the
|
||||
host's is once that stops, or if they drift apart while it moves;
|
||||
- which named objects exist, so scripted creates and deletes match.
|
||||
|
||||
Every machine follows the host's structure BSP: a switch is sent at once
|
||||
and reliably, and each client's input says which BSP it has loaded.
|
||||
Until a client has the host's, the host takes none of its players'
|
||||
movement and none of its loading zones, and after any switch no loading
|
||||
zone switches again until every machine has the new BSP (ten seconds at
|
||||
most). A loading zone into a
|
||||
BSP the team hasn't been in brings every player to whoever crossed it,
|
||||
as split screen does; one back into a BSP it has been in switches only
|
||||
with two thirds of the living players at it (in the trigger, or within
|
||||
15 world units of the player in it, about 45 metres), so one player can't
|
||||
drag the team back through the level; a player held back is told how
|
||||
many are there and how many it needs. A player outside the loaded BSP
|
||||
and falling for two seconds is brought back beside a teammate. A dead
|
||||
player watches a living teammate (`coop_spectate.c`) and comes back
|
||||
beside one once it is safe. With everyone dead they come back where they
|
||||
were at the last checkpoint, without a revert. A mission the scripts fail
|
||||
with players still alive reverts to the last checkpoint on the host, as a
|
||||
skipped cutscene does (below); a client never reverts on its own. A level
|
||||
won ends the round as in multiplayer, and the next round is the
|
||||
campaign's next level.
|
||||
|
||||
Cutscenes are skipped by vote: more than half the machines must press
|
||||
skip. The host then reverts as single player does, but keeps its clock
|
||||
moving forward (the netcode depends on that) and moves the script
|
||||
threads' wake times along with it. The object, device and name syncs
|
||||
bring the clients up to date.
|
||||
|
||||
The host's EXTRA ENEMIES (`coop_enemies.c`, `network.coop_enemies_mode`)
|
||||
give each squad of enemies a level places more of itself: PER PLAYER, a
|
||||
percentage of itself for each player past the first; STATIC MULTIPLIER,
|
||||
that many times itself for any number of players. They stand around its
|
||||
starting locations on free ground (the same floor, clear of crates and
|
||||
other actors, with room to stand), or where none is left on rings about
|
||||
them as before, and never take the actors a level needs for its own (the
|
||||
actor pool, `halo_port_capacity.h`, holds 1024). Riders a dropship has no
|
||||
seats for are kept, and placed beside its riders once they get out. Only
|
||||
the host runs the AI, so the clients see them as the host's other actors.
|
||||
- **Host authoritative.** The host alone decides damage, deaths, spawns,
|
||||
pickups, scores and the game's objects; clients do not decide them but
|
||||
apply what the host sends.
|
||||
@@ -93,7 +156,24 @@ is dead; version 8 is the first whose clients play by the host's rules
|
||||
(below), so a build without them joins no host of it; version 9 tells
|
||||
every machine of a player the host dropped for cheating, each client
|
||||
tells the host its Discord user, and a machine's join request carries its
|
||||
hardware id; version 10 sends every player's ping for the scoreboard.
|
||||
hardware id; version 10 sends every player's ping for the scoreboard;
|
||||
version 11 sends with the game's settings its gametype's PC options;
|
||||
version 12 plays the campaign together (co-op, above), drives the host's
|
||||
actors on its clients and sends the flinches and deaths the host picked;
|
||||
version 13 drives up to 1056 of the host's AI units on its clients (co-op's
|
||||
extra enemies), where 12 drove 288; version 14 sends co-op's device positions
|
||||
and its units opening and closing; version 15 sends co-op's allegiances with
|
||||
its presentation, a message of another size; version 16 has a client's input
|
||||
say which structure BSP it has loaded (co-op); version 17 breaks the host's
|
||||
glass and destructible scenery on every machine (and takes a client's hits on
|
||||
scenery), sends the cluster a co-op cutscene keeps active, and leaves a
|
||||
failed co-op mission's revert to the host; version 18 sends with an object
|
||||
the bitmap of its shaders it draws with when its actor variant set one (co-op:
|
||||
the Elite major's and commander's armor); version 19 sends with the game's
|
||||
settings whether co-op's players collide with each other (Server Setup's PLAYER
|
||||
COLLISIONS: each machine's players then pass through the others'); version 20
|
||||
lists a public game with a password with its invite's token sealed with the
|
||||
password's key (`p2p_lobby.c`), a listing of another layout.
|
||||
|
||||
A client plays by its host's rules: in another's game (searching for it,
|
||||
in its lobby, or playing it) the developer console, the telnet console
|
||||
@@ -115,9 +195,13 @@ only ever jumps forward to it when behind, so an honest one is never ahead
|
||||
while going faster (one that caught up, or a host that stalled, is one or
|
||||
the other, not both). One more than a tenth faster and half a second ahead
|
||||
has its players' predictions refused at once (the host's copies go as its
|
||||
own ticks have them), and after ten seconds of it is dropped, its address
|
||||
kept out of the host's games while the host runs, and every machine is
|
||||
told who, in red on its console and in its `debug.txt`
|
||||
own ticks have them), and after ten seconds of it is dropped, and every
|
||||
machine is told who, in red on its console and in its `debug.txt`. Its
|
||||
address is kept out of the host's games while the host runs only when a
|
||||
message that came over its connection's stream was that far ahead too: a
|
||||
datagram is known to be the machine's only by the address it came from,
|
||||
which another machine can send one as, so on its datagrams alone it is
|
||||
dropped, logged, and may join again
|
||||
(`distributed_note_client_clock`, `network_game_server_kick_machine`,
|
||||
`_distributed_message_notice`). The host also adds a line to
|
||||
`cheaters.txt` beside its `debug.txt`: when, the player's address (an
|
||||
@@ -132,13 +216,16 @@ A joining machine tells the host its hardware id: a keyed hash (HMAC-SHA-256,
|
||||
16 bytes as hex) of what its machine is known by (Windows' SMBIOS UUID, else
|
||||
its MachineGuid; Linux's `/etc/machine-id`; Android's `ANDROID_ID`, which the
|
||||
launcher writes to `hardware_id.txt`: `p2p_hardware_id`), kept by the host
|
||||
as hex only. A player dropped for cheating, and one the host bans with the
|
||||
as hex only. A player dropped for cheating (on its stream's word, as
|
||||
above), and one the host bans with the
|
||||
console's `ban <player name>` (Tab completes the name; the host's alone), is
|
||||
added to `bans.txt` beside `debug.txt` (a line each, as in `cheaters.txt`,
|
||||
with `ip=` and `hwid=`): the host refuses a machine joining whose address or
|
||||
hardware id is in it (a line taken out unbans). Both are as the player's
|
||||
machine tells them: anyone with administrator or root access can change
|
||||
them, and players behind one address share it.
|
||||
them, and players behind one address share it. The console's `kick <player
|
||||
name>` drops a player as `ban` does (every machine told), but adds no line
|
||||
and keeps no address out: the player may join again at once.
|
||||
A speed hack of less than a tenth is let be: the host's bounds on how far
|
||||
and how fast a client's player moves and fires hold it to the host's time
|
||||
anyway.
|
||||
@@ -282,8 +369,10 @@ a pregame keep-alive every five seconds from the host
|
||||
host's latest tick it had heard of when it made the report.
|
||||
- The host deals a report once it has checked it: from that machine's
|
||||
player; damage one of their weapons (a vehicle's a driver's or
|
||||
gunner's; now or in the last ten seconds), their grenades (while they
|
||||
have them, and for a while after) or the vehicle they drove (in the
|
||||
gunner's; now or in the last ten seconds), a grenade the host's own game
|
||||
saw them throw in the last ten seconds that has not gone off (each
|
||||
throw's explosion is taken once, its other hits that tick with it:
|
||||
holding grenades deals nothing) or the vehicle they drove (in the
|
||||
last ten seconds: its collisions) can deal (its projectiles' impacts
|
||||
and detonations, followed through the tags), no harder than it can be
|
||||
(all of it, but an airborne melee blow's half again); of the shape the
|
||||
|
||||
@@ -83,7 +83,8 @@ These files are in the data root:
|
||||
| `init.txt` | Console commands that the game does at start-up. For example, `map_name levels\a10\a10` starts the first campaign level. |
|
||||
|
||||
The settings are in `config.toml` next to the executable. Refer to
|
||||
"Settings".
|
||||
"Settings". Internet play's MQTT brokers are in `brokers.txt` next to it
|
||||
(`network.brokers_file`).
|
||||
|
||||
If the game stops because of a fatal signal, it writes the address and a
|
||||
backtrace to the standard error. To find the function at the address, enter
|
||||
@@ -95,8 +96,12 @@ The keyboard and the mouse are a control scheme of their own for the player
|
||||
of controller 1: each action has up to two keys or mouse buttons, which
|
||||
Settings > Controls Setup (or `[controls]` in `config.toml`) changes. The
|
||||
game adds the input of the first gamepad to controller 1. The other
|
||||
gamepads operate controllers 2 to 4. The profile's button layout (Settings >
|
||||
Gamepads) is the gamepads' only.
|
||||
gamepads operate controllers 2 to 4. With two or more players on this
|
||||
computer (co-op, or split screen in a network game) and only one gamepad,
|
||||
that gamepad is controller 2 (player 2) and the keyboard and mouse stay
|
||||
controller 1. The gamepad changes controller only when none of its buttons
|
||||
is held. The profile's button layout (Settings > Gamepads) is the
|
||||
gamepads' only.
|
||||
|
||||
| Action | Keys and buttons (default) |
|
||||
| --- | --- |
|
||||
@@ -157,6 +162,37 @@ change. The screens open, close and move between each other as the PC
|
||||
version's. `display.menus = "xbox"` gives the Xbox's menus, which start every
|
||||
kind of game.
|
||||
|
||||
Multiplayer > CO-OP CAMPAIGN is the Xbox's cooperative play, which the PC
|
||||
version does not have: two players on this computer play the campaign in
|
||||
split screen. Player 1 is the player who chose it, on the current profile.
|
||||
Player 2 then chooses a profile with their own controller (a gamepad), and
|
||||
New Game's levels are those either profile has reached. Either player's
|
||||
controller chooses the level and the difficulty. A co-op game does
|
||||
not continue a saved game of one player.
|
||||
|
||||
Network games have split screen too: up to 4 players on each computer. In
|
||||
the game lobby, another controller presses START to join, and the new
|
||||
player's profile is chosen on the ADD PLAYER screen that opens (with any
|
||||
controller). With one gamepad, choose the lobby's ADD PLAYER button first:
|
||||
until then that gamepad shares controller 1 with the keyboard. Two players on one profile get different names from the host. A
|
||||
player's B in the lobby leaves the game alone, and the last player of the
|
||||
computer leaves it for all of them. In the game, each player's pause menu
|
||||
opens on their part of the screen, and its LEAVE GAME is theirs: their part
|
||||
of the screen stays until the game ends. A game under way shows its own
|
||||
screen before JOIN GAME: players join there the same way, START or ADD
|
||||
PLAYER then START, and JOIN GAME brings them all into the game.
|
||||
|
||||
In a multiplayer game, the pause menu (escape) has SETTINGS, which opens
|
||||
the profile's settings while the game goes on, and for the host END GAME.
|
||||
END GAME ends the game as its time limit does: the players stay, and after
|
||||
the carnage report the host picks the next map and gametype (PICK GAME).
|
||||
LEAVE GAME of the host still ends the game for everyone. The buttons go into
|
||||
the map's own pause menu, before LEAVE GAME, so the buttons of a custom map
|
||||
stay. The Xbox's pause box is drawn taller to hold them (a redraw,
|
||||
`port/assets/menus/port_svg/pause`); a custom map's box keeps its size, and
|
||||
what is below its list moves down. The few pictures of the settings that
|
||||
come from the main menu's map are not drawn there.
|
||||
|
||||
The menus are XML files in `port/assets/menus` (`tools/ce_menus.py` writes
|
||||
them from the PC version's tags), which the game contains. To change them,
|
||||
put files in a `menus` folder next to `config.toml`: a file with the same
|
||||
@@ -184,26 +220,33 @@ the setting for one start of the game. It has priority over the file.
|
||||
|
||||
| Setting | Default | Environment variable | Function |
|
||||
| --- | --- | --- | --- |
|
||||
| `display.mode` | `""` | `HALO_DISPLAY_MODE` | `"fullscreen"`: the display, taken at its desktop resolution. `"borderless"`: a window over the whole desktop. Both draw at the resolution of the display, the picture 480 lines of the game and the width of the display. `"windowed"`: a window with the 640x480 picture of the Xbox, scaled. Empty: `display.fullscreen` decides (`true`: borderless). F11 changes between the window and the fullscreen mode. Video Setup sets it. |
|
||||
| `display.fullscreen` | `true` | `HALO_FULLSCREEN` | `true`: fullscreen at the resolution of the display. The picture has 480 lines of the game and the width of the display. `false`: a window with the 640x480 picture of the Xbox. Used when `display.mode` is empty. |
|
||||
| `display.window_scale` | `2` | `HALO_WINDOW_SCALE` | The size of the window, as a multiple of 640x480. You can change the size of the window. |
|
||||
| `display.mode` | `""` | `HALO_DISPLAY_MODE` | `"fullscreen"`: the display, taken at the mode of `display.resolution` (the nearest the display has), or at its desktop mode. `"borderless"`: a window over the whole desktop, whose mode does not change. `"windowed"`: a window of `display.window_size`. Empty: `display.fullscreen` decides (`true`: borderless). F11 changes between the window and the fullscreen mode. Video Setup sets it. |
|
||||
| `display.fullscreen` | `true` | `HALO_FULLSCREEN` | `true`: borderless, as `display.mode = "borderless"`. `false`: a window, as `display.mode = "windowed"`. Used when `display.mode` is empty. |
|
||||
| `display.resolution` | `"native"` | `HALO_RESOLUTION` | What fullscreen and borderless draw at: `"native"`, the display's own resolution, or `"<width>x<height>"`, such as `"1920x1080"`, 640x480 or more. Fullscreen sets the display to it. Borderless draws at it and scales the picture to the display, where the display has room for it. The picture has 480 lines of the game and the width of the resolution's shape. A window draws at its own size instead. Video Setup's Resolution sets it, from the display's modes; it shows with Fullscreen and Borderless. |
|
||||
| `display.resolution_scaling` | `"native"` | `HALO_RESOLUTION_SCALING` | `"native"`: the game draws at the resolution of the window, or of the display (or `display.resolution`) fullscreen. `"original"`: the game draws the 640x480 picture of the Xbox and scales it up to the window or the display, whatever `display.mode` is. Video Setup sets it. |
|
||||
| `display.window_size` | `""` | `HALO_WINDOW_SIZE` | The size of the window, as `"<width>x<height>"`, such as `"1920x1080"`, 640x480 or more. You can change the size of the window; the game's picture takes its shape. Empty: `display.window_scale` decides. Video Setup's Window Size sets it, from sizes of each shape (4:3, 16:10, 16:9 and 21:9) that fit the desktop; it shows with Windowed. |
|
||||
| `display.window_scale` | `2` | `HALO_WINDOW_SCALE` | Used when `display.window_size` is empty: the size of the window, as a multiple of 640x480. |
|
||||
| `display.vsync` | `true` | `HALO_NO_VSYNC=1` sets `false` | `true`: each frame waits for the display. |
|
||||
| `display.max_fps` | `0` | `HALO_MAX_FPS` | With vsync off, the most frames each second. `0`: twice the display's refresh rate. `-1`: no limit, which can hang some Intel graphics (Raptor Lake), resetting the desktop's graphics too. |
|
||||
| `display.anti_aliasing` | `"off"` | `HALO_ANTI_ALIASING` | The smoothing of jagged edges, which the Xbox did not have. `"off"`: none, as on the Xbox. `"fxaa"` or `"smaa"`: a pass over the 3D view after the game draws it. The HUD and the menus stay sharp. SMAA is the sharper and costs more. `"ssaa2x"`: the game draws at two times the resolution in each direction (at most the GPU's largest texture), and the picture is scaled down. The GPU does four times the work. Not with `display.resolution_scaling = "original"`. `"msaa2x"`, `"msaa4x"` or `"msaa8x"`: each pixel of the 3D view has that many samples (at most the GPU's). On Android, `"smaa"` gives FXAA and `"ssaa2x"` none. A change applies from the next frame. Refer to "Anti-aliasing" in "What operates". |
|
||||
| `debug.gpu_flush_draws` | `-1` | `HALO_GPU_FLUSH_DRAWS` | Flush the GPU's pipeline every this many draws. `-1`: every 3 on Intel graphics with Mesa's driver, which can otherwise hang in the game's long runs of small draws and reset the desktop's graphics too. `0`: never. |
|
||||
| `display.interpolation` | `true` | `HALO_INTERPOLATION` | `true`: one frame for each refresh of the display. `false`: 30 frames each second, as on the Xbox. Refer to "Frame rate". |
|
||||
| `display.direct_camera` | `true` | `HALO_DIRECT_CAMERA` | `true`: in first person, on foot, the view points where the player aims in each frame, not where the last tick left it. Refer to "Frame rate". |
|
||||
| `display.high_res_hud` | `true` | `HALO_HIGH_RES_HUD` | `true`: the HUD (meters, counters, panels and their outlines, the motion sensor, reticles, waypoints, scopes) is drawn from the high-res assets in `port/assets/hud`, 8x the size of the maps' bitmaps. The bitmaps with English text keep the maps' own. `false`: the maps' own bitmaps. |
|
||||
| `display.high_res_text` | `true` | `HALO_HIGH_RES_TEXT` | `true`: the menus' and HUD's text is drawn with the fonts in `port/assets/fonts` (Overpass, in place of the maps' Interstate) at the display's resolution, laid out as before, and the menus' titles are drawn from the high-res pictures in `port/assets/titles`. `false`: the maps' bitmap fonts and titles. |
|
||||
| `display.high_res_text` | `true` | `HALO_HIGH_RES_TEXT` | `true`: the menus' and HUD's text is drawn with the fonts in `port/assets/fonts` (Overpass, in place of the maps' Interstate) at the resolution the game draws at, laid out as before, and the menus' titles are drawn from the high-res pictures in `port/assets/titles`. `false`: the maps' bitmap fonts and titles. |
|
||||
| `display.shadow_resolution` | `128` | `HALO_SHADOW_RESOLUTION` | The size of the maps that the shadows of the objects are drawn in, in pixels each way: `128`, `256`, `512` or `1024` (other values go down to one of these). The game draws the shadow of each object into a map of 128x128 pixels, blurs it and projects it onto the ground. On a large screen, the edges of these shadows show steps that move when the object moves. A larger map makes the edges smooth; the blur is made wider to match, so the shadows are as soft as on the Xbox. Each doubling adds two passes of the blur. `128`: as on the Xbox. |
|
||||
| `display.menus` | `"pc"` | `HALO_MENUS` | `"pc"`: the PC version's menus, from the files in `port/assets/menus` and a `menus` folder next to `config.toml`. Refer to "Menus". `"xbox"`: the Xbox's menus. |
|
||||
| `display.player_names` | `"all"` | `HALO_PLAYER_NAMES` | In multiplayer, whose names are drawn above their heads: `"all"`, `"allies"`, `"enemies"` or `"none"`. An ally's name is drawn above the triangle the game shows over teammates. An enemy's name shows only while the enemy is in sight and not camouflaged, so it never shows where an enemy hides, and only as far away as the weapon in hand turns its reticle red over an enemy (at least 20 world units, the motion sensor's reach, and at most 70). |
|
||||
| `display.player_names` | `"all"` | `HALO_PLAYER_NAMES` | In multiplayer, whose names are drawn above their heads: `"all"`, `"allies"`, `"enemies"` or `"none"`. An ally's name is drawn above the triangle the game shows over teammates. An enemy's name shows only within the motion sensor's reach, while the enemy is in sight and not camouflaged, so it never shows where an enemy hides. The gametype's motion tracker setting also applies: no names if it shows no players, only allies' if it shows only friends. |
|
||||
| `display.player_name_scale` | `1.0` | `HALO_PLAYER_NAME_SCALE` | How large the players' names are drawn: `1.0` is three quarters of the size of the HUD's text, from `0.25` to `4`. With high-res text, larger names are rasterized at their size, so they stay sharp. |
|
||||
| `display.scoreboard_team_layout` | `"teams"` | `HALO_SCOREBOARD_TEAM_LAYOUT` | How the multiplayer scoreboard (hold BACK, or tab) lists a team game's players. `"teams"`: a column for each team, red on the left and blue on the right. `"score"`: all the players in order of score. With more players than fit, the mouse wheel and Page Up / Page Down scroll the scoreboard. |
|
||||
| `display.scoreboard_background` | `true` | `HALO_SCOREBOARD_BACKGROUND` | `true`: the multiplayer scoreboard (hold BACK, or tab) has a panel behind its text, for clearer text. |
|
||||
| `display.scoreboard_background_color` | `"16, 16, 16, 150"` | `HALO_SCOREBOARD_BACKGROUND_COLOR` | The colour of the scoreboard's panel: `"red, green, blue, alpha"`, each from `0` to `255`. Alpha `0` is see-through, `255` is solid. |
|
||||
| `display.per_pixel_lighting` | `false` | `HALO_PER_PIXEL_LIGHTING` | `false`: the models (characters, weapons, vehicles, scenery) are lit at each vertex and the light is blended between them, as on the Xbox. The light across a curved surface then shows facets, and a point light that passes close lights only the vertices it reaches. `true`: the models are lit at each pixel by the same lights (the ambient light, two distant lights and two point lights), which changes their look. |
|
||||
| `audio.enabled` | `true` | `HALO_NO_AUDIO=1` sets `false` | `false`: no audio device. The sound continues without output. |
|
||||
| `audio.volume` | `1.0` | `HALO_VOLUME` | The master volume. |
|
||||
| `audio.music_volume` | `1.0` | `HALO_MUSIC_VOLUME` | The music's volume, of the master volume. |
|
||||
| `audio.effects_volume` | `1.0` | `HALO_EFFECTS_VOLUME` | The volume of the other sounds (effects and speech), of the master volume. |
|
||||
| `audio.reverb` | `true` | `HALO_REVERB` | `true`: the sounds of the world reverberate as the place the player is in does: the sound environments of the maps (a corridor, a cave, a large hall, outdoors) set the reverberation, as the I3DL2 reverb of the Xbox did. A sound behind a wall or a door is muffled in it too. `false`: no reverberation (sounds behind a wall are still muffled). |
|
||||
| `input.mouse_sensitivity` | `1.0` | `HALO_MOUSE_SENSITIVITY` | The multiplier for the mouse aim. |
|
||||
| `input.mouse_vertical_sensitivity` | `0.0` | `HALO_MOUSE_VERTICAL_SENSITIVITY` | The multiplier for the vertical mouse aim. `0`: the same as `input.mouse_sensitivity`. |
|
||||
| `input.invert_mouse` | `false` | `HALO_MOUSE_INVERT=1` sets `true` | `true`: the vertical mouse aim is inverted. |
|
||||
@@ -219,7 +262,15 @@ the setting for one start of the game. It has priority over the file.
|
||||
| `network.join_from_clipboard` | `true` | `HALO_NET_JOIN_FROM_CLIPBOARD` | `true`: when the game comes to the front, it joins the game of an invite link on the clipboard. |
|
||||
| `network.tunnel_port` | `0` | `HALO_NET_TUNNEL_PORT` | The UDP port for internet play. `0`: the game selects a port. Refer to "Internet play". |
|
||||
| `network.allow_upnp` | `true` | `HALO_NET_ALLOW_UPNP` | `true`: internet play can ask the router to forward its port (UPnP). `false`: the game does not ask. Refer to "Internet play". |
|
||||
| `network.signalling_brokers` | three public brokers | `HALO_NET_BROKERS` | The public MQTT brokers (`host:port`, with commas between them) that let the machines of an invite find each other. |
|
||||
| `network.public_lobby` | `true` | `HALO_NET_PUBLIC_LOBBY` | `true`: the server browser. Public games are listed, and Join Game > Server Browser shows them. `false`: no games are listed or shown. Refer to "Server browser". |
|
||||
| `network.host_public` | `true` | `HALO_NET_HOST_PUBLIC` | `true`: a new game of Create Game > Internet starts as PUBLIC. `false`: it starts as PRIVATE. LISTING in Server Setup changes it for each game. Refer to "Server browser". |
|
||||
| `network.coop_friendly_fire` | `"on"` | `HALO_NET_COOP_FRIENDLY_FIRE` | Whether the players of an online co-op game hurt each other: `"off"`, `"on"`, `"shields_only"` or `"explosives_only"`. FRIENDLY FIRE in co-op's Server Setup writes its choice here. Their AI allies they always can, as in the campaign. |
|
||||
| `network.coop_player_collisions` | `true` | `HALO_NET_COOP_PLAYER_COLLISIONS` | Whether the players of an online co-op game bump into each other. `false`: they walk through each other, so that one cannot block a doorway or stand on another; they still bump into the AI's characters. PLAYER COLLISIONS in co-op's Server Setup writes its choice here. |
|
||||
| `network.coop_enemies_mode` | `"per_player"` | `HALO_NET_COOP_ENEMIES_MODE` | Online co-op's extra enemies: `"none"`; `"per_player"`, each squad of enemies that a level places grows by `network.coop_enemies` for each player past the first; or `"multiplier"`, each squad is `network.coop_enemies_multiplier` times as large, for any number of players. The extra enemies stand around the squad's places, and those that a dropship has no seats for drop out of it after its passengers. EXTRA ENEMIES in co-op's Server Setup writes its choice here. |
|
||||
| `network.coop_enemies` | `50` | `HALO_NET_COOP_ENEMIES` | The extra enemies per player, a percentage from `25` to `200`: for each player past the first, each squad of enemies gets this much of itself more (`100`: as many again, so four players meet four times the squad). PER PLAYER in co-op's Server Setup writes its choice here. |
|
||||
| `network.coop_enemies_multiplier` | `2` | `HALO_NET_COOP_ENEMIES_MULTIPLIER` | The static multiplier of the enemies, `2` to `32`: each squad of enemies is this many times as large. MULTIPLIER in co-op's Server Setup writes its choice here. |
|
||||
| `network.coop_public` | `false` | `HALO_NET_COOP_PUBLIC` | `true`: an online co-op game (Create Game > Internet, a SINGLEPLAYER map) starts as PUBLIC. `false`: it starts as PRIVATE. LISTING in co-op's Server Setup writes its choice here. Refer to "Server browser". |
|
||||
| `network.brokers_file` | `"brokers.txt"` | `HALO_NET_BROKERS_FILE` | The file of the public MQTT brokers that let the machines of an invite find each other, and that carry the listings of the server browser: next to `config.toml`, unless a full path. One `host:port` on each line, up to 4; `#` starts a comment. |
|
||||
| `network.stun_servers` | Google and Cloudflare | `HALO_NET_STUN` | The public STUN servers (`host:port`, with commas between them) that give the internet address of a machine. |
|
||||
| `discord.application_id` | the application of the project | `HALO_DISCORD_APPLICATION` | The Discord application for invites. Empty: no Discord. |
|
||||
| `update.auto` | `true` | `HALO_UPDATE_AUTO` | `true`: at start-up, the game looks for a new version. Refer to "Updates". `false`: the game does not look. |
|
||||
@@ -402,17 +453,89 @@ When the machines connect, the game of the host shows in Multiplayer,
|
||||
System Link. Join the game as on a local network. System link on a local
|
||||
network does not need an invite.
|
||||
|
||||
### Server browser
|
||||
|
||||
Server Setup in Create Game > Internet has a LISTING row:
|
||||
|
||||
- PUBLIC (the default): the game also shows in Join Game > Server Browser
|
||||
on every machine. Anyone can see and join the game.
|
||||
- PRIVATE: only players with the invite link can join.
|
||||
|
||||
Each new game starts as PUBLIC (`network.host_public = false` makes new
|
||||
games start as PRIVATE). An online co-op game starts as PRIVATE, and keeps
|
||||
the last choice of its LISTING (`network.coop_public`). A LAN game is never listed. `network.public_lobby = false` turns the server browser off.
|
||||
|
||||
A PUBLIC game can also have a PASSWORD (a row of Server Setup, below
|
||||
LISTING). The Server Browser shows a lock at the left of a game with a
|
||||
password. A player who selects that game must type the password, and JOIN
|
||||
GAME joins only with the correct password. The invite link of the game joins
|
||||
it without the password. The host keeps the password only while the game
|
||||
runs.
|
||||
|
||||
In the Server Browser, select a game to join it. The game joins the invite
|
||||
of the game, as for a link. When it reaches the host, it opens the lobby.
|
||||
If it cannot reach the host in 30 seconds, it marks the game FAILED. A game
|
||||
that is full or starting shows CLOSED. REFRESH asks the hosts for their
|
||||
listings again.
|
||||
|
||||
How it operates (`src/p2p_lobby.c`):
|
||||
|
||||
- The host of a public game publishes a listing: the invite, and the name,
|
||||
map, gametype and player counts of the game. The listing goes to the
|
||||
same MQTT brokers as the invites (`network.brokers_file`), retained,
|
||||
to a topic of the host (`hceu/3/lobby/s/<hash of its key>`).
|
||||
- The key of the host signs the listing (Ed25519). The key is the key of the
|
||||
invite, so no other machine can list the invite of the host, change its
|
||||
listing, or list a game with false details.
|
||||
- The host publishes the listing again every 30 seconds, when the game
|
||||
changes, and when a browser asks. If the topic of the host is empty or
|
||||
holds another listing, the host publishes again in 5 seconds or less. Thus
|
||||
a broker that deletes the listing does not remove the game.
|
||||
- When the host stops (it stops hosting, the game becomes private, or the
|
||||
game quits), it publishes a closed listing, and then empties its topic.
|
||||
If the host loses its connection, the broker empties its topic (the will
|
||||
of the connection). A browser removes a game that it does not hear for 90
|
||||
seconds.
|
||||
- When a public game becomes private, the host makes a new invite. Thus a
|
||||
player who saw the listing cannot join with the old invite.
|
||||
- The listing of a game with a password does not hold the invite in clear
|
||||
text. The secret part of the invite (its token) is encrypted with a key
|
||||
from the password (Argon2id, salted with the key of the host, then
|
||||
XChaCha20-Poly1305). The browser makes the key from the password that the
|
||||
player types, and opens the invite only if the password is correct. When
|
||||
the host sets or changes the password, it makes a new invite. A player who
|
||||
has the listing can try passwords on their own machine without the host,
|
||||
so use a long password.
|
||||
|
||||
A public game does not publish the address of the host. But any machine
|
||||
with the invite can ask the host to connect, and the host then sends its
|
||||
addresses. Thus anyone can learn the address of the host of a public game,
|
||||
as for any public server.
|
||||
|
||||
The brokers are in `brokers.txt` next to the executable (from
|
||||
`port/assets/network/brokers.txt`; on Android, the app writes it next to
|
||||
`config.toml` at each start), one `host:port` on each line. The game uses
|
||||
all of them at once (up to 4), so one that works is enough. An update
|
||||
replaces `brokers.txt`: to use brokers of your own, put them in another
|
||||
file and name it in `network.brokers_file`. All the players must use the
|
||||
same broker to see each other's games. The game uses
|
||||
MQTT 5 if the broker has it, else MQTT 3.1.1. A broker that does not keep
|
||||
retained messages, or does not let clients subscribe with wildcards, carries
|
||||
only invites, not listings.
|
||||
|
||||
### Security
|
||||
|
||||
Only machines with the invite can find the game:
|
||||
|
||||
- Each copy of the game makes an X25519 key pair when it starts. Its
|
||||
identifier is from the hash of its public key.
|
||||
- Each copy of the game makes an Ed25519 key pair when it starts, and from
|
||||
it an X25519 key pair (Monocypher, `port/third_party/monocypher`). Its
|
||||
identifier is from the hash of its X25519 public key. The Ed25519 key
|
||||
signs the listing of a public game.
|
||||
- The link contains a 16-byte hash of the public key of the host and a
|
||||
random 16-byte token. The identifier of the host is from the first 6
|
||||
bytes of the hash.
|
||||
- The machines exchange their public keys and addresses through public MQTT
|
||||
brokers (`network.signalling_brokers`). The topics are HMACs of the token.
|
||||
brokers (`network.brokers_file`). The topics are HMACs of the token.
|
||||
A key from the token encrypts and authenticates the messages
|
||||
(`src/p2p_signal.c`, `src/p2p_crypto.c`). The host authenticates its answer
|
||||
with a key that only it and the player can calculate. Its public key must
|
||||
@@ -444,15 +567,20 @@ Only machines with the invite can find the game:
|
||||
flood of requests can make players join more slowly. A player asks again
|
||||
for 90 seconds.
|
||||
- The host drops a player whose game runs faster than time (a speed hack)
|
||||
for ten seconds, and keeps that address out of its games. Each player
|
||||
sees who in red on the console. The host adds a line to `cheaters.txt`
|
||||
(beside `debug.txt`) with the address and hardware id of the player, and
|
||||
the Discord name and id that the game of the player told it (a player can
|
||||
change these). The host also bans the player: it adds the line to
|
||||
`bans.txt`, and refuses a machine whose address or hardware id is in it.
|
||||
for ten seconds. Each player sees who in red on the console. The host
|
||||
adds a line to `cheaters.txt` (beside `debug.txt`) with the address and
|
||||
hardware id of the player, and the Discord name and id that the game of
|
||||
the player told it (a player can change these). If the messages on the
|
||||
player's connection were also ahead, the host keeps that address out of
|
||||
its games and bans the player: it adds the line to `bans.txt`, and refuses
|
||||
a machine whose address or hardware id is in it. If only the player's
|
||||
datagrams were ahead, the player can join again: another machine can send
|
||||
datagrams with the player's address.
|
||||
- The host can ban a player with `ban <player name>` in the developer
|
||||
console (Tab completes the name). Remove a line from `bans.txt` to unban.
|
||||
Refer to `NETCODE.md`. So that every player can be named, the host trims
|
||||
Refer to `NETCODE.md`. `kick <player name>` drops the player the same
|
||||
way, but keeps nothing: no line in `bans.txt`, and the player can join
|
||||
again at once. So that every player can be named, the host trims
|
||||
the spaces around a name and removes characters that draw as nothing. A
|
||||
letter with a mark is typed as the plain letter (`ban jose` for "José").
|
||||
A name with nothing left to type becomes "Player", and a name that another
|
||||
@@ -522,7 +650,8 @@ The game sends the activity only to a Discord client of the same user.
|
||||
| Game code | All 466 C files of the game. The changes are in "Game source changes". |
|
||||
| Graphics | Direct3D 8 on OpenGL 4.5 core through SDL3 (`src/d3d8_gl.c`). The port translates the NV2A vertex shaders and register combiners to GLSL. It decodes all the Xbox texture formats. The vertex and index buffers come from a GL copy of the Xbox memory. |
|
||||
| High-res HUD | The HUD is drawn from high-res assets: redraws at 8x the size of the maps' bitmaps (4x for the largest), in `port/assets/hud`. They cover the meters, counters, panels and their outlines, the motion sensor, reticles, waypoints and scopes, but no bitmap with English text. `tools/hud_assets.py` makes them from the SVG redraws, and the build embeds them in the executable. When the game uploads one of those bitmaps, `src/hud_hires.c` gives the high-res texture in its place, if the bitmap's pixels are those of the English maps: another language's maps keep their own. The game sizes and places the HUD from its tags as before. `display.high_res_hud = false` turns this off. |
|
||||
| High-res text | The menus' and HUD's text is drawn with Overpass (`port/assets/fonts`, SIL Open Font License) in place of the maps' bitmap fonts, which are Interstate. `src/text_hires.c` rasterizes each glyph with stb_truetype (`port/third_party/stb`) at the display's resolution, into an atlas that a placeholder bitmap of the game stands for. The game lays the text out from its font tags as before. The menus' titles (the screens' headers and the main menu's items) are pictures of text in the maps, so they are drawn as the high-res HUD is: `tools/title_assets.py` sets each one again in OpenCE, Roger White's public-domain Newtown respaced to match the maps' commercial title typeface (`tools/title_font.py`), at 4x the bitmap's size over its own plate or glow, each letter placed where the map's letter is, in `port/assets/titles`. The postgame carnage report's title is set over a hand-made SVG redraw of its panel (`port/assets/titles/svg`) instead. `display.high_res_text = false` turns it off. |
|
||||
| High-res text | The menus' and HUD's text is drawn with Overpass (`port/assets/fonts`, SIL Open Font License) in place of the maps' bitmap fonts, which are Interstate. `src/text_hires.c` rasterizes each glyph with stb_truetype (`port/third_party/stb`) at the resolution the game draws at, into an atlas that a placeholder bitmap of the game stands for. The game lays the text out from its font tags as before. The menus' titles (the screens' headers and the main menu's items) are pictures of text in the maps, so they are drawn as the high-res HUD is: `tools/title_assets.py` sets each one again in OpenCE, Roger White's public-domain Newtown respaced to match the maps' commercial title typeface (`tools/title_font.py`), at 4x the bitmap's size over its own plate or glow, each letter placed where the map's letter is, in `port/assets/titles`. The postgame carnage report's title is set over a hand-made SVG redraw of its panel (`port/assets/titles/svg`) instead. `display.high_res_text = false` turns it off. |
|
||||
| Anti-aliasing | Off unless `display.anti_aliasing` is set (`src/d3d8_gl.c`, `src/xgpu_post.c`). FXAA (written in the port) and SMAA (`port/third_party/smaa`, MIT licensed, at its HIGH preset, compiled as GLSL) are passes over the 3D view of each window, after the lens flares and before the HUD and the menus (`render/render.c`). Their programs are built when the setting is chosen. Supersampling draws the render targets the size of the screen at two times the resolution in each direction, and the display blit scales them down. Multisampling draws the back buffer and its depth buffer into multisampled renderbuffers, and with them any target that is drawn together with one of them (a mirror's view, in the secondary target with the back buffer's depth buffer), so that the attachments of a framebuffer are all multisampled or none is. A target's pixels are resolved into its texture before something reads the texture (as a texture, or at the display blit). Visibility tests count samples, divided by the samples of a pixel. An alpha-tested surface (foliage, grates) covers the samples of a pixel in proportion to its alpha past the reference (`gl_SampleMask`, not on Android). |
|
||||
| Sound | Xbox DirectSound on SDL3 audio (`src/dsound_sdl.c`): PCM and Xbox ADPCM, mixed at 48 kHz, with volume, pitch, mix bins, distance, stereo pan, occlusion and obstruction. There is no Doppler effect, no cones and no reverb. |
|
||||
| Input | XInput on SDL3 (`src/xinput_sdl.c`): keyboard, mouse, gamepads with rumble, and the debug keyboard for the console. |
|
||||
| Files | The Win32 file functions and the MSVC file functions on POSIX, with the translation of Xbox paths. |
|
||||
@@ -608,11 +737,13 @@ Other changes:
|
||||
| `networking/`, `game/`, `interface/`, `bungie_net/network/` and the pools of objects, effects and sounds | The system link limits and the memory for them. |
|
||||
| `game/`, `objects/`, `units/`, `networking/` | The distributed netcode. Refer to `NETCODE.md`. |
|
||||
| `cache/cache_files.c` | When a map's tags load and unload, the port finds the bitmaps that the high-res HUD replaces (`game/hud_hires_tags.c`), and adds the tags of the menus to the menus' map (`game/menu_tags.c`). |
|
||||
| `interface/ui_widget.c`, `interface/ui_widget_event_handler_functions.c`, `interface/ui_widget_game_data_input_functions.c` | The main menu is the PC version's from `port/assets/menus` (`display.menus`); the menus' widgets can call the port's functions (`game/menu_functions.c`) and send the PC version's custom activation event; the widgets' memory is 256 KB, not 16 KB. |
|
||||
| `interface/ui_widget.c`, `interface/ui_widget_event_handler_functions.c`, `interface/ui_widget_game_data_input_functions.c` | The main menu is the PC version's from `port/assets/menus` (`display.menus`); the menus' widgets can call the port's functions (`game/menu_functions.c`) and send the PC version's custom activation event; the widgets' memory is 256 KB, not 16 KB; the main menu and Multiplayer clear co-op's controllers, so that a gamepad going back to controller 1 is not a controller unplugged; the lobby's split screen players leave alone, and one who quits in game is not joined to the next game (`interface/player_ui.c`). |
|
||||
| `input/input_abstraction.c`, `game/player_control.c`, `game/players.c`, `game/player_queues_new.c`, `units/units.h` | The keyboard and mouse's actions (`src/xinput_sdl.c`, `include/halo_keyboard.h`) join controller 1's game controls; their reload key reloads on its own, and their action key only acts (a control flag of the port's, sent with the player's action, stops the reload the controller's X falls back to). |
|
||||
| `sound/sound_manager.c`, `interface/hud.c`, `game/game_engine.c` | The music's and the other sounds' volumes; the HUD's and the scoreboard's settings are read again when Settings changes them. |
|
||||
| `rasterizer/xbox/rasterizer_xbox_shadows.c` | With larger shadow maps (`display.shadow_resolution`), the blur's taps stay half a texel apart, and more passes widen it to cover the same part of the map as on the Xbox. |
|
||||
| `render/render.c` | The 3D view of each window is antialiased before the HUD is drawn (`display.anti_aliasing`). |
|
||||
| `interface/hud.c` | In multiplayer, players' names are drawn above their heads (`display.player_names`, `display.player_name_scale`). |
|
||||
| `rasterizer/rasterizer_text.c`, `text/draw_string.c` | Text is drawn from an atlas of the fonts' glyphs, rasterized at the display's resolution (`src/text_hires.c`), when the font has every character of the string. Text can be drawn scaled about a point (`rasterizer_text_set_scale`), as the players' names are. Each glyph's advance is centred on the font tag character's, so the layout is the same, and a glyph is cut at a text box only where the font tag's character visibly was. |
|
||||
| `rasterizer/rasterizer_text.c`, `text/draw_string.c` | Text is drawn from an atlas of the fonts' glyphs, rasterized at the resolution the game draws at (`src/text_hires.c`), when the font has every character of the string. Text can be drawn scaled about a point (`rasterizer_text_set_scale`), as the players' names are. Each glyph's advance is centred on the font tag character's, so the layout is the same, and a glyph is cut at a text box only where the font tag's character visibly was. |
|
||||
|
||||
The x86 inline assembly of the game is replaced by C. Thus the compiler
|
||||
can optimize that code for each processor:
|
||||
|
||||
@@ -0,0 +1,677 @@
|
||||
/*
|
||||
COOP_ENEMIES.C
|
||||
|
||||
Network co-op's extra enemies: Server Setup's EXTRA ENEMIES
|
||||
(network.coop_enemies_mode). PER PLAYER (network.coop_enemies, a
|
||||
percentage): for each player past the first, each squad of the players'
|
||||
enemies that a level places (encounters.c's encounter_create) gets that
|
||||
much of its count more; at 100%, two players meet twice the squad, four
|
||||
players four times it. STATIC MULTIPLIER (network.coop_enemies_multiplier):
|
||||
each squad is that many times as large, for any number of players.
|
||||
|
||||
Extra enemies are placed in widening rings around the squad's starting
|
||||
locations, on a spot on the same floor, reachable without passing through
|
||||
a wall, crate or machine, with room to stand and nobody already there. A
|
||||
starting location with no room left passes its enemy to the squad's next
|
||||
one; if none has room, the enemy goes where extra enemies went before free
|
||||
ground was looked for (rings around the starting location, whoever stands
|
||||
there), so a squad still gets every enemy the setting asks for.
|
||||
|
||||
A squad a script loads into a dropship (vehicle_load_magic) can be larger
|
||||
than the dropship's seats. The riders left without a seat are erased, and
|
||||
kept: once the dropship's own riders get out (vehicle_unload, or any other
|
||||
way), they are placed beside those riders, a few ticks apart, and drop and
|
||||
fight as they do. A dropship gone first takes them with it.
|
||||
|
||||
Only the host runs the AI, so all of this is the host's.
|
||||
*/
|
||||
|
||||
#include "cseries.h"
|
||||
#include "ai/actor_placement.h"
|
||||
#include "ai/actors.h"
|
||||
#include "ai/ai_scenario_definitions.h"
|
||||
#include "ai/encounters.h"
|
||||
#include "game/game.h"
|
||||
#include "game/game_allegiance.h"
|
||||
#include "game/players.h"
|
||||
#include "networking/network_game_globals.h"
|
||||
#include "networking/network_game_manager.h"
|
||||
#include "objects/objects.h"
|
||||
#include "physics/collisions.h"
|
||||
#include "scenario/scenario.h"
|
||||
#include "scenario/scenario_definitions.h"
|
||||
#include "units/units.h"
|
||||
#include "units/unit_definitions.h"
|
||||
|
||||
#include "coop_enemies.h"
|
||||
#include "network_coop.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
/* port_config.c's */
|
||||
long config_integer(char const *name);
|
||||
char const *config_string(char const *name);
|
||||
|
||||
/* ---------- constants */
|
||||
|
||||
enum
|
||||
{
|
||||
/* the actors a level keeps for its own placements, which the extra
|
||||
enemies never take: as many as the Xbox's whole pool */
|
||||
COOP_ENEMIES_LEVEL_ACTORS = 256,
|
||||
/* EXTRA ENEMIES' amounts, as Server Setup has them: 25 to 200% per
|
||||
player, or 2 to 32 times (none is its NONE) */
|
||||
COOP_ENEMIES_MINIMUM_PERCENT = 25,
|
||||
COOP_ENEMIES_MAXIMUM_PERCENT = 200,
|
||||
COOP_ENEMIES_MINIMUM_MULTIPLIER = 2,
|
||||
COOP_ENEMIES_MAXIMUM_MULTIPLIER = 32,
|
||||
/* the rings tried around a starting location, the first holding
|
||||
SPREAD_PLACES_PER_RING places and each further one that many more */
|
||||
SPREAD_RINGS = 5,
|
||||
SPREAD_PLACES_PER_RING = 6,
|
||||
/* the rings coop_enemies_fallback_position tries, a place on each */
|
||||
FALLBACK_RINGS = 8,
|
||||
MAXIMUM_RIDING_VEHICLES = 32,
|
||||
MAXIMUM_SEATED_RIDERS = 16,
|
||||
MAXIMUM_KEPT_RIDERS = 512,
|
||||
/* a kept rider placed every this many ticks, as the seated ones
|
||||
jumped out */
|
||||
RIDER_RELEASE_TICKS = 4,
|
||||
};
|
||||
|
||||
/* (coop_enemies.h's count of the places on all the rings) */
|
||||
typedef char coop_enemies_spread_spots_assert[
|
||||
COOP_ENEMIES_SPREAD_SPOTS == SPREAD_PLACES_PER_RING * SPREAD_RINGS * (SPREAD_RINGS + 1) / 2 ? 1 : -1];
|
||||
|
||||
/* distance between rings */
|
||||
#define SPREAD_SPACING 0.8f
|
||||
/* height above the floor at which the way to a spot is checked */
|
||||
#define SPREAD_STEP_HEIGHT 0.6f
|
||||
/* how far a spot's floor may be above or below the starting location's:
|
||||
a step, not a ledge */
|
||||
#define SPREAD_FLOOR_DIFFERENCE 0.5f
|
||||
/* room a spot needs above its floor */
|
||||
#define SPREAD_HEADROOM 1.6f
|
||||
/* how close across the ground a spot may be to a biped already there
|
||||
(about two bipeds' collision radius), and how far around it to look */
|
||||
#define SPREAD_CLEARANCE 0.6f
|
||||
#define SPREAD_SEARCH_RADIUS 1.0f
|
||||
/* how far below a fallback place the ground is looked for */
|
||||
#define FALLBACK_GROUND_DEPTH 2.0f
|
||||
/* a kept rider's place beside a rider who got out, each a little apart */
|
||||
#define RIDER_SPACING 0.5f
|
||||
|
||||
/* EXTRA ENEMIES' choices (network.coop_enemies_mode's values) */
|
||||
enum
|
||||
{
|
||||
_coop_enemies_none,
|
||||
_coop_enemies_per_player,
|
||||
_coop_enemies_multiplier,
|
||||
};
|
||||
|
||||
/* ---------- structures */
|
||||
|
||||
/* a vehicle a script loaded riders into: its seated ones, and whether they
|
||||
have begun to get out */
|
||||
struct coop_riding_vehicle
|
||||
{
|
||||
long vehicle_index;
|
||||
long seated_unit_indices[MAXIMUM_SEATED_RIDERS];
|
||||
short seat_indices[MAXIMUM_SEATED_RIDERS];
|
||||
short seated_count;
|
||||
boolean releasing;
|
||||
short released_count;
|
||||
long next_release_time;
|
||||
};
|
||||
|
||||
/* a rider left without a seat, to place once its vehicle's get out */
|
||||
struct coop_kept_rider
|
||||
{
|
||||
long vehicle_index;
|
||||
long variant_definition_index;
|
||||
long encounter_index;
|
||||
short squad_index;
|
||||
};
|
||||
|
||||
/* ---------- globals */
|
||||
|
||||
static struct
|
||||
{
|
||||
/* EXTRA ENEMIES, as the game began with it: its choice, and the amount
|
||||
of PER PLAYER (a percentage) and of STATIC MULTIPLIER */
|
||||
short mode;
|
||||
short percent;
|
||||
short multiplier;
|
||||
struct coop_riding_vehicle vehicles[MAXIMUM_RIDING_VEHICLES];
|
||||
short vehicle_count;
|
||||
struct coop_kept_rider riders[MAXIMUM_KEPT_RIDERS];
|
||||
short rider_count;
|
||||
} coop_enemies;
|
||||
|
||||
/* ---------- private code */
|
||||
|
||||
static boolean coop_enemies_host(
|
||||
void)
|
||||
{
|
||||
return game_connection() == _game_connection_network_server && network_coop_active();
|
||||
}
|
||||
|
||||
/* whether this game has extra enemies (it is a co-op host's, with some
|
||||
chosen) */
|
||||
static boolean coop_enemies_on(
|
||||
void)
|
||||
{
|
||||
return coop_enemies.mode != _coop_enemies_none && coop_enemies_host();
|
||||
}
|
||||
|
||||
/* the players in the game, every machine's: the network game's (a level
|
||||
places its first enemies before the players' units are made, as it loads:
|
||||
game_initialize_for_new_map) */
|
||||
static short coop_enemies_player_count(
|
||||
void)
|
||||
{
|
||||
struct network_game *game = network_game_get_game();
|
||||
short count = 0;
|
||||
short index;
|
||||
|
||||
for (index = 0; game && index < HALO_PORT_MAXIMUM_NETWORK_PLAYERS; index++)
|
||||
{
|
||||
if (network_player_is_valid(&game->players[index]))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* what a spot is tested against: the level, and the objects that block
|
||||
the way (crates and other scenery, machines, vehicles) */
|
||||
#define SPREAD_COLLISION_FLAGS (FLAG(_collision_test_structure_bit) | FLAG(_collision_test_objects_bit) | \
|
||||
_collision_test_objects_sight_blocking_flags | FLAG(_collision_test_front_facing_surfaces_bit) | \
|
||||
FLAG(_collision_test_back_facing_surfaces_bit))
|
||||
|
||||
/* whether anything is in the way from `from`, along `vector` */
|
||||
static boolean coop_enemies_blocked(
|
||||
real_point3d const *from,
|
||||
real_vector3d const *vector)
|
||||
{
|
||||
struct collision_result collision;
|
||||
|
||||
return collision_test_vector(SPREAD_COLLISION_FLAGS, from, vector, NONE, &collision);
|
||||
}
|
||||
|
||||
/* the floor under a point, looked for from SPREAD_STEP_HEIGHT above it to
|
||||
SPREAD_FLOOR_DIFFERENCE below it */
|
||||
static boolean coop_enemies_floor(
|
||||
real_point3d const *point,
|
||||
real_point3d *floor)
|
||||
{
|
||||
struct collision_result collision;
|
||||
real_point3d from = *point;
|
||||
real_vector3d down = { 0.0f, 0.0f, -(2.0f * SPREAD_STEP_HEIGHT + SPREAD_FLOOR_DIFFERENCE) };
|
||||
|
||||
from.z += SPREAD_STEP_HEIGHT;
|
||||
if (!collision_test_vector(SPREAD_COLLISION_FLAGS, &from, &down, NONE, &collision))
|
||||
return FALSE;
|
||||
*floor = collision.point;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* whether a biped stands within SPREAD_CLEARANCE of a spot on the floor,
|
||||
or the spot is inside a vehicle */
|
||||
static boolean coop_enemies_occupied(
|
||||
real_point3d const *floor)
|
||||
{
|
||||
real_point3d body = { floor->x, floor->y, floor->z + SPREAD_STEP_HEIGHT };
|
||||
struct location location;
|
||||
long object_indices[32];
|
||||
short object_count;
|
||||
short index;
|
||||
|
||||
scenario_location_from_point(&location, &body);
|
||||
if (location.cluster_index == NONE)
|
||||
return TRUE;
|
||||
object_count = objects_in_sphere(0, _object_mask_biped | _object_mask_vehicle, &location, &body,
|
||||
SPREAD_SEARCH_RADIUS, object_indices, NUMBEROF(object_indices));
|
||||
for (index = 0; index < object_count; index++)
|
||||
{
|
||||
struct object_datum *object = object_get(object_indices[index]);
|
||||
|
||||
if (object->object.type == _object_type_vehicle)
|
||||
{
|
||||
if (point_in_sphere(&body, &object->object.bounding_sphere_center, object->object.bounding_sphere_radius))
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
real dx = object->object.position.x - floor->x;
|
||||
real dy = object->object.position.y - floor->y;
|
||||
|
||||
if (dx * dx + dy * dy < SPREAD_CLEARANCE * SPREAD_CLEARANCE)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Whether an enemy can stand at `spot`: reachable from `from` (beside the
|
||||
starting location) with nothing in the way, a floor within a step of
|
||||
`floor_height` (the starting location's), room above it, and nobody there.
|
||||
The floor goes in `position`. */
|
||||
static boolean coop_enemies_spot_free(
|
||||
real_point3d const *from,
|
||||
real_point3d const *spot,
|
||||
real floor_height,
|
||||
real_point3d *position)
|
||||
{
|
||||
/* (level, at step height: down to the starting location's floor, a spot
|
||||
whose floor is a little higher would end the look inside it) */
|
||||
real_vector3d way = { spot->x - from->x, spot->y - from->y, 0.0f };
|
||||
real_vector3d up = { 0.0f, 0.0f, SPREAD_HEADROOM };
|
||||
real_point3d floor;
|
||||
real_point3d feet;
|
||||
|
||||
if (coop_enemies_blocked(from, &way) || !coop_enemies_floor(spot, &floor) ||
|
||||
fabsf(floor.z - floor_height) > SPREAD_FLOOR_DIFFERENCE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
/* (headroom is checked from just above the floor, so the floor itself
|
||||
doesn't count as in the way) */
|
||||
feet = floor;
|
||||
feet.z += 0.1f;
|
||||
if (coop_enemies_blocked(&feet, &up) || coop_enemies_occupied(&floor))
|
||||
return FALSE;
|
||||
*position = floor;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct coop_riding_vehicle *coop_enemies_riding_vehicle(
|
||||
long vehicle_index,
|
||||
boolean create)
|
||||
{
|
||||
short index;
|
||||
|
||||
for (index = 0; index < coop_enemies.vehicle_count; index++)
|
||||
{
|
||||
if (coop_enemies.vehicles[index].vehicle_index == vehicle_index)
|
||||
return &coop_enemies.vehicles[index];
|
||||
}
|
||||
if (!create || coop_enemies.vehicle_count >= MAXIMUM_RIDING_VEHICLES)
|
||||
return NULL;
|
||||
csmemset(&coop_enemies.vehicles[coop_enemies.vehicle_count], 0, sizeof(coop_enemies.vehicles[0]));
|
||||
coop_enemies.vehicles[coop_enemies.vehicle_count].vehicle_index = vehicle_index;
|
||||
return &coop_enemies.vehicles[coop_enemies.vehicle_count++];
|
||||
}
|
||||
|
||||
/* the riders kept for a vehicle forgotten, and the vehicle with them */
|
||||
static void coop_enemies_forget_vehicle(
|
||||
short vehicle_number)
|
||||
{
|
||||
long vehicle_index = coop_enemies.vehicles[vehicle_number].vehicle_index;
|
||||
short index, kept = 0;
|
||||
|
||||
for (index = 0; index < coop_enemies.rider_count; index++)
|
||||
{
|
||||
if (coop_enemies.riders[index].vehicle_index != vehicle_index)
|
||||
coop_enemies.riders[kept++] = coop_enemies.riders[index];
|
||||
}
|
||||
coop_enemies.rider_count = kept;
|
||||
coop_enemies.vehicles[vehicle_number] = coop_enemies.vehicles[--coop_enemies.vehicle_count];
|
||||
}
|
||||
|
||||
/* whether a vehicle's seated riders have begun to get out: one alive and
|
||||
out of it (one killed in its seat is not getting out) */
|
||||
static boolean coop_enemies_riders_getting_out(
|
||||
struct coop_riding_vehicle const *vehicle)
|
||||
{
|
||||
short index;
|
||||
|
||||
for (index = 0; index < vehicle->seated_count; index++)
|
||||
{
|
||||
struct object_datum *unit = object_try_and_get_and_verify_type(vehicle->seated_unit_indices[index],
|
||||
_object_mask_unit);
|
||||
|
||||
if (unit && !TEST_FLAG(unit->object.damage_flags, _object_dead_bit) &&
|
||||
unit->object.parent_object_index != vehicle->vehicle_index)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* where a vehicle's `number`th kept rider is placed: beside one of the
|
||||
riders who got out of it (where it is now: out of the vehicle, in the
|
||||
open), a ring further about them each round; else at a seat's marker, else
|
||||
the vehicle's place */
|
||||
static void coop_enemies_rider_place(
|
||||
struct coop_riding_vehicle const *vehicle,
|
||||
short number,
|
||||
real_point3d *position,
|
||||
real *facing)
|
||||
{
|
||||
struct object_datum *object = object_get(vehicle->vehicle_index);
|
||||
struct unit_definition *definition = unit_definition_get(object->definition_index);
|
||||
long out_unit_indices[MAXIMUM_SEATED_RIDERS];
|
||||
short out_count = 0;
|
||||
short index, round;
|
||||
real angle;
|
||||
real_point3d spread;
|
||||
|
||||
*position = object->object.position;
|
||||
*facing = (real)atan2(object->object.forward.j, object->object.forward.i);
|
||||
for (index = 0; index < vehicle->seated_count; index++)
|
||||
{
|
||||
struct object_datum *unit = object_try_and_get_and_verify_type(vehicle->seated_unit_indices[index],
|
||||
_object_mask_unit);
|
||||
|
||||
if (unit && !TEST_FLAG(unit->object.damage_flags, _object_dead_bit) &&
|
||||
unit->object.parent_object_index != vehicle->vehicle_index)
|
||||
{
|
||||
out_unit_indices[out_count++] = vehicle->seated_unit_indices[index];
|
||||
}
|
||||
}
|
||||
if (out_count > 0)
|
||||
{
|
||||
*position = object_get(out_unit_indices[number % out_count])->object.position;
|
||||
round = (short)(number / out_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct object_marker marker;
|
||||
|
||||
round = number;
|
||||
if (vehicle->seated_count > 0 && VALID_INDEX(vehicle->seat_indices[0], definition->unit.seats.count))
|
||||
{
|
||||
struct unit_seat *seat = TAG_BLOCK_GET_ELEMENT(&definition->unit.seats, vehicle->seat_indices[0],
|
||||
struct unit_seat);
|
||||
|
||||
if (seat->marker_name[0] &&
|
||||
object_get_marker_by_name(vehicle->vehicle_index, seat->marker_name, &marker, 1) > 0)
|
||||
{
|
||||
*position = marker.matrix.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* free ground around that spot, as the squad's own extra enemies get;
|
||||
failing that, a ring around it, further out each round */
|
||||
if (coop_enemies_spread_position(position, (short)(number + 1), NULL, &spread))
|
||||
{
|
||||
*position = spread;
|
||||
return;
|
||||
}
|
||||
angle = (real)number * (_pi * 2.0f / SPREAD_PLACES_PER_RING);
|
||||
position->x += (real)cos(angle) * RIDER_SPACING * (real)(round / SPREAD_PLACES_PER_RING + 1);
|
||||
position->y += (real)sin(angle) * RIDER_SPACING * (real)(round / SPREAD_PLACES_PER_RING + 1);
|
||||
}
|
||||
|
||||
/* ---------- public code */
|
||||
|
||||
void coop_enemies_new_game(
|
||||
void)
|
||||
{
|
||||
char const *mode = config_string("network.coop_enemies_mode");
|
||||
|
||||
csmemset(&coop_enemies, 0, sizeof(coop_enemies));
|
||||
/* (an amount past Server Setup's, as it shows it: its nearest choice's
|
||||
end) */
|
||||
coop_enemies.percent = (short)PIN(config_integer("network.coop_enemies"), COOP_ENEMIES_MINIMUM_PERCENT,
|
||||
COOP_ENEMIES_MAXIMUM_PERCENT);
|
||||
coop_enemies.multiplier = (short)PIN(config_integer("network.coop_enemies_multiplier"),
|
||||
COOP_ENEMIES_MINIMUM_MULTIPLIER, COOP_ENEMIES_MAXIMUM_MULTIPLIER);
|
||||
coop_enemies.mode = !strcmp(mode, "per_player") ? _coop_enemies_per_player :
|
||||
!strcmp(mode, "multiplier") ? _coop_enemies_multiplier : _coop_enemies_none;
|
||||
}
|
||||
|
||||
void coop_enemies_reset(
|
||||
void)
|
||||
{
|
||||
coop_enemies.vehicle_count = 0;
|
||||
coop_enemies.rider_count = 0;
|
||||
}
|
||||
|
||||
short coop_enemies_extra_count(
|
||||
long encounter_index,
|
||||
short count)
|
||||
{
|
||||
struct encounter_datum *encounter;
|
||||
long extra, room;
|
||||
short players;
|
||||
|
||||
if (count <= 0 || !coop_enemies_on())
|
||||
return 0;
|
||||
encounter = encounter_get(encounter_index);
|
||||
if (!game_team_is_enemy(_game_team_player, encounter->team_index))
|
||||
return 0;
|
||||
if (coop_enemies.mode == _coop_enemies_multiplier)
|
||||
extra = (long)count * (coop_enemies.multiplier - 1);
|
||||
else
|
||||
{
|
||||
players = coop_enemies_player_count();
|
||||
if (players <= 1)
|
||||
return 0;
|
||||
extra = ((long)count * coop_enemies.percent * (players - 1) + 50) / 100;
|
||||
}
|
||||
room = MAXIMUM_ACTORS - COOP_ENEMIES_LEVEL_ACTORS - actor_data->actual_count;
|
||||
return (short)PIN(extra, 0, MAX(room, 0));
|
||||
}
|
||||
|
||||
boolean coop_enemies_spread_position(
|
||||
real_point3d const *origin,
|
||||
short number,
|
||||
long *taken,
|
||||
real_point3d *position)
|
||||
{
|
||||
real_point3d from = *origin;
|
||||
real_point3d floor;
|
||||
real floor_height = coop_enemies_floor(origin, &floor) ? floor.z : origin->z;
|
||||
short ring, first_spot = 0;
|
||||
|
||||
from.z = floor_height + SPREAD_STEP_HEIGHT;
|
||||
for (ring = 0; ring < SPREAD_RINGS; ring++)
|
||||
{
|
||||
short place_count = (short)(SPREAD_PLACES_PER_RING * (ring + 1));
|
||||
real radius = SPREAD_SPACING * (real)(ring + 1);
|
||||
short place;
|
||||
|
||||
/* (each enemy starts at a different place on the ring, so a squad
|
||||
spreads all the way round rather than filling one side first) */
|
||||
for (place = 0; place < place_count; place++)
|
||||
{
|
||||
short around = (short)((number + place) % place_count);
|
||||
short spot_index = (short)(first_spot + around);
|
||||
real angle = (real)around * (_pi * 2.0f / (real)place_count);
|
||||
real_point3d spot = from;
|
||||
|
||||
if (taken && BIT_VECTOR_TEST_FLAG(taken, spot_index))
|
||||
continue;
|
||||
spot.x += (real)cos(angle) * radius;
|
||||
spot.y += (real)sin(angle) * radius;
|
||||
spot.z = floor_height;
|
||||
if (coop_enemies_spot_free(&from, &spot, floor_height, position))
|
||||
return TRUE;
|
||||
if (taken)
|
||||
BIT_VECTOR_SET_FLAG(taken, spot_index, TRUE);
|
||||
}
|
||||
first_spot = (short)(first_spot + place_count);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
boolean coop_enemies_fallback_position(
|
||||
real_point3d const *origin,
|
||||
short number,
|
||||
real_point3d *position)
|
||||
{
|
||||
real_point3d from = *origin;
|
||||
short place = (short)((number - 1) % SPREAD_PLACES_PER_RING);
|
||||
short ring = (short)((number - 1) / SPREAD_PLACES_PER_RING);
|
||||
short attempt;
|
||||
|
||||
from.z += SPREAD_STEP_HEIGHT;
|
||||
for (attempt = 0; attempt < FALLBACK_RINGS; attempt++, ring++)
|
||||
{
|
||||
/* (each ring turned half a place from the last, so its places fall
|
||||
between the last's) */
|
||||
real angle = ((real)place + 0.5f * (real)(ring % 2)) * (_pi * 2.0f / SPREAD_PLACES_PER_RING);
|
||||
real radius = SPREAD_SPACING * (real)(ring + 1);
|
||||
real_point3d to = from;
|
||||
real_vector3d way = { 0.0f, 0.0f, 0.0f };
|
||||
real_vector3d down = { 0.0f, 0.0f, -(SPREAD_STEP_HEIGHT + FALLBACK_GROUND_DEPTH) };
|
||||
struct collision_result collision;
|
||||
|
||||
way.i = (real)cos(angle) * radius;
|
||||
way.j = (real)sin(angle) * radius;
|
||||
to.x += way.i;
|
||||
to.y += way.j;
|
||||
/* (the level only: the way open, and ground below) */
|
||||
if (!collision_test_vector(FLAG(_collision_test_structure_bit) | FLAG(_collision_test_front_facing_surfaces_bit) |
|
||||
FLAG(_collision_test_back_facing_surfaces_bit), &from, &way, NONE, &collision) &&
|
||||
collision_test_vector(FLAG(_collision_test_structure_bit) | FLAG(_collision_test_front_facing_surfaces_bit),
|
||||
&to, &down, NONE, &collision))
|
||||
{
|
||||
*position = collision.point;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void coop_enemies_rider_seated(
|
||||
long vehicle_index,
|
||||
long unit_index)
|
||||
{
|
||||
struct coop_riding_vehicle *vehicle;
|
||||
struct unit_datum *unit;
|
||||
|
||||
if (!coop_enemies_on())
|
||||
return;
|
||||
vehicle = coop_enemies_riding_vehicle(vehicle_index, TRUE);
|
||||
unit = unit_get(unit_index);
|
||||
if (!vehicle)
|
||||
return;
|
||||
/* (a vehicle loaded again: the riders that got out of it before are not
|
||||
this load's) */
|
||||
{
|
||||
short index, kept = 0;
|
||||
|
||||
for (index = 0; index < vehicle->seated_count; index++)
|
||||
{
|
||||
struct object_datum *seated = object_try_and_get_and_verify_type(vehicle->seated_unit_indices[index],
|
||||
_object_mask_unit);
|
||||
|
||||
if (seated && seated->object.parent_object_index == vehicle_index)
|
||||
{
|
||||
vehicle->seated_unit_indices[kept] = vehicle->seated_unit_indices[index];
|
||||
vehicle->seat_indices[kept++] = vehicle->seat_indices[index];
|
||||
}
|
||||
}
|
||||
vehicle->seated_count = kept;
|
||||
}
|
||||
if (vehicle->seated_count >= MAXIMUM_SEATED_RIDERS)
|
||||
return;
|
||||
vehicle->seated_unit_indices[vehicle->seated_count] = unit_index;
|
||||
vehicle->seat_indices[vehicle->seated_count] = unit->unit.parent_seat_index;
|
||||
vehicle->seated_count++;
|
||||
/* (a vehicle loaded again, after its riders got out: they get out again) */
|
||||
vehicle->releasing = FALSE;
|
||||
}
|
||||
|
||||
boolean coop_enemies_rider_unseated(
|
||||
long vehicle_index,
|
||||
long unit_index)
|
||||
{
|
||||
struct unit_datum *unit;
|
||||
struct actor_datum *actor;
|
||||
struct coop_kept_rider *rider;
|
||||
struct coop_riding_vehicle *vehicle;
|
||||
|
||||
if (!coop_enemies_on() || coop_enemies.rider_count >= MAXIMUM_KEPT_RIDERS)
|
||||
return FALSE;
|
||||
unit = unit_get(unit_index);
|
||||
vehicle = coop_enemies_riding_vehicle(vehicle_index, FALSE);
|
||||
/* (kept only for a vehicle with riders seated, whose getting out places
|
||||
it: one of a load that seated nobody is left where it is) */
|
||||
if (unit->object.type != _object_type_biped || unit->unit.actor_index == NONE || !vehicle ||
|
||||
vehicle->seated_count == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
actor = actor_get(unit->unit.actor_index);
|
||||
if (actor->meta.swarm || actor->meta.encounter_index == NONE ||
|
||||
!game_team_is_enemy(_game_team_player, encounter_get(actor->meta.encounter_index)->team_index))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
rider = &coop_enemies.riders[coop_enemies.rider_count++];
|
||||
rider->vehicle_index = vehicle_index;
|
||||
rider->variant_definition_index = actor->meta.variant_definition_index;
|
||||
rider->encounter_index = actor->meta.encounter_index;
|
||||
rider->squad_index = actor->meta.squad_index;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void coop_enemies_update(
|
||||
void)
|
||||
{
|
||||
long now = game_time_get();
|
||||
short vehicle_number;
|
||||
|
||||
if (!coop_enemies_host())
|
||||
return;
|
||||
for (vehicle_number = coop_enemies.vehicle_count - 1; vehicle_number >= 0; vehicle_number--)
|
||||
{
|
||||
struct coop_riding_vehicle *vehicle = &coop_enemies.vehicles[vehicle_number];
|
||||
struct object_datum *object = object_try_and_get_and_verify_type(vehicle->vehicle_index, _object_mask_unit);
|
||||
short index;
|
||||
|
||||
/* (the vehicle's next kept rider) */
|
||||
for (index = 0; index < coop_enemies.rider_count; index++)
|
||||
{
|
||||
if (coop_enemies.riders[index].vehicle_index == vehicle->vehicle_index)
|
||||
break;
|
||||
}
|
||||
/* (a vehicle gone, or destroyed, takes its kept riders with it; one
|
||||
with none kept, every one loaded seated or all placed, is done with) */
|
||||
if (!object || TEST_FLAG(object->object.damage_flags, _object_dead_bit) || index >= coop_enemies.rider_count)
|
||||
{
|
||||
coop_enemies_forget_vehicle(vehicle_number);
|
||||
continue;
|
||||
}
|
||||
if (!vehicle->releasing)
|
||||
{
|
||||
if (!coop_enemies_riders_getting_out(vehicle))
|
||||
continue;
|
||||
vehicle->releasing = TRUE;
|
||||
vehicle->released_count = 0;
|
||||
vehicle->next_release_time = now;
|
||||
}
|
||||
if (now < vehicle->next_release_time)
|
||||
continue;
|
||||
{
|
||||
struct coop_kept_rider rider = coop_enemies.riders[index];
|
||||
struct encounter_definition *encounter_definition;
|
||||
struct squad_definition *squad_definition;
|
||||
struct actor_starting_location location;
|
||||
|
||||
coop_enemies.riders[index] = coop_enemies.riders[--coop_enemies.rider_count];
|
||||
encounter_definition = TAG_BLOCK_GET_ELEMENT(&global_scenario_get()->ai_encounters,
|
||||
DATUM_INDEX_TO_ABSOLUTE_INDEX(rider.encounter_index), struct encounter_definition);
|
||||
squad_definition = TAG_BLOCK_GET_ELEMENT(&encounter_definition->squads, rider.squad_index,
|
||||
struct squad_definition);
|
||||
/* (as the squad's: its states, no command list of a starting
|
||||
location's) */
|
||||
csmemset(&location, 0, sizeof(location));
|
||||
coop_enemies_rider_place(vehicle, vehicle->released_count++, &location.position, &location.facing);
|
||||
location.cluster_index = NONE;
|
||||
location.noncombat_sequence_id = NONE;
|
||||
location.default_state = squad_definition->default_state;
|
||||
location.initial_state = squad_definition->initial_state;
|
||||
location.actor_variant_index = NONE;
|
||||
location.command_list_index = NONE;
|
||||
actor_place(rider.variant_definition_index, rider.encounter_index, rider.squad_index, &location, FALSE, 0);
|
||||
encounter_update_status(rider.encounter_index);
|
||||
}
|
||||
vehicle->next_release_time = now + RIDER_RELEASE_TICKS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
COOP_ENEMIES.H
|
||||
|
||||
Network co-op's extra enemies, for its players (coop_enemies.c).
|
||||
*/
|
||||
|
||||
#ifndef __COOP_ENEMIES_H
|
||||
#define __COOP_ENEMIES_H
|
||||
|
||||
/* network_coop.c: a game begins (its EXTRA ENEMIES read), or the host's
|
||||
game state went back (a cutscene skipped): the dropships' riders kept are
|
||||
forgotten */
|
||||
void coop_enemies_new_game(
|
||||
void);
|
||||
void coop_enemies_reset(
|
||||
void);
|
||||
|
||||
/* encounters.c: how many enemies more a squad placed with `count` gets
|
||||
(none but on a co-op host, for an encounter of the players' enemies) */
|
||||
short coop_enemies_extra_count(
|
||||
long encounter_index,
|
||||
short count);
|
||||
|
||||
/* the places coop_enemies_spread_position tries around a starting location */
|
||||
#define COOP_ENEMIES_SPREAD_SPOTS 90
|
||||
|
||||
/* encounters.c: finds a spot for a squad's `number`th extra enemy
|
||||
(counting from 1) around the starting location `origin`, on its floor,
|
||||
clear of walls and objects, with room to stand and nobody there. FALSE if
|
||||
there's no room. `taken` (COOP_ENEMIES_SPREAD_SPOTS bits, or NULL) marks the
|
||||
places found taken, which stay so while the squad's enemies are placed: they
|
||||
aren't tried again. */
|
||||
boolean coop_enemies_spread_position(
|
||||
real_point3d const *origin,
|
||||
short number,
|
||||
long *taken,
|
||||
real_point3d *position);
|
||||
/* encounters.c: where the `number`th extra enemy (counting from 1) goes
|
||||
when no starting location has room: a place on rings around `origin` with
|
||||
the way open and ground below, whoever stands there (as extra enemies were
|
||||
placed before free ground was looked for), so the squad still gets every
|
||||
enemy the setting asks for. FALSE if none (the starting location itself
|
||||
then) */
|
||||
boolean coop_enemies_fallback_position(
|
||||
real_point3d const *origin,
|
||||
short number,
|
||||
real_point3d *position);
|
||||
|
||||
/* units.c's vehicle_scripting_load_magic: a rider seated, and one left
|
||||
without a seat (the vehicle's seats taken: an extra enemy), which is kept,
|
||||
off the map, until the vehicle's riders get out (TRUE: kept, the caller
|
||||
erases it) */
|
||||
void coop_enemies_rider_seated(
|
||||
long vehicle_index,
|
||||
long unit_index);
|
||||
boolean coop_enemies_rider_unseated(
|
||||
long vehicle_index,
|
||||
long unit_index);
|
||||
|
||||
/* network_coop.c, after each of the host's ticks: the riders kept placed
|
||||
at their vehicle's seats once its own riders get out */
|
||||
void coop_enemies_update(
|
||||
void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
COOP_SCRIPTS.C
|
||||
|
||||
Campaign scripts made to work for every player in network co-op.
|
||||
|
||||
The campaign's scripts were written for one or two players. Only the host
|
||||
runs them (game.c), against every player's unit, so most of what they do
|
||||
already happens for everyone: a trigger volume tested against (players)
|
||||
fires for whoever walks into it, and what it starts is sent to the clients
|
||||
(network_coop.c). Three habits of the scripts don't carry over:
|
||||
|
||||
- Waiting for every player at once (volume_test_objects_all on the
|
||||
players): the Maw's run to the Pillar of Autumn's bridge, a30's Pelican
|
||||
pickups. Split-screen players stand together; network players don't, so
|
||||
the wait would never end. In co-op one player arriving is enough.
|
||||
- Waiting until it's safe (game_safe_to_save) before a cutscene: the
|
||||
game's test fails while any enemy sees any player. In co-op one player
|
||||
out of danger is enough.
|
||||
- Naming players one at a time: the scripts reach the players through
|
||||
player0 and player1 (the first two in the players list), to put them in
|
||||
a Pelican, take them out of it, stage them for a cutscene or give them a
|
||||
starting profile. Everyone past the second would be left out, so they
|
||||
follow player0: wherever the scripts put player0, they go too.
|
||||
*/
|
||||
|
||||
/* ---------- headers */
|
||||
|
||||
#include "cseries.h"
|
||||
#include "ai/ai.h"
|
||||
#include "game/game.h"
|
||||
#include "game/players.h"
|
||||
#include "hs/object_lists.h"
|
||||
#include "objects/objects.h"
|
||||
#include "objects/object_types.h"
|
||||
#include "units/bipeds.h"
|
||||
#include "units/units.h"
|
||||
|
||||
#include "coop_scripts.h"
|
||||
#include "network_coop.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* ---------- constants */
|
||||
|
||||
/* players the scripts name: player0 and player1 */
|
||||
#define NAMED_PLAYERS 2
|
||||
|
||||
/* ---------- private code */
|
||||
|
||||
static boolean coop_scripts_host(
|
||||
void)
|
||||
{
|
||||
return game_connection() == _game_connection_network_server && network_coop_active();
|
||||
}
|
||||
|
||||
/* the seat label to look for when boarding a follower: player0's own up to
|
||||
and including "rider" (Pelicans have "p-riderlf", "p-riderrf", "p-riderlb"
|
||||
and so on), else up to the '-' ("b-driver" gives "b-") */
|
||||
static void follower_seat_name(
|
||||
char const *seat_name,
|
||||
char *follower_seat,
|
||||
size_t size)
|
||||
{
|
||||
char *rider;
|
||||
char *dash;
|
||||
|
||||
/* (lower case: vehicle_scripting_find_available_seats compares it with
|
||||
lowered seat labels) */
|
||||
snprintf(follower_seat, size, "%s", seat_name);
|
||||
strlwr(follower_seat);
|
||||
rider = strstr(follower_seat, "rider");
|
||||
dash = strchr(follower_seat, '-');
|
||||
if (rider)
|
||||
rider[strlen("rider")] = 0;
|
||||
else if (dash)
|
||||
dash[1] = 0;
|
||||
}
|
||||
|
||||
/* ---------- public code */
|
||||
|
||||
boolean coop_scripts_any_player_will_do(
|
||||
long object_list_index)
|
||||
{
|
||||
long reference_index;
|
||||
long object_index;
|
||||
boolean any = FALSE;
|
||||
|
||||
if (!coop_scripts_host())
|
||||
return FALSE;
|
||||
for (object_index = object_list_get_first(object_list_index, &reference_index);
|
||||
object_index != NONE;
|
||||
object_index = object_list_get_next(object_list_index, &reference_index))
|
||||
{
|
||||
if (player_index_from_unit_index(object_index) == NONE)
|
||||
return FALSE;
|
||||
any = TRUE;
|
||||
}
|
||||
return any;
|
||||
}
|
||||
|
||||
/* the units of the players following player0, if `unit_index` is
|
||||
player0's; how many */
|
||||
static short players_following(
|
||||
long unit_index,
|
||||
long *unit_indices,
|
||||
short maximum_count)
|
||||
{
|
||||
struct data_iterator iterator;
|
||||
struct player_datum *player;
|
||||
short position = 0;
|
||||
short count = 0;
|
||||
|
||||
if (unit_index == NONE || !coop_scripts_host())
|
||||
return 0;
|
||||
/* (in the order (players) lists them: player0 is the first with a unit) */
|
||||
data_iterator_new(&iterator, player_data);
|
||||
while ((player = data_iterator_next(&iterator)) != NULL)
|
||||
{
|
||||
if (player->unit_index == NONE)
|
||||
continue;
|
||||
if (position == 0 && player->unit_index != unit_index)
|
||||
return 0;
|
||||
if (position >= NAMED_PLAYERS && count < maximum_count)
|
||||
unit_indices[count++] = player->unit_index;
|
||||
position++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void coop_scripts_teleport_followers(
|
||||
long unit_index)
|
||||
{
|
||||
long followers[HALO_PORT_MAXIMUM_NETWORK_PLAYERS];
|
||||
short count = players_following(unit_index, followers, NUMBEROF(followers));
|
||||
short index;
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
player_teleport(player_index_from_unit_index(followers[index]), unit_index,
|
||||
&object_get(unit_index)->object.position);
|
||||
}
|
||||
}
|
||||
|
||||
void coop_scripts_suspend_followers(
|
||||
long unit_index,
|
||||
boolean suspended)
|
||||
{
|
||||
long followers[HALO_PORT_MAXIMUM_NETWORK_PLAYERS];
|
||||
short count = players_following(unit_index, followers, NUMBEROF(followers));
|
||||
short index;
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
unit_scripting_suspended(followers[index], suspended);
|
||||
}
|
||||
|
||||
void coop_scripts_exit_followers(
|
||||
long unit_index,
|
||||
long vehicle_index)
|
||||
{
|
||||
long followers[HALO_PORT_MAXIMUM_NETWORK_PLAYERS];
|
||||
short count = players_following(unit_index, followers, NUMBEROF(followers));
|
||||
short index;
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
if (object_get(followers[index])->object.parent_object_index == vehicle_index)
|
||||
unit_scripting_exit_vehicle(followers[index]);
|
||||
}
|
||||
}
|
||||
|
||||
void coop_scripts_board_followers(
|
||||
long unit_index,
|
||||
long vehicle_index,
|
||||
char const *seat_name)
|
||||
{
|
||||
long followers[HALO_PORT_MAXIMUM_NETWORK_PLAYERS];
|
||||
short count = players_following(unit_index, followers, NUMBEROF(followers));
|
||||
char follower_seat[64];
|
||||
short index;
|
||||
|
||||
if (count == 0 || vehicle_index == NONE)
|
||||
return;
|
||||
follower_seat_name(seat_name, follower_seat, sizeof(follower_seat));
|
||||
/* (each list freed at once: there are few, and the scripts' own are only
|
||||
collected after the tick's threads have run) */
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
long list_index = object_list_new();
|
||||
|
||||
if (list_index == NONE)
|
||||
break;
|
||||
object_list_add(list_index, followers[index]);
|
||||
vehicle_scripting_load_magic(vehicle_index, follower_seat, list_index);
|
||||
object_list_delete(list_index);
|
||||
}
|
||||
}
|
||||
|
||||
boolean coop_scripts_safe_to_save(
|
||||
void)
|
||||
{
|
||||
struct data_iterator iterator;
|
||||
struct player_datum *player;
|
||||
|
||||
if (game_safe_to_save())
|
||||
return TRUE;
|
||||
if (!coop_scripts_host())
|
||||
return FALSE;
|
||||
data_iterator_new(&iterator, player_data);
|
||||
while ((player = data_iterator_next(&iterator)) != NULL)
|
||||
{
|
||||
struct biped_datum *biped = biped_try_and_get(player->unit_index);
|
||||
|
||||
if (biped && !TEST_FLAG(biped->object.damage_flags, _object_dead_bit) &&
|
||||
!TEST_FLAG(biped->biped.flags, _biped_airborne_bit) && !ai_port_enemies_can_see_unit(player->unit_index))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void coop_scripts_player_add_equipment(
|
||||
long unit_index,
|
||||
short starting_profile_index,
|
||||
boolean reset_equipment)
|
||||
{
|
||||
long followers[HALO_PORT_MAXIMUM_NETWORK_PLAYERS];
|
||||
short count = players_following(unit_index, followers, NUMBEROF(followers));
|
||||
short index;
|
||||
|
||||
player_add_equipment(unit_index, starting_profile_index, reset_equipment);
|
||||
for (index = 0; index < count; index++)
|
||||
player_add_equipment(followers[index], starting_profile_index, reset_equipment);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
COOP_SCRIPTS.H
|
||||
|
||||
Campaign scripts made to work for every player in network co-op
|
||||
(coop_scripts.c).
|
||||
*/
|
||||
|
||||
#ifndef __COOP_SCRIPTS_H
|
||||
#define __COOP_SCRIPTS_H
|
||||
|
||||
/* ---------- prototypes */
|
||||
|
||||
/* hs_library_external.c's volume_test_objects_all: whether to count the
|
||||
list as inside once any of it is, because every object in it is a player */
|
||||
boolean coop_scripts_any_player_will_do(
|
||||
long object_list_index);
|
||||
|
||||
/* What the scripts do to player0, done to the players they can't name too
|
||||
(the "followers"). Each does nothing unless `unit_index` is player0's in a
|
||||
co-op host's game. */
|
||||
|
||||
/* hs_library_external.c's object_teleport: around player0 */
|
||||
void coop_scripts_teleport_followers(
|
||||
long unit_index);
|
||||
/* units.c's unit_suspended */
|
||||
void coop_scripts_suspend_followers(
|
||||
long unit_index,
|
||||
boolean suspended);
|
||||
/* units.c's unit_exit_vehicle: those riding player0's vehicle get out */
|
||||
void coop_scripts_exit_followers(
|
||||
long unit_index,
|
||||
long vehicle_index);
|
||||
/* units.c's vehicle_load_magic and unit_enter_vehicle: into the vehicle,
|
||||
each in a free seat of the same kind as player0's (`seat_name`) */
|
||||
void coop_scripts_board_followers(
|
||||
long unit_index,
|
||||
long vehicle_index,
|
||||
char const *seat_name);
|
||||
|
||||
/* hs.c's game_safe_to_save, for the scripts: the game's own test, or in
|
||||
co-op, any one player alive, on the ground and unseen by enemies. The
|
||||
scripts wait on it before a cutscene, and with players spread out a fight
|
||||
somewhere else would hold up the one a player has reached. Checkpoints
|
||||
keep the game's own test. */
|
||||
boolean coop_scripts_safe_to_save(
|
||||
void);
|
||||
|
||||
/* hs.c's player_add_equipment, for the scripts: gives the starting profile
|
||||
to player0's followers too */
|
||||
void coop_scripts_player_add_equipment(
|
||||
long unit_index,
|
||||
short starting_profile_index,
|
||||
boolean reset_equipment);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
COOP_SPECTATE.C
|
||||
|
||||
Spectating in network co-op. A dead player watches a living teammate
|
||||
until they respawn (players.c respawns them beside a teammate once it is
|
||||
safe). The campaign's dead camera would watch the body; instead this
|
||||
follows a teammate from behind, and A (jump on the keyboard) switches to
|
||||
the next one. director.c and hud.c call in here.
|
||||
|
||||
It also draws the line telling players about the vote to skip a cutscene
|
||||
(network_coop.c counts the votes).
|
||||
*/
|
||||
|
||||
#include "cseries.h"
|
||||
#include "camera/dead_camera.h"
|
||||
#include "game/game.h"
|
||||
#include "game/game_engine.h"
|
||||
#include "game/players.h"
|
||||
#include "input/input.h"
|
||||
#include "interface/hud_messaging.h"
|
||||
#include "objects/objects.h"
|
||||
#include "rasterizer/rasterizer.h"
|
||||
#include "render/render.h"
|
||||
#include "text/draw_string.h"
|
||||
#include "text/font_group.h"
|
||||
#include "text/unicode.h"
|
||||
#include "units/units.h"
|
||||
|
||||
#include "coop_spectate.h"
|
||||
#include "network_coop.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* ---------- constants */
|
||||
|
||||
/* camera distance behind the unit, pitch (radians), and how much of the
|
||||
turn toward the unit's facing it makes each frame */
|
||||
#define SPECTATE_DISTANCE 3.5f
|
||||
#define SPECTATE_PITCH -0.3f
|
||||
#define SPECTATE_TURN 0.15f
|
||||
|
||||
/* a passenger (riding a Pelican) is watched from in front of them, above
|
||||
and looking down, so the camera stays inside the vehicle; a wide view (the
|
||||
observer allows up to 90 degrees) takes in all of them from that close */
|
||||
#define SPECTATE_PASSENGER_DISTANCE 1.0f
|
||||
#define SPECTATE_PASSENGER_PITCH -0.5f
|
||||
#define SPECTATE_PASSENGER_FIELD_OF_VIEW DEGREES_TO_RADIANS(85.0f)
|
||||
/* field of view for every other spectate view (dead_camera.c's default) */
|
||||
#define SPECTATE_FIELD_OF_VIEW DEGREES_TO_RADIANS(70.0f)
|
||||
|
||||
/* a teammate the scripts hold (Pillar of Autumn's cryo tube) is watched from
|
||||
in front, far enough back to see all of what holds them */
|
||||
#define SPECTATE_HELD_DISTANCE 2.0f
|
||||
#define SPECTATE_HELD_PITCH -0.1f
|
||||
|
||||
/* ---------- globals */
|
||||
|
||||
/* the player each local player is watching, or NONE */
|
||||
static long coop_spectate_watched[MAXIMUM_LOCAL_PLAYERS] = { NONE, NONE, NONE, NONE };
|
||||
|
||||
/* input_abstraction.c: how many ticks the keyboard's jump key has been held */
|
||||
byte input_abstraction_port_accept(short controller_index);
|
||||
|
||||
/* ---------- private code */
|
||||
|
||||
/* The next living player after `after` (or the first, if `after` is NONE),
|
||||
skipping `self` and wrapping around. NONE if nobody else is alive. */
|
||||
static long next_living_player(long self, long after)
|
||||
{
|
||||
struct data_iterator iterator;
|
||||
struct player_datum *player;
|
||||
long first = NONE;
|
||||
boolean passed = after == NONE;
|
||||
|
||||
data_iterator_new(&iterator, player_data);
|
||||
while ((player = data_iterator_next(&iterator)) != NULL)
|
||||
{
|
||||
if (iterator.datum_index == after)
|
||||
{
|
||||
passed = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (iterator.datum_index == self || player->unit_index == NONE)
|
||||
continue;
|
||||
if (passed)
|
||||
return iterator.datum_index;
|
||||
if (first == NONE)
|
||||
first = iterator.datum_index;
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
/* Returns TRUE once per press of A (or jump on the keyboard), however long
|
||||
it is held. The buttons count ticks, and one tick can span several frames,
|
||||
so testing "held" alone would switch more than once. */
|
||||
static boolean next_pressed(short controller_index)
|
||||
{
|
||||
static boolean held[MAXIMUM_GAMEPADS];
|
||||
struct gamepad_state const *gamepad;
|
||||
boolean down;
|
||||
boolean pressed;
|
||||
|
||||
if (controller_index < 0 || controller_index >= MAXIMUM_GAMEPADS)
|
||||
return FALSE;
|
||||
gamepad = input_get_gamepad_state(controller_index);
|
||||
down = (gamepad && gamepad->buttons[FIRST_GAMEPAD_ANALOG_BUTTON + _gamepad_analog_button_a] > 0) ||
|
||||
input_abstraction_port_accept(controller_index) > 0;
|
||||
pressed = down && !held[controller_index];
|
||||
held[controller_index] = down;
|
||||
return pressed;
|
||||
}
|
||||
|
||||
/* whether the unit rides in a vehicle it isn't driving */
|
||||
static boolean unit_is_passenger(
|
||||
long unit_index)
|
||||
{
|
||||
long vehicle_index = object_get(unit_index)->object.parent_object_index;
|
||||
|
||||
return vehicle_index != NONE && object_try_and_get_and_verify_type(vehicle_index, _object_mask_unit) &&
|
||||
unit_get(vehicle_index)->unit.driver_object_index != unit_index;
|
||||
}
|
||||
|
||||
/* ---------- public code */
|
||||
|
||||
boolean coop_spectating(
|
||||
void)
|
||||
{
|
||||
return network_coop_active();
|
||||
}
|
||||
|
||||
long coop_spectate_unit(
|
||||
short local_player_index)
|
||||
{
|
||||
long self = local_player_get_player_index(local_player_index);
|
||||
long *watched = &coop_spectate_watched[local_player_index];
|
||||
struct player_datum *player;
|
||||
|
||||
boolean next;
|
||||
|
||||
if (self == NONE)
|
||||
return NONE;
|
||||
player = player_get(self);
|
||||
/* checked every frame so a press is never missed or counted twice */
|
||||
next = next_pressed(player->network_player_data.controller_index);
|
||||
/* alive: keep `watched`, so the next death starts on the same teammate */
|
||||
if (player->unit_index != NONE)
|
||||
return NONE;
|
||||
if (*watched == NONE || !player_try_and_get(*watched) || player_get(*watched)->unit_index == NONE || next)
|
||||
{
|
||||
*watched = next_living_player(self, *watched);
|
||||
}
|
||||
|
||||
return *watched != NONE ? player_get(*watched)->unit_index : NONE;
|
||||
}
|
||||
|
||||
boolean coop_spectate_watching_rider(
|
||||
short local_player_index)
|
||||
{
|
||||
long self = local_player_get_player_index(local_player_index);
|
||||
long watched = coop_spectate_watched[local_player_index];
|
||||
long unit_index;
|
||||
long driver_index;
|
||||
|
||||
if (self == NONE || player_get(self)->unit_index != NONE)
|
||||
return FALSE;
|
||||
/* the scripted camera may have been running since before this player
|
||||
died, so nobody has been picked to watch yet */
|
||||
if (watched == NONE || !player_try_and_get(watched) || player_get(watched)->unit_index == NONE)
|
||||
watched = next_living_player(self, NONE);
|
||||
unit_index = watched != NONE ? player_get(watched)->unit_index : NONE;
|
||||
if (unit_index == NONE || !unit_is_passenger(unit_index))
|
||||
return FALSE;
|
||||
driver_index = unit_get(object_get(unit_index)->object.parent_object_index)->unit.driver_object_index;
|
||||
return driver_index == NONE || unit_get(driver_index)->unit.player_index == NONE;
|
||||
}
|
||||
|
||||
boolean coop_spectate_nothing_to_watch(
|
||||
short local_player_index)
|
||||
{
|
||||
long self = local_player_get_player_index(local_player_index);
|
||||
|
||||
return self != NONE && player_get(self)->unit_index == NONE && next_living_player(self, NONE) == NONE;
|
||||
}
|
||||
|
||||
void coop_spectate_camera(
|
||||
struct dead_camera *camera)
|
||||
{
|
||||
struct object_datum *unit = camera->unit_index != NONE ? object_try_and_get(camera->unit_index) : NULL;
|
||||
real yaw, turn;
|
||||
|
||||
if (!unit)
|
||||
return;
|
||||
yaw = (real)atan2(unit->object.forward.j, unit->object.forward.i);
|
||||
if (unit_is_passenger(camera->unit_index))
|
||||
{
|
||||
/* fixed in front of the seat, turning with the vehicle */
|
||||
camera->facing.yaw = yaw + _pi;
|
||||
camera->facing.pitch = SPECTATE_PASSENGER_PITCH;
|
||||
camera->distance = SPECTATE_PASSENGER_DISTANCE;
|
||||
camera->field_of_view = SPECTATE_PASSENGER_FIELD_OF_VIEW;
|
||||
return;
|
||||
}
|
||||
camera->field_of_view = SPECTATE_FIELD_OF_VIEW;
|
||||
if (!player_input_enabled())
|
||||
{
|
||||
camera->facing.yaw = yaw + _pi;
|
||||
camera->facing.pitch = SPECTATE_HELD_PITCH;
|
||||
camera->distance = SPECTATE_HELD_DISTANCE;
|
||||
return;
|
||||
}
|
||||
/* ease the camera round behind the unit */
|
||||
turn = yaw - camera->facing.yaw;
|
||||
while (turn > _pi)
|
||||
turn -= 2.0f * _pi;
|
||||
while (turn < -_pi)
|
||||
turn += 2.0f * _pi;
|
||||
camera->facing.yaw += turn * SPECTATE_TURN;
|
||||
camera->facing.pitch = SPECTATE_PITCH;
|
||||
camera->distance = SPECTATE_DISTANCE;
|
||||
}
|
||||
|
||||
/* centred text near the bottom of the screen, in the HUD's font */
|
||||
static void draw_bottom_text(
|
||||
wchar_t const *text)
|
||||
{
|
||||
long font_index = hud_get_font_index();
|
||||
struct font_header *font;
|
||||
real_argb_color color = *global_real_argb_white;
|
||||
rectangle2d bounds;
|
||||
short height;
|
||||
|
||||
if (font_index == NONE)
|
||||
return;
|
||||
font = font_definition_get(font_index);
|
||||
height = (short)(font->ascending_height + font->descending_height);
|
||||
bounds = render.camera.window_bounds;
|
||||
bounds.y0 = (short)(bounds.y1 - 3 * height - 24);
|
||||
bounds.y1 = (short)(bounds.y1 - 24);
|
||||
/* draw mode 2: centered */
|
||||
draw_string_set_draw_mode(font_index, NONE, 2, 0, &color);
|
||||
rasterizer_draw_unicode_string(&bounds, NULL, NULL, 0, text);
|
||||
}
|
||||
|
||||
void coop_spectate_draw(
|
||||
short local_player_index)
|
||||
{
|
||||
long watched = coop_spectate_watched[local_player_index];
|
||||
wchar_t text[96];
|
||||
wchar_t const *hint;
|
||||
|
||||
/* nobody to watch yet (still joining): network_coop.c shows the host's
|
||||
view from behind instead */
|
||||
if (watched == NONE || !player_try_and_get(watched))
|
||||
{
|
||||
if (coop_spectate_nothing_to_watch(local_player_index))
|
||||
draw_bottom_text(L"JOINING THE GAME\r\nYou spawn beside a teammate once it is safe");
|
||||
return;
|
||||
}
|
||||
if (!players_coop_waiting_to_start(local_player_get_player_index(local_player_index)))
|
||||
hint = L"You come back beside them once it is safe";
|
||||
else
|
||||
hint = L"You join them when they're on foot";
|
||||
usnprintf(text, NUMBEROF(text) - 1, L"SPECTATING %.12s (A: NEXT)\r\n%s", player_get(watched)->name, hint);
|
||||
text[NUMBEROF(text) - 1] = 0;
|
||||
draw_bottom_text(text);
|
||||
}
|
||||
|
||||
void coop_skip_vote_draw(
|
||||
short local_player_index)
|
||||
{
|
||||
short votes, voters;
|
||||
boolean voted;
|
||||
wchar_t text[96];
|
||||
|
||||
/* once, for the first local player */
|
||||
if (local_player_index != local_player_get_next(NONE) || !network_coop_skip_vote_status(&votes, &voters, &voted))
|
||||
return;
|
||||
if (voted)
|
||||
usnprintf(text, NUMBEROF(text) - 1, L"VOTED TO SKIP %d OF %d", votes, voters);
|
||||
else
|
||||
usnprintf(text, NUMBEROF(text) - 1, L"PRESS SPACE OR A TO VOTE TO SKIP %d OF %d", votes, voters);
|
||||
text[NUMBEROF(text) - 1] = 0;
|
||||
draw_bottom_text(text);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
COOP_SPECTATE.H
|
||||
|
||||
Spectating in network co-op, and the cutscene skip vote's line
|
||||
(coop_spectate.c).
|
||||
*/
|
||||
|
||||
#ifndef __COOP_SPECTATE_H
|
||||
#define __COOP_SPECTATE_H
|
||||
|
||||
struct dead_camera;
|
||||
|
||||
/* whether this is network co-op: a network game with no game engine (a campaign map) */
|
||||
boolean coop_spectating(
|
||||
void);
|
||||
|
||||
/* the unit a dead local player watches (A switches teammate), or NONE if
|
||||
the player is alive or nobody else is */
|
||||
long coop_spectate_unit(
|
||||
short local_player_index);
|
||||
|
||||
/* TRUE if the teammate this local player is spectating (while dead or not
|
||||
yet spawned) rides in an AI-driven vehicle, such as an insertion Pelican.
|
||||
network_coop.c then shows that seat instead of the scripted camera. */
|
||||
boolean coop_spectate_watching_rider(
|
||||
short local_player_index);
|
||||
|
||||
/* whether a local player has nothing to look at: no unit of its own and
|
||||
no living teammate to watch (network_coop.c shows it the host's view) */
|
||||
boolean coop_spectate_nothing_to_watch(
|
||||
short local_player_index);
|
||||
|
||||
/* keeps the dead camera behind the watched unit as it turns */
|
||||
void coop_spectate_camera(
|
||||
struct dead_camera *camera);
|
||||
|
||||
/* the HUD line saying who a dead local player is watching */
|
||||
void coop_spectate_draw(
|
||||
short local_player_index);
|
||||
|
||||
/* during a skippable cutscene in network co-op, the vote count and how to vote */
|
||||
void coop_skip_vote_draw(
|
||||
short local_player_index);
|
||||
|
||||
#endif
|
||||
@@ -23,6 +23,11 @@ game keeps its own menus.
|
||||
The tag table cannot grow where it is (the tags' names follow it), so it
|
||||
is copied, with ours after it; every existing tag keeps its index. All of it
|
||||
is let go in scenario_tags_unload, before the next map's tags load.
|
||||
|
||||
A multiplayer map gets them too, for its in-game pause menu's SETTINGS
|
||||
(pause_patch): there the map's tags they name that it has not (ui.map's
|
||||
pictures, sounds and screens) are none, a missing picture drawn blank, and
|
||||
no screen pauses the game (a network game's clock runs on).
|
||||
*/
|
||||
|
||||
#include "cseries.h"
|
||||
@@ -40,6 +45,11 @@ is let go in scenario_tags_unload, before the next map's tags load.
|
||||
/* the platform layer's (port/linux/src) */
|
||||
void platform_log(char const *format, ...);
|
||||
char const *config_string(char const *name);
|
||||
int platform_display_resolutions(long *widths, long *heights, int maximum);
|
||||
int platform_window_sizes(long *widths, long *heights, int maximum);
|
||||
|
||||
/* the game's network server (this machine hosts: network_game_globals.c) */
|
||||
void *global_network_game_server_get(void);
|
||||
|
||||
/* cache_files.c's (port) */
|
||||
void *cache_files_tag_instances(long *count);
|
||||
@@ -59,6 +69,13 @@ boolean pc_menu_tag(long tag_index);
|
||||
/* ---------- constants */
|
||||
|
||||
#define PC_MENU_TAG_PREFIX "pc\\"
|
||||
/* the multiplayer maps' widget collection, whose pause screens pause_patch
|
||||
adds to */
|
||||
#define MULTIPLAYER_COLLECTION "ui\\shell\\multiplayer"
|
||||
/* the tags pause_patch adds: two buttons and their texts */
|
||||
#define PAUSE_PATCH_TAGS 4
|
||||
/* what a frame of ui.map's is drawn as in a game map, which has not got it */
|
||||
#define BLANK_PNG "ce/port/blank__0.png"
|
||||
#define UI_WIDGET_DEFINITION_TAG 'DeLa'
|
||||
#define UNICODE_STRING_LIST_TAG 'ustr'
|
||||
#define FONT_TAG 'font'
|
||||
@@ -326,6 +343,12 @@ static char const *const port_function_names[] =
|
||||
"mp level select", "mp profiles list initialize", "mp profiles list dispose", "mp profile set for game",
|
||||
"port lobby preview join",
|
||||
"port setup edit",
|
||||
"port map list back",
|
||||
"port pause end game",
|
||||
"port coop begin", "port coop player 2 list initialize", "port coop player 2",
|
||||
"port lobby open", "port lobby add player", "port lobby join", "port lobby leave",
|
||||
"port lobby player list initialize", "port lobby player choose",
|
||||
"port lobby preview add", "port lobby preview leave",
|
||||
/* (the gametype editor's: the Xbox's walk their rows by place, which the
|
||||
PC version's screens changed) */
|
||||
"mp profile begin editing", "mp profile save changes", "request del playlist profile", "final del playlist profile",
|
||||
@@ -335,6 +358,11 @@ static char const *const port_function_names[] =
|
||||
"mp profile init indicator opts", "mp profile set ctf rules", "mp profile set koth rules",
|
||||
"mp profile set slayer rules", "mp profile set oddball rules", "mp profile set racing rules",
|
||||
"mp profile set player options", "mp profile set item options", "mp profile set indicator opts",
|
||||
/* (Settings' OK: the Xbox's fails when the profile has no changes, the
|
||||
settings' screens having written theirs to config.toml) */
|
||||
"player profile save changes",
|
||||
/* (the server browser's password screen) */
|
||||
"port password init", "port password edit", "port password join", "port password back",
|
||||
};
|
||||
|
||||
/* the PC version's game data functions that the Xbox's have not, from
|
||||
@@ -352,6 +380,7 @@ static char const *const port_game_data_input_names[] =
|
||||
/* (the gametype editor's: the Xbox's stops the game on the buttons'
|
||||
row; the Xbox's read only player_ui's gametype, not Server Setup's) */
|
||||
"game settings lists text update", "get edit game settings name", "mp edit profile set rule text",
|
||||
"port password update",
|
||||
};
|
||||
|
||||
static struct
|
||||
@@ -384,6 +413,9 @@ static struct
|
||||
long *text_tags;
|
||||
long *spinner_tags;
|
||||
boolean failed;
|
||||
/* a multiplayer map's build (the pause menu's SETTINGS): what the map
|
||||
has not got is none, not a failure */
|
||||
boolean game_map;
|
||||
} build;
|
||||
|
||||
/* ---------- private code */
|
||||
@@ -497,7 +529,8 @@ static long map_tag(long group_tag, char const *name, char const *file, long lin
|
||||
{
|
||||
long index = tag_loaded(group_tag, name);
|
||||
|
||||
if (index == NONE)
|
||||
/* (a game map has few of ui.map's: those are none) */
|
||||
if (index == NONE && !build.game_map)
|
||||
problem(file, line, "the map has no tag", name);
|
||||
return index;
|
||||
}
|
||||
@@ -674,6 +707,41 @@ static long split(char const *text, char const **pieces)
|
||||
return count;
|
||||
}
|
||||
|
||||
/* a spinner's strings, or its values, split: its own, but Video Setup's
|
||||
sizes are the display's (sdl_platform.c), shown "1920 x 1080" and set
|
||||
"1920x1080": its resolutions after Resolution's own (NATIVE), and the
|
||||
window sizes that fit it in place of Window Size's own */
|
||||
static long spinner_split(struct halo_menu_widget const *widget, boolean values, char const **pieces)
|
||||
{
|
||||
long count = split(values ? widget->values : widget->strings, pieces);
|
||||
long widths[MAXIMUM_STRINGS], heights[MAXIMUM_STRINGS];
|
||||
long added, index;
|
||||
|
||||
if (widget->setting && !strcmp(widget->setting, "display.resolution"))
|
||||
added = platform_display_resolutions(widths, heights, (int)(MAXIMUM_STRINGS - count));
|
||||
else if (widget->setting && !strcmp(widget->setting, "display.window_size"))
|
||||
{
|
||||
added = platform_window_sizes(widths, heights, MAXIMUM_STRINGS);
|
||||
if (added > 0)
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
return count;
|
||||
for (index = 0; index < added; index++)
|
||||
{
|
||||
char text[32];
|
||||
char *piece;
|
||||
|
||||
snprintf(text, sizeof(text), values ? "%ldx%ld" : "%ld x %ld", widths[index], heights[index]);
|
||||
piece = allocate((long)strlen(text) + 1);
|
||||
if (!piece)
|
||||
break;
|
||||
strcpy(piece, text);
|
||||
pieces[count++] = piece;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void *bitmap_build(struct halo_menu_bitmap const *source, long tag_index)
|
||||
{
|
||||
struct bitmap_group *group = allocate(sizeof(struct bitmap_group));
|
||||
@@ -698,10 +766,18 @@ static void *bitmap_build(struct halo_menu_bitmap const *source, long tag_index)
|
||||
{
|
||||
struct halo_menu_frame const *data = &build.menus->frames[source->first_frame + frame];
|
||||
struct bitmap_data *bitmap = &bitmaps[frame];
|
||||
char const *png = data->png;
|
||||
long width = data->width, height = data->height;
|
||||
|
||||
/* (a frame of the map's: a copy of its bitmap, which the texture cache
|
||||
loads from the map as its own) */
|
||||
if (data->map)
|
||||
loads from the map as its own; in a game map that has not got it,
|
||||
nothing) */
|
||||
if (data->map && build.game_map && tag_loaded(BITMAP_GROUP_TAG, data->map) == NONE)
|
||||
{
|
||||
png = BLANK_PNG;
|
||||
width = height = PLACEHOLDER_SIZE;
|
||||
}
|
||||
else if (data->map)
|
||||
{
|
||||
long group_index = map_tag(BITMAP_GROUP_TAG, data->map, source->file, source->line);
|
||||
struct bitmap_group *group_source;
|
||||
@@ -720,9 +796,9 @@ static void *bitmap_build(struct halo_menu_bitmap const *source, long tag_index)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data->width <= 0 || data->height <= 0 || data->width > 2048 || data->height > 2048)
|
||||
if (width <= 0 || height <= 0 || width > 2048 || height > 2048)
|
||||
{
|
||||
problem(source->file, source->line, "a frame is 1 to 2048 wide and high:", data->png);
|
||||
problem(source->file, source->line, "a frame is 1 to 2048 wide and high:", png);
|
||||
return group;
|
||||
}
|
||||
/* (its D3D texture is a small one, which its PNG is drawn for: the
|
||||
@@ -741,13 +817,13 @@ static void *bitmap_build(struct halo_menu_bitmap const *source, long tag_index)
|
||||
problem(source->file, source->line, "could not make the texture of bitmap", source->name);
|
||||
return group;
|
||||
}
|
||||
bitmap->width = (short)data->width;
|
||||
bitmap->height = (short)data->height;
|
||||
bitmap->width = (short)width;
|
||||
bitmap->height = (short)height;
|
||||
menu_tags.bitmaps = realloc(menu_tags.bitmaps, (menu_tags.bitmap_count + 1) * sizeof(*menu_tags.bitmaps));
|
||||
menu_tags.bitmaps[menu_tags.bitmap_count++] = bitmap;
|
||||
/* (none without a renderer: debug.null_renderer) */
|
||||
if (bitmap->hardware_format)
|
||||
halo_menus_art_register(bitmap->hardware_format, data->png);
|
||||
halo_menus_art_register(bitmap->hardware_format, png);
|
||||
}
|
||||
return group;
|
||||
}
|
||||
@@ -880,7 +956,7 @@ static void setting_add(struct halo_menu_widget const *source, long definition_i
|
||||
setting->definition_index = definition_index;
|
||||
setting->setting = source->setting;
|
||||
setting->loaded_index = NONE;
|
||||
setting->value_count = split(source->values, setting->values);
|
||||
setting->value_count = spinner_split(source, TRUE, setting->values);
|
||||
}
|
||||
|
||||
/* a font: large, small, terminal, or the map's by its path */
|
||||
@@ -928,6 +1004,9 @@ static void *widget_build(long widget_index)
|
||||
definition->bounds.x1 = (short)(source->left + (source->has_width ? source->width : 640));
|
||||
definition->flags = flags_parse(source->flags, widget_flag_names, NUMBEROF(widget_flag_names),
|
||||
source->file, source->line);
|
||||
/* (in a network game the clock runs on) */
|
||||
if (build.game_map)
|
||||
definition->flags &= ~FLAG(1); /* pause_game */
|
||||
definition->milliseconds_to_auto_close = source->auto_close;
|
||||
definition->auto_close_fade_time = source->auto_close_fade;
|
||||
reference_clear(&definition->background_bitmap, BITMAP_GROUP_TAG);
|
||||
@@ -1170,6 +1249,14 @@ static struct cache_file_tag_instance *instances_grow(long count, long *first_in
|
||||
|
||||
if (!instances)
|
||||
return NULL;
|
||||
/* (every tag's absolute index fits a tag index's 16 bits, short of
|
||||
NONE's, and the table's size cannot wrap: the map's count was checked
|
||||
as it loaded, cache_files.c, and is again) */
|
||||
if (existing < 0 || count < 0 || existing > UNSIGNED_SHORT_MAX - count)
|
||||
{
|
||||
platform_log("menus: %ld tags and the map's %ld are too many for a tag table", count, existing);
|
||||
return NULL;
|
||||
}
|
||||
grown = allocate((existing + count) * sizeof(*grown));
|
||||
if (!grown)
|
||||
return NULL;
|
||||
@@ -1250,6 +1337,281 @@ static void menu_tags_release(void)
|
||||
|
||||
/* ---------- public code */
|
||||
|
||||
/* ---------- the in-game pause menu (a multiplayer map's)
|
||||
|
||||
Its list (RESUME GAME, LEAVE GAME; a custom map's own buttons too) gets
|
||||
SETTINGS, the menus' settings (as the main menu's SETTINGS opens them), and
|
||||
for the host END GAME, which ends the game as its time limit would: its
|
||||
players stay, and the host picks the next map after the carnage report.
|
||||
They are copies of the map's LEAVE GAME button (its look), put before it.
|
||||
The map's pause screens move to fit them: on the Xbox's own (its box of
|
||||
pausebox2 pieces), the box is the port's taller one (pause/pausebox_*:
|
||||
tools/port_settings.py), centred where the old one was; on a custom map's,
|
||||
what is below the list moves down. */
|
||||
|
||||
#define PAUSE_SETTINGS_SCREEN "main_menu/settings_select/player_setup/player_profile_edit/player_profile_edit_screen"
|
||||
#define PAUSE_BUTTON_SPACING 35
|
||||
#define PAUSE_BOX_FIRST_BUTTONS 3
|
||||
|
||||
static long ui_function_named(char const *name)
|
||||
{
|
||||
long index;
|
||||
|
||||
for (index = 0; index < 512; index++)
|
||||
{
|
||||
char const *function = ui_widget_event_handler_function_name(index);
|
||||
|
||||
if (!function)
|
||||
break;
|
||||
if (!strcmp(function, name))
|
||||
return index;
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
static boolean tag_name_ends(long tag_index, char const *end)
|
||||
{
|
||||
char const *name = tag_index == NONE ? NULL : tag_get_name(tag_index);
|
||||
size_t length = name ? strlen(name) : 0, end_length = strlen(end);
|
||||
|
||||
return name && length >= end_length && !strcmp(name + length - end_length, end);
|
||||
}
|
||||
|
||||
/* the index of the list's button that runs the function (LEAVE GAME's),
|
||||
else NONE */
|
||||
static long pause_quit_button(struct ui_widget_definition const *list, long quit_function)
|
||||
{
|
||||
struct ui_widget_child_reference const *children = list->child_widgets.address;
|
||||
long child;
|
||||
|
||||
for (child = 0; child < list->child_widgets.count; child++)
|
||||
{
|
||||
struct ui_widget_definition const *button;
|
||||
struct ui_widget_event_handler_reference const *handlers;
|
||||
long handler;
|
||||
|
||||
if (children[child].widget_tag.index == NONE)
|
||||
continue;
|
||||
button = tag_get(UI_WIDGET_DEFINITION_TAG, children[child].widget_tag.index);
|
||||
handlers = button->event_handlers.address;
|
||||
for (handler = 0; handler < button->event_handlers.count; handler++)
|
||||
{
|
||||
if (handlers[handler].function == quit_function &&
|
||||
TEST_FLAG(handlers[handler].flags, _event_handler_run_function_bit))
|
||||
{
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
/* a button like the model (its look), its own text, each of the model's
|
||||
events (its A and Start) running the function and opening the widget (if
|
||||
not NONE) */
|
||||
static void *pause_button(struct cache_file_tag_instance *instances, struct ui_widget_definition const *model,
|
||||
char const *name, char const *text, long function, long widget_tag)
|
||||
{
|
||||
struct ui_widget_definition *button = allocate(sizeof(*button));
|
||||
struct ui_widget_event_handler_reference *handlers =
|
||||
allocate(model->event_handlers.count * sizeof(struct ui_widget_event_handler_reference));
|
||||
long text_tag = next_tag(), handler;
|
||||
|
||||
if (!button || !handlers)
|
||||
return NULL;
|
||||
memcpy(button, model, sizeof(*button));
|
||||
instance_set(instances, UNICODE_STRING_LIST_TAG, text_tag, name, " text", string_list_build(&text, 1));
|
||||
reference_set(&button->text_label_string_list, UNICODE_STRING_LIST_TAG, text_tag);
|
||||
button->string_list_index = 0;
|
||||
button->game_data_inputs.count = 0;
|
||||
button->game_data_inputs.address = NULL;
|
||||
/* (the game's memcpy asserts on a NULL source, even for nothing) */
|
||||
if (model->event_handlers.count)
|
||||
memcpy(handlers, model->event_handlers.address, model->event_handlers.count * sizeof(*handlers));
|
||||
for (handler = 0; handler < model->event_handlers.count; handler++)
|
||||
{
|
||||
handlers[handler].flags = FLAG(_event_handler_run_function_bit);
|
||||
handlers[handler].function = (short)function;
|
||||
handlers[handler].script[0] = 0;
|
||||
reference_set(&handlers[handler].widget_tag, UI_WIDGET_DEFINITION_TAG, widget_tag);
|
||||
if (widget_tag != NONE)
|
||||
{
|
||||
handlers[handler].flags |= FLAG(_event_handler_open_widget_bit) |
|
||||
FLAG(_event_handler_try_to_branch_on_failure_bit);
|
||||
}
|
||||
}
|
||||
button->event_handlers.address = handlers;
|
||||
return button;
|
||||
}
|
||||
|
||||
/* the list's buttons: SETTINGS (and the host's END GAME) put before LEAVE
|
||||
GAME (quit); returns how many were added */
|
||||
static long pause_list_patch(struct cache_file_tag_instance *instances, struct ui_widget_definition *list, long quit,
|
||||
boolean host)
|
||||
{
|
||||
struct ui_widget_child_reference *children = list->child_widgets.address;
|
||||
long count = list->child_widgets.count, added = host ? 2 : 1, child;
|
||||
struct ui_widget_child_reference *grown = allocate((count + added) * sizeof(struct ui_widget_child_reference));
|
||||
struct ui_widget_definition const *model = tag_get(UI_WIDGET_DEFINITION_TAG, children[quit].widget_tag.index);
|
||||
long settings_widget = widget_named(PAUSE_SETTINGS_SCREEN);
|
||||
short spacing = count >= 2 ? (short)(children[count - 1].vertical_offset - children[count - 2].vertical_offset) :
|
||||
PAUSE_BUTTON_SPACING;
|
||||
void *buttons[2];
|
||||
long tags[2];
|
||||
|
||||
if (!grown || settings_widget == NONE || spacing <= 0)
|
||||
return 0;
|
||||
tags[0] = next_tag();
|
||||
buttons[0] = pause_button(instances, model, "pause/settings_button", "SETTINGS",
|
||||
function_index("profile set edit begin", "pause", 0), build.widget_tags[settings_widget]);
|
||||
tags[1] = host ? next_tag() : NONE;
|
||||
buttons[1] = host ? pause_button(instances, model, "pause/end_game_button", "END GAME",
|
||||
function_index("port pause end game", "pause", 0), NONE) : NULL;
|
||||
if (!buttons[0] || (host && !buttons[1]))
|
||||
return 0;
|
||||
for (child = 0; child < added; child++)
|
||||
{
|
||||
instance_set(instances, UI_WIDGET_DEFINITION_TAG, tags[child],
|
||||
child ? "pause/end_game_button" : "pause/settings_button", "", buttons[child]);
|
||||
}
|
||||
if (quit)
|
||||
memcpy(grown, children, quit * sizeof(*grown));
|
||||
for (child = 0; child < added; child++)
|
||||
{
|
||||
grown[quit + child] = children[quit];
|
||||
reference_set(&grown[quit + child].widget_tag, UI_WIDGET_DEFINITION_TAG, tags[child]);
|
||||
grown[quit + child].vertical_offset = (short)(children[quit].vertical_offset + child * spacing);
|
||||
}
|
||||
for (child = quit; child < count; child++)
|
||||
{
|
||||
grown[child + added] = children[child];
|
||||
grown[child + added].vertical_offset = (short)(children[child].vertical_offset + added * spacing);
|
||||
}
|
||||
list->child_widgets.address = grown;
|
||||
list->child_widgets.count = count + added;
|
||||
/* (the list draws within its bounds) */
|
||||
list->bounds.y1 = (short)(list->bounds.y1 + added * spacing);
|
||||
return added;
|
||||
}
|
||||
|
||||
/* the Xbox's own box: a widget of the three pausebox2 pieces */
|
||||
static boolean pause_box_stock(struct ui_widget_definition const *box)
|
||||
{
|
||||
struct ui_widget_child_reference const *pieces = box->child_widgets.address;
|
||||
|
||||
return box->child_widgets.count == 3 && tag_name_ends(pieces[0].widget_tag.index, "\\pausebox2_left") &&
|
||||
tag_name_ends(pieces[1].widget_tag.index, "\\pausebox2_left_center") &&
|
||||
tag_name_ends(pieces[2].widget_tag.index, "\\pausebox2_right");
|
||||
}
|
||||
|
||||
/* the stock box's pieces drawn with the port's taller box: its frame for
|
||||
the number of buttons */
|
||||
static void pause_box_redraw(struct ui_widget_definition const *box, long buttons)
|
||||
{
|
||||
static char const *const names[] = { "pause/pausebox_left", "pause/pausebox_center", "pause/pausebox_right" };
|
||||
struct ui_widget_child_reference const *pieces = box->child_widgets.address;
|
||||
long piece;
|
||||
|
||||
for (piece = 0; piece < 3; piece++)
|
||||
{
|
||||
struct ui_widget_definition *definition = tag_get(UI_WIDGET_DEFINITION_TAG, pieces[piece].widget_tag.index);
|
||||
long bitmap = find(names[piece], build.menus->bitmap_count, bitmap_name);
|
||||
struct bitmap_group *group;
|
||||
struct bitmap_group_sequence *sequence;
|
||||
|
||||
if (bitmap == NONE)
|
||||
continue;
|
||||
group = bitmap_group_get(build.bitmap_tags[bitmap]);
|
||||
sequence = group->sequences.address;
|
||||
/* (one frame: the one for the number of buttons) */
|
||||
sequence->first_bitmap_index = (short)PIN(buttons - PAUSE_BOX_FIRST_BUTTONS, 0, group->bitmaps.count - 1);
|
||||
sequence->bitmap_count = 1;
|
||||
reference_set(&definition->background_bitmap, BITMAP_GROUP_TAG, build.bitmap_tags[bitmap]);
|
||||
definition->bounds.y1 = (short)(definition->bounds.y0 + 256);
|
||||
}
|
||||
}
|
||||
|
||||
static void pause_patch(struct cache_file_tag_instance *instances)
|
||||
{
|
||||
long collection = tag_loaded('Soul', MULTIPLAYER_COLLECTION);
|
||||
long quit_function = ui_function_named("mp game player quit");
|
||||
boolean host = global_network_game_server_get() != NULL;
|
||||
struct tag_block const *screens;
|
||||
long patched_list = NONE, added = 0, buttons = 0, screen;
|
||||
boolean box_redrawn = FALSE;
|
||||
|
||||
if (collection == NONE || quit_function == NONE)
|
||||
return;
|
||||
screens = tag_get('Soul', collection);
|
||||
for (screen = 0; screen < screens->count; screen++)
|
||||
{
|
||||
long screen_tag = ((struct tag_reference const *)screens->address)[screen].index;
|
||||
struct ui_widget_definition *definition;
|
||||
struct ui_widget_child_reference *children;
|
||||
long child, list_child = NONE, box_child = NONE;
|
||||
short grow, list_top;
|
||||
|
||||
if (screen_tag == NONE)
|
||||
continue;
|
||||
definition = tag_get(UI_WIDGET_DEFINITION_TAG, screen_tag);
|
||||
children = definition->child_widgets.address;
|
||||
for (child = 0; child < definition->child_widgets.count && list_child == NONE; child++)
|
||||
{
|
||||
struct ui_widget_definition *list;
|
||||
long quit;
|
||||
|
||||
if (children[child].widget_tag.index == NONE)
|
||||
continue;
|
||||
list = tag_get(UI_WIDGET_DEFINITION_TAG, children[child].widget_tag.index);
|
||||
if (list->type != _widget_type_column_list)
|
||||
continue;
|
||||
/* (one list, which the screens share: patched once) */
|
||||
if (children[child].widget_tag.index == patched_list)
|
||||
{
|
||||
list_child = child;
|
||||
continue;
|
||||
}
|
||||
quit = pause_quit_button(list, quit_function);
|
||||
if (quit == NONE || patched_list != NONE)
|
||||
continue;
|
||||
added = pause_list_patch(instances, list, quit, host);
|
||||
if (!added)
|
||||
return;
|
||||
buttons = list->child_widgets.count;
|
||||
patched_list = children[child].widget_tag.index;
|
||||
list_child = child;
|
||||
}
|
||||
if (list_child == NONE)
|
||||
continue;
|
||||
for (child = 0; child < definition->child_widgets.count; child++)
|
||||
{
|
||||
if (child != list_child && children[child].widget_tag.index != NONE &&
|
||||
pause_box_stock(tag_get(UI_WIDGET_DEFINITION_TAG, children[child].widget_tag.index)))
|
||||
{
|
||||
box_child = child;
|
||||
}
|
||||
}
|
||||
/* the stock box: taller, centred where it was, the list with it, and
|
||||
what is below it moved down; else only what is below the list */
|
||||
grow = (short)(added * PAUSE_BUTTON_SPACING);
|
||||
list_top = children[list_child].vertical_offset;
|
||||
for (child = 0; child < definition->child_widgets.count; child++)
|
||||
{
|
||||
if (box_child != NONE && (child == box_child || child == list_child))
|
||||
children[child].vertical_offset -= grow / 2;
|
||||
else if (children[child].vertical_offset > list_top)
|
||||
children[child].vertical_offset += box_child != NONE ? grow - grow / 2 : grow;
|
||||
}
|
||||
if (box_child != NONE && !box_redrawn)
|
||||
{
|
||||
pause_box_redraw(tag_get(UI_WIDGET_DEFINITION_TAG, children[box_child].widget_tag.index), buttons);
|
||||
box_redrawn = TRUE;
|
||||
}
|
||||
}
|
||||
if (patched_list != NONE)
|
||||
platform_log("menus: the pause menu has SETTINGS%s", host ? " and END GAME" : "");
|
||||
}
|
||||
|
||||
void menu_tags_loaded(
|
||||
char const *map_name)
|
||||
{
|
||||
@@ -1257,17 +1619,23 @@ void menu_tags_loaded(
|
||||
struct cache_file_tag_instance *instances;
|
||||
long widget_count, own_lists = 0, total, index;
|
||||
|
||||
if (strcmp(map_name, "ui") || strcmp(config_string("display.menus"), "pc"))
|
||||
boolean game_map = strcmp(map_name, "ui") != 0;
|
||||
|
||||
/* (ui.map, and a multiplayer map: its pause menu's SETTINGS) */
|
||||
if ((game_map && tag_loaded('Soul', MULTIPLAYER_COLLECTION) == NONE) ||
|
||||
strcmp(config_string("display.menus"), "pc"))
|
||||
{
|
||||
return;
|
||||
/* (in VR, the Xbox's: the VR port's join codes, game list, host options
|
||||
and keyboard pointer are built into its screens) */
|
||||
if (halo_vr_active())
|
||||
}
|
||||
/* (in VR, the Xbox's unless vr.menus asks for the PC version's) */
|
||||
if (halo_vr_active() && strcmp(config_string("vr.menus"), "pc"))
|
||||
return;
|
||||
menus = halo_menus_load();
|
||||
if (!menus)
|
||||
return;
|
||||
memset(&build, 0, sizeof(build));
|
||||
build.menus = menus;
|
||||
build.game_map = game_map;
|
||||
widget_count = menus->widget_count;
|
||||
build.widget_tags = malloc((widget_count + 1) * sizeof(long));
|
||||
build.text_tags = malloc((widget_count + 1) * sizeof(long));
|
||||
@@ -1282,7 +1650,8 @@ void menu_tags_loaded(
|
||||
problem(menus->widgets[index].file, menus->widgets[index].line, "two widgets are named",
|
||||
menus->widgets[index].name);
|
||||
}
|
||||
total = widget_count + own_lists + menus->string_list_count + menus->bitmap_count;
|
||||
total = widget_count + own_lists + menus->string_list_count + menus->bitmap_count +
|
||||
(game_map ? PAUSE_PATCH_TAGS : 0);
|
||||
instances = build.failed ? NULL : instances_grow(total, &build.first_index, &build.first_salt);
|
||||
if (!instances)
|
||||
goto failed;
|
||||
@@ -1323,7 +1692,7 @@ void menu_tags_loaded(
|
||||
if (widget->strings)
|
||||
{
|
||||
char const *pieces[MAXIMUM_STRINGS];
|
||||
long count = split(widget->strings, pieces);
|
||||
long count = spinner_split(widget, FALSE, pieces);
|
||||
|
||||
instance_set(instances, UNICODE_STRING_LIST_TAG, build.spinner_tags[index], widget->name, " strings",
|
||||
string_list_build(pieces, count));
|
||||
@@ -1332,12 +1701,27 @@ void menu_tags_loaded(
|
||||
}
|
||||
if (build.failed)
|
||||
goto failed;
|
||||
/* (pause_patch's, until it makes them: nothing a name finds) */
|
||||
for (index = build.first_index + build.next; index < build.first_index + total; index++)
|
||||
{
|
||||
instances[index].group_tag = NONE;
|
||||
instances[index].tag_index = NONE;
|
||||
instances[index].name = "";
|
||||
}
|
||||
cache_files_set_tag_instances(instances, build.first_index + total);
|
||||
for (index = 0; index < widget_count && !build.failed; index++)
|
||||
instances[DATUM_INDEX_TO_ABSOLUTE_INDEX(build.widget_tags[index])].base_address = widget_build(index);
|
||||
if (build.failed)
|
||||
goto failed;
|
||||
if (widget_named(menus->root) != NONE)
|
||||
if (game_map)
|
||||
{
|
||||
pause_patch(instances);
|
||||
if (build.failed)
|
||||
goto failed;
|
||||
/* (those it made) */
|
||||
cache_files_set_tag_instances(instances, build.first_index + build.next);
|
||||
}
|
||||
else if (widget_named(menus->root) != NONE)
|
||||
{
|
||||
snprintf(menu_tags.root, sizeof(menu_tags.root), "%s%s", PC_MENU_TAG_PREFIX, menus->root);
|
||||
for (index = 0; menu_tags.root[index]; index++)
|
||||
|
||||
@@ -0,0 +1,901 @@
|
||||
/*
|
||||
NETWORK_ACTORS.C
|
||||
|
||||
AI sync (port/linux/NETCODE.md).
|
||||
|
||||
Only the host runs the AI (game.c skips ai_update on clients). An actor
|
||||
drives its unit the way a player does, through unit_control. The clients
|
||||
have the units (network_objects.c); this file makes them move like the
|
||||
host's.
|
||||
|
||||
Each tick the host records the control every actor gave its unit (a hook
|
||||
in unit_control, and the bursts it holds the trigger for) and sends it to
|
||||
each client with the unit's state: position, seat, shields and health,
|
||||
camouflage, and whether it flees in a panic. Units near a client's players
|
||||
are sent every tick, others less often, but a unit starting a one-tick
|
||||
action (a jump, a grenade) goes to everyone that tick. Each tick a client
|
||||
feeds the latest control into unit_control, the same path that drives a
|
||||
remote player's unit, so the unit walks, aims, fires and throws as it does
|
||||
on the host. The state corrects any drift.
|
||||
|
||||
What the AI starts once is numbered, so a client plays each once however
|
||||
many times it receives it: animation impulses (dives, vaults), melee
|
||||
attacks and leaps (which the AI starts directly, not through the control),
|
||||
speech, and custom animations (outside co-op, whose events carry them).
|
||||
Pain and death sounds aren't sent: a client plays those itself as it
|
||||
replays the host's damage.
|
||||
|
||||
A client creates no actors of its own (actors.c): the host's are the only
|
||||
ones. Deaths need nothing here: network_damage.c kills a client's copy of
|
||||
an AI unit the same way it kills a player's.
|
||||
*/
|
||||
|
||||
/* ---------- headers */
|
||||
|
||||
#include "cseries.h"
|
||||
#include "game/game.h"
|
||||
#include "networking/network_game_globals.h"
|
||||
#include "objects/objects.h"
|
||||
#include "objects/damage.h"
|
||||
#include "sound/game_sound.h"
|
||||
#include "sound/sound_definitions.h"
|
||||
#include "units/units.h"
|
||||
#include "units/unit_control_data.h"
|
||||
#include "network_coop.h"
|
||||
#include "network_distributed.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* ---------- constants */
|
||||
|
||||
enum
|
||||
{
|
||||
/* AI units tracked at once: every actor (halo_port_capacity.h's
|
||||
HALO_PORT_MAXIMUM_ACTORS) and the units the cutscenes' recorded
|
||||
animations drive */
|
||||
MAXIMUM_NETWORK_ACTORS = HALO_PORT_MAXIMUM_ACTORS + 32,
|
||||
MAXIMUM_ENTRIES_PER_MESSAGE = 64,
|
||||
/* A client keeps applying a control for this long after the host last
|
||||
sent one. After that the unit is left alone: the actor let go of it, or
|
||||
the host went quiet. */
|
||||
CONTROL_HELD_TICKS = 2 * TICKS_PER_SECOND,
|
||||
/* an impulse is repeated in this many entries, in case one is lost */
|
||||
IMPULSE_REPEAT_TICKS = 3,
|
||||
/* the number of unit_start_animation_impulse impulses (private to units.c) */
|
||||
NUMBER_OF_UNIT_ANIMATION_IMPULSES = 14,
|
||||
NO_IMPULSE = 0xFF,
|
||||
NO_TEAM = 0xFF,
|
||||
|
||||
/* An entry's impulse is one of the animation impulses or, past them, an
|
||||
action the AI starts directly: a melee attack (unit_melee_attack_begin)
|
||||
or a leap (unit_leap_begin). */
|
||||
_actor_action_melee = NUMBER_OF_UNIT_ANIMATION_IMPULSES,
|
||||
_actor_action_leap,
|
||||
NUMBER_OF_ACTOR_ACTIONS,
|
||||
|
||||
/* control flags a unit acts on in one tick: a unit that sets one goes to
|
||||
every client that tick, however far away, so the action isn't missed */
|
||||
ONE_SHOT_CONTROL_FLAGS = FLAG(_unit_control_jump_bit) | FLAG(_unit_control_action_bit) |
|
||||
FLAG(_unit_control_weapon_reload_bit) | FLAG(_unit_control_throw_grenade_bit) |
|
||||
FLAG(_unit_control_swap_weapons_bit),
|
||||
};
|
||||
|
||||
/* struct distributed_actor_state flags */
|
||||
enum
|
||||
{
|
||||
_distributed_actor_rides_bit = 0,
|
||||
_distributed_actor_shield_depleted_bit,
|
||||
_distributed_actor_shield_charging_bit,
|
||||
_distributed_actor_shield_over_charging_bit,
|
||||
_distributed_actor_camouflaged_bit,
|
||||
_distributed_actor_super_camouflaged_bit,
|
||||
/* the impulse turns the unit to impulse_alignment */
|
||||
_distributed_actor_impulse_aligned_bit,
|
||||
/* fleeing in a panic, toward run_blindly_angle (unit_start_running_blindly) */
|
||||
_distributed_actor_running_blindly_bit,
|
||||
};
|
||||
|
||||
/* facing, aiming and looking vectors are sent as yaw and pitch */
|
||||
enum
|
||||
{
|
||||
_angle_yaw,
|
||||
_angle_pitch,
|
||||
NUMBER_OF_ANGLES
|
||||
};
|
||||
|
||||
/* ---------- structures */
|
||||
|
||||
/* an AI unit's control and state at the end of the host's tick (like
|
||||
struct distributed_unit_state for players) */
|
||||
struct distributed_actor_state
|
||||
{
|
||||
long unit_index;
|
||||
long vehicle_index;
|
||||
short seat_index;
|
||||
byte flags;
|
||||
/* the impulse's sequence number; impulse is NO_IMPULSE when there is none */
|
||||
byte impulse_number;
|
||||
byte impulse;
|
||||
byte animation_state;
|
||||
byte aiming_speed;
|
||||
byte primary_trigger;
|
||||
word control_flags;
|
||||
signed char throttle[3];
|
||||
byte active_camouflage;
|
||||
/* the speech's sequence number; 0 when there is none */
|
||||
byte speech_number;
|
||||
/* the unit's team (NO_TEAM for none): the AI sets it after the unit is
|
||||
made, so a client's copy would keep the team it was made with */
|
||||
byte team;
|
||||
short facing[NUMBER_OF_ANGLES];
|
||||
short aiming[NUMBER_OF_ANGLES];
|
||||
short looking[NUMBER_OF_ANGLES];
|
||||
short impulse_alignment;
|
||||
short run_blindly_angle;
|
||||
word body_vitality;
|
||||
word shield_vitality;
|
||||
/* the sound the unit started saying (a sound tag) */
|
||||
long speech_sound;
|
||||
/* the custom animation it started (unit_start_user_animation), and its
|
||||
sequence number; the graph is NONE when there is none */
|
||||
long user_animation_graph;
|
||||
short user_animation;
|
||||
byte user_animation_number;
|
||||
byte user_animation_interpolate;
|
||||
real_point3d position;
|
||||
struct distributed_vector velocity;
|
||||
struct distributed_vector forward;
|
||||
struct distributed_vector up;
|
||||
};
|
||||
|
||||
/* the damage an AI unit is taking: its shield's flare and its body's wounds
|
||||
are drawn by it */
|
||||
struct distributed_actor_damage
|
||||
{
|
||||
long unit_index;
|
||||
word current_shield_damage;
|
||||
word recent_shield_damage;
|
||||
word current_body_damage;
|
||||
word recent_body_damage;
|
||||
};
|
||||
|
||||
struct distributed_actor_damage_message
|
||||
{
|
||||
struct distributed_message_header header;
|
||||
struct distributed_actor_damage units[MAXIMUM_ENTRIES_PER_MESSAGE];
|
||||
};
|
||||
|
||||
struct distributed_actor_state_message
|
||||
{
|
||||
struct distributed_message_header header;
|
||||
struct distributed_actor_state states[MAXIMUM_ENTRIES_PER_MESSAGE];
|
||||
};
|
||||
|
||||
/* host: what an actor gave its unit this tick */
|
||||
struct host_actor
|
||||
{
|
||||
long unit_index;
|
||||
/* got a control since the last send (noted during game_tick, sent after it) */
|
||||
boolean noted;
|
||||
/* its damage was sent last tick (and once more when it ends) */
|
||||
boolean damaged;
|
||||
struct unit_control_data control;
|
||||
/* the control flags of the last tick's entry */
|
||||
word sent_control_flags;
|
||||
/* the latest impulse, how many more entries carry it, and its number */
|
||||
short impulse;
|
||||
short impulse_sends;
|
||||
byte impulse_number;
|
||||
boolean impulse_aligned;
|
||||
real_vector2d impulse_alignment;
|
||||
/* the latest speech, how many more entries carry it, and its number */
|
||||
long speech_sound;
|
||||
short speech_sends;
|
||||
byte speech_number;
|
||||
/* the latest custom animation, the same way */
|
||||
long user_animation_graph;
|
||||
short user_animation;
|
||||
boolean user_animation_interpolate;
|
||||
short user_animation_sends;
|
||||
byte user_animation_number;
|
||||
};
|
||||
|
||||
/* client: the latest the host sent about an AI unit */
|
||||
struct client_actor
|
||||
{
|
||||
long unit_index;
|
||||
long received_time;
|
||||
struct unit_control_data control;
|
||||
/* the impulse to play, and the number of the last one played */
|
||||
short impulse;
|
||||
byte impulse_number;
|
||||
byte played_impulse_number;
|
||||
boolean impulse_aligned;
|
||||
real_vector2d impulse_alignment;
|
||||
/* the speech to play (NONE when there is none), and the number of the last played */
|
||||
long speech_sound;
|
||||
byte speech_number;
|
||||
byte played_speech_number;
|
||||
/* the custom animation to play (graph NONE when there is none), and the
|
||||
number of the last played */
|
||||
long user_animation_graph;
|
||||
short user_animation;
|
||||
boolean user_animation_interpolate;
|
||||
byte user_animation_number;
|
||||
byte played_user_animation_number;
|
||||
boolean driven;
|
||||
};
|
||||
|
||||
/* ---------- globals */
|
||||
|
||||
static struct host_actor host_actors[MAXIMUM_NETWORK_ACTORS];
|
||||
static short host_actor_count;
|
||||
/* host: the numbers of every unit's impulses, speech and animations, from
|
||||
one counter, so a unit that drops out of the table and comes back can't
|
||||
repeat the number a client last played */
|
||||
static byte host_event_number;
|
||||
|
||||
static struct client_actor client_actors[MAXIMUM_NETWORK_ACTORS];
|
||||
static short client_actor_count;
|
||||
|
||||
/* ---------- private code */
|
||||
|
||||
static void angles_pack(
|
||||
real_vector3d const *vector,
|
||||
short *angles)
|
||||
{
|
||||
angles[_angle_yaw] = distributed_angle_pack((real)atan2(vector->j, vector->i));
|
||||
angles[_angle_pitch] = distributed_angle_pack((real)asin(PIN(vector->k, -1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
static void angles_unpack(
|
||||
short const *angles,
|
||||
real_vector3d *vector)
|
||||
{
|
||||
real yaw = distributed_angle_unpack(angles[_angle_yaw], FALSE);
|
||||
real pitch = distributed_angle_unpack(angles[_angle_pitch], TRUE);
|
||||
|
||||
vector->i = (real)(cos(pitch) * cos(yaw));
|
||||
vector->j = (real)(cos(pitch) * sin(yaw));
|
||||
vector->k = (real)sin(pitch);
|
||||
}
|
||||
|
||||
/* host: the next event's number (never 0, which a client's new entry has
|
||||
as played) */
|
||||
static byte next_event_number(
|
||||
void)
|
||||
{
|
||||
if (++host_event_number == 0)
|
||||
host_event_number = 1;
|
||||
return host_event_number;
|
||||
}
|
||||
|
||||
/* the unit's entry, adding one if needed; NULL if the table is full */
|
||||
static struct host_actor *host_actor_for(
|
||||
long unit_index)
|
||||
{
|
||||
short index;
|
||||
|
||||
for (index = 0; index < host_actor_count; index++)
|
||||
{
|
||||
if (host_actors[index].unit_index == unit_index)
|
||||
return &host_actors[index];
|
||||
}
|
||||
if (host_actor_count >= MAXIMUM_NETWORK_ACTORS)
|
||||
return NULL;
|
||||
csmemset(&host_actors[host_actor_count], 0, sizeof(host_actors[0]));
|
||||
host_actors[host_actor_count].unit_index = unit_index;
|
||||
host_actors[host_actor_count].impulse = NONE;
|
||||
host_actors[host_actor_count].speech_sound = NONE;
|
||||
host_actors[host_actor_count].user_animation_graph = NONE;
|
||||
return &host_actors[host_actor_count++];
|
||||
}
|
||||
|
||||
static struct client_actor *client_actor_for(
|
||||
long unit_index)
|
||||
{
|
||||
short index;
|
||||
|
||||
for (index = 0; index < client_actor_count; index++)
|
||||
{
|
||||
if (client_actors[index].unit_index == unit_index)
|
||||
return &client_actors[index];
|
||||
}
|
||||
if (client_actor_count >= MAXIMUM_NETWORK_ACTORS)
|
||||
return NULL;
|
||||
csmemset(&client_actors[client_actor_count], 0, sizeof(client_actors[0]));
|
||||
client_actors[client_actor_count].unit_index = unit_index;
|
||||
client_actors[client_actor_count].impulse = NONE;
|
||||
client_actors[client_actor_count].speech_sound = NONE;
|
||||
client_actors[client_actor_count].user_animation_graph = NONE;
|
||||
return &client_actors[client_actor_count++];
|
||||
}
|
||||
|
||||
/* whether the unit exists, is alive, and isn't a player's */
|
||||
static boolean actor_unit_valid(
|
||||
long unit_index)
|
||||
{
|
||||
struct unit_datum *unit;
|
||||
|
||||
if (!object_try_and_get_and_verify_type(unit_index, _object_mask_unit))
|
||||
return FALSE;
|
||||
unit = unit_get(unit_index);
|
||||
return !TEST_FLAG(unit->object.damage_flags, _object_dead_bit) && unit->unit.player_index == NONE;
|
||||
}
|
||||
|
||||
/* host: builds the entry to send for an AI unit */
|
||||
static void actor_state_from_unit(
|
||||
struct host_actor const *actor,
|
||||
struct distributed_actor_state *state)
|
||||
{
|
||||
struct unit_datum *unit = unit_get(actor->unit_index);
|
||||
struct damage_network_state damage;
|
||||
real camouflage = PIN(unit->unit.active_camouflage, 0.0f, 1.0f);
|
||||
|
||||
csmemset(state, 0, sizeof(*state));
|
||||
state->unit_index = actor->unit_index;
|
||||
state->vehicle_index = NONE;
|
||||
state->seat_index = NONE;
|
||||
if (unit->object.parent_object_index != NONE && unit->unit.parent_seat_index != NONE)
|
||||
{
|
||||
SET_FLAG(state->flags, _distributed_actor_rides_bit, TRUE);
|
||||
state->vehicle_index = unit->object.parent_object_index;
|
||||
state->seat_index = unit->unit.parent_seat_index;
|
||||
}
|
||||
state->animation_state = (byte)actor->control.animation_state;
|
||||
state->aiming_speed = (byte)actor->control.aiming_speed;
|
||||
state->primary_trigger = (byte)(long)floor(PIN(actor->control.primary_trigger, 0.0f, 1.0f) * 255.0f + 0.5f);
|
||||
state->control_flags = actor->control.control_flags;
|
||||
/* for a burst the AI holds the trigger for (unit_persistent_control),
|
||||
send the flags and trigger the unit's update produced this tick */
|
||||
if (unit->unit.persistent_control_timer > 0)
|
||||
{
|
||||
state->control_flags = (word)(unit->unit.control_flags & (FLAG(NUMBER_OF_UNIT_CONTROL_FLAGS) - 1));
|
||||
state->primary_trigger = (byte)(long)floor(PIN(unit->unit.primary_trigger, 0.0f, 1.0f) * 255.0f + 0.5f);
|
||||
}
|
||||
state->throttle[0] = (signed char)(long)floor(PIN(actor->control.throttle.i, -1.0f, 1.0f) * 127.0f + 0.5f);
|
||||
state->throttle[1] = (signed char)(long)floor(PIN(actor->control.throttle.j, -1.0f, 1.0f) * 127.0f + 0.5f);
|
||||
state->throttle[2] = (signed char)(long)floor(PIN(actor->control.throttle.k, -1.0f, 1.0f) * 127.0f + 0.5f);
|
||||
angles_pack(&actor->control.facing_vector, state->facing);
|
||||
angles_pack(&actor->control.aiming_vector, state->aiming);
|
||||
angles_pack(&actor->control.looking_vector, state->looking);
|
||||
state->impulse = NO_IMPULSE;
|
||||
if (actor->impulse != NONE && actor->impulse_sends > 0)
|
||||
{
|
||||
state->impulse = (byte)actor->impulse;
|
||||
state->impulse_number = actor->impulse_number;
|
||||
SET_FLAG(state->flags, _distributed_actor_impulse_aligned_bit, actor->impulse_aligned);
|
||||
if (actor->impulse_aligned)
|
||||
{
|
||||
state->impulse_alignment = distributed_angle_pack(
|
||||
(real)atan2(actor->impulse_alignment.j, actor->impulse_alignment.i));
|
||||
}
|
||||
}
|
||||
state->speech_sound = NONE;
|
||||
if (actor->speech_sound != NONE && actor->speech_sends > 0)
|
||||
{
|
||||
state->speech_sound = actor->speech_sound;
|
||||
state->speech_number = actor->speech_number;
|
||||
}
|
||||
state->user_animation_graph = NONE;
|
||||
if (actor->user_animation_graph != NONE && actor->user_animation_sends > 0)
|
||||
{
|
||||
state->user_animation_graph = actor->user_animation_graph;
|
||||
state->user_animation = actor->user_animation;
|
||||
state->user_animation_interpolate = (byte)actor->user_animation_interpolate;
|
||||
state->user_animation_number = actor->user_animation_number;
|
||||
}
|
||||
if (TEST_FLAG(unit->unit.flags, _unit_running_blindly_bit))
|
||||
{
|
||||
SET_FLAG(state->flags, _distributed_actor_running_blindly_bit, TRUE);
|
||||
state->run_blindly_angle = distributed_angle_pack(unit->unit.run_blindly_angle);
|
||||
}
|
||||
damage_get_network_state(actor->unit_index, &damage);
|
||||
SET_FLAG(state->flags, _distributed_actor_shield_depleted_bit, damage.shield_depleted);
|
||||
SET_FLAG(state->flags, _distributed_actor_shield_charging_bit, damage.shield_charging);
|
||||
SET_FLAG(state->flags, _distributed_actor_shield_over_charging_bit, damage.shield_over_charging);
|
||||
state->body_vitality = distributed_vitality_pack(damage.body_vitality);
|
||||
state->shield_vitality = distributed_vitality_pack(damage.shield_vitality);
|
||||
SET_FLAG(state->flags, _distributed_actor_camouflaged_bit,
|
||||
TEST_FLAG(unit->unit.flags, _unit_active_camouflaged_bit));
|
||||
SET_FLAG(state->flags, _distributed_actor_super_camouflaged_bit,
|
||||
TEST_FLAG(unit->unit.flags, _unit_super_camouflaged_bit));
|
||||
state->active_camouflage = (byte)(long)floor(camouflage * 255.0f + 0.5f);
|
||||
state->team = unit->object.owner_team_index >= 0 && unit->object.owner_team_index < NO_TEAM ?
|
||||
(byte)unit->object.owner_team_index : NO_TEAM;
|
||||
state->position = unit->object.position;
|
||||
distributed_vector_pack(&unit->object.translational_velocity, DISTRIBUTED_VELOCITY_SCALE, &state->velocity);
|
||||
distributed_vector_pack(&unit->object.forward, DISTRIBUTED_UNIT_SCALE, &state->forward);
|
||||
distributed_vector_pack(&unit->object.up, DISTRIBUTED_UNIT_SCALE, &state->up);
|
||||
}
|
||||
|
||||
/* Client: stores the entry's control and applies its state to the unit.
|
||||
Returns FALSE for an entry with invalid values. */
|
||||
static boolean actor_state_apply(
|
||||
struct distributed_actor_state const *state,
|
||||
long now)
|
||||
{
|
||||
struct client_actor *actor;
|
||||
struct unit_datum *unit;
|
||||
struct damage_network_state damage;
|
||||
real_vector3d velocity;
|
||||
real_vector3d forward;
|
||||
real_vector3d up;
|
||||
|
||||
if (!distributed_object_index_valid(state->unit_index) || !network_objects_client_has(state->unit_index))
|
||||
return FALSE;
|
||||
/* (a body the host's unit got back up from: a Flood combat form that
|
||||
feigned death, which it does only once its body is at rest. Left dead,
|
||||
the ragdoll was dragged about by the host's positions. The host sends
|
||||
only living units.) */
|
||||
if (object_try_and_get_and_verify_type(state->unit_index, _object_mask_unit) &&
|
||||
TEST_FLAG(unit_get(state->unit_index)->object.damage_flags, _object_dead_bit) &&
|
||||
TEST_FLAG(unit_get(state->unit_index)->object.flags, _object_at_rest_bit) &&
|
||||
unit_get(state->unit_index)->unit.player_index == NONE && state->body_vitality > 0)
|
||||
{
|
||||
unit_port_resurrect(state->unit_index);
|
||||
}
|
||||
if (!actor_unit_valid(state->unit_index) ||
|
||||
state->animation_state >= NUMBER_OF_UNIT_ANIMATION_STATES ||
|
||||
state->aiming_speed >= NUMBER_OF_UNIT_AIMING_SPEEDS ||
|
||||
!VALID_FLAGS(state->control_flags, NUMBER_OF_UNIT_CONTROL_FLAGS) ||
|
||||
(state->impulse != NO_IMPULSE && state->impulse >= NUMBER_OF_ACTOR_ACTIONS) ||
|
||||
(state->speech_sound != NONE && !distributed_tag_of_group(state->speech_sound, SOUND_DEFINITION_TAG)) ||
|
||||
(state->user_animation_graph != NONE &&
|
||||
!distributed_graph_animation(state->user_animation_graph, state->user_animation)) ||
|
||||
!distributed_point_valid(&state->position, UNIT_WORLD_BOUND))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
distributed_vector_unpack(&state->velocity, DISTRIBUTED_VELOCITY_SCALE, &velocity);
|
||||
distributed_vector_unpack(&state->forward, DISTRIBUTED_UNIT_SCALE, &forward);
|
||||
distributed_vector_unpack(&state->up, DISTRIBUTED_UNIT_SCALE, &up);
|
||||
if (!distributed_axes_make_valid(&forward, &up))
|
||||
return FALSE;
|
||||
actor = client_actor_for(state->unit_index);
|
||||
if (!actor)
|
||||
return TRUE;
|
||||
|
||||
/* the control, applied every tick until the next entry */
|
||||
actor->received_time = now;
|
||||
actor->control.animation_state = (char)state->animation_state;
|
||||
actor->control.aiming_speed = (char)state->aiming_speed;
|
||||
actor->control.control_flags = state->control_flags;
|
||||
actor->control.weapon_index = NONE;
|
||||
actor->control.grenade_index = NONE;
|
||||
actor->control.zoom_level = NONE;
|
||||
actor->control.throttle.i = (real)state->throttle[0] / 127.0f;
|
||||
actor->control.throttle.j = (real)state->throttle[1] / 127.0f;
|
||||
actor->control.throttle.k = (real)state->throttle[2] / 127.0f;
|
||||
actor->control.primary_trigger = (real)state->primary_trigger / 255.0f;
|
||||
angles_unpack(state->facing, &actor->control.facing_vector);
|
||||
angles_unpack(state->aiming, &actor->control.aiming_vector);
|
||||
angles_unpack(state->looking, &actor->control.looking_vector);
|
||||
if (state->impulse != NO_IMPULSE && state->impulse_number != actor->played_impulse_number)
|
||||
{
|
||||
real yaw = distributed_angle_unpack(state->impulse_alignment, FALSE);
|
||||
|
||||
actor->impulse = state->impulse;
|
||||
actor->impulse_number = state->impulse_number;
|
||||
actor->impulse_aligned = TEST_FLAG(state->flags, _distributed_actor_impulse_aligned_bit);
|
||||
actor->impulse_alignment.i = (real)cos(yaw);
|
||||
actor->impulse_alignment.j = (real)sin(yaw);
|
||||
}
|
||||
|
||||
if (state->speech_sound != NONE && state->speech_number != actor->played_speech_number)
|
||||
{
|
||||
actor->speech_sound = state->speech_sound;
|
||||
actor->speech_number = state->speech_number;
|
||||
}
|
||||
if (state->user_animation_graph != NONE && state->user_animation_number != actor->played_user_animation_number)
|
||||
{
|
||||
actor->user_animation_graph = state->user_animation_graph;
|
||||
actor->user_animation = state->user_animation;
|
||||
actor->user_animation_interpolate = state->user_animation_interpolate != 0;
|
||||
actor->user_animation_number = state->user_animation_number;
|
||||
}
|
||||
|
||||
/* the state: seat, shields and health, camouflage, running blindly, and
|
||||
position (a unit in a vehicle goes where the vehicle goes) */
|
||||
unit = unit_get(state->unit_index);
|
||||
if (TEST_FLAG(state->flags, _distributed_actor_rides_bit))
|
||||
{
|
||||
if (unit->object.parent_object_index != state->vehicle_index ||
|
||||
unit->unit.parent_seat_index != state->seat_index)
|
||||
{
|
||||
network_objects_set_seat(state->unit_index, state->vehicle_index, state->seat_index);
|
||||
}
|
||||
}
|
||||
else if (unit->object.parent_object_index != NONE)
|
||||
{
|
||||
network_objects_set_seat(state->unit_index, NONE, NONE);
|
||||
}
|
||||
damage_get_network_state(state->unit_index, &damage);
|
||||
damage.shield_depleted = TEST_FLAG(state->flags, _distributed_actor_shield_depleted_bit);
|
||||
damage.shield_charging = TEST_FLAG(state->flags, _distributed_actor_shield_charging_bit);
|
||||
damage.shield_over_charging = TEST_FLAG(state->flags, _distributed_actor_shield_over_charging_bit);
|
||||
damage.body_vitality = distributed_vitality_unpack(state->body_vitality);
|
||||
damage.shield_vitality = distributed_vitality_unpack(state->shield_vitality);
|
||||
damage_set_network_state(state->unit_index, &damage);
|
||||
SET_FLAG(unit->unit.flags, _unit_active_camouflaged_bit,
|
||||
TEST_FLAG(state->flags, _distributed_actor_camouflaged_bit));
|
||||
SET_FLAG(unit->unit.flags, _unit_super_camouflaged_bit,
|
||||
TEST_FLAG(state->flags, _distributed_actor_super_camouflaged_bit));
|
||||
unit->unit.active_camouflage = (real)state->active_camouflage / 255.0f;
|
||||
if (state->team != NO_TEAM)
|
||||
unit->object.owner_team_index = state->team;
|
||||
SET_FLAG(unit->unit.flags, _unit_running_blindly_bit,
|
||||
TEST_FLAG(state->flags, _distributed_actor_running_blindly_bit));
|
||||
if (TEST_FLAG(state->flags, _distributed_actor_running_blindly_bit))
|
||||
unit->unit.run_blindly_angle = distributed_angle_unpack(state->run_blindly_angle, FALSE);
|
||||
/* vehicles are placed only by the host's object states (network_objects.c) */
|
||||
if (unit->object.parent_object_index == NONE && unit->object.type != _object_type_vehicle)
|
||||
{
|
||||
real dx = state->position.x - unit->object.position.x;
|
||||
real dy = state->position.y - unit->object.position.y;
|
||||
real dz = state->position.z - unit->object.position.z;
|
||||
|
||||
if (dx * dx + dy * dy + dz * dz > REMOTE_CORRECTION_TOLERANCE * REMOTE_CORRECTION_TOLERANCE &&
|
||||
network_objects_reconcile(state->unit_index, &state->position, &forward, &up, &velocity, NULL,
|
||||
REMOTE_BLEND_DISTANCE))
|
||||
{
|
||||
distributed_count_correction();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Client: plays a sound at the unit's head, as unit_dialogue_update starts
|
||||
a unit's speech. */
|
||||
static void speech_play(
|
||||
long unit_index,
|
||||
long sound_definition_index)
|
||||
{
|
||||
struct object_marker marker;
|
||||
real_point3d position = *global_origin3d;
|
||||
real_vector3d forward = *global_forward3d;
|
||||
short node_index = 0;
|
||||
|
||||
if (object_get_marker_by_name(unit_index, "head", &marker, 1))
|
||||
{
|
||||
node_index = marker.node_index;
|
||||
position = marker.node_matrix.position;
|
||||
forward = marker.node_matrix.forward;
|
||||
}
|
||||
object_impulse_sound_new(unit_index, sound_definition_index, node_index, &position, &forward, 1.0f);
|
||||
}
|
||||
|
||||
/* ---------- public code */
|
||||
|
||||
void network_actors_new_game(
|
||||
void)
|
||||
{
|
||||
host_actor_count = 0;
|
||||
client_actor_count = 0;
|
||||
}
|
||||
|
||||
/* host: unit_control calls this when an actor drives its unit */
|
||||
void network_actors_note_control(
|
||||
long unit_index,
|
||||
struct unit_control_data const *control_data)
|
||||
{
|
||||
struct host_actor *actor;
|
||||
|
||||
if (game_connection() != _game_connection_network_server)
|
||||
return;
|
||||
actor = host_actor_for(unit_index);
|
||||
if (!actor)
|
||||
return;
|
||||
actor->noted = TRUE;
|
||||
actor->control = *control_data;
|
||||
}
|
||||
|
||||
/* host: an impulse or action for an AI unit, sent in the next few entries */
|
||||
static void note_action(
|
||||
long unit_index,
|
||||
short action,
|
||||
real_vector2d const *alignment_vector)
|
||||
{
|
||||
struct host_actor *actor;
|
||||
|
||||
if (game_connection() != _game_connection_network_server)
|
||||
return;
|
||||
actor = host_actor_for(unit_index);
|
||||
if (!actor)
|
||||
return;
|
||||
actor->impulse = action;
|
||||
actor->impulse_sends = IMPULSE_REPEAT_TICKS;
|
||||
actor->impulse_number = next_event_number();
|
||||
actor->impulse_aligned = alignment_vector != NULL;
|
||||
if (alignment_vector)
|
||||
actor->impulse_alignment = *alignment_vector;
|
||||
}
|
||||
|
||||
/* host: unit_start_animation_impulse calls this for an AI unit */
|
||||
void network_actors_note_impulse(
|
||||
long unit_index,
|
||||
short animation_impulse,
|
||||
real_vector2d const *alignment_vector)
|
||||
{
|
||||
note_action(unit_index, animation_impulse, alignment_vector);
|
||||
}
|
||||
|
||||
/* host: unit_melee_attack_begin calls this when an AI unit starts a melee attack */
|
||||
void network_actors_note_melee(
|
||||
long unit_index,
|
||||
real_vector2d const *alignment_vector)
|
||||
{
|
||||
note_action(unit_index, _actor_action_melee, alignment_vector);
|
||||
}
|
||||
|
||||
/* host: unit_leap_begin calls this when an AI unit leaps */
|
||||
void network_actors_note_leap(
|
||||
long unit_index,
|
||||
real_vector2d const *alignment_vector)
|
||||
{
|
||||
note_action(unit_index, _actor_action_leap, alignment_vector);
|
||||
}
|
||||
|
||||
/* host: unit_dialogue_update calls this when an AI unit starts saying
|
||||
something (not a pain or death sound, which clients play themselves) */
|
||||
void network_actors_note_speech(
|
||||
long unit_index,
|
||||
long sound_definition_index)
|
||||
{
|
||||
struct host_actor *actor;
|
||||
|
||||
if (game_connection() != _game_connection_network_server)
|
||||
return;
|
||||
actor = host_actor_for(unit_index);
|
||||
if (!actor)
|
||||
return;
|
||||
actor->speech_sound = sound_definition_index;
|
||||
actor->speech_sends = IMPULSE_REPEAT_TICKS;
|
||||
actor->speech_number = next_event_number();
|
||||
}
|
||||
|
||||
/* host: unit_start_user_animation calls this when an AI unit starts a
|
||||
custom animation (co-op's events carry them in co-op) */
|
||||
void network_actors_note_user_animation(
|
||||
long unit_index,
|
||||
long animation_graph_index,
|
||||
short animation_index,
|
||||
boolean interpolate)
|
||||
{
|
||||
struct host_actor *actor;
|
||||
|
||||
if (game_connection() != _game_connection_network_server || network_coop_active())
|
||||
return;
|
||||
actor = host_actor_for(unit_index);
|
||||
if (!actor)
|
||||
return;
|
||||
actor->user_animation_graph = animation_graph_index;
|
||||
actor->user_animation = animation_index;
|
||||
actor->user_animation_interpolate = interpolate;
|
||||
actor->user_animation_sends = IMPULSE_REPEAT_TICKS;
|
||||
actor->user_animation_number = next_event_number();
|
||||
}
|
||||
|
||||
/* host: the damage of the AI units taking some, to every client (and once
|
||||
more when it ends, so a flare goes) */
|
||||
static void host_send_damage(
|
||||
void)
|
||||
{
|
||||
struct distributed_actor_damage_message message;
|
||||
short count = 0;
|
||||
short index;
|
||||
|
||||
for (index = 0; index < host_actor_count; index++)
|
||||
{
|
||||
struct host_actor *actor = &host_actors[index];
|
||||
struct damage_network_state damage;
|
||||
boolean damaged;
|
||||
|
||||
if (!actor_unit_valid(actor->unit_index))
|
||||
continue;
|
||||
damage_get_network_state(actor->unit_index, &damage);
|
||||
damaged = damage.current_shield_damage > 0.0f || damage.recent_shield_damage > 0.0f ||
|
||||
damage.current_body_damage > 0.0f || damage.recent_body_damage > 0.0f;
|
||||
if (!damaged && !actor->damaged)
|
||||
continue;
|
||||
actor->damaged = damaged;
|
||||
message.units[count].unit_index = actor->unit_index;
|
||||
message.units[count].current_shield_damage = distributed_vitality_pack(damage.current_shield_damage);
|
||||
message.units[count].recent_shield_damage = distributed_vitality_pack(damage.recent_shield_damage);
|
||||
message.units[count].current_body_damage = distributed_vitality_pack(damage.current_body_damage);
|
||||
message.units[count].recent_body_damage = distributed_vitality_pack(damage.recent_body_damage);
|
||||
if (++count == MAXIMUM_ENTRIES_PER_MESSAGE)
|
||||
{
|
||||
distributed_send(&message, _distributed_message_actor_damage, count,
|
||||
(word)(sizeof(message.header) + count * sizeof(message.units[0])), _distributed_to_clients);
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
if (count)
|
||||
{
|
||||
distributed_send(&message, _distributed_message_actor_damage, count,
|
||||
(word)(sizeof(message.header) + count * sizeof(message.units[0])), _distributed_to_clients);
|
||||
}
|
||||
}
|
||||
|
||||
/* Host, after each tick: sends each client the AI units driven this tick.
|
||||
Units near the client's players go every tick, others less often. A unit
|
||||
with a fresh impulse, action, speech or animation goes to everyone in each
|
||||
of the next IMPULSE_REPEAT_TICKS ticks, and one starting a one-tick action
|
||||
goes that tick. A unit no actor drove this tick is dropped from the table,
|
||||
unless it is fleeing: a unit running blindly moves by itself, without its
|
||||
actor's control, and dropped it stood running in place on the clients. */
|
||||
void network_actors_host_tick(
|
||||
void)
|
||||
{
|
||||
static struct distributed_actor_state states[MAXIMUM_NETWORK_ACTORS];
|
||||
/* sent to every client this tick, whatever its period */
|
||||
static boolean urgent[MAXIMUM_NETWORK_ACTORS];
|
||||
struct distributed_actor_state_message message;
|
||||
long machine_indices[HALO_PORT_MAXIMUM_NETWORK_MACHINES];
|
||||
short machine_count = distributed_client_machines(machine_indices, HALO_PORT_MAXIMUM_NETWORK_MACHINES);
|
||||
long now = game_time_get();
|
||||
short state_count = 0;
|
||||
short index;
|
||||
short machine_number;
|
||||
|
||||
for (index = 0; index < host_actor_count; index++)
|
||||
{
|
||||
struct host_actor *actor = &host_actors[index];
|
||||
|
||||
if (!actor_unit_valid(actor->unit_index) ||
|
||||
(!actor->noted && !TEST_FLAG(unit_get(actor->unit_index)->unit.flags, _unit_running_blindly_bit)))
|
||||
{
|
||||
host_actors[index--] = host_actors[--host_actor_count];
|
||||
continue;
|
||||
}
|
||||
actor_state_from_unit(actor, &states[state_count]);
|
||||
urgent[state_count] = states[state_count].impulse != NO_IMPULSE || states[state_count].speech_sound != NONE ||
|
||||
states[state_count].user_animation_graph != NONE ||
|
||||
(states[state_count].control_flags & ~actor->sent_control_flags & ONE_SHOT_CONTROL_FLAGS) != 0;
|
||||
actor->sent_control_flags = states[state_count].control_flags;
|
||||
state_count++;
|
||||
actor->noted = FALSE;
|
||||
if (actor->impulse_sends > 0)
|
||||
actor->impulse_sends--;
|
||||
if (actor->speech_sends > 0)
|
||||
actor->speech_sends--;
|
||||
if (actor->user_animation_sends > 0)
|
||||
actor->user_animation_sends--;
|
||||
}
|
||||
host_send_damage();
|
||||
for (machine_number = 0; machine_number < machine_count; machine_number++)
|
||||
{
|
||||
long machine_index = machine_indices[machine_number];
|
||||
short count = 0;
|
||||
|
||||
for (index = 0; index < state_count; index++)
|
||||
{
|
||||
struct distributed_actor_state const *state = &states[index];
|
||||
short period = network_objects_send_period(machine_index, &state->position);
|
||||
|
||||
if (!urgent[index] && (now + DATUM_INDEX_TO_ABSOLUTE_INDEX(state->unit_index)) % period != 0)
|
||||
continue;
|
||||
message.states[count++] = *state;
|
||||
if (count == MAXIMUM_ENTRIES_PER_MESSAGE || count == DATAGRAM_ENTRIES(struct distributed_actor_state))
|
||||
{
|
||||
distributed_send_to_machine(machine_index, &message, _distributed_message_actor_states, count,
|
||||
(word)(sizeof(message.header) + count * sizeof(struct distributed_actor_state)));
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
if (count)
|
||||
{
|
||||
distributed_send_to_machine(machine_index, &message, _distributed_message_actor_states, count,
|
||||
(word)(sizeof(message.header) + count * sizeof(struct distributed_actor_state)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
word network_actors_damage_entry_size(
|
||||
void)
|
||||
{
|
||||
return sizeof(struct distributed_actor_damage);
|
||||
}
|
||||
|
||||
/* client: the damage the host's AI units are taking */
|
||||
void network_actors_handle_damage(
|
||||
void const *entries,
|
||||
short count)
|
||||
{
|
||||
struct distributed_actor_damage const *units = entries;
|
||||
short index;
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
struct damage_network_state damage;
|
||||
|
||||
if (!distributed_object_index_valid(units[index].unit_index) ||
|
||||
!network_objects_client_has(units[index].unit_index) || !actor_unit_valid(units[index].unit_index))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
damage_get_network_state(units[index].unit_index, &damage);
|
||||
damage.current_shield_damage = distributed_vitality_unpack(units[index].current_shield_damage);
|
||||
damage.recent_shield_damage = distributed_vitality_unpack(units[index].recent_shield_damage);
|
||||
damage.current_body_damage = distributed_vitality_unpack(units[index].current_body_damage);
|
||||
damage.recent_body_damage = distributed_vitality_unpack(units[index].recent_body_damage);
|
||||
damage_set_network_state(units[index].unit_index, &damage);
|
||||
}
|
||||
}
|
||||
|
||||
word network_actors_entry_size(
|
||||
void)
|
||||
{
|
||||
return sizeof(struct distributed_actor_state);
|
||||
}
|
||||
|
||||
/* client: entries from the host */
|
||||
void network_actors_handle_states(
|
||||
void const *entries,
|
||||
short count)
|
||||
{
|
||||
struct distributed_actor_state const *states = entries;
|
||||
long now = game_time_get();
|
||||
short index;
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
actor_state_apply(&states[index], now);
|
||||
}
|
||||
|
||||
/* Client: called at the point in the tick where the host runs the AI.
|
||||
Drives each AI unit with the last control the host sent. */
|
||||
void network_actors_drive(
|
||||
void)
|
||||
{
|
||||
long now = game_time_get();
|
||||
short index;
|
||||
|
||||
for (index = 0; index < client_actor_count; index++)
|
||||
{
|
||||
struct client_actor *actor = &client_actors[index];
|
||||
|
||||
if (!actor_unit_valid(actor->unit_index) || now - actor->received_time > CONTROL_HELD_TICKS)
|
||||
{
|
||||
if (actor->driven && object_try_and_get_and_verify_type(actor->unit_index, _object_mask_unit))
|
||||
unit_set_actively_controlled(actor->unit_index, FALSE);
|
||||
client_actors[index--] = client_actors[--client_actor_count];
|
||||
continue;
|
||||
}
|
||||
/* vehicles follow the host's transform instead (network_objects.c) */
|
||||
if (object_get(actor->unit_index)->object.type == _object_type_vehicle)
|
||||
continue;
|
||||
if (!actor->driven)
|
||||
{
|
||||
unit_set_actively_controlled(actor->unit_index, TRUE);
|
||||
actor->driven = TRUE;
|
||||
}
|
||||
unit_control(actor->unit_index, &actor->control);
|
||||
if (actor->impulse != NONE && actor->impulse_number != actor->played_impulse_number)
|
||||
{
|
||||
real_vector2d *alignment = actor->impulse_aligned ? &actor->impulse_alignment : NULL;
|
||||
|
||||
if (actor->impulse == _actor_action_melee)
|
||||
unit_melee_attack_begin(actor->unit_index, FALSE, alignment);
|
||||
else if (actor->impulse == _actor_action_leap)
|
||||
unit_leap_begin(actor->unit_index, alignment);
|
||||
else
|
||||
unit_start_animation_impulse(actor->unit_index, actor->impulse, alignment);
|
||||
actor->played_impulse_number = actor->impulse_number;
|
||||
actor->impulse = NONE;
|
||||
}
|
||||
if (actor->speech_sound != NONE)
|
||||
{
|
||||
speech_play(actor->unit_index, actor->speech_sound);
|
||||
actor->played_speech_number = actor->speech_number;
|
||||
actor->speech_sound = NONE;
|
||||
}
|
||||
if (actor->user_animation_graph != NONE)
|
||||
{
|
||||
unit_port_play_user_animation(actor->unit_index, actor->user_animation_graph, actor->user_animation,
|
||||
actor->user_animation_interpolate, 0);
|
||||
actor->played_user_animation_number = actor->user_animation_number;
|
||||
actor->user_animation_graph = NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
NETWORK_COOP.H
|
||||
|
||||
The calls Halo's own code (source/) makes into network_coop.c. On a co-op
|
||||
host the note_ functions send what the scripts just did to the clients; on
|
||||
any other machine they do nothing, so the clients can call the same engine
|
||||
functions to apply what they receive.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORK_COOP_H
|
||||
#define __NETWORK_COOP_H
|
||||
|
||||
/* ---------- constants */
|
||||
|
||||
/* network_coop_note_hud */
|
||||
enum
|
||||
{
|
||||
_coop_hud_help_text,
|
||||
_coop_hud_objective,
|
||||
_coop_hud_help_flash,
|
||||
_coop_hud_messages_clear,
|
||||
_coop_hud_checkpoint,
|
||||
};
|
||||
|
||||
/* network_coop_note_player_effect */
|
||||
enum
|
||||
{
|
||||
_coop_player_effect_translation,
|
||||
_coop_player_effect_rotation,
|
||||
_coop_player_effect_start,
|
||||
_coop_player_effect_stop,
|
||||
};
|
||||
|
||||
/* network_coop_note_nav_point */
|
||||
enum
|
||||
{
|
||||
_coop_nav_point_team_flag,
|
||||
_coop_nav_point_team_object,
|
||||
_coop_nav_point_unit_flag,
|
||||
_coop_nav_point_unit_object,
|
||||
};
|
||||
|
||||
/* ---------- prototypes/NETWORK_COOP.C */
|
||||
|
||||
/* whether this is a network co-op game (not its lobby, whose menu scene also
|
||||
has no game engine) */
|
||||
boolean network_coop_active(void);
|
||||
/* whether the players collide with each other: FALSE in a co-op game whose
|
||||
host set Server Setup's PLAYER COLLISIONS off (bipeds.c, collisions.c) */
|
||||
boolean network_coop_player_collisions(void);
|
||||
/* whether this machine is a co-op client, whose devices only the host moves */
|
||||
boolean network_coop_devices_remote(void);
|
||||
/* devices.c: a group's devices were set straight to its value */
|
||||
void network_coop_note_device_snap(short group_index);
|
||||
/* unit_scripting_commands.c: a script set a unit's maximum or current
|
||||
vitality; TRUE if it was a co-op player's, now set on every player's */
|
||||
boolean network_coop_set_players_vitality(long unit_index, boolean maximum, real body, real shield);
|
||||
/* host: whether the player's machine has the host's structure BSP loaded
|
||||
(always outside co-op, and for the host's own players). Until a client has,
|
||||
the host takes none of its players' movement, which falls there with no
|
||||
floor, and lets them trigger no BSP switch (players.c). */
|
||||
boolean network_coop_player_has_structure_bsp(long player_index);
|
||||
/* network_distributed.c: the structure BSP a client's input says it has */
|
||||
void network_coop_note_player_structure_bsp(short player_index, short structure_bsp_index);
|
||||
/* units.c: a vehicle left the vehicle carrying it (a Pelican's Warthog drop) */
|
||||
void network_coop_vehicle_dropped(long vehicle_index, long carrier_index);
|
||||
|
||||
/* cinematics.c: a chapter title */
|
||||
void network_coop_note_title(short title_index, real delay);
|
||||
/* hud_messaging.c, hud.c: value is a message index, or TRUE/FALSE */
|
||||
void network_coop_note_hud(short kind, short value);
|
||||
/* player_effects.c: the script screen shake (a, b, c as the function takes them) */
|
||||
void network_coop_note_player_effect(short kind, real a, real b, real c);
|
||||
/* hud_nav_points.c: activate (or, with nav_index NONE, deactivate) a nav point.
|
||||
target is the team or the unit; marker is the cutscene flag or the object. */
|
||||
void network_coop_note_nav_point(short kind, short nav_index, long target, long marker, real vertical_offset);
|
||||
|
||||
/* units.c: a unit started a custom animation (animation_index NONE: stopped) */
|
||||
void network_coop_note_unit_animation(long unit_index, long animation_graph_index, short animation_index,
|
||||
boolean interpolate);
|
||||
/* units.c: a unit (a dropship) opened or closed (unit_open, unit_close) */
|
||||
void network_coop_note_unit_open(long unit_index, boolean open);
|
||||
/* units.c: unit_custom_animation_at_frame moved it to a frame */
|
||||
void network_coop_note_unit_animation_frame(long unit_index, short frame_index);
|
||||
/* scenery.c: a scenery animation started */
|
||||
/* the scripts' effects (hs_library_external.c): at a cutscene flag, or on an
|
||||
object's marker */
|
||||
void network_coop_note_effect(long effect_definition_index, short cutscene_flag_index);
|
||||
/* the scripts' objects_attach and objects_detach (objects.c) */
|
||||
void network_coop_note_attach(long parent_index, char const *parent_marker_name, long child_index,
|
||||
char const *child_marker_name);
|
||||
void network_coop_note_detach(long parent_index, long child_index);
|
||||
void network_coop_note_object_effect(long effect_definition_index, long object_index, char const *marker_name);
|
||||
/* breakable_surfaces.c: a breakable surface (glass) broke, from damage at
|
||||
`epicenter`. Each machine's own shots break glass too, but with their own
|
||||
random damage, so the host's breaks are the ones everyone keeps. */
|
||||
void network_coop_note_surface_broken(short breakable_surface_index, real_point3d const *epicenter);
|
||||
void network_coop_note_scenery_animation(long object_index, long animation_graph_index, short animation_index,
|
||||
short frame_index);
|
||||
|
||||
/* player_control.c: whether the skip key should do anything, and the press.
|
||||
network_coop_vote_skip returns FALSE outside network co-op, where the
|
||||
cinematic is skipped as usual. */
|
||||
boolean network_coop_skip_offered(void);
|
||||
boolean network_coop_vote_skip(void);
|
||||
/* main.c: after a co-op host reverts to its last saved state (to skip a
|
||||
cinematic, or because the mission failed); now is the game time before the
|
||||
revert */
|
||||
void network_coop_reverted(long now);
|
||||
/* main.c: the skip vote is over once the skip has reverted */
|
||||
void network_coop_skip_done(void);
|
||||
/* the vote count to show, if a skippable cinematic is playing */
|
||||
boolean network_coop_skip_vote_status(short *votes, short *voters, boolean *voted);
|
||||
|
||||
#endif
|
||||
@@ -16,8 +16,9 @@ being hit looks and feels like on the clients).
|
||||
- A client deals no damage itself. What its own players' shots, grenades,
|
||||
melee and vehicles hit it reports to the host, which deals it once it has
|
||||
checked it: the report is of that machine's player, the damage one that
|
||||
player's weapons (now or lately), grenades or the vehicle they drove
|
||||
deal, of the shape the game gives it (at a point, a melee blow from the
|
||||
player's weapons (now or lately), a grenade the host saw them throw
|
||||
(each throw's explosion once) or the vehicle they drove deal, of the
|
||||
shape the game gives it (at a point, a melee blow from the
|
||||
striker, a collision from the vehicle), the target about where the host
|
||||
had it when the shooter saw it (the host keeps a second of where
|
||||
players' units and vehicles were, and looks back as far as the report
|
||||
@@ -33,9 +34,14 @@ being hit looks and feels like on the clients).
|
||||
- The damage to a unit goes to the machines of the players it concerns
|
||||
(the unit's, its riders', the damage's owner's) and those sent the
|
||||
unit's player this tick, which see it; a killing blow to all.
|
||||
- Scenery and devices that can be destroyed (lights, panels) are the
|
||||
map's, at the same index on every machine. A client reports its hits on
|
||||
them like any other, and every client deals the host's damage to its own
|
||||
copy, which breaks and plays its effects as the host's did.
|
||||
*/
|
||||
|
||||
#include "cseries.h"
|
||||
#include "cseries/errors.h"
|
||||
#include "game/game.h"
|
||||
#include "game/game_globals.h"
|
||||
#include "game/players.h"
|
||||
@@ -57,6 +63,8 @@ being hit looks and feels like on the clients).
|
||||
void damage_replay_player_effect(long player_index, struct damage_data *damage, real total_damage);
|
||||
void damage_replay_aftermath(long object_index, struct damage_data *damage, unsigned long being_damaged_flags,
|
||||
real shield_damage, real body_damage, real body_damage_multiplier, short body_part);
|
||||
void damage_replay_static(long object_index, struct damage_data *damage, short node_index, short region_index,
|
||||
short material_index);
|
||||
void damage_replay_kill(long object_index, struct damage_data *damage, short node_index, short region_index,
|
||||
short material_index);
|
||||
/* network_distributed.c's */
|
||||
@@ -81,6 +89,13 @@ enum
|
||||
died or dropped the launcher) */
|
||||
MAXIMUM_RECENT_WEAPONS = 8,
|
||||
RECENT_WEAPON_TICKS = 10 * TICKS_PER_SECOND,
|
||||
/* the grenades a player has thrown lately, as the host's own game threw
|
||||
them, whose damage the host takes from them: each goes off once, within
|
||||
RECENT_WEAPON_TICKS of its throw. Each player has their own (all of
|
||||
MAXIMUM_TRACKED_PLAYERS); one that hits nothing is kept the whole time,
|
||||
so this is more than a player throws in it, infinite grenades and all
|
||||
(a throw takes most of a second); past it the oldest gives way */
|
||||
MAXIMUM_GRENADE_THROWS = 32,
|
||||
/* a player's hits: a bucket of this many seconds of fire, filling at a
|
||||
second a second, a hit taking what one of its weapon's projectiles
|
||||
takes to fire (at twice the weapon's fastest rate: a shotgun's
|
||||
@@ -133,8 +148,14 @@ enum
|
||||
_damage_event_player_effect,
|
||||
_damage_event_aftermath,
|
||||
_damage_event_kill,
|
||||
/* damage to destructible scenery or a device, to every machine */
|
||||
_damage_event_static,
|
||||
};
|
||||
|
||||
/* the objects every machine has from the map, at the same index, which
|
||||
damage can break (static_target) */
|
||||
#define STATIC_TARGET_TYPES (_object_mask_scenery | _object_mask_device)
|
||||
|
||||
/* what a player's damage is, by how the game deals it (the shape of their
|
||||
report of it) */
|
||||
enum
|
||||
@@ -341,8 +362,14 @@ static struct
|
||||
{
|
||||
long definition_indices[MAXIMUM_RECENT_WEAPONS];
|
||||
long times[MAXIMUM_RECENT_WEAPONS];
|
||||
long grenade_times[NUMBER_OF_UNIT_GRENADE_TYPES];
|
||||
/* (the grenades thrown, not yet gone off: NONE for none) */
|
||||
long throw_times[MAXIMUM_GRENADE_THROWS];
|
||||
short throw_types[MAXIMUM_GRENADE_THROWS];
|
||||
long driven_time;
|
||||
/* (the blow of the player's unit with no weapon: units.c's
|
||||
unit_unarmed_melee_damage) */
|
||||
long unarmed_melee_damage_index;
|
||||
long unarmed_time;
|
||||
real hit_seconds;
|
||||
long hit_seconds_time;
|
||||
} damage_players[MAXIMUM_TRACKED_PLAYERS];
|
||||
@@ -452,7 +479,8 @@ static boolean distributed_damage_to_data(
|
||||
if (!tag_index_is_group(damage->definition_index, DAMAGE_EFFECT_DEFINITION_TAG))
|
||||
return FALSE;
|
||||
damage_data_new(result, damage->definition_index);
|
||||
result->flags = damage->flags;
|
||||
/* (the flags the game has) */
|
||||
result->flags = damage->flags & (FLAG(NUMBER_OF_DAMAGE_DATA_FLAGS) - 1);
|
||||
result->owner_player_index = distributed_player_from_byte(damage->owner_player_index);
|
||||
result->owner_team_index = damage->owner_team_index;
|
||||
result->owner_object_index = distributed_object_index_valid(damage->owner_object_index) &&
|
||||
@@ -463,11 +491,22 @@ static boolean distributed_damage_to_data(
|
||||
result->scale = damage->scale;
|
||||
result->multiplier = damage->multiplier;
|
||||
result->material_effect_scale = damage->material_effect_scale;
|
||||
result->material_type = damage->material_type;
|
||||
/* (a material the game has, else none, damage_data_new's: it indexes
|
||||
the materials' modifiers) */
|
||||
if (damage->material_type >= 0 && damage->material_type < NUMBER_OF_MATERIAL_TYPES)
|
||||
result->material_type = damage->material_type;
|
||||
scenario_location_from_point(&result->location, &result->epicenter);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* whether the object is scenery or a device that damage can destroy */
|
||||
static boolean static_target(
|
||||
long object_index)
|
||||
{
|
||||
return object_try_and_get_and_verify_type(object_index, STATIC_TARGET_TYPES) &&
|
||||
object_get_maximum_body_vitality(object_index, TRUE) > 0.0f;
|
||||
}
|
||||
|
||||
/* ---------- object_cause_damage (damage.c) */
|
||||
|
||||
/* whether the damage is a weapon's own at the unit that fires it (weapons.c:
|
||||
@@ -614,7 +653,8 @@ boolean network_damage_deals(
|
||||
damage_replay_player_effect(unit->unit.player_index, &effect, 0.0f);
|
||||
}
|
||||
/* a hit of this machine's own player's, on the host's object */
|
||||
if (distributed_player_is_local(damage->owner_player_index) && network_objects_client_has(object_index) &&
|
||||
if (distributed_player_is_local(damage->owner_player_index) &&
|
||||
(network_objects_client_has(object_index) || static_target(object_index)) &&
|
||||
damage_report_count < MAXIMUM_HIT_REPORTS_PER_TICK)
|
||||
{
|
||||
struct distributed_hit_report *report = &damage_reports[damage_report_count++];
|
||||
@@ -702,6 +742,33 @@ void network_damage_player_effect(
|
||||
|
||||
/* the host: an object damaged, and what that did (object_damage_aftermath
|
||||
done, so that a kill's killer is known) */
|
||||
/* a damage event of this tick for the object, or NULL once the tick's are
|
||||
spent (the last RESERVED_KILL_EVENTS are kept for killing blows) */
|
||||
static struct distributed_damage_event *damage_event_new(
|
||||
byte kind,
|
||||
long object_index,
|
||||
struct damage_data const *damage,
|
||||
short node_index,
|
||||
short region_index,
|
||||
short material_index,
|
||||
boolean kill)
|
||||
{
|
||||
struct distributed_damage_event *event;
|
||||
|
||||
if (damage_event_count >= MAXIMUM_DAMAGE_EVENTS_PER_TICK - (kill ? 0 : RESERVED_KILL_EVENTS))
|
||||
return NULL;
|
||||
event = &damage_events[damage_event_count++];
|
||||
csmemset(event, 0, sizeof(*event));
|
||||
event->kind = kind;
|
||||
event->player_index = NO_PLAYER;
|
||||
event->object_index = object_index;
|
||||
distributed_damage_from_data(damage, &event->damage);
|
||||
event->node_index = node_index;
|
||||
event->region_index = region_index;
|
||||
event->material_index = material_index;
|
||||
return event;
|
||||
}
|
||||
|
||||
void network_damage_aftermath(
|
||||
long object_index,
|
||||
struct damage_data const *damage,
|
||||
@@ -721,6 +788,11 @@ void network_damage_aftermath(
|
||||
|
||||
if (game_connection() != _game_connection_network_server)
|
||||
return;
|
||||
if (static_target(object_index))
|
||||
{
|
||||
damage_event_new(_damage_event_static, object_index, damage, node_index, region_index, material_index, FALSE);
|
||||
return;
|
||||
}
|
||||
/* (units only: items and the like the objects' states place) */
|
||||
unit = (struct unit_datum *)object_try_and_get_and_verify_type(object_index, _object_mask_unit);
|
||||
if (!unit)
|
||||
@@ -734,22 +806,15 @@ void network_damage_aftermath(
|
||||
(victim_player_index != NONE ||
|
||||
(TEST_FLAG(_object_mask_biped, unit->object.type) &&
|
||||
!TEST_FLAG(being_damaged_flags, _object_being_damaged_body_destroyed_bit)));
|
||||
if (damage_event_count >= MAXIMUM_DAMAGE_EVENTS_PER_TICK - (kill ? 0 : RESERVED_KILL_EVENTS))
|
||||
event = damage_event_new(_damage_event_aftermath, object_index, damage, node_index, region_index, material_index,
|
||||
kill);
|
||||
if (!event)
|
||||
return;
|
||||
event = &damage_events[damage_event_count++];
|
||||
csmemset(event, 0, sizeof(*event));
|
||||
event->kind = _damage_event_aftermath;
|
||||
event->player_index = NO_PLAYER;
|
||||
event->object_index = object_index;
|
||||
distributed_damage_from_data(damage, &event->damage);
|
||||
event->being_damaged_flags = being_damaged_flags;
|
||||
event->shield_damage = shield_damage;
|
||||
event->body_damage = body_damage;
|
||||
event->body_damage_multiplier = body_damage_multiplier;
|
||||
event->body_part = body_part;
|
||||
event->node_index = node_index;
|
||||
event->region_index = region_index;
|
||||
event->material_index = material_index;
|
||||
/* a killing blow, a player's with who the host says dealt it */
|
||||
if (kill)
|
||||
{
|
||||
@@ -1074,21 +1139,74 @@ static real distributed_source_deals(
|
||||
return distributed_source_deals_uncached(source_index, damage_index, grenade, kinds, reach);
|
||||
}
|
||||
|
||||
/* the oldest grenade of the type the host saw the player throw within
|
||||
RECENT_WEAPON_TICKS that has not gone off yet (network_damage_note_grenade),
|
||||
NONE for none */
|
||||
static short distributed_grenade_throw(
|
||||
short player_index,
|
||||
short grenade_type)
|
||||
{
|
||||
short index;
|
||||
short oldest = NONE;
|
||||
|
||||
for (index = 0; index < MAXIMUM_GRENADE_THROWS; index++)
|
||||
{
|
||||
long time = damage_players[player_index].throw_times[index];
|
||||
|
||||
if (time != NONE && damage_players[player_index].throw_types[index] == grenade_type &&
|
||||
game_time_get() - time <= RECENT_WEAPON_TICKS &&
|
||||
(oldest == NONE || time < damage_players[player_index].throw_times[oldest]))
|
||||
{
|
||||
oldest = index;
|
||||
}
|
||||
}
|
||||
return oldest;
|
||||
}
|
||||
|
||||
/* whether an explosion of the damage is among the player's this tick
|
||||
(distributed_report_paid): at the epicenter, or (NULL) anywhere */
|
||||
static boolean distributed_explosion_this_tick(
|
||||
short player_index,
|
||||
long damage_index,
|
||||
real_point3d const *epicenter)
|
||||
{
|
||||
short index;
|
||||
|
||||
if (damage_explosions[player_index].time != game_time_get())
|
||||
return FALSE;
|
||||
for (index = 0; index < damage_explosions[player_index].count; index++)
|
||||
{
|
||||
if (damage_explosions[player_index].explosions[index].definition_index == damage_index &&
|
||||
(!epicenter || (damage_explosions[player_index].explosions[index].epicenter.x == epicenter->x &&
|
||||
damage_explosions[player_index].explosions[index].epicenter.y == epicenter->y &&
|
||||
damage_explosions[player_index].explosions[index].epicenter.z == epicenter->z)))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* how many hits a second the player could deal of the damage: their
|
||||
weapons, lately, their grenades, the vehicle they drove lately; 0 when none
|
||||
of them deals it; how they deal it (the _damage_source flags); and how far
|
||||
from them what they fire deals it */
|
||||
weapons, lately, a grenade the host saw them throw that has not gone off
|
||||
(or one going off this tick, hitting more than one object), the vehicle
|
||||
they drove lately; 0 when none of them deals it; how they deal it (the
|
||||
_damage_source flags); how far from them what they fire deals it; and the
|
||||
type of grenade when nothing but a grenade of theirs deals it, else NONE */
|
||||
static real distributed_player_deals(
|
||||
short player_index,
|
||||
long damage_index,
|
||||
byte *kinds,
|
||||
struct damage_reach *reach)
|
||||
struct damage_reach *reach,
|
||||
short *grenade_type)
|
||||
{
|
||||
struct game_globals *globals = scenario_get_game_globals();
|
||||
short index;
|
||||
real rate = 0.0f;
|
||||
real grenade_rate = 0.0f;
|
||||
|
||||
*kinds = 0;
|
||||
*grenade_type = NONE;
|
||||
reach->distance = 0.0f;
|
||||
reach->ticks = 0.0f;
|
||||
reach->carried_ticks = 0.0f;
|
||||
@@ -1108,24 +1226,12 @@ static real distributed_player_deals(
|
||||
*kinds |= weapon_kinds;
|
||||
}
|
||||
}
|
||||
for (index = 0; index < globals->grenades.count && index < NUMBER_OF_UNIT_GRENADE_TYPES; index++)
|
||||
/* (a blow with no weapon: the unit's own, units.c) */
|
||||
if (damage_players[player_index].unarmed_melee_damage_index == damage_index && damage_index != NONE &&
|
||||
game_time_get() - damage_players[player_index].unarmed_time <= RECENT_WEAPON_TICKS)
|
||||
{
|
||||
struct game_globals_grenade *grenade = TAG_BLOCK_GET_ELEMENT(&globals->grenades, index,
|
||||
struct game_globals_grenade);
|
||||
|
||||
if (game_time_get() - damage_players[player_index].grenade_times[index] <= RECENT_WEAPON_TICKS &&
|
||||
grenade->projectile.index != NONE)
|
||||
{
|
||||
byte grenade_kinds;
|
||||
struct damage_reach grenade_reach;
|
||||
real grenade_rate = distributed_source_deals(grenade->projectile.index, damage_index, TRUE, &grenade_kinds,
|
||||
&grenade_reach);
|
||||
|
||||
if (grenade_rate > 0.0f)
|
||||
distributed_reach_combine(reach, &grenade_reach);
|
||||
rate = MAX(rate, grenade_rate);
|
||||
*kinds |= grenade_kinds;
|
||||
}
|
||||
rate = MAX(rate, MELEE_HITS_PER_SECOND);
|
||||
SET_FLAG(*kinds, _damage_source_melee_bit, TRUE);
|
||||
}
|
||||
/* (a vehicle's collision is its driver's, physics.c; the damage it deals
|
||||
a unit it kills is no one's) */
|
||||
@@ -1141,6 +1247,36 @@ static real distributed_player_deals(
|
||||
SET_FLAG(*kinds, _damage_source_collision_bit, TRUE);
|
||||
}
|
||||
}
|
||||
/* (a grenade's damage only from one thrown: holding grenades deals
|
||||
nothing) */
|
||||
for (index = 0; index < globals->grenades.count && index < NUMBER_OF_UNIT_GRENADE_TYPES; index++)
|
||||
{
|
||||
struct game_globals_grenade *grenade = TAG_BLOCK_GET_ELEMENT(&globals->grenades, index,
|
||||
struct game_globals_grenade);
|
||||
boolean thrown = distributed_grenade_throw(player_index, index) != NONE;
|
||||
|
||||
if ((thrown || distributed_explosion_this_tick(player_index, damage_index, NULL)) &&
|
||||
grenade->projectile.index != NONE)
|
||||
{
|
||||
byte this_kinds;
|
||||
struct damage_reach this_reach;
|
||||
real this_rate = distributed_source_deals(grenade->projectile.index, damage_index, TRUE, &this_kinds,
|
||||
&this_reach);
|
||||
|
||||
if (this_rate > 0.0f)
|
||||
{
|
||||
distributed_reach_combine(reach, &this_reach);
|
||||
/* (one with a throw left before one only going off now) */
|
||||
if (*grenade_type == NONE || thrown)
|
||||
*grenade_type = index;
|
||||
}
|
||||
grenade_rate = MAX(grenade_rate, this_rate);
|
||||
*kinds |= this_kinds;
|
||||
}
|
||||
}
|
||||
if (rate > 0.0f)
|
||||
*grenade_type = NONE;
|
||||
rate = MAX(rate, grenade_rate);
|
||||
return rate * HIT_REPORT_RATE_MARGIN;
|
||||
}
|
||||
|
||||
@@ -1409,6 +1545,8 @@ static void distributed_note_weapons(
|
||||
|
||||
if (player_index >= MAXIMUM_TRACKED_PLAYERS || unit_index == NONE)
|
||||
continue;
|
||||
damage_players[player_index].unarmed_melee_damage_index = unit_unarmed_melee_damage(unit_index);
|
||||
damage_players[player_index].unarmed_time = game_time_get();
|
||||
units[0] = unit_index;
|
||||
units[1] = object_get(unit_index)->object.parent_object_index;
|
||||
/* (a vehicle's collisions are its driver's, physics.c) */
|
||||
@@ -1419,16 +1557,6 @@ static void distributed_note_weapons(
|
||||
if (vehicle && vehicle->unit.driver_object_index == unit_index)
|
||||
damage_players[player_index].driven_time = game_time_get();
|
||||
}
|
||||
{
|
||||
struct unit_datum *unit = unit_get(unit_index);
|
||||
short grenade_index;
|
||||
|
||||
for (grenade_index = 0; grenade_index < NUMBER_OF_UNIT_GRENADE_TYPES; grenade_index++)
|
||||
{
|
||||
if (unit->unit.grenade_counts[grenade_index] > 0)
|
||||
damage_players[player_index].grenade_times[grenade_index] = game_time_get();
|
||||
}
|
||||
}
|
||||
for (unit_number = 0; unit_number < 2; unit_number++)
|
||||
{
|
||||
struct unit_datum *unit = units[unit_number] != NONE ?
|
||||
@@ -1626,6 +1754,8 @@ static boolean distributed_report_valid(
|
||||
real reach;
|
||||
struct damage_reach fired_reach;
|
||||
short seen;
|
||||
short grenade_type;
|
||||
short throw_index = NONE;
|
||||
|
||||
/* that machine's player */
|
||||
if (player_index == NO_PLAYER || player_index >= MAXIMUM_TRACKED_PLAYERS ||
|
||||
@@ -1639,6 +1769,8 @@ static boolean distributed_report_valid(
|
||||
return FALSE;
|
||||
target = (struct object_datum *)object_try_and_get_and_verify_type(report->object_index,
|
||||
_object_mask_biped | _object_mask_vehicle | _object_mask_weapon | _object_mask_equipment);
|
||||
if (!target && static_target(report->object_index))
|
||||
target = object_get(report->object_index);
|
||||
if (!target || !tag_index_is_group(report->damage.definition_index, DAMAGE_EFFECT_DEFINITION_TAG))
|
||||
return FALSE;
|
||||
/* numbers the game can take */
|
||||
@@ -1658,7 +1790,8 @@ static boolean distributed_report_valid(
|
||||
return FALSE;
|
||||
ticks = MIN(now - report->host_time + TARGET_HISTORY_SLACK_TICKS, TARGET_HISTORY_TICKS - 1);
|
||||
/* damage that player could deal, and how they deal it */
|
||||
rate = distributed_player_deals(player_index, report->damage.definition_index, &kinds, &fired_reach);
|
||||
rate = distributed_player_deals(player_index, report->damage.definition_index, &kinds, &fired_reach,
|
||||
&grenade_type);
|
||||
if (rate <= 0.0f)
|
||||
return FALSE;
|
||||
/* ... of its shape: at a point, else a melee blow, else a collision; and
|
||||
@@ -1700,12 +1833,26 @@ static boolean distributed_report_valid(
|
||||
reach += definition->cutoff_radius;
|
||||
if (!(distributed_distance_squared(&report->damage.origin, &report->target_position) <= reach * reach))
|
||||
return FALSE;
|
||||
/* what only a grenade of theirs deals, from one the host saw them throw
|
||||
that has not gone off: its explosion once (the explosion's other objects
|
||||
that tick come free, distributed_report_paid), what it hits at a point
|
||||
while it is about */
|
||||
if (grenade_type != NONE &&
|
||||
!distributed_explosion_this_tick(player_index, report->damage.definition_index, &report->damage.epicenter))
|
||||
{
|
||||
throw_index = distributed_grenade_throw(player_index, grenade_type);
|
||||
if (throw_index == NONE)
|
||||
return FALSE;
|
||||
}
|
||||
/* no more than the weapon fires */
|
||||
if (!distributed_report_paid(player_index, report, rate, area && !melee && !collision,
|
||||
definition->cutoff_radius > 0.0f))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
/* (the grenade gone off: its throw spent) */
|
||||
if (throw_index != NONE && area && !melee && !collision)
|
||||
damage_players[player_index].throw_times[throw_index] = NONE;
|
||||
/* a melee blow from where the host had the player (its origin their
|
||||
head, its epicenter their body); a collision from the vehicle they
|
||||
drove */
|
||||
@@ -1926,6 +2073,26 @@ static boolean distributed_event_goes_to(
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* How often the host logs how many client hits it accepted and refused
|
||||
(only when it refused some). Tells "my shots don't register" apart from
|
||||
"I missed". */
|
||||
#define REPORT_LOG_TICKS (30 * TICKS_PER_SECOND)
|
||||
|
||||
static void distributed_log_reports(
|
||||
void)
|
||||
{
|
||||
static long logged_dealt;
|
||||
static long logged_rejected;
|
||||
|
||||
if (game_time_get() % REPORT_LOG_TICKS != 0 || damage_rejected_reports == logged_rejected)
|
||||
return;
|
||||
error(_error_silent, "damage: clients' hits in the last %d seconds: %ld dealt, %ld refused",
|
||||
REPORT_LOG_TICKS / TICKS_PER_SECOND, damage_dealt_reports - logged_dealt,
|
||||
damage_rejected_reports - logged_rejected);
|
||||
logged_dealt = damage_dealt_reports;
|
||||
logged_rejected = damage_rejected_reports;
|
||||
}
|
||||
|
||||
void network_damage_host_tick(
|
||||
void)
|
||||
{
|
||||
@@ -1936,6 +2103,7 @@ void network_damage_host_tick(
|
||||
distributed_client_machines(machine_indices, HALO_PORT_MAXIMUM_NETWORK_MACHINES) : 0;
|
||||
short machine_number;
|
||||
|
||||
distributed_log_reports();
|
||||
distributed_note_weapons();
|
||||
distributed_note_targets();
|
||||
distributed_note_event_destinations();
|
||||
@@ -2044,6 +2212,15 @@ void network_damage_handle_events(
|
||||
players_show_telefragged(victim_player_index);
|
||||
}
|
||||
break;
|
||||
case _damage_event_static:
|
||||
if (distributed_object_index_valid(event->object_index) && static_target(event->object_index) &&
|
||||
distributed_damage_indices_valid(event->object_index, event->node_index, event->region_index,
|
||||
event->material_index))
|
||||
{
|
||||
damage_replay_static(event->object_index, &damage, event->node_index, event->region_index,
|
||||
event->material_index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2089,6 +2266,41 @@ void network_damage_statistics(
|
||||
*replayed_events = damage_replayed_events;
|
||||
}
|
||||
|
||||
/* the host: a grenade a player's unit threw (units.c), as the host's own
|
||||
game threw it, which that player's machine reports the damage of
|
||||
(distributed_report_valid) */
|
||||
void network_damage_note_grenade(
|
||||
long unit_index,
|
||||
short grenade_type)
|
||||
{
|
||||
struct unit_datum *unit = unit_get(unit_index);
|
||||
long player_index;
|
||||
short index;
|
||||
short slot = 0;
|
||||
|
||||
if (game_connection() != _game_connection_network_server || unit->unit.player_index == NONE ||
|
||||
grenade_type < 0 || grenade_type >= NUMBER_OF_UNIT_GRENADE_TYPES)
|
||||
{
|
||||
return;
|
||||
}
|
||||
player_index = DATUM_INDEX_TO_ABSOLUTE_INDEX(unit->unit.player_index);
|
||||
if (player_index >= MAXIMUM_TRACKED_PLAYERS)
|
||||
return;
|
||||
/* (in a free place, else the oldest's) */
|
||||
for (index = 0; index < MAXIMUM_GRENADE_THROWS; index++)
|
||||
{
|
||||
if (damage_players[player_index].throw_times[index] == NONE)
|
||||
{
|
||||
slot = index;
|
||||
break;
|
||||
}
|
||||
if (damage_players[player_index].throw_times[index] < damage_players[player_index].throw_times[slot])
|
||||
slot = index;
|
||||
}
|
||||
damage_players[player_index].throw_times[slot] = game_time_get();
|
||||
damage_players[player_index].throw_types[slot] = grenade_type;
|
||||
}
|
||||
|
||||
void network_damage_new_game(
|
||||
void)
|
||||
{
|
||||
@@ -2107,8 +2319,9 @@ void network_damage_new_game(
|
||||
|
||||
for (index = 0; index < MAXIMUM_RECENT_WEAPONS; index++)
|
||||
damage_players[player_index].definition_indices[index] = NONE;
|
||||
for (index = 0; index < NUMBER_OF_UNIT_GRENADE_TYPES; index++)
|
||||
damage_players[player_index].grenade_times[index] = -RECENT_WEAPON_TICKS - 1;
|
||||
damage_players[player_index].unarmed_melee_damage_index = NONE;
|
||||
for (index = 0; index < MAXIMUM_GRENADE_THROWS; index++)
|
||||
damage_players[player_index].throw_times[index] = NONE;
|
||||
damage_players[player_index].driven_time = -RECENT_WEAPON_TICKS - 1;
|
||||
damage_players[player_index].hit_seconds = HIT_REPORT_BURST_SECONDS;
|
||||
damage_explosions[player_index].time = NONE;
|
||||
|
||||
@@ -53,18 +53,24 @@ machine (their datum identifiers need not be).
|
||||
|
||||
#include "cseries.h"
|
||||
#include "cseries/errors.h"
|
||||
#include "cache/cache_files.h"
|
||||
#include "models/model_animation_definitions.h"
|
||||
#include "game/game.h"
|
||||
#include "game/game_globals.h"
|
||||
#include "game/players.h"
|
||||
#include "game/game_engine.h"
|
||||
#include "main/main.h"
|
||||
#include "game/player_queues_new.h"
|
||||
#include "networking/network_game_globals.h"
|
||||
#include "objects/objects.h"
|
||||
#include "objects/damage.h"
|
||||
#include "scenario/scenario.h"
|
||||
#include "scenario/scenario_definitions.h"
|
||||
#include "structures/structure_bsp_definitions.h"
|
||||
#include "units/units.h"
|
||||
#include "units/biped_definitions.h"
|
||||
#include "units/bipeds.h"
|
||||
#include "network_coop.h"
|
||||
#include "network_distributed.h"
|
||||
|
||||
#include <limits.h>
|
||||
@@ -89,7 +95,7 @@ void game_engine_read_network_state(byte const *buffer, long size);
|
||||
/* physics.c's (world units a tick, each tick) */
|
||||
extern real global_gravity;
|
||||
/* network_server_manager.c's, cseries_windows.c's, console.c's, p2p.c's */
|
||||
void network_game_server_kick_machine(long machine_index);
|
||||
void network_game_server_kick_machine(long machine_index, boolean kept_out);
|
||||
unsigned long network_game_server_machine_address(long machine_index);
|
||||
char const *network_game_server_machine_hardware_id(long machine_index);
|
||||
void p2p_hardware_id_sanitize(char *destination, int size, const char *source);
|
||||
@@ -238,11 +244,8 @@ before the host takes it no longer, and before the client is put where the
|
||||
host has it (no further than that: between the two they would disagree for
|
||||
good, the host's player somewhere its own is not) */
|
||||
#define HOST_ACCEPT_TOLERANCE 3.5f
|
||||
#define REMOTE_CORRECTION_TOLERANCE 0.05f
|
||||
#define LOCAL_CORRECTION_TOLERANCE 3.0f
|
||||
/* how far from the origin a unit is (world units), and how fast a client's
|
||||
own player's unit moves at most (world units a tick) */
|
||||
#define UNIT_WORLD_BOUND 32768.0f
|
||||
/* how fast a client's own player's unit moves at most (world units a tick) */
|
||||
#define MAXIMUM_PREDICTED_SPEED 2.0f
|
||||
/* ... on foot: this many times as fast as a player runs and jumps, or as
|
||||
fast as the host's ticks threw its copy lately, whichever is more; and how
|
||||
@@ -317,7 +320,9 @@ ticks before it */
|
||||
struct distributed_player_input
|
||||
{
|
||||
byte player_index;
|
||||
byte pad[3];
|
||||
/* co-op: the structure BSP the client has loaded */
|
||||
byte structure_bsp_index;
|
||||
byte pad[2];
|
||||
/* the client's tick */
|
||||
long tick;
|
||||
/* the latest host tick the client has had a message of (the host
|
||||
@@ -583,7 +588,10 @@ static long distributed_received_times[MAXIMUM_SENDERS][NUMBER_OF_DISTRIBUTED_ME
|
||||
/* the host: each client machine's clock, measured (CLIENT_CLOCK_WINDOW_MILLISECONDS):
|
||||
its latest tick, and its tick and the host's time as the window began
|
||||
(NONE: none begun); how many windows in a row it went fast, and whether
|
||||
the last did */
|
||||
the last did; and whether, since they began, a message that came over its
|
||||
stream was that far ahead too (a datagram's source address is all that
|
||||
says which machine sent it, and anyone can send one as from another's: a
|
||||
machine is banned only on its stream's word, distributed_note_client_clock) */
|
||||
/* the host: each client machine's Discord user, as it told it, the text
|
||||
kept only of what is allowed (p2p_discord_sanitize) */
|
||||
static struct distributed_client_identity distributed_client_identities[HALO_PORT_MAXIMUM_NETWORK_MACHINES];
|
||||
@@ -597,7 +605,11 @@ static struct distributed_client_clock
|
||||
unsigned long window_time;
|
||||
short fast_windows;
|
||||
boolean fast;
|
||||
boolean ahead_on_stream;
|
||||
} distributed_client_clocks[HALO_PORT_MAXIMUM_NETWORK_MACHINES];
|
||||
/* the host: whether the message being handled came over its machine's
|
||||
stream (network_distributed_handle_stream_message) */
|
||||
static boolean distributed_handling_stream_message;
|
||||
/* a client: the host's latest tick it has had a message of */
|
||||
static long distributed_host_time = NONE;
|
||||
/* the host: each client's round trip, in ticks, and its jitter */
|
||||
@@ -666,6 +678,40 @@ boolean distributed_point_valid(
|
||||
return fabsf(point->x) <= bound && fabsf(point->y) <= bound && fabsf(point->z) <= bound;
|
||||
}
|
||||
|
||||
/* whether a tag index from the host really is a tag of that group */
|
||||
boolean distributed_tag_of_group(
|
||||
long tag_index,
|
||||
unsigned long group_tag)
|
||||
{
|
||||
struct tag_iterator iterator;
|
||||
long index;
|
||||
|
||||
tag_iterator_new(&iterator, group_tag);
|
||||
while ((index = tag_iterator_next(&iterator)) != NONE)
|
||||
{
|
||||
if (index == tag_index)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* the graph's animation, if the graph tag and index are valid */
|
||||
struct animation *distributed_graph_animation(
|
||||
long animation_graph_index,
|
||||
short animation_index)
|
||||
{
|
||||
struct animation_graph *graph;
|
||||
|
||||
if (!distributed_tag_of_group(animation_graph_index, ANIMATION_GRAPH_TAG))
|
||||
return NULL;
|
||||
graph = animation_graph_definition_get(animation_graph_index);
|
||||
if (animation_index < 0 || animation_index >= graph->animations.count)
|
||||
return NULL;
|
||||
|
||||
return TAG_BLOCK_GET_ELEMENT(&graph->animations, animation_index, struct animation);
|
||||
}
|
||||
|
||||
boolean distributed_object_index_valid(
|
||||
long object_index)
|
||||
{
|
||||
@@ -749,7 +795,7 @@ void distributed_unit_vector_unpack(
|
||||
}
|
||||
}
|
||||
|
||||
static word distributed_vitality_pack(
|
||||
word distributed_vitality_pack(
|
||||
real value)
|
||||
{
|
||||
value *= VITALITY_SCALE;
|
||||
@@ -757,15 +803,13 @@ static word distributed_vitality_pack(
|
||||
return (word)(long)floor(value + 0.5f);
|
||||
}
|
||||
|
||||
static real distributed_vitality_unpack(
|
||||
real distributed_vitality_unpack(
|
||||
word value)
|
||||
{
|
||||
return (real)value / VITALITY_SCALE;
|
||||
}
|
||||
|
||||
/* an angle as a 16-bit fraction of a turn, and back (yaw from 0 to 2 pi,
|
||||
pitch from -pi to pi) */
|
||||
static short distributed_angle_pack(
|
||||
short distributed_angle_pack(
|
||||
real angle)
|
||||
{
|
||||
real turns = angle / (2.0f * _pi);
|
||||
@@ -774,7 +818,7 @@ static short distributed_angle_pack(
|
||||
return (short)(word)((long)floor(turns * 65536.0f + 0.5f) & 0xFFFF);
|
||||
}
|
||||
|
||||
static real distributed_angle_unpack(
|
||||
real distributed_angle_unpack(
|
||||
short value,
|
||||
boolean signed_angle)
|
||||
{
|
||||
@@ -1585,6 +1629,14 @@ static void distributed_correct_own_unit(
|
||||
short local_player_index = player->local_player_index;
|
||||
real_point3d position = state->position;
|
||||
|
||||
/* (co-op: the host has its player in a BSP this machine hasn't loaded
|
||||
yet, the switch still on its way. Moved there, it would fall with no
|
||||
floor under it, so it stays on the floor it has until the BSP loads.) */
|
||||
if (network_coop_active() && scenario_leaf_index_from_point(&state->position) == NONE &&
|
||||
scenario_leaf_index_from_point(&object_get(unit_index)->object.position) != NONE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (TEST_FLAG(state->flags, _distributed_unit_predicted_bit) &&
|
||||
local_player_index >= 0 && local_player_index < MAXIMUM_LOCAL_PLAYERS)
|
||||
{
|
||||
@@ -2048,9 +2100,15 @@ static void distributed_apply_predictions(
|
||||
{
|
||||
distributed_predictions[player_index].valid = FALSE;
|
||||
distributed_predictions[player_index].taken_host_time = NONE;
|
||||
/* (of the unit it has now: not one of a life before) */
|
||||
if (unit_index != NONE && unit_index == state->unit_index)
|
||||
/* (of the unit it has now: not one of a life before; and not
|
||||
from a co-op client still loading the host's BSP, whose player
|
||||
falls there with no floor under it) */
|
||||
if (unit_index != NONE && unit_index == state->unit_index &&
|
||||
unit_get(unit_index)->unit.player_index != NONE &&
|
||||
network_coop_player_has_structure_bsp(unit_get(unit_index)->unit.player_index))
|
||||
{
|
||||
distributed_take_prediction(player_index, unit_index, &bound);
|
||||
}
|
||||
}
|
||||
/* (what the host's next tick starts from) */
|
||||
if (unit_index != NONE)
|
||||
@@ -2222,6 +2280,7 @@ static void distributed_client_send_inputs(
|
||||
if (!update_client_distributed_input(local_player_index, &input->tick, &input->action, input->control_flags))
|
||||
continue;
|
||||
input->player_index = distributed_player_to_byte(player_index);
|
||||
input->structure_bsp_index = (byte)global_structure_bsp_index_get();
|
||||
input->host_time = distributed_host_time;
|
||||
count++;
|
||||
}
|
||||
@@ -2232,6 +2291,37 @@ static void distributed_client_send_inputs(
|
||||
}
|
||||
}
|
||||
|
||||
/* (the host, in co-op) where each client player's input last faced, by
|
||||
absolute index: how far it turns between inputs is its looking around */
|
||||
static struct
|
||||
{
|
||||
boolean valid;
|
||||
real_euler_angles2d facing;
|
||||
} distributed_input_facings[MAXIMUM_TRACKED_PLAYERS];
|
||||
|
||||
/* (the host, in co-op) a client player's input counted in the scripts'
|
||||
action tests, as a local player's is (player_control_action_test_note) */
|
||||
static void distributed_note_input_actions(
|
||||
short player_index,
|
||||
struct player_action const *action)
|
||||
{
|
||||
real_euler_angles2d turn = { 0.0f, 0.0f };
|
||||
|
||||
if (distributed_input_facings[player_index].valid)
|
||||
{
|
||||
turn.yaw = action->desired_facing.yaw - distributed_input_facings[player_index].facing.yaw;
|
||||
turn.pitch = action->desired_facing.pitch - distributed_input_facings[player_index].facing.pitch;
|
||||
/* (the short way round) */
|
||||
if (turn.yaw > _pi)
|
||||
turn.yaw -= 2.0f * _pi;
|
||||
else if (turn.yaw < -_pi)
|
||||
turn.yaw += 2.0f * _pi;
|
||||
}
|
||||
distributed_input_facings[player_index].valid = TRUE;
|
||||
distributed_input_facings[player_index].facing = action->desired_facing;
|
||||
player_control_action_test_note(action->control_flags, &turn, &action->throttle, action->primary_trigger);
|
||||
}
|
||||
|
||||
/* (the host) a client's players' input, and from it (once a message) how
|
||||
long a message takes that client and back */
|
||||
static void distributed_handle_inputs(
|
||||
@@ -2261,6 +2351,10 @@ static void distributed_handle_inputs(
|
||||
action.throttle.i = PIN(action.throttle.i, -1.0f, 1.0f);
|
||||
action.throttle.j = PIN(action.throttle.j, -1.0f, 1.0f);
|
||||
action.primary_trigger = PIN(action.primary_trigger, 0.0f, 1.0f);
|
||||
/* (a spectator's buttons pick whom it watches: not counted) */
|
||||
if (network_coop_active() && player->unit_index != NONE)
|
||||
distributed_note_input_actions(input->player_index, &action);
|
||||
network_coop_note_player_structure_bsp(input->player_index, input->structure_bsp_index);
|
||||
update_server_handle_distributed_input(DATUM_INDEX_NEW(input->player_index, player->identifier), input->tick,
|
||||
&action, input->control_flags, DISTRIBUTED_INPUT_HISTORY);
|
||||
if (input->host_time != NONE && (host_time == NONE || input->host_time > host_time))
|
||||
@@ -2931,6 +3025,52 @@ static void distributed_send_pings(
|
||||
}
|
||||
}
|
||||
|
||||
/* Co-op: the host's structure BSP. Clients switch BSP only when told
|
||||
(their own trigger volumes don't, players.c). A switch is sent at once and
|
||||
reliably; it is also resent regularly so a client that joined late catches
|
||||
up. */
|
||||
#define STRUCTURE_BSP_INTERVAL_TICKS (TICKS_PER_SECOND / 2)
|
||||
|
||||
static short distributed_sent_structure_bsp_index = NONE;
|
||||
|
||||
struct distributed_structure_bsp
|
||||
{
|
||||
short structure_bsp_index;
|
||||
short pad;
|
||||
};
|
||||
|
||||
struct distributed_structure_bsp_message
|
||||
{
|
||||
struct distributed_message_header header;
|
||||
struct distributed_structure_bsp structure_bsp;
|
||||
};
|
||||
|
||||
static void distributed_send_structure_bsp(
|
||||
void)
|
||||
{
|
||||
struct distributed_structure_bsp_message message;
|
||||
short index = global_structure_bsp_index_get();
|
||||
boolean switched = index != distributed_sent_structure_bsp_index;
|
||||
|
||||
message.structure_bsp.structure_bsp_index = index;
|
||||
message.structure_bsp.pad = 0;
|
||||
distributed_send(&message, _distributed_message_structure_bsp, 1, (word)sizeof(message),
|
||||
switched ? _distributed_to_clients_reliably : _distributed_to_clients);
|
||||
distributed_sent_structure_bsp_index = index;
|
||||
}
|
||||
|
||||
static void distributed_handle_structure_bsp(
|
||||
struct distributed_structure_bsp const *structure_bsp)
|
||||
{
|
||||
short index = structure_bsp->structure_bsp_index;
|
||||
|
||||
if (network_coop_active() && index >= 0 && index < global_scenario_get()->structure_bsp_references.count &&
|
||||
index != global_structure_bsp_index_get())
|
||||
{
|
||||
main_switch_structure_bsp(index);
|
||||
}
|
||||
}
|
||||
|
||||
/* the players' statistics that changed since they were last sent, and when
|
||||
refreshing, STATISTICS_REFRESH_PLAYERS more whatever they are, round them
|
||||
all (a client that lost a change has it again within eight seconds) */
|
||||
@@ -3076,6 +3216,7 @@ void network_distributed_new_game(
|
||||
csmemset(distributed_accepted, 0, sizeof(distributed_accepted));
|
||||
csmemset(distributed_host_speeds, 0, sizeof(distributed_host_speeds));
|
||||
csmemset(distributed_round_trips, 0, sizeof(distributed_round_trips));
|
||||
csmemset(distributed_input_facings, 0, sizeof(distributed_input_facings));
|
||||
csmemset(distributed_client_clocks, 0, sizeof(distributed_client_clocks));
|
||||
csmemset(distributed_client_identities, 0, sizeof(distributed_client_identities));
|
||||
distributed_identity_sent = FALSE;
|
||||
@@ -3136,6 +3277,8 @@ void network_distributed_new_game(
|
||||
network_damage_new_game();
|
||||
network_vr_new_game();
|
||||
bots_new_game();
|
||||
network_actors_new_game();
|
||||
network_coop_new_game();
|
||||
}
|
||||
|
||||
/* after each tick (game_time.c) */
|
||||
@@ -3178,9 +3321,18 @@ void network_distributed_tick(
|
||||
distributed_statistics_due = FALSE;
|
||||
if (game_time_get() % PING_INTERVAL_TICKS == 0)
|
||||
distributed_send_pings();
|
||||
/* (before the players, so clients load a new BSP before they hear
|
||||
where the host moved everyone into it) */
|
||||
if (network_coop_active() && (global_structure_bsp_index_get() != distributed_sent_structure_bsp_index ||
|
||||
game_time_get() % STRUCTURE_BSP_INTERVAL_TICKS == 0))
|
||||
{
|
||||
distributed_send_structure_bsp();
|
||||
}
|
||||
distributed_host_send_players();
|
||||
network_vr_tick();
|
||||
bots_tick();
|
||||
network_actors_host_tick();
|
||||
network_coop_host_tick();
|
||||
distributed_send_pickups();
|
||||
if (game_time_get() % GAME_STATE_INTERVAL_TICKS == 0)
|
||||
distributed_send_game_state(NONE);
|
||||
@@ -3193,6 +3345,7 @@ void network_distributed_tick(
|
||||
distributed_client_send_predictions();
|
||||
network_objects_client_tick();
|
||||
network_damage_client_tick();
|
||||
network_coop_client_tick();
|
||||
}
|
||||
distributed_batches_flush();
|
||||
distributed_machines.in_tick = FALSE;
|
||||
@@ -3221,6 +3374,19 @@ static boolean distributed_message_stale(
|
||||
case _distributed_message_damage_events:
|
||||
case _distributed_message_vr_poses:
|
||||
case _distributed_message_pings:
|
||||
case _distributed_message_actor_states:
|
||||
case _distributed_message_structure_bsp:
|
||||
case _distributed_message_coop_presentation:
|
||||
case _distributed_message_coop_device_groups:
|
||||
case _distributed_message_coop_object_names:
|
||||
case _distributed_message_coop_skip_vote:
|
||||
case _distributed_message_coop_events:
|
||||
case _distributed_message_coop_object_transforms:
|
||||
case _distributed_message_actor_damage:
|
||||
case _distributed_message_coop_object_looks:
|
||||
case _distributed_message_damage_animations:
|
||||
case _distributed_message_coop_screen_effect:
|
||||
case _distributed_message_coop_device_states:
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
@@ -3523,6 +3689,27 @@ void network_distributed_ban(
|
||||
}
|
||||
}
|
||||
|
||||
/* (the host: network_server_manager.c, its kick command) players kicked by
|
||||
the host, which may join again: every machine told, nothing kept (no line
|
||||
in BANS_FILE) */
|
||||
void network_distributed_kick(
|
||||
char const *names)
|
||||
{
|
||||
char kept_names[64];
|
||||
char notice[MAXIMUM_NOTICE_LENGTH];
|
||||
|
||||
distributed_printable(kept_names, sizeof(kept_names), names);
|
||||
snprintf(notice, sizeof(notice), "%s kicked by the host", kept_names);
|
||||
/* (to every client in the game: in the lobby, the host's own) */
|
||||
if (game_in_progress())
|
||||
distributed_send_notice(notice);
|
||||
else
|
||||
{
|
||||
console_warning("%s", notice);
|
||||
error(_error_log, "%s", notice);
|
||||
}
|
||||
}
|
||||
|
||||
/* (the host) a client machine's tick, which one of its messages is
|
||||
stamped with: its clock measured, each window, against the host's; one
|
||||
whose game runs fast (distributed_client_clock) has its players'
|
||||
@@ -3538,6 +3725,8 @@ static void distributed_note_client_clock(
|
||||
if (machine_index < 0 || machine_index >= HALO_PORT_MAXIMUM_NETWORK_MACHINES)
|
||||
return;
|
||||
clock = &distributed_client_clocks[machine_index];
|
||||
if (distributed_handling_stream_message && tick - game_time_get() > CLIENT_CLOCK_AHEAD_TICKS)
|
||||
clock->ahead_on_stream = TRUE;
|
||||
if (clock->window_tick == NONE)
|
||||
{
|
||||
clock->latest_tick = tick;
|
||||
@@ -3559,6 +3748,7 @@ static void distributed_note_client_clock(
|
||||
if (!clock->fast)
|
||||
{
|
||||
clock->fast_windows = 0;
|
||||
clock->ahead_on_stream = FALSE;
|
||||
}
|
||||
else if (++clock->fast_windows == 1)
|
||||
{
|
||||
@@ -3575,7 +3765,7 @@ static void distributed_note_client_clock(
|
||||
char discord_id[DISCORD_ID_SIZE];
|
||||
char discord_name[DISCORD_NAME_SIZE];
|
||||
char discord[DISCORD_ID_SIZE + DISCORD_NAME_SIZE + 16] = "";
|
||||
char reason[64];
|
||||
char reason[96];
|
||||
char text[MAXIMUM_NOTICE_LENGTH];
|
||||
|
||||
distributed_machine_player_names(machine_index, names, sizeof(names));
|
||||
@@ -3585,14 +3775,30 @@ static void distributed_note_client_clock(
|
||||
distributed_client_identities[machine_index].discord_name, 1);
|
||||
if (discord_id[0] || discord_name[0])
|
||||
snprintf(discord, sizeof(discord), " (Discord: %s, %s)", discord_name, discord_id);
|
||||
snprintf(reason, sizeof(reason), "speed hack (game ran %.2f times as fast)", rate);
|
||||
snprintf(reason, sizeof(reason), "speed hack (game ran %.2f times as fast)%s", rate,
|
||||
clock->ahead_on_stream ? "" : " (its datagrams only: not banned)");
|
||||
snprintf(text, sizeof(text), "%s%s kicked by the host: their game ran %.2f times as fast (a speed hack)",
|
||||
names, discord, rate);
|
||||
distributed_send_notice(text);
|
||||
distributed_log_cheater(machine_index, names, reason);
|
||||
/* banned, and kept out, only when its stream said so
|
||||
too; on its datagrams' word alone (which another machine
|
||||
could have sent as from its address), logged and dropped,
|
||||
and it may join again */
|
||||
if (clock->ahead_on_stream)
|
||||
{
|
||||
distributed_log_cheater(machine_index, names, reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
char address[32];
|
||||
|
||||
distributed_machine_address_text(machine_index, address, sizeof(address));
|
||||
distributed_write_player_record(CHEATERS_FILE, address, machine_index, names, reason);
|
||||
}
|
||||
}
|
||||
network_game_server_kick_machine(machine_index);
|
||||
network_game_server_kick_machine(machine_index, clock->ahead_on_stream);
|
||||
clock->fast_windows = 0;
|
||||
clock->ahead_on_stream = FALSE;
|
||||
}
|
||||
}
|
||||
clock->window_tick = clock->latest_tick;
|
||||
@@ -3658,6 +3864,19 @@ void network_distributed_handle_message(
|
||||
case _distributed_message_unit_states: entry_size = DISTRIBUTED_UNIT_STATE_MINIMUM_SIZE; break;
|
||||
case _distributed_message_player_statistics: entry_size = sizeof(struct distributed_player_statistics); break;
|
||||
case _distributed_message_pings: entry_size = sizeof(struct distributed_player_ping); break;
|
||||
case _distributed_message_actor_states: entry_size = network_actors_entry_size(); break;
|
||||
case _distributed_message_structure_bsp: entry_size = sizeof(struct distributed_structure_bsp); break;
|
||||
case _distributed_message_coop_presentation: entry_size = network_coop_presentation_entry_size(); break;
|
||||
case _distributed_message_coop_events: entry_size = network_coop_event_entry_size(); break;
|
||||
case _distributed_message_coop_skip_vote: entry_size = network_coop_skip_vote_entry_size(); break;
|
||||
case _distributed_message_coop_device_groups: entry_size = network_coop_device_group_entry_size(); break;
|
||||
case _distributed_message_coop_object_names: entry_size = network_coop_object_names_entry_size(); break;
|
||||
case _distributed_message_coop_object_transforms: entry_size = network_coop_object_transform_entry_size(); break;
|
||||
case _distributed_message_actor_damage: entry_size = network_actors_damage_entry_size(); break;
|
||||
case _distributed_message_coop_object_looks: entry_size = network_coop_object_look_entry_size(); break;
|
||||
case _distributed_message_damage_animations: entry_size = network_objects_damage_animation_entry_size(); break;
|
||||
case _distributed_message_coop_screen_effect: entry_size = network_coop_screen_effect_entry_size(); break;
|
||||
case _distributed_message_coop_device_states: entry_size = network_coop_device_state_entry_size(); break;
|
||||
case _distributed_message_pickups: entry_size = sizeof(struct distributed_pickup); break;
|
||||
case _distributed_message_player_inputs: entry_size = sizeof(struct distributed_player_input); break;
|
||||
case _distributed_message_relayed_actions: entry_size = DISTRIBUTED_RELAYED_ACTION_MINIMUM_SIZE; break;
|
||||
@@ -3676,6 +3895,19 @@ void network_distributed_handle_message(
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* (the kinds whose handlers read one entry: not without it) */
|
||||
switch (header.type)
|
||||
{
|
||||
case _distributed_message_structure_bsp:
|
||||
case _distributed_message_coop_presentation:
|
||||
case _distributed_message_coop_object_names:
|
||||
case _distributed_message_coop_skip_vote:
|
||||
if (header.count < 1)
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
distributed_statistics.received++;
|
||||
|
||||
/* (each kind from the host, or from a client; a VR player's hands
|
||||
@@ -3699,6 +3931,7 @@ void network_distributed_handle_message(
|
||||
case _distributed_message_hit_reports:
|
||||
case _distributed_message_vehicle_prediction:
|
||||
case _distributed_message_player_inputs:
|
||||
case _distributed_message_coop_skip_vote:
|
||||
if (machine_index == NONE || game_connection() != _game_connection_network_server)
|
||||
return;
|
||||
break;
|
||||
@@ -3735,6 +3968,45 @@ void network_distributed_handle_message(
|
||||
case _distributed_message_unit_states:
|
||||
distributed_handle_unit_states((byte const *)entries, (byte const *)message + size, header.count);
|
||||
break;
|
||||
case _distributed_message_actor_states:
|
||||
network_actors_handle_states(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_structure_bsp:
|
||||
distributed_handle_structure_bsp((struct distributed_structure_bsp const *)entries);
|
||||
break;
|
||||
case _distributed_message_coop_presentation:
|
||||
network_coop_handle_presentation(entries, header.game_time);
|
||||
break;
|
||||
case _distributed_message_coop_events:
|
||||
network_coop_handle_events(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_coop_skip_vote:
|
||||
network_coop_handle_skip_vote(machine_index, entries);
|
||||
break;
|
||||
case _distributed_message_coop_device_groups:
|
||||
network_coop_handle_device_groups(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_coop_object_names:
|
||||
network_coop_handle_object_names(entries);
|
||||
break;
|
||||
case _distributed_message_coop_object_transforms:
|
||||
network_coop_handle_object_transforms(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_actor_damage:
|
||||
network_actors_handle_damage(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_coop_object_looks:
|
||||
network_coop_handle_object_looks(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_damage_animations:
|
||||
network_objects_handle_damage_animations(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_coop_screen_effect:
|
||||
network_coop_handle_screen_effect(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_coop_device_states:
|
||||
network_coop_handle_device_states(entries, header.count);
|
||||
break;
|
||||
case _distributed_message_player_statistics:
|
||||
{
|
||||
/* the host's count of kills, deaths, ... */
|
||||
@@ -3864,3 +4136,16 @@ void network_distributed_handle_message(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (the host: network_server_message_handler.c) a client machine's message
|
||||
of the distributed kind that came over its stream, which no other machine
|
||||
can send as it: as network_distributed_handle_message */
|
||||
void network_distributed_handle_stream_message(
|
||||
long machine_index,
|
||||
word const *message,
|
||||
word size)
|
||||
{
|
||||
distributed_handling_stream_message = TRUE;
|
||||
network_distributed_handle_message(machine_index, message, size);
|
||||
distributed_handling_stream_message = FALSE;
|
||||
}
|
||||
@@ -65,6 +65,47 @@ enum
|
||||
/* every player's ping as the host measures it, every two seconds, for
|
||||
the scoreboard (unreliable) */
|
||||
_distributed_message_pings,
|
||||
/* the host's actors' units: their control and state (network_actors.c).
|
||||
A number of its own, clear of the kinds upstream adds: a build without
|
||||
it drops the message as a kind it does not know, so the network version
|
||||
stays upstream's and its players join as before */
|
||||
_distributed_message_actor_states = 64,
|
||||
/* co-op (a campaign map, no game engine): the host's structure BSP,
|
||||
twice a second, for a client to switch to; numbered as actor_states */
|
||||
_distributed_message_structure_bsp,
|
||||
/* co-op: the host's cinematic, camera and screen fade, every tick
|
||||
(network_coop.c) */
|
||||
_distributed_message_coop_presentation,
|
||||
/* (0.2.0's co-op script sounds; now part of coop_events. The number
|
||||
stays taken so a 0.2.0 build never misreads a newer message.) */
|
||||
_distributed_message_coop_sounds_retired,
|
||||
/* co-op: device group state (network_coop.c) */
|
||||
_distributed_message_coop_device_groups,
|
||||
/* co-op: which named objects exist on the host (network_coop.c) */
|
||||
_distributed_message_coop_object_names,
|
||||
/* co-op: a client's vote to skip the cutscene, to the host (network_coop.c) */
|
||||
_distributed_message_coop_skip_vote,
|
||||
/* co-op: what the host's scripts did once: sounds, titles, HUD text,
|
||||
animations (network_coop.c) */
|
||||
_distributed_message_coop_events,
|
||||
/* co-op: where the host's scenery and machines are, when they move
|
||||
(network_coop.c) */
|
||||
_distributed_message_coop_object_transforms,
|
||||
/* the damage the host's AI units are taking, which their shields'
|
||||
flares are drawn by (network_actors.c); 73 in upstream's AI sync too */
|
||||
_distributed_message_actor_damage = 73,
|
||||
/* co-op: how the host's objects look (their permutations, scale), when
|
||||
that changes (network_coop.c) */
|
||||
_distributed_message_coop_object_looks,
|
||||
/* the flinch and death animations the host picked for its units, which a
|
||||
client plays rather than its own picks (network_objects.c) */
|
||||
_distributed_message_damage_animations = 75,
|
||||
/* co-op: the host's cinematic screen effect (blur, filters, video), when
|
||||
it changes and every two seconds (network_coop.c) */
|
||||
_distributed_message_coop_screen_effect = 76,
|
||||
/* co-op: where the host's devices are (doors, elevators), when they move
|
||||
(network_coop.c) */
|
||||
_distributed_message_coop_device_states = 77,
|
||||
|
||||
/* The VR port's own messages, numbered far past the game's (240 on),
|
||||
so that messages upstream adds never take their numbers: a build
|
||||
@@ -93,6 +134,10 @@ tick, drawn as it goes; further, it is put there, drawn gliding
|
||||
#define HOST_BLEND_DISTANCE 0.25f
|
||||
#define HOST_VEHICLE_BLEND_DISTANCE 0.5f
|
||||
#define REMOTE_BLEND_DISTANCE 1.0f
|
||||
/* world units: how far a remote unit may be from where the host says
|
||||
before it is put there, and how far from the origin a unit can be */
|
||||
#define REMOTE_CORRECTION_TOLERANCE 0.05f
|
||||
#define UNIT_WORLD_BOUND 32768.0f
|
||||
#define REMOTE_VEHICLE_BLEND_DISTANCE 2.0f
|
||||
|
||||
enum
|
||||
@@ -190,6 +235,10 @@ never 0, which any object at the index matches) */
|
||||
boolean distributed_real_valid(real value);
|
||||
boolean distributed_point_valid(real_point3d const *point, real bound);
|
||||
boolean distributed_object_index_valid(long object_index);
|
||||
/* whether a tag index from the host really is a tag of that group */
|
||||
boolean distributed_tag_of_group(long tag_index, unsigned long group_tag);
|
||||
/* the graph's animation, if a graph tag and animation index from the host are valid */
|
||||
struct animation *distributed_graph_animation(long animation_graph_index, short animation_index);
|
||||
/* ... an orientation's two axes (unpacked): TRUE when they are one long
|
||||
and about square, then made exactly so */
|
||||
boolean distributed_axes_make_valid(real_vector3d *forward, real_vector3d *up);
|
||||
@@ -200,12 +249,70 @@ void distributed_unit_vector_unpack(struct distributed_vector const *vector, rea
|
||||
#define DISTRIBUTED_UNIT_SCALE 32767.0f
|
||||
#define DISTRIBUTED_VELOCITY_SCALE 1024.0f
|
||||
#define DISTRIBUTED_ANGULAR_VELOCITY_SCALE 4096.0f
|
||||
/* an angle as a 16-bit fraction of a turn, and back (yaw from 0 to 2 pi,
|
||||
pitch from -pi to pi) */
|
||||
short distributed_angle_pack(real angle);
|
||||
real distributed_angle_unpack(short value, boolean signed_angle);
|
||||
/* shields and health in 16 bits */
|
||||
word distributed_vitality_pack(real value);
|
||||
real distributed_vitality_unpack(word value);
|
||||
|
||||
/* ---------- prototypes/NETWORK_ACTORS.C */
|
||||
|
||||
void network_actors_new_game(void);
|
||||
/* (the host, after each tick) the units its actors drove this tick, to
|
||||
each client */
|
||||
void network_actors_host_tick(void);
|
||||
/* (a client) the host's word on its actors' units */
|
||||
void network_actors_handle_states(void const *entries, short count);
|
||||
word network_actors_entry_size(void);
|
||||
/* (a client, in its tick where the host runs its actors) each actor's unit
|
||||
given the control the host last sent for it */
|
||||
void network_actors_drive(void);
|
||||
|
||||
/* ---------- prototypes/NETWORK_COOP.C */
|
||||
|
||||
void network_coop_new_game(void);
|
||||
/* after each tick, on the host and on a client */
|
||||
void network_coop_host_tick(void);
|
||||
void network_coop_client_tick(void);
|
||||
/* the message handlers, and their entry sizes */
|
||||
word network_coop_presentation_entry_size(void);
|
||||
void network_coop_handle_presentation(void const *entries, long host_time);
|
||||
word network_coop_event_entry_size(void);
|
||||
void network_coop_handle_events(void const *entries, short count);
|
||||
word network_coop_device_group_entry_size(void);
|
||||
void network_coop_handle_device_groups(void const *entries, short count);
|
||||
word network_coop_object_names_entry_size(void);
|
||||
void network_coop_handle_object_names(void const *entries);
|
||||
word network_coop_object_transform_entry_size(void);
|
||||
word network_coop_object_look_entry_size(void);
|
||||
void network_coop_handle_object_looks(void const *entries, short count);
|
||||
word network_coop_screen_effect_entry_size(void);
|
||||
word network_coop_device_state_entry_size(void);
|
||||
void network_coop_handle_device_states(void const *entries, short count);
|
||||
void network_coop_handle_screen_effect(void const *entries, short count);
|
||||
word network_actors_damage_entry_size(void);
|
||||
void network_actors_handle_damage(void const *entries, short count);
|
||||
void network_coop_handle_object_transforms(void const *entries, short count);
|
||||
word network_coop_skip_vote_entry_size(void);
|
||||
void network_coop_handle_skip_vote(long machine_index, void const *entries);
|
||||
/* game_sound.c: a sound the host's scripts played */
|
||||
enum
|
||||
{
|
||||
_coop_sound_impulse,
|
||||
_coop_sound_looping_start,
|
||||
_coop_sound_looping_stop,
|
||||
};
|
||||
void network_coop_note_sound(short kind, long definition_index, long object_index, real scale);
|
||||
|
||||
/* ---------- prototypes/NETWORK_OBJECTS.C */
|
||||
|
||||
void network_objects_new_game(void);
|
||||
/* after each tick */
|
||||
void network_objects_host_tick(void);
|
||||
word network_objects_damage_animation_entry_size(void);
|
||||
void network_objects_handle_damage_animations(void const *entries, short count);
|
||||
void network_objects_client_tick(void);
|
||||
/* (the host) a client has loaded the game and asks for the host's objects:
|
||||
again, having failed to make one of them */
|
||||
@@ -214,6 +321,8 @@ void network_objects_handle_changes(void const *entries, short count);
|
||||
void network_objects_handle_synchronized(void);
|
||||
void network_objects_handle_states(void const *entries, short count);
|
||||
void network_objects_handle_inventories(void const *entries, short count);
|
||||
/* (a client) its own player picked up the weapon, to ready once its unit has it */
|
||||
void network_objects_client_picked_up_weapon(short local_player_index, long unit_index, long definition_index);
|
||||
void network_objects_handle_vehicle_prediction(long machine_index, void const *entries, short count);
|
||||
/* (the host) the vehicle predictions come in since the last tick, taken */
|
||||
void network_objects_apply_vehicle_predictions(void);
|
||||
@@ -230,10 +339,16 @@ boolean network_objects_reconcile(long object_index, real_point3d const *positio
|
||||
real blend_distance);
|
||||
/* a unit in the vehicle's seat as the host has it (NONE: in none) */
|
||||
void network_objects_set_seat(long unit_index, long vehicle_index, short seat_index);
|
||||
/* (the host) the ticks between sends to a machine of a unit at position, by
|
||||
how near that machine's players are (network_actors.c) */
|
||||
short network_objects_send_period(long machine_index, real_point3d const *position);
|
||||
|
||||
/* ---------- prototypes/NETWORK_DAMAGE.C */
|
||||
|
||||
void network_damage_new_game(void);
|
||||
/* the host: a grenade a player's unit threw (units.c), whose damage that
|
||||
player's machine reports */
|
||||
void network_damage_note_grenade(long unit_index, short grenade_type);
|
||||
void network_damage_host_tick(void);
|
||||
void network_damage_client_tick(void);
|
||||
void network_damage_handle_events(void const *entries, short count);
|
||||
|
||||
@@ -50,6 +50,7 @@ same datum index (identifier and all), so that any message can name one:
|
||||
#include "objects/objects.h"
|
||||
#include "objects/damage.h"
|
||||
#include "objects/object_definitions.h"
|
||||
#include "models/model_animation_definitions.h"
|
||||
#include "models/model_definitions.h"
|
||||
#include "units/units.h"
|
||||
#include "units/biped_definitions.h"
|
||||
@@ -59,6 +60,9 @@ same datum index (identifier and all), so that any message can name one:
|
||||
#include "items/weapons.h"
|
||||
#include "items/weapon_definitions.h"
|
||||
#include "items/equipment_definitions.h"
|
||||
#include "camera/observer.h"
|
||||
#include "cutscene/cinematics.h"
|
||||
#include "network_coop.h"
|
||||
#include "network_distributed.h"
|
||||
|
||||
#include <math.h>
|
||||
@@ -175,6 +179,9 @@ enum
|
||||
/* ... the round trip without one measured, and the most */
|
||||
DEFAULT_OWN_ROUND_TRIP_TICKS = 6,
|
||||
MAXIMUM_OWN_ROUND_TRIP_TICKS = 60,
|
||||
/* ... how long the weapon the host says it picked up may take to reach
|
||||
its unit, to be readied (the host's messages are not in step) */
|
||||
PICKED_UP_WEAPON_TICKS = 3 * TICKS_PER_SECOND,
|
||||
/* the most grenades of a kind a unit carries, as the host says (a dead
|
||||
unit drops each) */
|
||||
MAXIMUM_INVENTORY_GRENADES = 16,
|
||||
@@ -238,7 +245,11 @@ struct distributed_object_change
|
||||
byte change;
|
||||
byte flags;
|
||||
byte owner_player_index;
|
||||
byte pad;
|
||||
/* which bitmap of its shaders it draws with, when not its tag's (0). An
|
||||
AI unit's actor variant sets it after the unit is made
|
||||
(actor_customize_unit): the Elite major's and commander's armor are 1
|
||||
and 2. Builds before it sent 0 here. */
|
||||
byte forced_shader_permutation_index;
|
||||
long object_index;
|
||||
long definition_index;
|
||||
short owner_team_index;
|
||||
@@ -326,11 +337,14 @@ static struct
|
||||
} objects_host_inventories[MAXIMUM_TRACKED_OBJECTS];
|
||||
/* ... each client machine, found once a tick: where its players' living
|
||||
units are, those units, and the vehicles they drive (with the player's
|
||||
absolute index) */
|
||||
absolute index); and where every player's living unit is, for a machine
|
||||
with none (dead or joining, it watches one of them) */
|
||||
static struct
|
||||
{
|
||||
short count;
|
||||
long indices[HALO_PORT_MAXIMUM_NETWORK_MACHINES];
|
||||
short player_unit_count;
|
||||
real_point3d player_unit_origins[MAXIMUM_TRACKED_PLAYERS];
|
||||
struct
|
||||
{
|
||||
short unit_count;
|
||||
@@ -422,6 +436,14 @@ static struct distributed_own_inventory
|
||||
long fired_times[MAXIMUM_WEAPONS_PER_UNIT];
|
||||
long weapon_times[MAXIMUM_WEAPONS_PER_UNIT];
|
||||
} objects_client_own_inventories[MAXIMUM_LOCAL_PLAYERS];
|
||||
/* ... the weapon each of them last picked up (the host said so), its unit
|
||||
and when, until it is readied (definition NONE: none) */
|
||||
static struct distributed_picked_up_weapon
|
||||
{
|
||||
long unit_index;
|
||||
long definition_index;
|
||||
long time;
|
||||
} objects_client_picked_up_weapons[MAXIMUM_LOCAL_PLAYERS];
|
||||
/* ... whether it failed to make one of the host's objects since it last
|
||||
asked for them (it says so when it asks again) */
|
||||
static boolean objects_client_ask_again;
|
||||
@@ -626,6 +648,32 @@ static void distributed_vector_clamp(
|
||||
}
|
||||
}
|
||||
|
||||
/* Whether the object is a vehicle no player drives in co-op (a Pelican on
|
||||
its flight path): nothing on a client steers it, so its copy is kept at rest
|
||||
there (no physics of its own) and moved only to where the host has it. In
|
||||
multiplayer an empty vehicle (one bailed out of, or tumbling) keeps its own
|
||||
physics between updates. */
|
||||
static boolean distributed_vehicle_unsteered(
|
||||
long object_index)
|
||||
{
|
||||
struct unit_datum *vehicle;
|
||||
|
||||
if (!network_coop_active() || object_get(object_index)->object.type != _object_type_vehicle)
|
||||
return FALSE;
|
||||
vehicle = unit_get(object_index);
|
||||
return vehicle->unit.driver_object_index == NONE ||
|
||||
unit_get(vehicle->unit.driver_object_index)->unit.player_index == NONE;
|
||||
}
|
||||
|
||||
/* Whether a client puts its copy exactly where the host has it, rather than
|
||||
closing on it: an unsteered vehicle, and anything in a co-op cutscene
|
||||
(where it keeps up with the host's camera). */
|
||||
static boolean distributed_object_follows_host(
|
||||
long object_index)
|
||||
{
|
||||
return (network_coop_active() && cinematic_in_progress()) || distributed_vehicle_unsteered(object_index);
|
||||
}
|
||||
|
||||
/* (the transform checked) */
|
||||
static void distributed_object_move(
|
||||
long object_index,
|
||||
@@ -647,7 +695,10 @@ static void distributed_object_move(
|
||||
object->object.translational_velocity = *velocity;
|
||||
if (angular_velocity)
|
||||
object->object.angular_velocity = *angular_velocity;
|
||||
render_interpolation_correct_object(object_index, &offset);
|
||||
if (!distributed_object_follows_host(object_index))
|
||||
render_interpolation_correct_object(object_index, &offset);
|
||||
if (distributed_vehicle_unsteered(object_index))
|
||||
SET_FLAG(object->object.flags, _object_at_rest_bit, TRUE);
|
||||
}
|
||||
|
||||
void network_objects_correct(
|
||||
@@ -692,15 +743,33 @@ boolean network_objects_reconcile(
|
||||
distributed_object_move(object_index, position, &valid_forward, &valid_up, velocity, angular_velocity);
|
||||
return TRUE;
|
||||
}
|
||||
/* (half of the way: the tick's snapshots draw it moving, no jump) */
|
||||
blended.x = object->object.position.x + dx * 0.5f;
|
||||
blended.y = object->object.position.y + dy * 0.5f;
|
||||
blended.z = object->object.position.z + dz * 0.5f;
|
||||
object_set_position(object_index, &blended, &valid_forward, &valid_up);
|
||||
/* Move halfway, and draw the move as a glide over the next few frames,
|
||||
as larger corrections are. Drawn as one step, a unit corrected every tick
|
||||
or two (a distant enemy) visibly hitched each time. */
|
||||
if (distributed_object_follows_host(object_index))
|
||||
blended = *position;
|
||||
else
|
||||
{
|
||||
blended.x = object->object.position.x + dx * 0.5f;
|
||||
blended.y = object->object.position.y + dy * 0.5f;
|
||||
blended.z = object->object.position.z + dz * 0.5f;
|
||||
}
|
||||
{
|
||||
real_vector3d offset;
|
||||
|
||||
offset.i = object->object.position.x - blended.x;
|
||||
offset.j = object->object.position.y - blended.y;
|
||||
offset.k = object->object.position.z - blended.z;
|
||||
object_set_position(object_index, &blended, &valid_forward, &valid_up);
|
||||
if (!distributed_object_follows_host(object_index))
|
||||
render_interpolation_correct_object(object_index, &offset);
|
||||
}
|
||||
if (velocity)
|
||||
object->object.translational_velocity = *velocity;
|
||||
if (angular_velocity)
|
||||
object->object.angular_velocity = *angular_velocity;
|
||||
if (distributed_vehicle_unsteered(object_index))
|
||||
SET_FLAG(object->object.flags, _object_at_rest_bit, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -755,6 +824,175 @@ static long distributed_driven_vehicle(
|
||||
object_get(unit_index)->object.parent_object_index : NONE;
|
||||
}
|
||||
|
||||
/* ---------- damage animations
|
||||
|
||||
A unit's flinches and deaths are animations picked by where the damage came
|
||||
from and at random among their permutations, so a client replaying the
|
||||
host's damage could pick others. The host sends its picks (each in three
|
||||
ticks' messages, in case one is lost). A client plays the host's pick when
|
||||
it gets there first, or switches to it if its own has only just begun
|
||||
(unit_port_correct_damage_animation). */
|
||||
|
||||
enum
|
||||
{
|
||||
DAMAGE_ANIMATION_SENDS = 3,
|
||||
MAXIMUM_QUEUED_DAMAGE_ANIMATIONS = 32,
|
||||
/* how long a client keeps the host's pick for a hit it hasn't replayed yet */
|
||||
DAMAGE_ANIMATION_KEPT_TICKS = 2 * TICKS_PER_SECOND,
|
||||
};
|
||||
|
||||
/* type: units.h's _unit_damage_animation_soft_ping and the rest; number:
|
||||
the pick's, so a client tells a pick sent again from a new one */
|
||||
struct distributed_damage_animation
|
||||
{
|
||||
long unit_index;
|
||||
short animation_index;
|
||||
byte type;
|
||||
byte number;
|
||||
};
|
||||
|
||||
struct distributed_damage_animations_message
|
||||
{
|
||||
struct distributed_message_header header;
|
||||
struct distributed_damage_animation animations[MAXIMUM_QUEUED_DAMAGE_ANIMATIONS];
|
||||
};
|
||||
|
||||
/* host: the picks still to be sent */
|
||||
static struct
|
||||
{
|
||||
struct distributed_damage_animation animation;
|
||||
short sends;
|
||||
} host_damage_animations[MAXIMUM_QUEUED_DAMAGE_ANIMATIONS];
|
||||
static short host_damage_animation_count;
|
||||
static byte host_damage_animation_number;
|
||||
|
||||
/* client: the host's latest pick of each type for each unit, by absolute
|
||||
index: its number, and when it came (NONE once played) */
|
||||
static struct
|
||||
{
|
||||
long unit_index;
|
||||
short animation_index[NUMBER_OF_UNIT_DAMAGE_ANIMATIONS];
|
||||
byte number[NUMBER_OF_UNIT_DAMAGE_ANIMATIONS];
|
||||
long time[NUMBER_OF_UNIT_DAMAGE_ANIMATIONS];
|
||||
} client_damage_animations[MAXIMUM_TRACKED_OBJECTS];
|
||||
|
||||
/* whether the animation is one of the unit's graph */
|
||||
static boolean distributed_unit_has_animation(
|
||||
long unit_index,
|
||||
short animation_index)
|
||||
{
|
||||
long graph_index = unit_definition_get(unit_get(unit_index)->definition_index)->object.animation_graph.index;
|
||||
|
||||
return graph_index != NONE && animation_index >= 0 &&
|
||||
animation_index < animation_graph_definition_get(graph_index)->animations.count;
|
||||
}
|
||||
|
||||
/* units.c, as a unit flinches or dies: the host notes the animation it
|
||||
picked; a client takes the host's pick when it has one */
|
||||
short network_objects_damage_animation(
|
||||
long unit_index,
|
||||
short type,
|
||||
short animation_index)
|
||||
{
|
||||
short connection = game_connection();
|
||||
long absolute_index = DATUM_INDEX_TO_ABSOLUTE_INDEX(unit_index);
|
||||
|
||||
if (type < 0 || type >= NUMBER_OF_UNIT_DAMAGE_ANIMATIONS)
|
||||
return animation_index;
|
||||
if (connection == _game_connection_network_server && animation_index != NONE &&
|
||||
host_damage_animation_count < MAXIMUM_QUEUED_DAMAGE_ANIMATIONS)
|
||||
{
|
||||
struct distributed_damage_animation *animation =
|
||||
&host_damage_animations[host_damage_animation_count].animation;
|
||||
|
||||
animation->unit_index = unit_index;
|
||||
animation->animation_index = animation_index;
|
||||
animation->type = (byte)type;
|
||||
animation->number = ++host_damage_animation_number;
|
||||
host_damage_animations[host_damage_animation_count++].sends = DAMAGE_ANIMATION_SENDS;
|
||||
}
|
||||
else if (connection == _game_connection_network_client && absolute_index >= 0 &&
|
||||
absolute_index < MAXIMUM_TRACKED_OBJECTS && client_damage_animations[absolute_index].unit_index == unit_index)
|
||||
{
|
||||
long *time = &client_damage_animations[absolute_index].time[type];
|
||||
|
||||
if (*time != NONE && game_time_get() - *time < DAMAGE_ANIMATION_KEPT_TICKS)
|
||||
{
|
||||
*time = NONE;
|
||||
return client_damage_animations[absolute_index].animation_index[type];
|
||||
}
|
||||
}
|
||||
return animation_index;
|
||||
}
|
||||
|
||||
/* host, each tick: the picks still to be sent, to every client */
|
||||
static void distributed_host_send_damage_animations(
|
||||
void)
|
||||
{
|
||||
struct distributed_damage_animations_message message;
|
||||
short count = 0;
|
||||
short index;
|
||||
|
||||
for (index = 0; index < host_damage_animation_count; index++)
|
||||
{
|
||||
message.animations[count++] = host_damage_animations[index].animation;
|
||||
if (--host_damage_animations[index].sends <= 0)
|
||||
host_damage_animations[index--] = host_damage_animations[--host_damage_animation_count];
|
||||
}
|
||||
if (count > 0)
|
||||
{
|
||||
distributed_send(&message, _distributed_message_damage_animations, count,
|
||||
(word)(sizeof(message.header) + count * sizeof(message.animations[0])), _distributed_to_clients);
|
||||
}
|
||||
}
|
||||
|
||||
word network_objects_damage_animation_entry_size(
|
||||
void)
|
||||
{
|
||||
return sizeof(struct distributed_damage_animation);
|
||||
}
|
||||
|
||||
void network_objects_handle_damage_animations(
|
||||
void const *entries,
|
||||
short count)
|
||||
{
|
||||
struct distributed_damage_animation const *animations = entries;
|
||||
short index;
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
struct distributed_damage_animation const *animation = &animations[index];
|
||||
long absolute_index = DATUM_INDEX_TO_ABSOLUTE_INDEX(animation->unit_index);
|
||||
short type;
|
||||
|
||||
if (!distributed_object_index_valid(animation->unit_index) || absolute_index >= MAXIMUM_TRACKED_OBJECTS ||
|
||||
animation->type >= NUMBER_OF_UNIT_DAMAGE_ANIMATIONS || !network_objects_client_has(animation->unit_index) ||
|
||||
!object_try_and_get_and_verify_type(animation->unit_index, _object_mask_unit) ||
|
||||
!distributed_unit_has_animation(animation->unit_index, animation->animation_index))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (client_damage_animations[absolute_index].unit_index != animation->unit_index)
|
||||
{
|
||||
csmemset(&client_damage_animations[absolute_index], 0, sizeof(client_damage_animations[absolute_index]));
|
||||
client_damage_animations[absolute_index].unit_index = animation->unit_index;
|
||||
for (type = 0; type < NUMBER_OF_UNIT_DAMAGE_ANIMATIONS; type++)
|
||||
client_damage_animations[absolute_index].time[type] = NONE;
|
||||
}
|
||||
/* (a pick sent again) */
|
||||
else if (client_damage_animations[absolute_index].number[animation->type] == animation->number)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
client_damage_animations[absolute_index].number[animation->type] = animation->number;
|
||||
client_damage_animations[absolute_index].animation_index[animation->type] = animation->animation_index;
|
||||
/* (replayed here already: switched to the host's if it has only just begun) */
|
||||
client_damage_animations[absolute_index].time[animation->type] =
|
||||
unit_port_correct_damage_animation(animation->unit_index, animation->type, animation->animation_index) ?
|
||||
NONE : game_time_get();
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- the host */
|
||||
|
||||
static void distributed_change_from_object(
|
||||
@@ -770,6 +1008,7 @@ static void distributed_change_from_object(
|
||||
change->owner_player_index = distributed_player_to_byte(object->object.owner_player_index);
|
||||
change->owner_team_index = object->object.owner_team_index;
|
||||
change->variant_number = object->object.variant_number;
|
||||
change->forced_shader_permutation_index = (byte)PIN(object->object.forced_shader_permutation_index, 0, 0xFF);
|
||||
change->position = object->object.position;
|
||||
change->forward = object->object.forward;
|
||||
change->up = object->object.up;
|
||||
@@ -866,6 +1105,30 @@ static void distributed_host_update_objects(
|
||||
}
|
||||
}
|
||||
|
||||
/* The order a newly loaded client receives the host's objects in, most
|
||||
needed first: players' units (it may spectate them), the vehicles players
|
||||
and AI ride, other units, then everything else. */
|
||||
enum
|
||||
{
|
||||
_send_rank_player_unit,
|
||||
_send_rank_vehicle,
|
||||
_send_rank_unit,
|
||||
_send_rank_other,
|
||||
NUMBER_OF_SEND_RANKS
|
||||
};
|
||||
|
||||
static short distributed_object_send_rank(
|
||||
long object_index)
|
||||
{
|
||||
struct object_datum *object = object_get(object_index);
|
||||
|
||||
if (object->object.type == _object_type_vehicle)
|
||||
return _send_rank_vehicle;
|
||||
if (object_try_and_get_and_verify_type(object_index, _object_mask_unit))
|
||||
return unit_get(object_index)->unit.player_index != NONE ? _send_rank_player_unit : _send_rank_unit;
|
||||
return _send_rank_other;
|
||||
}
|
||||
|
||||
/* a client has loaded the game: every object the host has, to it alone,
|
||||
and word that that is all of them; asked again, only the word (they are on
|
||||
their way ahead of it), unless it failed to make one since it last asked
|
||||
@@ -878,6 +1141,7 @@ void network_objects_client_asked(
|
||||
short count = 0;
|
||||
short limit = MIN(MAXIMUM_ENTRIES_PER_MESSAGE, RELIABLE_ENTRIES(struct distributed_object_change));
|
||||
long absolute_index;
|
||||
short rank;
|
||||
long *player_list;
|
||||
|
||||
if (machine_index < 0 || machine_index >= HALO_PORT_MAXIMUM_NETWORK_MACHINES)
|
||||
@@ -905,14 +1169,22 @@ void network_objects_client_asked(
|
||||
/* (what every unit carries, with the next of them) */
|
||||
objects_host_inventories[absolute_index].checksum = 0;
|
||||
objects_host_inventories[absolute_index].weapons_checksum = 0;
|
||||
if (objects_host_told[absolute_index] == NONE)
|
||||
continue;
|
||||
distributed_change_from_object(objects_host_told[absolute_index], &message.changes[count]);
|
||||
if (++count == limit)
|
||||
}
|
||||
for (rank = 0; rank < NUMBER_OF_SEND_RANKS; rank++)
|
||||
{
|
||||
for (absolute_index = 0; absolute_index < objects_host_told_count; absolute_index++)
|
||||
{
|
||||
distributed_send_to_machine_reliably(machine_index, &message, _distributed_message_object_changes, count,
|
||||
(word)(sizeof(message.header) + count * sizeof(struct distributed_object_change)));
|
||||
count = 0;
|
||||
long object_index = objects_host_told[absolute_index];
|
||||
|
||||
if (object_index == NONE || distributed_object_send_rank(object_index) != rank)
|
||||
continue;
|
||||
distributed_change_from_object(object_index, &message.changes[count]);
|
||||
if (++count == limit)
|
||||
{
|
||||
distributed_send_to_machine_reliably(machine_index, &message, _distributed_message_object_changes, count,
|
||||
(word)(sizeof(message.header) + count * sizeof(struct distributed_object_change)));
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count)
|
||||
@@ -957,8 +1229,24 @@ static void distributed_host_find_viewers(
|
||||
{
|
||||
short machine_number;
|
||||
|
||||
struct data_iterator iterator;
|
||||
struct player_datum *player;
|
||||
|
||||
objects_host_viewers.count = distributed_client_machines(objects_host_viewers.indices,
|
||||
HALO_PORT_MAXIMUM_NETWORK_MACHINES);
|
||||
objects_host_viewers.player_unit_count = 0;
|
||||
data_iterator_new(&iterator, player_data);
|
||||
while ((player = data_iterator_next(&iterator)) != NULL &&
|
||||
objects_host_viewers.player_unit_count < MAXIMUM_TRACKED_PLAYERS)
|
||||
{
|
||||
long unit_index = distributed_living_unit(player);
|
||||
|
||||
if (unit_index != NONE)
|
||||
{
|
||||
object_get_origin(unit_index,
|
||||
&objects_host_viewers.player_unit_origins[objects_host_viewers.player_unit_count++]);
|
||||
}
|
||||
}
|
||||
for (machine_number = 0; machine_number < objects_host_viewers.count; machine_number++)
|
||||
{
|
||||
long *player_list = machine_get_player_list(objects_host_viewers.indices[machine_number]);
|
||||
@@ -990,19 +1278,44 @@ static void distributed_host_find_viewers(
|
||||
}
|
||||
}
|
||||
|
||||
/* how often (ticks) the host sends that client machine an object where it
|
||||
is, moving: by its nearest player; every tick to one with none in the
|
||||
world (dead, it watches anyone) */
|
||||
/* How often, in ticks, the host sends a moving object's position to a
|
||||
client machine, based on its distance from that machine's nearest player.
|
||||
A machine with no player in the world (dead or joining) spectates someone,
|
||||
so the distance is measured from every player instead. Sending such a
|
||||
machine every moving object every tick flooded it on campaign levels and
|
||||
threw everything it saw out of sync. */
|
||||
static short distributed_host_object_period(
|
||||
short machine_number,
|
||||
real_point3d const *position)
|
||||
{
|
||||
short count = objects_host_viewers.machines[machine_number].unit_count;
|
||||
real_point3d const *origins = objects_host_viewers.machines[machine_number].origins;
|
||||
real nearest = -1.0f;
|
||||
short index;
|
||||
|
||||
for (index = 0; index < objects_host_viewers.machines[machine_number].unit_count; index++)
|
||||
if (!count)
|
||||
{
|
||||
real_point3d const *origin = &objects_host_viewers.machines[machine_number].origins[index];
|
||||
count = objects_host_viewers.player_unit_count;
|
||||
origins = objects_host_viewers.player_unit_origins;
|
||||
}
|
||||
/* in a co-op cutscene every client looks through the host's camera, so
|
||||
what it films is sent as often as what's next to the client's players
|
||||
(b30's sword Elite walking out of the door) */
|
||||
if (network_coop_active() && cinematic_in_progress())
|
||||
{
|
||||
real_point3d const *camera = &observer_get_camera(0)->position;
|
||||
real dx = position->x - camera->x;
|
||||
real dy = position->y - camera->y;
|
||||
real dz = position->z - camera->z;
|
||||
|
||||
nearest = dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
/* nobody is alive anywhere, so nothing needs to be sent often */
|
||||
if (!count && nearest < 0.0f)
|
||||
return MAXIMUM_OBJECT_PERIOD_TICKS;
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
real_point3d const *origin = &origins[index];
|
||||
real dx = position->x - origin->x;
|
||||
real dy = position->y - origin->y;
|
||||
real dz = position->z - origin->z;
|
||||
@@ -1016,6 +1329,21 @@ static short distributed_host_object_period(
|
||||
nearest < FAR_OBJECT_DISTANCE * FAR_OBJECT_DISTANCE ? 3 : MAXIMUM_OBJECT_PERIOD_TICKS;
|
||||
}
|
||||
|
||||
/* ... for other units sent by a machine's index (network_actors.c) */
|
||||
short network_objects_send_period(
|
||||
long machine_index,
|
||||
real_point3d const *position)
|
||||
{
|
||||
short machine_number;
|
||||
|
||||
for (machine_number = 0; machine_number < objects_host_viewers.count; machine_number++)
|
||||
{
|
||||
if (objects_host_viewers.indices[machine_number] == machine_index)
|
||||
return distributed_host_object_period(machine_number, position);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* the kinds of states sent this tick */
|
||||
enum
|
||||
{
|
||||
@@ -1485,6 +1813,10 @@ void network_objects_apply_vehicle_predictions(
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* (not from a co-op client still loading the host's BSP: the
|
||||
vehicle falls there with no ground under it) */
|
||||
if (!network_coop_player_has_structure_bsp(driver->unit.player_index))
|
||||
continue;
|
||||
dx = state->position.x - vehicle->object.position.x;
|
||||
dy = state->position.y - vehicle->object.position.y;
|
||||
dz = state->position.z - vehicle->object.position.z;
|
||||
@@ -1633,6 +1965,7 @@ void network_objects_host_tick(
|
||||
distributed_host_send_states();
|
||||
if (game_time_get() % INVENTORY_INTERVAL_TICKS == 0)
|
||||
distributed_host_send_inventories();
|
||||
distributed_host_send_damage_animations();
|
||||
}
|
||||
|
||||
/* ---------- a client */
|
||||
@@ -1827,6 +2160,21 @@ static void distributed_client_apply_change(
|
||||
struct object_datum *object = object_get(object_index);
|
||||
|
||||
csmemcpy(object->object.base_change_colors, change->change_colors, sizeof(object->object.base_change_colors));
|
||||
if (change->forced_shader_permutation_index)
|
||||
object->object.forced_shader_permutation_index = change->forced_shader_permutation_index;
|
||||
/* (and the colors drawn, which object_new chose from the tag: an AI unit's
|
||||
are its variant's, set after it was made, actors.c) */
|
||||
{
|
||||
short color_index;
|
||||
|
||||
for (color_index = 0; color_index < NUMBER_OF_OBJECT_CHANGE_COLORS; color_index++)
|
||||
{
|
||||
object->object.outgoing_change_colors[color_index].red = PIN(change->change_colors[color_index].red, 0.0f, 1.0f);
|
||||
object->object.outgoing_change_colors[color_index].green =
|
||||
PIN(change->change_colors[color_index].green, 0.0f, 1.0f);
|
||||
object->object.outgoing_change_colors[color_index].blue = PIN(change->change_colors[color_index].blue, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
/* (a permutation the model has, or none: the model's renderer takes it
|
||||
as it is) */
|
||||
{
|
||||
@@ -2081,6 +2429,20 @@ static void distributed_client_dead_biped(
|
||||
}
|
||||
}
|
||||
|
||||
/* client: a vehicle the host says is dead is destroyed here too, with its
|
||||
explosion. No killing blow comes for vehicles, only for bipeds. */
|
||||
static void distributed_client_dead_vehicle(
|
||||
long object_index)
|
||||
{
|
||||
struct unit_datum *vehicle = (struct unit_datum *)object_try_and_get_and_verify_type(object_index,
|
||||
_object_mask_vehicle);
|
||||
|
||||
if (!vehicle || TEST_FLAG(vehicle->object.damage_flags, _object_dead_bit))
|
||||
return;
|
||||
unit_kill_no_statistics(object_index);
|
||||
object_damage_update(object_index);
|
||||
}
|
||||
|
||||
void network_objects_handle_states(
|
||||
void const *entries,
|
||||
short count)
|
||||
@@ -2104,6 +2466,7 @@ void network_objects_handle_states(
|
||||
if (TEST_FLAG(state->flags, _distributed_object_dead_bit))
|
||||
{
|
||||
distributed_client_dead_biped(state->object_index);
|
||||
distributed_client_dead_vehicle(state->object_index);
|
||||
/* (a body its tag destroys at once is gone) */
|
||||
if (!object_try_and_get_and_verify_type(state->object_index, _object_mask_all))
|
||||
continue;
|
||||
@@ -2136,6 +2499,12 @@ void network_objects_handle_states(
|
||||
|
||||
if (blend_distance > 0.0f)
|
||||
blend_distance = REMOTE_VEHICLE_BLEND_DISTANCE;
|
||||
/* (one no player drives follows every move the host sends, however small) */
|
||||
if (distributed_vehicle_unsteered(state->object_index))
|
||||
{
|
||||
tolerance = 0.0f;
|
||||
angle_tolerance = 2.0f;
|
||||
}
|
||||
if (vehicle->unit.driver_object_index != NONE &&
|
||||
distributed_player_is_local(unit_get(vehicle->unit.driver_object_index)->unit.player_index))
|
||||
{
|
||||
@@ -2166,7 +2535,8 @@ void network_objects_handle_states(
|
||||
{
|
||||
distributed_count_correction();
|
||||
}
|
||||
SET_FLAG(object->object.flags, _object_at_rest_bit, TEST_FLAG(state->flags, _distributed_object_at_rest_bit));
|
||||
SET_FLAG(object->object.flags, _object_at_rest_bit, TEST_FLAG(state->flags, _distributed_object_at_rest_bit) ||
|
||||
distributed_vehicle_unsteered(state->object_index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2377,6 +2747,68 @@ static void distributed_client_apply_inventory(
|
||||
distributed_client_note_own_inventory(own, inventory->unit_index, FALSE);
|
||||
}
|
||||
|
||||
/* a client's own player picked up a weapon (network_player_show_pickup) */
|
||||
void network_objects_client_picked_up_weapon(
|
||||
short local_player_index,
|
||||
long unit_index,
|
||||
long definition_index)
|
||||
{
|
||||
struct distributed_picked_up_weapon *picked_up;
|
||||
|
||||
if (local_player_index < 0 || local_player_index >= MAXIMUM_LOCAL_PLAYERS)
|
||||
return;
|
||||
picked_up = &objects_client_picked_up_weapons[local_player_index];
|
||||
picked_up->unit_index = unit_index;
|
||||
picked_up->definition_index = definition_index;
|
||||
picked_up->time = game_time_get();
|
||||
}
|
||||
|
||||
/* the weapons its own players picked up readied once they have them, as
|
||||
unit_add_weapon_to_inventory readies a pickup where it decides it (not
|
||||
while firing): the client chooses its players' weapons in hand
|
||||
(distributed_client_apply_inventory), and the host follows */
|
||||
static void distributed_client_ready_picked_up_weapons(
|
||||
void)
|
||||
{
|
||||
short local_player_index;
|
||||
|
||||
for (local_player_index = 0; local_player_index < MAXIMUM_LOCAL_PLAYERS; local_player_index++)
|
||||
{
|
||||
struct distributed_picked_up_weapon *picked_up = &objects_client_picked_up_weapons[local_player_index];
|
||||
long player_index = local_player_get_player_index(local_player_index);
|
||||
struct player_datum *player = player_index != NONE ? player_try_and_get(player_index) : NULL;
|
||||
long unit_index = distributed_living_unit(player);
|
||||
struct unit_datum *unit;
|
||||
short weapon_slot;
|
||||
|
||||
if (picked_up->definition_index == NONE)
|
||||
continue;
|
||||
if (unit_index == NONE || unit_index != picked_up->unit_index ||
|
||||
game_time_get() - picked_up->time > PICKED_UP_WEAPON_TICKS)
|
||||
{
|
||||
picked_up->definition_index = NONE;
|
||||
continue;
|
||||
}
|
||||
unit = unit_get(unit_index);
|
||||
for (weapon_slot = 0; weapon_slot < MAXIMUM_WEAPONS_PER_UNIT; weapon_slot++)
|
||||
{
|
||||
long weapon_index = unit->unit.weapon_object_indices[weapon_slot];
|
||||
struct weapon_datum *weapon = weapon_index != NONE ? weapon_try_and_get(weapon_index) : NULL;
|
||||
|
||||
if (weapon && weapon->definition_index == picked_up->definition_index)
|
||||
break;
|
||||
}
|
||||
if (weapon_slot == MAXIMUM_WEAPONS_PER_UNIT)
|
||||
continue;
|
||||
if (!TEST_FLAG(unit->unit.control_flags, _unit_control_weapon_primary_trigger_bit))
|
||||
{
|
||||
player_control_set_desired_weapon(unit_index, weapon_slot);
|
||||
unit->unit.desired_weapon_index = weapon_slot;
|
||||
}
|
||||
picked_up->definition_index = NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void network_objects_handle_inventories(
|
||||
void const *entries,
|
||||
short count)
|
||||
@@ -2525,6 +2957,51 @@ static void distributed_client_remove_own_objects(
|
||||
objects_client_new_object_count = 0;
|
||||
}
|
||||
|
||||
/* Client: keeps each AI-driven vehicle (such as a Pelican on its flight
|
||||
path) moving at the velocity the host last sent. These vehicles are held at
|
||||
rest here, and a distant one is only updated every few ticks, so otherwise
|
||||
it would stop between updates and jump on each one. */
|
||||
static void distributed_client_carry_unsteered_vehicles(
|
||||
void)
|
||||
{
|
||||
struct object_iterator iterator;
|
||||
struct object_datum *object;
|
||||
|
||||
object_iterator_new(&iterator, _object_mask_vehicle, 0);
|
||||
while ((object = object_iterator_next(&iterator)) != NULL)
|
||||
{
|
||||
real_vector3d const *velocity = &object->object.translational_velocity;
|
||||
real_vector3d axis = object->object.angular_velocity;
|
||||
real_vector3d forward = object->object.forward;
|
||||
real_vector3d up = object->object.up;
|
||||
real_point3d position;
|
||||
real angle;
|
||||
|
||||
if (object->object.parent_object_index != NONE || unit_get(iterator.index)->unit.driver_object_index == NONE ||
|
||||
!distributed_vehicle_unsteered(iterator.index))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
angle = normalize3d(&axis);
|
||||
if (velocity->i == 0.0f && velocity->j == 0.0f && velocity->k == 0.0f && angle == 0.0f)
|
||||
continue;
|
||||
position.x = object->object.position.x + velocity->i;
|
||||
position.y = object->object.position.y + velocity->j;
|
||||
position.z = object->object.position.z + velocity->k;
|
||||
/* rotate the same way physics.c applies angular velocity */
|
||||
if (angle != 0.0f)
|
||||
{
|
||||
real_matrix4x3 rotation;
|
||||
|
||||
matrix4x3_rotation_from_axis_and_angle(&rotation, &axis, (real)sin(angle), (real)cos(angle));
|
||||
matrix4x3_transform_vector(&rotation, &object->object.forward, &forward);
|
||||
matrix4x3_transform_vector(&rotation, &object->object.up, &up);
|
||||
}
|
||||
if (distributed_transform_valid(&position, &forward, &up, NULL, NULL, &forward, &up))
|
||||
object_set_position(iterator.index, &position, &forward, &up);
|
||||
}
|
||||
}
|
||||
|
||||
void network_objects_client_tick(
|
||||
void)
|
||||
{
|
||||
@@ -2549,8 +3026,10 @@ void network_objects_client_tick(
|
||||
/* (too many to look at one by one later: all of them) */
|
||||
else if (objects_client_new_object_count >= MAXIMUM_CLIENT_NEW_OBJECTS)
|
||||
objects_client_check_all = TRUE;
|
||||
distributed_client_ready_picked_up_weapons();
|
||||
distributed_client_note_own_inventories();
|
||||
distributed_client_send_vehicles();
|
||||
distributed_client_carry_unsteered_vehicles();
|
||||
/* (who it is, as its Discord told it: once its ready went, which makes
|
||||
it a machine the host takes messages of) */
|
||||
if (objects_client_ready_time != NONE)
|
||||
@@ -2568,6 +3047,8 @@ void network_objects_new_game(
|
||||
short index;
|
||||
|
||||
csmemset(objects_host_inventories, 0, sizeof(objects_host_inventories));
|
||||
host_damage_animation_count = 0;
|
||||
csmemset(client_damage_animations, 0, sizeof(client_damage_animations));
|
||||
for (absolute_index = 0; absolute_index < MAXIMUM_TRACKED_OBJECTS; absolute_index++)
|
||||
{
|
||||
objects_host_told[absolute_index] = NONE;
|
||||
@@ -2606,6 +3087,7 @@ void network_objects_new_game(
|
||||
for (local_player_index = 0; local_player_index < MAXIMUM_LOCAL_PLAYERS; local_player_index++)
|
||||
{
|
||||
objects_client_own_inventories[local_player_index].unit_index = NONE;
|
||||
objects_client_picked_up_weapons[local_player_index].definition_index = NONE;
|
||||
for (index = 0; index < OWN_VEHICLE_POSITION_TICKS; index++)
|
||||
{
|
||||
objects_client_own_vehicles[local_player_index][index].time = NONE;
|
||||
|
||||
@@ -16,7 +16,10 @@ also need the tick after the pair it spans: two ticks behind.)
|
||||
Rotations are blended as quaternions (normalised lerp, taking the shorter
|
||||
way round), positions and scales linearly. Anything that moves further than
|
||||
a tick of motion plausibly allows (teleports, respawns, camera cuts) snaps
|
||||
instead of sweeping across the world.
|
||||
instead of sweeping across the world, and so does a pose whose nodes moved
|
||||
too far for one tick: two snapshots of different poses (a model swapped,
|
||||
another weapon's skeleton, a pose left from seconds before) blended node by
|
||||
node stretch vertices across the screen.
|
||||
|
||||
Particles, contrails and other effects already move every frame
|
||||
(game_frame), so they need nothing here.
|
||||
@@ -56,6 +59,17 @@ unsigned long config_changes(void);
|
||||
/* world units (10 feet each) a node may move in one tick before it snaps:
|
||||
well beyond any vehicle, short of any teleport */
|
||||
#define OBJECT_SNAP_DISTANCE 10.0f
|
||||
/* ... a node may move in the object's root node's frame in one tick before
|
||||
the pose is taken for a new one, not blended to: further than any limb or
|
||||
part of a model moves in 33 ms (37 m/s), short of the game changing a pose
|
||||
at once (an actor waking from dormancy, a model swapped), which blended
|
||||
sweeps the vertices through poses it never had. (In the root's frame, so
|
||||
that the whole object turning moves nothing: measured in the world, a fast
|
||||
turn swung the head and weapon far enough to snap, and characters moved
|
||||
like robots.) */
|
||||
#define NODE_SNAP_DISTANCE 0.4f
|
||||
/* ... a first-person node may move relative to the camera */
|
||||
#define FIRST_PERSON_SNAP_DISTANCE 0.25f
|
||||
/* a correction's difference left drawn after each tick (of 1) */
|
||||
#define CORRECTION_DECAY 0.6f
|
||||
/* ... and small enough to be none */
|
||||
@@ -311,16 +325,6 @@ static void matrix_blend_rotations(
|
||||
result->up.k = lerp(a->up.k, b->up.k, t);
|
||||
}
|
||||
|
||||
/* a matrix a fraction t of the way from a to b */
|
||||
static void matrix_blend(real_matrix4x3 const *a, real_matrix4x3 const *b, real t, real_matrix4x3 *result)
|
||||
{
|
||||
struct interpolation_rotation rotation_a, rotation_b;
|
||||
|
||||
rotation_from_matrix(a, &rotation_a);
|
||||
rotation_from_matrix(b, &rotation_b);
|
||||
matrix_blend_rotations(a, b, &rotation_a, &rotation_b, t, result);
|
||||
}
|
||||
|
||||
/* the vector's parts' sum, large enough to be a correction (so written that
|
||||
one not a number is none) */
|
||||
static boolean correction_significant(real_vector3d const *correction)
|
||||
@@ -530,14 +534,22 @@ real_matrix4x3 *render_interpolation_object_node_matrices(long object_index)
|
||||
real_matrix4x3 const *latest = record->nodes + record->latest * record->node_capacity;
|
||||
real_matrix4x3 *blended = record->nodes + 2 * record->node_capacity;
|
||||
short node_index;
|
||||
|
||||
/* (so written that a position not a number snaps) */
|
||||
if (!(distance_squared(&previous[0].position, &latest[0].position) <=
|
||||
OBJECT_SNAP_DISTANCE * OBJECT_SNAP_DISTANCE))
|
||||
boolean snap = !(distance_squared(&previous[0].position, &latest[0].position) <=
|
||||
OBJECT_SNAP_DISTANCE * OBJECT_SNAP_DISTANCE);
|
||||
|
||||
/* a node moved further in the root's frame than a tick allows: the
|
||||
two snapshots are different poses, not one moving (so written that
|
||||
a position not a number snaps) */
|
||||
for (node_index = 1; !snap && node_index < record->node_count; node_index++)
|
||||
{
|
||||
memcpy(blended, latest, record->node_count * sizeof(real_matrix4x3));
|
||||
real_point3d previous_local, latest_local;
|
||||
|
||||
matrix4x3_inverse_transform_point(&previous[0], &previous[node_index].position, &previous_local);
|
||||
matrix4x3_inverse_transform_point(&latest[0], &latest[node_index].position, &latest_local);
|
||||
snap = !(distance_squared(&previous_local, &latest_local) <= NODE_SNAP_DISTANCE * NODE_SNAP_DISTANCE);
|
||||
}
|
||||
else
|
||||
if (!snap)
|
||||
{
|
||||
struct interpolation_rotation *previous_rotations =
|
||||
record->rotations + (record->latest ^ 1) * record->node_capacity;
|
||||
@@ -566,6 +578,8 @@ real_matrix4x3 *render_interpolation_object_node_matrices(long object_index)
|
||||
&latest_rotations[node_index], interpolation_fraction, &blended[node_index]);
|
||||
}
|
||||
}
|
||||
if (snap)
|
||||
memcpy(blended, latest, record->node_count * sizeof(real_matrix4x3));
|
||||
if (correction_significant(&record->correction) || correction_significant(&record->correction_pending))
|
||||
{
|
||||
real_vector3d drawn;
|
||||
@@ -804,6 +818,8 @@ void render_interpolation_first_person(
|
||||
struct interpolated_first_person *first_person;
|
||||
real_matrix4x3 camera_matrix;
|
||||
real_matrix4x3 inverse_camera;
|
||||
struct interpolation_rotation previous_rotations[MAXIMUM_INTERPOLATED_NODES];
|
||||
struct interpolation_rotation latest_rotations[MAXIMUM_INTERPOLATED_NODES];
|
||||
short node_index;
|
||||
|
||||
if (!interpolation_rendering ||
|
||||
@@ -817,8 +833,11 @@ void render_interpolation_first_person(
|
||||
matrix4x3_inverse(&camera_matrix, &inverse_camera);
|
||||
if (first_person->tick != interpolation_tick)
|
||||
{
|
||||
/* the pose drawn last, at the end of the previous tick */
|
||||
first_person->has_previous = first_person->node_count == node_count;
|
||||
/* the pose drawn last, if that was at the end of the tick just
|
||||
before: not one left from before the view was last away from first
|
||||
person (zoomed, in a vehicle, dead, in a cinematic), seconds old */
|
||||
first_person->has_previous = first_person->tick == interpolation_tick - 1 &&
|
||||
first_person->node_count == node_count;
|
||||
memcpy(first_person->previous, first_person->latest, sizeof(first_person->previous));
|
||||
first_person->tick = interpolation_tick;
|
||||
}
|
||||
@@ -827,13 +846,31 @@ void render_interpolation_first_person(
|
||||
first_person->node_count = node_count;
|
||||
if (!first_person->has_previous)
|
||||
return;
|
||||
/* a node that jumped further in the camera's frame than a tick allows:
|
||||
the last pose was another weapon's skeleton (of as many nodes), not this
|
||||
one moving (so written that a position not a number snaps) */
|
||||
for (node_index = 0; node_index < node_count; node_index++)
|
||||
{
|
||||
real_matrix4x3 const *previous = &first_person->previous[node_index];
|
||||
real_matrix4x3 const *latest = &first_person->latest[node_index];
|
||||
|
||||
if (!(distance_squared(&previous->position, &latest->position) <=
|
||||
FIRST_PERSON_SNAP_DISTANCE * FIRST_PERSON_SNAP_DISTANCE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
rotation_from_matrix(previous, &previous_rotations[node_index]);
|
||||
rotation_from_matrix(latest, &latest_rotations[node_index]);
|
||||
}
|
||||
for (node_index = 0; node_index < node_count; node_index++)
|
||||
{
|
||||
real_matrix4x3 blended;
|
||||
|
||||
matrix_blend(
|
||||
matrix_blend_rotations(
|
||||
&first_person->previous[node_index],
|
||||
&first_person->latest[node_index],
|
||||
&previous_rotations[node_index],
|
||||
&latest_rotations[node_index],
|
||||
interpolation_fraction,
|
||||
&blended);
|
||||
matrix4x3_multiply(&camera_matrix, &blended, &node_matrices[node_index]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* the game includes <StdDef.h>; Linux file names are case sensitive.
|
||||
#include_next, since on a case-insensitive file system (macOS) this file
|
||||
is also what <stddef.h> finds */
|
||||
/* the game includes <StdDef.h>; Linux file names are case sensitive. On a
|
||||
case-insensitive file system (macOS) a plain <stddef.h> would find this file
|
||||
again; include_next goes to the real one, as the other shims do. */
|
||||
#include_next <stddef.h>
|
||||
@@ -41,8 +41,17 @@ the display's shape, or 640 (port/linux/src/d3d8_gl.c) */
|
||||
long halo_screen_width(void);
|
||||
/* takes up a new width between frames (F11); returns the width */
|
||||
long halo_screen_commit(void);
|
||||
/* the shadow maps' pixels for each of their 128 texels each way, a power of
|
||||
two (display.shadow_resolution) */
|
||||
long halo_shadow_map_scale(void);
|
||||
/* while TRUE, drawing shifts right to center 640-column layouts */
|
||||
void halo_screen_ui_offset(unsigned char centered);
|
||||
/* names a model lighting vertex program, whose draws can be lit for each
|
||||
pixel (port/linux/src/d3d8_gl.c, display.per_pixel_lighting) */
|
||||
void halo_vertex_shader_lighting(unsigned long handle);
|
||||
/* display.anti_aliasing's pass over a window's 3D view, before the HUD and
|
||||
menus (source/render/render.c): the window's bounds on the screen */
|
||||
void halo_screen_anti_alias(short x0, short y0, short x1, short y1);
|
||||
/* the mouse in the menus (source/interface/ui_widget.c) */
|
||||
#include "halo_ui_pointer.h"
|
||||
|
||||
|
||||
@@ -24,15 +24,27 @@ state above the tag cache (which ends at 0x819A6000), inside the Xbox memory
|
||||
window (0x80000000-0x88000000, port/linux/src/platform.h) and below everything
|
||||
the window hands out top-down (texture and sound caches, Direct3D resources).
|
||||
|
||||
The CPU part holds about 13.6 MB of pools at the sizes below (the Xbox pools
|
||||
The CPU part holds about 17.2 MB of pools at the sizes below (the Xbox pools
|
||||
fill 3,165,260 of its 0x305000 bytes); the GPU part holds only the decal
|
||||
vertices, as on the Xbox. */
|
||||
vertices, as on the Xbox. A change to a pool's size changes the game state's
|
||||
layout: saved games of builds before it no longer load. */
|
||||
|
||||
#define HALO_PORT_GAME_STATE_BASE_ADDRESS 0x81A00000 /* (0x80061000) */
|
||||
#define HALO_PORT_GAME_STATE_CPU_SIZE 0xFC0000 /* (0x305000) */
|
||||
#define HALO_PORT_GAME_STATE_CPU_SIZE 0x13C0000 /* (0x305000) */
|
||||
#define HALO_PORT_GAME_STATE_GPU_SIZE 0x40000 /* (0x40000) */
|
||||
#define HALO_PORT_GAME_STATE_SIZE (HALO_PORT_GAME_STATE_CPU_SIZE+HALO_PORT_GAME_STATE_GPU_SIZE)
|
||||
|
||||
/* ---------- AI
|
||||
|
||||
Network co-op adds enemies for its players (port/linux/game/coop_enemies.c):
|
||||
the actors, and their knowledge of the units about them (props: with many
|
||||
players, more each), have room for several times a level's own. */
|
||||
|
||||
#define HALO_PORT_MAXIMUM_ACTORS 1024 /* (256) */
|
||||
#define HALO_PORT_MAXIMUM_PROPS 8192 /* (768) */
|
||||
#define HALO_PORT_MAXIMUM_SWARMS 128 /* (32) */
|
||||
#define HALO_PORT_MAXIMUM_SWARM_COMPONENTS 1024 /* (256) */
|
||||
|
||||
/* ---------- objects */
|
||||
|
||||
#define HALO_PORT_MAXIMUM_OBJECTS_PER_MAP 8192 /* (2048) */
|
||||
|
||||
@@ -66,7 +66,7 @@ is newer (network_client_manager.c). A host advertises it, with its netcode,
|
||||
in its game's advertisement's reserved bytes (network_server_message_handler.c),
|
||||
which hosts built before there was a version send as zeros: version 0.
|
||||
Raise it with any change to what the machines send each other. */
|
||||
#define HALO_PORT_NETWORK_VERSION 11
|
||||
#define HALO_PORT_NETWORK_VERSION 20
|
||||
/* ... the advertisement's reserved bytes: the version (a little-endian word),
|
||||
then flags */
|
||||
#define HALO_PORT_ADVERTISED_VERSION_OFFSET 0
|
||||
|
||||
@@ -63,6 +63,9 @@ void halo_vr_multiview_sky(int sky);
|
||||
/* the shared camera's projection's [2][2] and [3][2], for what the game
|
||||
projects itself (sprites, lens flare tests) */
|
||||
void halo_vr_multiview_projection(float projection_22, float projection_32);
|
||||
/* lens flares are being drawn: placed by their depth, though not depth
|
||||
tested */
|
||||
void halo_vr_multiview_lens_flares(int drawing);
|
||||
|
||||
/* clears the back buffer to transparent black for the overlay, after the
|
||||
eyes; menus_active chooses where the overlay is shown */
|
||||
@@ -201,6 +204,9 @@ driver's hands on it as drawn (world units, from the game's camera), or
|
||||
NULL; the player's own hands turn it. And whether they hold it. */
|
||||
void halo_vr_set_wheel(short local_player_index, const float left[3], const float right[3]);
|
||||
int halo_vr_wheel_held(void);
|
||||
/* the controllers' layout (HALO_XR_LAYOUT_*: 0 the Quest's, 1 the Steam
|
||||
Frame's), for what the game tells the player */
|
||||
int halo_vr_controller_layout(void);
|
||||
/* whether a seated player's view stays in first person (director.c) */
|
||||
int halo_vr_vehicle_first_person(void);
|
||||
/* VR test aid (debug.vehicle_spawn): both sticks held in for a moment asks
|
||||
@@ -244,6 +250,18 @@ void halo_vr_network_grenade_thrown(short local_player_index, long unit_index, c
|
||||
/* the platform layer's side (vr.c) */
|
||||
void halo_vr_initialize(void);
|
||||
void halo_vr_frame_begin(void);
|
||||
/* vr.log_performance: the end of a part of the frame, for the report: the
|
||||
input and network, the game's ticks (how many), the camera and director,
|
||||
the drawing; the rest is presenting */
|
||||
enum
|
||||
{
|
||||
HALO_VR_PHASE_INPUT,
|
||||
HALO_VR_PHASE_TICKS,
|
||||
HALO_VR_PHASE_CAMERA,
|
||||
HALO_VR_PHASE_DRAW,
|
||||
HALO_VR_PHASE_COUNT
|
||||
};
|
||||
void halo_vr_phase(int phase, int ticks);
|
||||
void halo_vr_present(unsigned int back_buffer_texture);
|
||||
/* the eye image size: the back buffer's size in pixels in VR */
|
||||
int halo_vr_eye_size(int *width, int *height);
|
||||
|
||||
@@ -86,6 +86,10 @@ this list to generate the guest's entry points */
|
||||
X(glCheckFramebufferStatus) \
|
||||
X(glBlitFramebuffer) \
|
||||
X(glDrawBuffers) \
|
||||
X(glGenRenderbuffers) \
|
||||
X(glBindRenderbuffer) \
|
||||
X(glRenderbufferStorageMultisample) \
|
||||
X(glFramebufferRenderbuffer) \
|
||||
X(glReadBuffer) \
|
||||
X(glInvalidateFramebuffer) \
|
||||
X(glGenBuffers) \
|
||||
@@ -195,6 +199,10 @@ this list to generate the guest's entry points */
|
||||
X(glCheckFramebufferStatus) \
|
||||
X(glBlitFramebuffer) \
|
||||
X(glDrawBuffers) \
|
||||
X(glGenRenderbuffers) \
|
||||
X(glBindRenderbuffer) \
|
||||
X(glRenderbufferStorageMultisample) \
|
||||
X(glFramebufferRenderbuffer) \
|
||||
X(glGenBuffers) \
|
||||
X(glDeleteBuffers) \
|
||||
X(glBindBuffer) \
|
||||
@@ -209,6 +217,11 @@ this list to generate the guest's entry points */
|
||||
X(glDisableVertexAttribArray) \
|
||||
X(glVertexAttribPointer) \
|
||||
X(glVertexAttribIPointer) \
|
||||
X(glVertexAttribFormat) \
|
||||
X(glVertexAttribIFormat) \
|
||||
X(glVertexAttribBinding) \
|
||||
X(glBindVertexBuffer) \
|
||||
X(glGetQueryBufferObjectuiv) \
|
||||
X(glVertexAttrib4fv) \
|
||||
X(glVertexAttribI4ui) \
|
||||
X(glDrawArrays) \
|
||||
@@ -306,6 +319,10 @@ pointers, sees the declarations without these aliases */
|
||||
#define glCheckFramebufferStatus halo_glCheckFramebufferStatus
|
||||
#define glBlitFramebuffer halo_glBlitFramebuffer
|
||||
#define glDrawBuffers halo_glDrawBuffers
|
||||
#define glGenRenderbuffers halo_glGenRenderbuffers
|
||||
#define glBindRenderbuffer halo_glBindRenderbuffer
|
||||
#define glRenderbufferStorageMultisample halo_glRenderbufferStorageMultisample
|
||||
#define glFramebufferRenderbuffer halo_glFramebufferRenderbuffer
|
||||
#define glReadBuffer halo_glReadBuffer
|
||||
#define glInvalidateFramebuffer halo_glInvalidateFramebuffer
|
||||
#define glGenBuffers halo_glGenBuffers
|
||||
@@ -413,6 +430,10 @@ pointers, sees the declarations without these aliases */
|
||||
#define glCheckFramebufferStatus halo_glCheckFramebufferStatus
|
||||
#define glBlitFramebuffer halo_glBlitFramebuffer
|
||||
#define glDrawBuffers halo_glDrawBuffers
|
||||
#define glGenRenderbuffers halo_glGenRenderbuffers
|
||||
#define glBindRenderbuffer halo_glBindRenderbuffer
|
||||
#define glRenderbufferStorageMultisample halo_glRenderbufferStorageMultisample
|
||||
#define glFramebufferRenderbuffer halo_glFramebufferRenderbuffer
|
||||
#define glGenBuffers halo_glGenBuffers
|
||||
#define glDeleteBuffers halo_glDeleteBuffers
|
||||
#define glBindBuffer halo_glBindBuffer
|
||||
@@ -427,6 +448,11 @@ pointers, sees the declarations without these aliases */
|
||||
#define glDisableVertexAttribArray halo_glDisableVertexAttribArray
|
||||
#define glVertexAttribPointer halo_glVertexAttribPointer
|
||||
#define glVertexAttribIPointer halo_glVertexAttribIPointer
|
||||
#define glVertexAttribFormat halo_glVertexAttribFormat
|
||||
#define glVertexAttribIFormat halo_glVertexAttribIFormat
|
||||
#define glVertexAttribBinding halo_glVertexAttribBinding
|
||||
#define glBindVertexBuffer halo_glBindVertexBuffer
|
||||
#define glGetQueryBufferObjectuiv halo_glGetQueryBufferObjectuiv
|
||||
#define glVertexAttrib4fv halo_glVertexAttrib4fv
|
||||
#define glVertexAttribI4ui halo_glVertexAttribI4ui
|
||||
#define glDrawArrays halo_glDrawArrays
|
||||
|
||||
@@ -125,7 +125,9 @@ HALO_COMMON(hs_global_data, 4); /* struct data_array *hs_global_data */
|
||||
HALO_COMMON(hs_thread_data, 4); /* struct data_array *hs_thread_data */
|
||||
HALO_COMMON(hud_msg_def, 4); /* struct hud_messaging_parameters_definition *hud_msg_def */
|
||||
HALO_COMMON(interrupt_result, 24); /* HRESULT interrupt_result */
|
||||
HALO_COMMON(light_cluster_partition, 12); /* struct cluster_partition light_cluster_partition */
|
||||
/* object_lights.c owns light_cluster_partition. On COFF a weak fallback
|
||||
can override its tentative COMMON definition; let the owner allocate the
|
||||
native struct cluster_partition, including its reference-cache fields. */
|
||||
HALO_COMMON(light_data, 4); /* struct data_array *light_data */
|
||||
HALO_COMMON(local_player_index_for_draw_string_and_hack_in_icons, 4); /* short local_player_index_for_draw_string_and_hack_in_icons */
|
||||
HALO_COMMON(looping_sound_data, 4); /* struct data_array *looping_sound_data */
|
||||
|
||||
@@ -911,6 +911,11 @@ static struct
|
||||
int failed;
|
||||
} art[MAXIMUM_ART];
|
||||
static long art_count;
|
||||
/* the lowest and highest texture the art stands for: every texture the
|
||||
renderer binds asks (xbox_textures.c), every frame of a game too, and the
|
||||
menus' lie together, made as the map loaded, mostly apart from the map's
|
||||
(in its texture cache) */
|
||||
static unsigned long art_lowest, art_highest;
|
||||
|
||||
void halo_menus_art_register(void const *texture, char const *png)
|
||||
{
|
||||
@@ -944,6 +949,10 @@ void halo_menus_art_register(void const *texture, char const *png)
|
||||
memset(&art[index], 0, sizeof(art[index]));
|
||||
art[index].data = data;
|
||||
art[index].png = strdup(png);
|
||||
if (art_count == 1 || data < art_lowest)
|
||||
art_lowest = data;
|
||||
if (art_count == 1 || data > art_highest)
|
||||
art_highest = data;
|
||||
}
|
||||
|
||||
void halo_menus_art_forget(void)
|
||||
@@ -957,12 +966,15 @@ void halo_menus_art_forget(void)
|
||||
glDeleteTextures(1, &art[index].texture);
|
||||
}
|
||||
art_count = 0;
|
||||
art_lowest = art_highest = 0;
|
||||
}
|
||||
|
||||
unsigned int menu_art_texture(unsigned long data, unsigned long *levels)
|
||||
{
|
||||
long index;
|
||||
|
||||
if (!art_count || data < art_lowest || data > art_highest)
|
||||
return 0;
|
||||
for (index = 0; index < art_count; index++)
|
||||
{
|
||||
if (art[index].data == data)
|
||||
|
||||
@@ -518,6 +518,59 @@ static const char *comparison_operator(unsigned long function)
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- per-pixel model lighting
|
||||
|
||||
The game lights its models for each vertex: its model lighting programs
|
||||
(nv2a_vsh.c nv2a_vertex_shader_lighting) sum the ambient light, two distant
|
||||
lights and two point lights into the diffuse color v0. Halo's models have
|
||||
few vertices, so the light across a curved surface comes out in facets, and
|
||||
a point light that passes close lights only the vertices it reaches.
|
||||
model_lighting computes the same sum for each pixel, from the normal and
|
||||
world position the vertex program hands on and the same constants
|
||||
(XGPU_MODEL_LIGHT_COUNT): the same falloff, facing, cone and translucency
|
||||
terms, clamped where the programs clamp them. The diffuse alpha, which the
|
||||
programs write apart (0, or planar fog's), is kept. */
|
||||
|
||||
static void model_lighting(struct xgpu_text *text, BOOL point_lights)
|
||||
{
|
||||
int light;
|
||||
|
||||
xgpu_text_append(text,
|
||||
"uniform vec4 model_lights[%d];\n"
|
||||
"in vec4 xWorldNormal;\n"
|
||||
"%s"
|
||||
"vec3 model_lighting()\n"
|
||||
"{\n"
|
||||
/* the normal's direction between the vertices, at the length the
|
||||
vertices' normals have, as the programs light by it unnormalized
|
||||
(shorter than 1 on some models: the first-person weapons) */
|
||||
"\tvec3 n = xWorldNormal.xyz * (xWorldNormal.w * inversesqrt(max(dot(xWorldNormal.xyz, xWorldNormal.xyz), 1.0e-24)));\n"
|
||||
/* the ambient light, the first distant light, which also lights the
|
||||
back by the translucency, and the second */
|
||||
"\tfloat facing = dot(n, -model_lights[7].xyz);\n"
|
||||
"\tvec3 light = model_lights[11].xyz + max(max(facing, -facing * model_lights[0].z), 0.0) * model_lights[8].xyz +\n"
|
||||
"\t\tmax(dot(n, -model_lights[9].xyz), 0.0) * model_lights[10].xyz;\n",
|
||||
XGPU_MODEL_LIGHT_COUNT, point_lights ? "in vec3 xWorldPosition;\n" : "");
|
||||
/* each point light: its position and 1 / radius squared, its cone's axis
|
||||
and falloff scale, its color and falloff offset */
|
||||
for (light = 0; point_lights && light < 2; light++)
|
||||
{
|
||||
int first = 1 + light * 3;
|
||||
|
||||
xgpu_text_append(text,
|
||||
"\t{\n"
|
||||
"\t\tvec3 to_light = model_lights[%d].xyz - xWorldPosition;\n"
|
||||
"\t\tfloat distance_squared = dot(to_light, to_light);\n"
|
||||
"\t\tvec3 l = to_light * inversesqrt(max(distance_squared, 1.0e-12));\n"
|
||||
"\t\tlight += max(1.0 - distance_squared * model_lights[%d].w, 0.0) * clamp(dot(l, n), 0.0, 1.0) *\n"
|
||||
"\t\t\tclamp(dot(l, -model_lights[%d].xyz) * model_lights[%d].w + model_lights[%d].w, 0.0, 1.0) *\n"
|
||||
"\t\t\tmodel_lights[%d].xyz;\n"
|
||||
"\t}\n",
|
||||
first, first, first + 1, first + 1, first + 2, first + 2);
|
||||
}
|
||||
xgpu_text_append(text, "\treturn clamp(light, 0.0, 1.0);\n}\n");
|
||||
}
|
||||
|
||||
char *nv2a_pixel_shader_to_glsl(const struct nv2a_pixel_shader_key *key)
|
||||
{
|
||||
const DWORD *state = key->combiner_state;
|
||||
@@ -556,6 +609,8 @@ char *nv2a_pixel_shader_to_glsl(const struct nv2a_pixel_shader_key *key)
|
||||
XGPU_PIXEL_UNIFORMS);
|
||||
for (stage = 0; stage < 4; stage++)
|
||||
xgpu_text_append(&text, "uniform %s tex%d;\n", sampler_declaration(key->sampler_type[stage]), stage);
|
||||
if (key->per_pixel_lighting)
|
||||
model_lighting(&text, key->per_pixel_lighting == 2);
|
||||
xgpu_text_append(&text,
|
||||
"float signed_byte(float x)\n"
|
||||
"{\n"
|
||||
@@ -572,6 +627,8 @@ char *nv2a_pixel_shader_to_glsl(const struct nv2a_pixel_shader_key *key)
|
||||
"\tvec4 v1 = xD1;\n"
|
||||
"\tvec4 t0 = vec4(0.0), t1 = vec4(0.0), t2 = vec4(0.0), t3 = vec4(0.0);\n"
|
||||
"\tfloat dot0 = 0.0, dot1 = 0.0, dot2 = 0.0, dot3 = 0.0;\n");
|
||||
if (key->per_pixel_lighting)
|
||||
xgpu_text_append(&text, "\tv0.rgb = model_lighting();\n");
|
||||
|
||||
for (stage = 0; stage < 4; stage++)
|
||||
texture_stage(&text, key, stage);
|
||||
@@ -645,9 +702,27 @@ char *nv2a_pixel_shader_to_glsl(const struct nv2a_pixel_shader_key *key)
|
||||
const char *comparison = comparison_operator(key->alpha_test_function);
|
||||
|
||||
if (!comparison)
|
||||
{
|
||||
xgpu_text_append(&text, "\tdiscard;\n");
|
||||
}
|
||||
else if (*comparison && key->alpha_test_samples && comparison[0] != '=' && comparison[0] != '!')
|
||||
{
|
||||
/* multisampled: the samples covered as alpha passes the reference
|
||||
over the pixel (its change across the pixel from fwidth), the rest
|
||||
left as they are; alpha itself is kept, the game keeping values of
|
||||
its own in destination alpha */
|
||||
xgpu_text_append(&text,
|
||||
"\tfloat test_alpha = clamp(result.a, 0.0, 1.0) * 255.0;\n"
|
||||
"\tfloat test_coverage = clamp(%s(test_alpha - alpha_reference) / max(fwidth(test_alpha), 1.0) + 0.5, 0.0, 1.0);\n"
|
||||
"\tint test_samples = int(test_coverage * %d.0 + 0.5);\n"
|
||||
"\tif (test_samples == 0) discard;\n"
|
||||
"\tgl_SampleMask[0] = (1 << test_samples) - 1;\n",
|
||||
comparison[0] == '<' ? "-" : "", (int)key->alpha_test_samples);
|
||||
}
|
||||
else if (*comparison)
|
||||
{
|
||||
xgpu_text_append(&text, "\tif (!(floor(clamp(result.a, 0.0, 1.0) * 255.0 + 0.5) %s alpha_reference)) discard;\n", comparison);
|
||||
}
|
||||
}
|
||||
if (*config_string("debug.gpu_debug_expression"))
|
||||
xgpu_text_append(&text, "\tresult = vec4(vec3(%s), 1.0);\n", config_string("debug.gpu_debug_expression"));
|
||||
|
||||
@@ -7,7 +7,7 @@ GLSL.
|
||||
Each instruction is four little-endian words. Word 1 to 3 hold a MAC
|
||||
(vector) operation and an ILU (scalar) operation that execute in parallel
|
||||
on the same three operands A, B and C, and the destinations of both; the
|
||||
bit positions of every field are spelled out in operand() and in
|
||||
bit positions of every field are spelled out in operand_fields() and in
|
||||
nv2a_vertex_shader_to_glsl(). When both units run, the ILU result goes to
|
||||
temporary r1, whatever the instruction's temporary register field says.
|
||||
|
||||
@@ -76,43 +76,55 @@ static void write_mask(unsigned long mask, char *out)
|
||||
out[count] = 0;
|
||||
}
|
||||
|
||||
static void operand(struct xgpu_text *text, const DWORD *instruction, char which, int relative)
|
||||
struct operand_fields
|
||||
{
|
||||
static const char swizzle_names[] = "xyzw";
|
||||
unsigned long negate, swizzle[4], index, mux;
|
||||
};
|
||||
|
||||
static void operand_fields(const DWORD *instruction, char which, struct operand_fields *fields)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
case 'A':
|
||||
negate = field(instruction, 1, 8, 1);
|
||||
swizzle[0] = field(instruction, 1, 6, 2);
|
||||
swizzle[1] = field(instruction, 1, 4, 2);
|
||||
swizzle[2] = field(instruction, 1, 2, 2);
|
||||
swizzle[3] = field(instruction, 1, 0, 2);
|
||||
index = field(instruction, 2, 28, 4);
|
||||
mux = field(instruction, 2, 26, 2);
|
||||
fields->negate = field(instruction, 1, 8, 1);
|
||||
fields->swizzle[0] = field(instruction, 1, 6, 2);
|
||||
fields->swizzle[1] = field(instruction, 1, 4, 2);
|
||||
fields->swizzle[2] = field(instruction, 1, 2, 2);
|
||||
fields->swizzle[3] = field(instruction, 1, 0, 2);
|
||||
fields->index = field(instruction, 2, 28, 4);
|
||||
fields->mux = field(instruction, 2, 26, 2);
|
||||
break;
|
||||
case 'B':
|
||||
negate = field(instruction, 2, 25, 1);
|
||||
swizzle[0] = field(instruction, 2, 23, 2);
|
||||
swizzle[1] = field(instruction, 2, 21, 2);
|
||||
swizzle[2] = field(instruction, 2, 19, 2);
|
||||
swizzle[3] = field(instruction, 2, 17, 2);
|
||||
index = field(instruction, 2, 13, 4);
|
||||
mux = field(instruction, 2, 11, 2);
|
||||
fields->negate = field(instruction, 2, 25, 1);
|
||||
fields->swizzle[0] = field(instruction, 2, 23, 2);
|
||||
fields->swizzle[1] = field(instruction, 2, 21, 2);
|
||||
fields->swizzle[2] = field(instruction, 2, 19, 2);
|
||||
fields->swizzle[3] = field(instruction, 2, 17, 2);
|
||||
fields->index = field(instruction, 2, 13, 4);
|
||||
fields->mux = field(instruction, 2, 11, 2);
|
||||
break;
|
||||
default:
|
||||
negate = field(instruction, 2, 10, 1);
|
||||
swizzle[0] = field(instruction, 2, 8, 2);
|
||||
swizzle[1] = field(instruction, 2, 6, 2);
|
||||
swizzle[2] = field(instruction, 2, 4, 2);
|
||||
swizzle[3] = field(instruction, 2, 2, 2);
|
||||
index = (field(instruction, 2, 0, 2) << 2) | field(instruction, 3, 30, 2);
|
||||
mux = field(instruction, 3, 28, 2);
|
||||
fields->negate = field(instruction, 2, 10, 1);
|
||||
fields->swizzle[0] = field(instruction, 2, 8, 2);
|
||||
fields->swizzle[1] = field(instruction, 2, 6, 2);
|
||||
fields->swizzle[2] = field(instruction, 2, 4, 2);
|
||||
fields->swizzle[3] = field(instruction, 2, 2, 2);
|
||||
fields->index = (field(instruction, 2, 0, 2) << 2) | field(instruction, 3, 30, 2);
|
||||
fields->mux = field(instruction, 3, 28, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
xgpu_text_append(text, "%s", negate ? "-" : "");
|
||||
static void operand(struct xgpu_text *text, const DWORD *instruction, char which, int relative)
|
||||
{
|
||||
static const char swizzle_names[] = "xyzw";
|
||||
struct operand_fields fields;
|
||||
unsigned long *swizzle = fields.swizzle, index, mux;
|
||||
|
||||
operand_fields(instruction, which, &fields);
|
||||
index = fields.index;
|
||||
mux = fields.mux;
|
||||
xgpu_text_append(text, "%s", fields.negate ? "-" : "");
|
||||
switch (mux)
|
||||
{
|
||||
case _mux_temporary:
|
||||
@@ -139,6 +151,183 @@ static void operand(struct xgpu_text *text, const DWORD *instruction, char which
|
||||
swizzle_names[swizzle[0]], swizzle_names[swizzle[1]], swizzle_names[swizzle[2]], swizzle_names[swizzle[3]]);
|
||||
}
|
||||
|
||||
/* ---------- model lighting
|
||||
|
||||
The game's model lighting programs (rasterizer_xbox_vertex_shaders_data.inc
|
||||
9, 10, 17 and 27) sum into the diffuse color oD0.xyz the ambient light
|
||||
c[-69], two distant lights (direction c[-73] and c[-71], color c[-72] and
|
||||
c[-70]; the first also lights the back by the translucency c[-82].z) and, in
|
||||
10 and 17, two point lights (c[-79] to c[-77] and c[-76] to c[-74]: position
|
||||
and 1 / radius squared, the cone's axis and falloff scale, the color and
|
||||
falloff offset). The normal and world position they light by are
|
||||
temporaries that the programs reuse (10 and 17 overwrite both after the
|
||||
sum). In 9, 10 and 17 the normal is the skinned normal turned by c[-84].w
|
||||
for the back faces' pass, r0 (written by instruction 17) and the position
|
||||
the skinned position, r10 (by 12); in 27, of a single node, the normal is
|
||||
r3 (by 5). They are taken as the first instruction that lights by them
|
||||
reads them: in 9 the normal before instruction 19, in 10 and 17 the normal
|
||||
before 24 and the position before 19, in 27 the normal before 7. A program
|
||||
is taken only where its lighting is the sum nv2a_psh.c computes for each
|
||||
pixel (the diffuse color written once, by the sum; both distant lights by
|
||||
one normal; the translucency; each point light by one position, its cone
|
||||
by its axis reversed) and the registers keep the same normal and position
|
||||
through it. Nothing else of the programs goes into oD0.xyz; oD0.w is 0, or
|
||||
in 17 the planar fog's. */
|
||||
|
||||
static BOOL xyz_unswizzled(const struct operand_fields *operand)
|
||||
{
|
||||
return operand->swizzle[0] == 0 && operand->swizzle[1] == 1 && operand->swizzle[2] == 2;
|
||||
}
|
||||
|
||||
/* the operand is c[reg] (as the game numbers them: -73), its xyz unswizzled */
|
||||
static BOOL light_constant(const DWORD *instruction, const struct operand_fields *operand, int reg, BOOL negated)
|
||||
{
|
||||
return operand->mux == _mux_constant && !field(instruction, 3, 1, 1) &&
|
||||
field(instruction, 1, 13, 8) == (unsigned long)(XGPU_VERTEX_CONSTANT_BIAS + reg) &&
|
||||
operand->negate == (negated ? 1UL : 0UL) && xyz_unswizzled(operand);
|
||||
}
|
||||
|
||||
/* the operand is a temporary (not the position output), its xyz unswizzled */
|
||||
static BOOL light_temporary(const struct operand_fields *operand, BOOL negated)
|
||||
{
|
||||
return operand->mux == _mux_temporary && operand->index < 12 &&
|
||||
operand->negate == (negated ? 1UL : 0UL) && xyz_unswizzled(operand);
|
||||
}
|
||||
|
||||
/* any of x, y and z of temporary reg written by the instructions in [first, last) */
|
||||
static BOOL temporary_written(const DWORD *instructions, unsigned long first, unsigned long last, unsigned long reg)
|
||||
{
|
||||
unsigned long index;
|
||||
|
||||
for (index = first; index < last; index++)
|
||||
{
|
||||
const DWORD *instruction = instructions + index * 4;
|
||||
unsigned long mac = field(instruction, 1, 21, 4);
|
||||
unsigned long ilu = field(instruction, 1, 25, 3);
|
||||
unsigned long temporary = field(instruction, 3, 20, 4);
|
||||
|
||||
if (mac != _mac_nop && mac != _mac_arl && temporary == reg && (field(instruction, 3, 24, 4) & 0xe))
|
||||
return TRUE;
|
||||
/* (the ILU writes r1 when both units run) */
|
||||
if (ilu != _ilu_nop && (mac != _mac_nop ? 1 : temporary) == reg && (field(instruction, 3, 16, 4) & 0xe))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL nv2a_vertex_shader_lighting(const DWORD *instructions, unsigned long instruction_count,
|
||||
struct nv2a_vertex_lighting *lighting)
|
||||
{
|
||||
unsigned long count, index, diffuse;
|
||||
unsigned long distant[2], distant_register[2] = { 0, 0 }, point[2], point_register[2] = { 0, 0 };
|
||||
BOOL cone[2] = { FALSE, FALSE }, translucency = FALSE, point_lights = FALSE;
|
||||
int light;
|
||||
|
||||
/* to the instruction that ends the program */
|
||||
for (count = 0; count < instruction_count;)
|
||||
{
|
||||
if (field(instructions + count++ * 4, 3, 0, 1))
|
||||
break;
|
||||
}
|
||||
diffuse = distant[0] = distant[1] = point[0] = point[1] = count;
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
const DWORD *instruction = instructions + index * 4;
|
||||
unsigned long mac = field(instruction, 1, 21, 4);
|
||||
unsigned long output_mask = field(instruction, 3, 12, 4);
|
||||
unsigned long constant = field(instruction, 1, 13, 8);
|
||||
struct operand_fields a, b, c;
|
||||
|
||||
operand_fields(instruction, 'A', &a);
|
||||
operand_fields(instruction, 'B', &b);
|
||||
operand_fields(instruction, 'C', &c);
|
||||
/* the diffuse color's x, y and z, written once and last by the sum:
|
||||
the second distant light's term times its color, plus the rest */
|
||||
if ((output_mask & 0xe) && field(instruction, 3, 11, 1) && field(instruction, 3, 3, 8) == 3)
|
||||
{
|
||||
if (diffuse != count || (output_mask & 0xe) != 0xe || field(instruction, 3, 2, 1) ||
|
||||
mac != _mac_mad || !light_constant(instruction, &b, -70, FALSE) || c.mux != _mux_temporary)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
diffuse = index;
|
||||
}
|
||||
for (light = 0; light < 2; light++)
|
||||
{
|
||||
/* each distant light's facing: the normal's dot product with the
|
||||
light's direction reversed */
|
||||
if (mac == _mac_dp3 && light_constant(instruction, &b, light ? -71 : -73, TRUE))
|
||||
{
|
||||
if (distant[light] != count || !light_temporary(&a, FALSE))
|
||||
return FALSE;
|
||||
distant[light] = index;
|
||||
distant_register[light] = a.index;
|
||||
}
|
||||
/* each point light's direction, from the world position */
|
||||
if (mac == _mac_add && light_constant(instruction, &a, light ? -76 : -79, FALSE) &&
|
||||
light_temporary(&c, TRUE))
|
||||
{
|
||||
if (point[light] != count)
|
||||
return FALSE;
|
||||
point[light] = index;
|
||||
point_register[light] = c.index;
|
||||
}
|
||||
/* and its cone: the direction's dot product with the light's axis
|
||||
reversed */
|
||||
if (mac == _mac_dp3 && b.mux == _mux_constant && !field(instruction, 3, 1, 1) &&
|
||||
constant == (unsigned long)(XGPU_VERTEX_CONSTANT_BIAS + (light ? -75 : -78)))
|
||||
{
|
||||
if (!light_constant(instruction, &b, light ? -75 : -78, TRUE))
|
||||
return FALSE;
|
||||
cone[light] = TRUE;
|
||||
}
|
||||
}
|
||||
/* the back lit by the first distant light: its facing reversed, times
|
||||
the translucency */
|
||||
if (mac == _mac_mul && a.mux == _mux_temporary && a.negate && b.mux == _mux_constant &&
|
||||
!field(instruction, 3, 1, 1) && constant == XGPU_VERTEX_CONSTANT_BIAS - 82 && b.swizzle[0] == 2)
|
||||
{
|
||||
translucency = TRUE;
|
||||
}
|
||||
if ((a.mux == _mux_constant || b.mux == _mux_constant || c.mux == _mux_constant) &&
|
||||
!field(instruction, 3, 1, 1) && constant >= XGPU_VERTEX_CONSTANT_BIAS - 79 &&
|
||||
constant <= XGPU_VERTEX_CONSTANT_BIAS - 74)
|
||||
{
|
||||
point_lights = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (diffuse == count || distant[0] >= diffuse || distant[1] >= diffuse ||
|
||||
distant_register[0] != distant_register[1] || !translucency)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
lighting->lights = 1;
|
||||
lighting->normal_register = distant_register[0];
|
||||
lighting->normal_instruction = distant[0] < distant[1] ? distant[0] : distant[1];
|
||||
if (temporary_written(instructions, lighting->normal_instruction, diffuse, lighting->normal_register))
|
||||
return FALSE;
|
||||
lighting->position_instruction = lighting->position_register = 0;
|
||||
if (point_lights)
|
||||
{
|
||||
unsigned long last = point[0] > point[1] ? point[0] : point[1];
|
||||
|
||||
if (point[0] >= diffuse || point[1] >= diffuse || point_register[0] != point_register[1] ||
|
||||
!cone[0] || !cone[1])
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
lighting->lights = 2;
|
||||
lighting->position_register = point_register[0];
|
||||
lighting->position_instruction = point[0] < point[1] ? point[0] : point[1];
|
||||
if (temporary_written(instructions, lighting->position_instruction, last, lighting->position_register))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ---------- translation */
|
||||
|
||||
static const char shader_prologue[] =
|
||||
#ifdef HALO_ANDROID
|
||||
/* the #version line comes first, from the context's capabilities */
|
||||
@@ -195,7 +384,7 @@ static const char shader_prologue[] =
|
||||
"}\n";
|
||||
|
||||
char *nv2a_vertex_shader_to_glsl(const DWORD *instructions, unsigned long instruction_count,
|
||||
unsigned long packed_attribute_mask, int multiview)
|
||||
unsigned long packed_attribute_mask, const struct nv2a_vertex_lighting *lighting, int multiview)
|
||||
{
|
||||
struct xgpu_text text = { 0 };
|
||||
unsigned long index;
|
||||
@@ -221,6 +410,11 @@ char *nv2a_vertex_shader_to_glsl(const DWORD *instructions, unsigned long instru
|
||||
(void)multiview;
|
||||
#endif
|
||||
xgpu_text_append(&text, "%s", shader_prologue);
|
||||
/* (the pixel shader's model_lighting; the normal's length in w) */
|
||||
if (lighting)
|
||||
xgpu_text_append(&text, "out vec4 xWorldNormal;\n");
|
||||
if (lighting && lighting->lights == 2)
|
||||
xgpu_text_append(&text, "out vec3 xWorldPosition;\n");
|
||||
for (index = 0; index < XGPU_VERTEX_ATTRIBUTE_COUNT; index++)
|
||||
{
|
||||
if (packed_attribute_mask & (1UL << index))
|
||||
@@ -249,9 +443,7 @@ char *nv2a_vertex_shader_to_glsl(const DWORD *instructions, unsigned long instru
|
||||
"\tvec4 oFog = vec4(1.0), oPts = vec4(point_size), oUnused = vec4(0.0);\n"
|
||||
"\tint a0 = 0;\n"
|
||||
"\tvec4 A, B, C, mac, ilu;\n");
|
||||
#ifdef HALO_ANDROID
|
||||
xgpu_text_append(&text, "\tvec4 clip_position = vec4(0.0);\n\tbool clip_captured = false;\n");
|
||||
#endif
|
||||
|
||||
for (index = 0; index < instruction_count; index++)
|
||||
{
|
||||
@@ -269,6 +461,14 @@ char *nv2a_vertex_shader_to_glsl(const DWORD *instructions, unsigned long instru
|
||||
char mask[5];
|
||||
|
||||
xgpu_text_append(&text, "\t/* %lu */\n", index);
|
||||
/* the lighting's normal and position, before the program reuses them */
|
||||
if (lighting && index == lighting->normal_instruction)
|
||||
{
|
||||
xgpu_text_append(&text, "\txWorldNormal = vec4(r%lu.xyz, length(r%lu.xyz));\n",
|
||||
lighting->normal_register, lighting->normal_register);
|
||||
}
|
||||
if (lighting && lighting->lights == 2 && index == lighting->position_instruction)
|
||||
xgpu_text_append(&text, "\txWorldPosition = r%lu.xyz;\n", lighting->position_register);
|
||||
xgpu_text_append(&text, "\tA = "); operand(&text, instruction, 'A', relative); xgpu_text_append(&text, ";\n");
|
||||
xgpu_text_append(&text, "\tB = "); operand(&text, instruction, 'B', relative); xgpu_text_append(&text, ";\n");
|
||||
xgpu_text_append(&text, "\tC = "); operand(&text, instruction, 'C', relative); xgpu_text_append(&text, ";\n");
|
||||
@@ -303,7 +503,6 @@ char *nv2a_vertex_shader_to_glsl(const DWORD *instructions, unsigned long instru
|
||||
case _ilu_lit: xgpu_text_append(&text, "\tilu = nv2a_lit(C);\n"); break;
|
||||
default: xgpu_text_append(&text, "\tilu = vec4(0.0);\n"); break;
|
||||
}
|
||||
#ifdef HALO_ANDROID
|
||||
/* the screen-space conversion takes the reciprocal of the clip-space
|
||||
position's w (rcc of r12.w); keep the position it converts */
|
||||
if (ilu == _ilu_rcc && field(instruction, 3, 28, 2) == _mux_temporary &&
|
||||
@@ -311,7 +510,6 @@ char *nv2a_vertex_shader_to_glsl(const DWORD *instructions, unsigned long instru
|
||||
{
|
||||
xgpu_text_append(&text, "\tclip_position = oPos;\n\tclip_captured = true;\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* results are written only after both units have read their inputs */
|
||||
if (mac == _mac_arl)
|
||||
@@ -357,21 +555,33 @@ char *nv2a_vertex_shader_to_glsl(const DWORD *instructions, unsigned long instru
|
||||
/* Direct3D 8 puts pixel centres on integer screen coordinates (the
|
||||
game offsets its screen-space quads by -0.5 to match), OpenGL on
|
||||
half-integers */
|
||||
#ifdef HALO_ANDROID
|
||||
/* The conversion is screen = clip * c[-38] * rcc(w) + c[-37]; undoing
|
||||
it by multiplying by w again is lossy near the camera plane, where
|
||||
rcc clamps and 1/w rounds differently on each GPU (Mali put vertices
|
||||
of the first-person weapon at the vanishing point). Where the clip
|
||||
position was kept, the same result is computed without dividing. */
|
||||
"\tvec4 position;\n"
|
||||
"\tif (clip_captured)\n"
|
||||
"\t\tgl_Position = vec4((clip_position.xyz * c[%d].xyz + (c[%d].xyz + vec3(0.5 + screen_offset, 0.5, 0.0)\n"
|
||||
"\t\tposition = vec4((clip_position.xyz * c[%d].xyz + (c[%d].xyz + vec3(0.5 + screen_offset, 0.5, 0.0)\n"
|
||||
"\t\t\t- viewport_offset.xyz) * clip_position.w) / scale, clip_position.w);\n"
|
||||
"\telse\n"
|
||||
"\t\tgl_Position = vec4((vec3(oPos.xy + vec2(0.5 + screen_offset, 0.5), oPos.z) - viewport_offset.xyz) / scale * oPos.w, oPos.w);\n"
|
||||
#else
|
||||
"\tvec3 ndc = (vec3(oPos.xy + vec2(0.5 + screen_offset, 0.5), oPos.z) - viewport_offset.xyz) / scale;\n"
|
||||
"\tgl_Position = vec4(ndc * oPos.w, oPos.w);\n"
|
||||
#endif
|
||||
"\t{\n"
|
||||
"\t\tvec3 ndc = (vec3(oPos.xy + vec2(0.5 + screen_offset, 0.5), oPos.z) - viewport_offset.xyz) / scale;\n"
|
||||
"\t\tposition = vec4(ndc * oPos.w, oPos.w);\n"
|
||||
"\t}\n"
|
||||
/* A position whose w is zero, or is not a number, is the clip-space
|
||||
origin: the screen conversion's reciprocal is clamped rather than
|
||||
infinite, so a large position times a w of zero is exactly zero, and
|
||||
the origin is inside the frustum. Nothing then clips the triangle
|
||||
away and OpenGL divides zero by zero there: the vertex lands on the
|
||||
middle of the screen and the triangle is drawn out to it from the
|
||||
first-person weapon, whose pose follows the camera and so reaches the
|
||||
camera plane. The divide on the Xbox sends such a vertex to infinity
|
||||
and the clipper takes the triangle; put it behind the camera instead,
|
||||
which the clipper also takes. */
|
||||
"\tif (!(abs(position.w) > 0.0))\n"
|
||||
"\t\tposition = vec4(0.0, 0.0, 0.0, -1.0);\n"
|
||||
"\tgl_Position = position;\n"
|
||||
#ifdef HALO_ANDROID
|
||||
/* what glClipControl(GL_UPPER_LEFT, GL_ZERO_TO_ONE) does on desktop
|
||||
GL: rows from the top, depth 0..1 */
|
||||
@@ -389,16 +599,16 @@ char *nv2a_vertex_shader_to_glsl(const DWORD *instructions, unsigned long instru
|
||||
"\txT2 = oT2;\n"
|
||||
"\txT3 = oT3;\n"
|
||||
"\txFog = oFog.x;\n"
|
||||
"}\n"
|
||||
"}\n",
|
||||
XGPU_VERTEX_CONSTANT_BIAS - 38, XGPU_VERTEX_CONSTANT_BIAS - 37
|
||||
#ifdef HALO_ANDROID
|
||||
, XGPU_VERTEX_CONSTANT_BIAS - 38, XGPU_VERTEX_CONSTANT_BIAS - 37,
|
||||
/* (what is drawn in screen space, which kept no clip position, is
|
||||
taken to each view as though infinitely far: a lens flare's sun
|
||||
lands where the sky's does) */
|
||||
/* (what the game projects itself, a sprite or a lens flare's
|
||||
test, comes as a screen position with w 1 and its depth in z: its
|
||||
eye's offset is by that depth, where it is depth tested) */
|
||||
multiview ?
|
||||
, multiview ?
|
||||
"\t{\n"
|
||||
"\t\tint row = int(gl_ViewID_OVR) * 2;\n"
|
||||
"\t\tfloat near = 0.0;\n"
|
||||
|
||||
@@ -274,7 +274,7 @@ struct stun_server
|
||||
struct p2p_candidate mapped;
|
||||
};
|
||||
|
||||
static pthread_mutex_t p2p_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_t p2p_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct
|
||||
{
|
||||
@@ -316,6 +316,11 @@ static struct
|
||||
int hosting_lan_only;
|
||||
int has_token;
|
||||
unsigned char token[P2P_TOKEN_SIZE];
|
||||
/* whether the server browser's exit hook is set (lobby_quit) */
|
||||
int lobby_quit_registered;
|
||||
/* whether the server browser listed this token (p2p_lobby.c): going
|
||||
private makes a new one */
|
||||
int token_listed;
|
||||
char invite[P2P_LINK_SIZE];
|
||||
int invite_copied;
|
||||
/* the game's players and its most (p2p_set_game_player_counts; 0: not
|
||||
@@ -355,7 +360,11 @@ p2p.local_address) */
|
||||
static unsigned short proxy_by_port[65536];
|
||||
|
||||
static unsigned char identifier[P2P_IDENTIFIER_SIZE];
|
||||
/* this run's X25519 keys, which the identifier comes from */
|
||||
/* this run's X25519 keys, which the identifier comes from: from an Ed25519
|
||||
seed, whose key signs the listing of a public game (p2p_lobby.c), so that a
|
||||
listing's key is also the invite's */
|
||||
static unsigned char seed[P2P_SEED_SIZE];
|
||||
static unsigned char signing_key[P2P_KEY_SIZE];
|
||||
static unsigned char secret_key[P2P_KEY_SIZE];
|
||||
static unsigned char public_key[P2P_KEY_SIZE];
|
||||
static int has_identifier;
|
||||
@@ -503,7 +512,8 @@ const unsigned char *p2p_identifier(void)
|
||||
pthread_mutex_lock(&identifier_lock);
|
||||
if (!has_identifier)
|
||||
{
|
||||
posix_random_bytes(secret_key, sizeof(secret_key));
|
||||
posix_random_bytes(seed, sizeof(seed));
|
||||
p2p_ed25519_public(seed, signing_key, secret_key);
|
||||
p2p_x25519(public_key, secret_key, NULL);
|
||||
p2p_identifier_for(public_key, identifier);
|
||||
has_identifier = 1;
|
||||
@@ -542,6 +552,18 @@ const unsigned char *p2p_public_key(void)
|
||||
return public_key;
|
||||
}
|
||||
|
||||
const unsigned char *p2p_signing_key(void)
|
||||
{
|
||||
p2p_identifier();
|
||||
return signing_key;
|
||||
}
|
||||
|
||||
void p2p_sign(const void *message, int size, unsigned char *signature)
|
||||
{
|
||||
p2p_identifier();
|
||||
p2p_ed25519_sign(seed, signing_key, message, size, signature);
|
||||
}
|
||||
|
||||
int p2p_shared_secret(const unsigned char *key, unsigned char *shared)
|
||||
{
|
||||
static const unsigned char zero[P2P_KEY_SIZE];
|
||||
@@ -2362,6 +2384,8 @@ void p2p_set_public_game(int public_game)
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
p2p_list_set_public(public_game);
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
/* (and in the server browser of every build: p2p_lobby.c) */
|
||||
p2p_set_hosting_public(public_game);
|
||||
}
|
||||
|
||||
int p2p_public_game(void)
|
||||
@@ -2382,13 +2406,53 @@ void p2p_set_game_description(const char *name, const char *map, const char *mod
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
}
|
||||
|
||||
/* the server browser's games first (every build lists its public games
|
||||
there: PC, phones, VR), then the VR port's own list's that it has not */
|
||||
int p2p_public_games(struct p2p_public_game *games, int maximum)
|
||||
{
|
||||
int count;
|
||||
struct p2p_listing listings[32];
|
||||
struct p2p_public_game own[32];
|
||||
int listing_count;
|
||||
int own_count;
|
||||
int count = 0;
|
||||
int index;
|
||||
|
||||
p2p_lobby_browse(1);
|
||||
listing_count = p2p_lobby_games(listings, 32);
|
||||
for (index = 0; index < listing_count && count < maximum; index++)
|
||||
{
|
||||
struct p2p_public_game *game;
|
||||
|
||||
/* (one with a password: joined from the server browser, which asks
|
||||
for it, not from this list, which has no way to) */
|
||||
if (listings[index].locked)
|
||||
continue;
|
||||
game = &games[count++];
|
||||
|
||||
memset(game, 0, sizeof(*game));
|
||||
snprintf(game->name, sizeof(game->name), "%s", listings[index].name);
|
||||
snprintf(game->map, sizeof(game->map), "%s", listings[index].map);
|
||||
snprintf(game->mode, sizeof(game->mode), "%s", listings[index].gametype);
|
||||
snprintf(game->invite, sizeof(game->invite), "%s", listings[index].invite);
|
||||
game->players = listings[index].player_count;
|
||||
game->maximum_players = listings[index].maximum_player_count;
|
||||
}
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
count = p2p.running ? p2p_list_games(games, maximum) : 0;
|
||||
own_count = p2p.running ? p2p_list_games(own, 32) : 0;
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
for (index = 0; index < own_count && count < maximum; index++)
|
||||
{
|
||||
int other;
|
||||
int listed = 0;
|
||||
|
||||
for (other = 0; other < listing_count; other++)
|
||||
{
|
||||
if (!strcmp(own[index].name, listings[other].name) && !strcmp(own[index].map, listings[other].map))
|
||||
listed = 1;
|
||||
}
|
||||
if (!listed)
|
||||
games[count++] = own[index];
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -2455,27 +2519,56 @@ static int connected_player_count(void)
|
||||
return count;
|
||||
}
|
||||
|
||||
/* a new invite (a new token) */
|
||||
static void make_invite(void)
|
||||
{
|
||||
unsigned char bytes[P2P_KEY_HASH_SIZE + P2P_TOKEN_SIZE];
|
||||
char text[2 * (P2P_KEY_HASH_SIZE + P2P_TOKEN_SIZE) + 1];
|
||||
|
||||
posix_random_bytes(p2p.token, sizeof(p2p.token));
|
||||
p2p.has_token = 1;
|
||||
p2p.token_listed = 0;
|
||||
p2p_key_hash(p2p_public_key(), bytes);
|
||||
memcpy(bytes + P2P_KEY_HASH_SIZE, p2p.token, P2P_TOKEN_SIZE);
|
||||
p2p_hex(bytes, sizeof(bytes), text);
|
||||
snprintf(p2p.invite, sizeof(p2p.invite), "halo://join/%s", text);
|
||||
}
|
||||
|
||||
void p2p_new_invite_if_listed(void)
|
||||
{
|
||||
if (!p2p.has_token || !p2p.token_listed)
|
||||
return;
|
||||
make_invite();
|
||||
platform_log("Internet play: a new invite, so that the one listed lets no one in (private, or a new password): %s",
|
||||
p2p.invite);
|
||||
if (p2p.hosting)
|
||||
{
|
||||
p2p_signal_host(p2p.token);
|
||||
memcpy(p2p.clipboard, p2p.invite, sizeof(p2p.clipboard));
|
||||
p2p.has_clipboard = 1;
|
||||
/* (Discord is told the new one) */
|
||||
p2p.reported_player_count = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* the hosted game's players, as the game says; else the host and the
|
||||
machines the tunnel reaches */
|
||||
static void hosted_player_counts(int *count, int *maximum)
|
||||
{
|
||||
*count = p2p.game_player_maximum > 0 ? p2p.game_player_count : connected_player_count() + 1;
|
||||
*maximum = p2p.game_player_maximum > 0 ? p2p.game_player_maximum : P2P_MAXIMUM_PEERS + 1;
|
||||
}
|
||||
|
||||
static void update_hosting(void)
|
||||
{
|
||||
int want = p2p.hosting_socket >= 0 && !p2p.hosting_lan_only;
|
||||
|
||||
if (want && !p2p.hosting)
|
||||
{
|
||||
char text[2 * (P2P_KEY_HASH_SIZE + P2P_TOKEN_SIZE) + 1];
|
||||
|
||||
/* one invite for the whole run, so a link keeps working from game
|
||||
to game */
|
||||
if (!p2p.has_token)
|
||||
{
|
||||
unsigned char bytes[P2P_KEY_HASH_SIZE + P2P_TOKEN_SIZE];
|
||||
|
||||
posix_random_bytes(p2p.token, sizeof(p2p.token));
|
||||
p2p.has_token = 1;
|
||||
p2p_key_hash(p2p_public_key(), bytes);
|
||||
memcpy(bytes + P2P_KEY_HASH_SIZE, p2p.token, P2P_TOKEN_SIZE);
|
||||
p2p_hex(bytes, sizeof(bytes), text);
|
||||
snprintf(p2p.invite, sizeof(p2p.invite), "halo://join/%s", text);
|
||||
}
|
||||
make_invite();
|
||||
p2p.hosting = 1;
|
||||
p2p.stun_started = 1;
|
||||
p2p_signal_start();
|
||||
@@ -2507,11 +2600,9 @@ static void update_hosting(void)
|
||||
}
|
||||
if (p2p.hosting)
|
||||
{
|
||||
/* the game's players, as the game says; else the host and the
|
||||
machines the tunnel reaches */
|
||||
int count = p2p.game_player_maximum > 0 ? p2p.game_player_count : connected_player_count() + 1;
|
||||
int maximum = p2p.game_player_maximum > 0 ? p2p.game_player_maximum : P2P_MAXIMUM_PEERS + 1;
|
||||
int count, maximum;
|
||||
|
||||
hosted_player_counts(&count, &maximum);
|
||||
if (count != p2p.reported_player_count || maximum != p2p.reported_player_maximum)
|
||||
{
|
||||
p2p.reported_player_count = count;
|
||||
@@ -2601,6 +2692,15 @@ static void *upnp_thread(void *unused)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* quitting: a game listed in the server browser is taken out of it at once
|
||||
(not when its listing lapses), as when it stops being hosted */
|
||||
static void lobby_quit(void)
|
||||
{
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
p2p_lobby_quit();
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
}
|
||||
|
||||
/* the game exits: the router forwards the port no longer (after a request
|
||||
under way, which may forward one, if it ends soon) */
|
||||
static void upnp_release(void)
|
||||
@@ -2637,6 +2737,9 @@ static int upnp_needed(void)
|
||||
|
||||
if (p2p.joining && elapsed(p2p.join_time, UPNP_JOIN_DELAY))
|
||||
return 1;
|
||||
/* a game in the server browser: at once (more joiners get through) */
|
||||
if (p2p_lobby_listed())
|
||||
return 1;
|
||||
for (index = 0; index < P2P_MAXIMUM_PEERS; index++)
|
||||
{
|
||||
struct peer const *peer = &p2p.peers[index];
|
||||
@@ -3013,6 +3116,24 @@ static void *p2p_thread(void *unused)
|
||||
expire_proxies();
|
||||
stun_update();
|
||||
update_hosting();
|
||||
/* the server browser (p2p_lobby.c): signalling while browsing too */
|
||||
if (p2p_lobby_browsing())
|
||||
p2p_signal_start();
|
||||
{
|
||||
int count, maximum;
|
||||
|
||||
hosted_player_counts(&count, &maximum);
|
||||
p2p_lobby_update(p2p.hosting && p2p.has_token ? p2p.token : NULL, count, maximum);
|
||||
if (p2p_lobby_listed())
|
||||
{
|
||||
p2p.token_listed = 1;
|
||||
if (!p2p.lobby_quit_registered)
|
||||
{
|
||||
p2p.lobby_quit_registered = 1;
|
||||
atexit(lobby_quit);
|
||||
}
|
||||
}
|
||||
}
|
||||
update_joining();
|
||||
update_upnp();
|
||||
p2p_discord_update();
|
||||
|
||||
@@ -74,6 +74,8 @@ struct p2p_public_game
|
||||
char code[12];
|
||||
int players;
|
||||
int maximum_players;
|
||||
/* (a game of the server browser's: no code, its invite) */
|
||||
char invite[77];
|
||||
};
|
||||
void p2p_set_public_game(int public_game);
|
||||
int p2p_public_game(void);
|
||||
@@ -140,6 +142,74 @@ are shown). The game's server calls it as they change (calling it with the
|
||||
same counts again costs little) */
|
||||
void p2p_set_game_player_counts(int count, int maximum);
|
||||
|
||||
/* ---- the server browser's public games (p2p_lobby.c) */
|
||||
|
||||
/* whether the game this machine hosts for the internet (not LAN) is listed
|
||||
in everyone's server browser: Create Game's PUBLIC; a private game is
|
||||
reached only by its invite. Going private makes a new invite, if the old one
|
||||
was listed */
|
||||
void p2p_set_hosting_public(int public);
|
||||
/* the password of the game hosted for the internet (Server Setup's
|
||||
PASSWORD; NULL or empty: none): its listing lets only those who know it
|
||||
join from the server browser (its invite link still joins it). Setting or
|
||||
changing it makes a new invite, if the old one was listed. It takes a few
|
||||
milliseconds (the password's key) */
|
||||
void p2p_set_hosting_password(const char *password);
|
||||
/* the hosted game's details as listed (printable ASCII is kept; NULL leaves
|
||||
one as it was): the game's server calls it as they change (calling it with
|
||||
the same again costs little) */
|
||||
void p2p_set_game_listing(const char *name, const char *map, const char *gametype, int engine_type, int open,
|
||||
int in_progress, int has_teams);
|
||||
/* the server browser: while on, the public games are gathered (asked for
|
||||
when turned on, and by p2p_lobby_refresh) */
|
||||
void p2p_lobby_browse(int on);
|
||||
void p2p_lobby_refresh(void);
|
||||
|
||||
enum
|
||||
{
|
||||
P2P_LISTING_NAME_SIZE = 32,
|
||||
P2P_LISTING_MAP_SIZE = 32,
|
||||
P2P_LISTING_GAMETYPE_SIZE = 24,
|
||||
/* an invite link's text (P2P_LINK_SIZE) */
|
||||
P2P_LISTING_INVITE_SIZE = 77,
|
||||
/* (struct p2p_public_game's invite is as large) */
|
||||
/* a password's game's: its host's key and its key's hash, and its token
|
||||
sealed (P2P_KEY_SIZE, P2P_KEY_HASH_SIZE, P2P_SEALED_TOKEN_SIZE) */
|
||||
P2P_LISTING_SIGNING_KEY_SIZE = 32,
|
||||
P2P_LISTING_KEY_HASH_SIZE = 16,
|
||||
P2P_LISTING_SEALED_TOKEN_SIZE = 56,
|
||||
};
|
||||
|
||||
struct p2p_listing
|
||||
{
|
||||
/* (empty for a locked one until p2p_listing_unlock opens it) */
|
||||
char invite[P2P_LISTING_INVITE_SIZE];
|
||||
/* the host's (its XNADDR's abEnet once reached) */
|
||||
unsigned char identifier[6];
|
||||
char name[P2P_LISTING_NAME_SIZE + 1];
|
||||
char map[P2P_LISTING_MAP_SIZE + 1];
|
||||
char gametype[P2P_LISTING_GAMETYPE_SIZE + 1];
|
||||
unsigned char player_count, maximum_player_count, engine_type;
|
||||
unsigned char open, in_progress, has_teams;
|
||||
/* joining it failed this run (p2p_lobby_mark_failed) */
|
||||
unsigned char failed;
|
||||
/* milliseconds, -1 if not known */
|
||||
short ping;
|
||||
/* it has a password: its invite is sealed with it (p2p_listing_unlock) */
|
||||
unsigned char locked;
|
||||
unsigned char key_hash[P2P_LISTING_KEY_HASH_SIZE];
|
||||
unsigned char signing_key[P2P_LISTING_SIGNING_KEY_SIZE];
|
||||
unsigned char sealed_token[P2P_LISTING_SEALED_TOKEN_SIZE];
|
||||
};
|
||||
/* a copy of the public games found, in the order shown (the most players
|
||||
first; then those not failed, the open ones, by name); returns their count */
|
||||
int p2p_lobby_games(struct p2p_listing *games, int maximum_count);
|
||||
/* a game the browser could not join: kept, marked failed, for this run */
|
||||
void p2p_lobby_mark_failed(const unsigned char *identifier);
|
||||
/* a locked game's invite (into its invite), if the password is its own:
|
||||
FALSE if not; TRUE for a game with none. It takes a few milliseconds */
|
||||
int p2p_listing_unlock(struct p2p_listing *listing, const char *password);
|
||||
|
||||
/* the sizes of a Discord user's id and name as kept (with their end), and
|
||||
the text kept of either as told: only the characters allowed (digits in an
|
||||
id; letters, digits, "_", "." and "-" in a name), no longer than that */
|
||||
|
||||
@@ -6,16 +6,21 @@ private (p2p.c): SHA-256 (FIPS 180-4) and HMAC-SHA256 (RFC 2104), from
|
||||
which an invite's topics and keys are derived; ChaCha20-Poly1305 (RFC 8439)
|
||||
with additional data, which seals the tunnel's packets (a counter for their
|
||||
nonce) and, with a random nonce sent ahead of the ciphertext, signalling's
|
||||
messages; and X25519 (RFC 7748), with which two machines agree on their
|
||||
tunnel's keys without sending them. The public brokers carry sealed
|
||||
messages, so only holders of the invite read them; the tunnel's packets are
|
||||
sealed with keys only its two machines have.
|
||||
messages; X25519 (RFC 7748), with which two machines agree on their
|
||||
tunnel's keys without sending them; and Ed25519 (RFC 8032, Monocypher's),
|
||||
with which a host signs its public game's listing (p2p_lobby.c). The public
|
||||
brokers carry sealed messages, so only holders of the invite read them; the
|
||||
tunnel's packets are sealed with keys only its two machines have.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "posix.h"
|
||||
#include "p2p_internal.h"
|
||||
|
||||
#include "monocypher.h"
|
||||
#include "monocypher-ed25519.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* ---------- SHA-256 */
|
||||
@@ -590,3 +595,112 @@ void p2p_x25519(unsigned char *result, const unsigned char *scalar, const unsign
|
||||
field_multiply(a, a, c);
|
||||
field_pack(result, a);
|
||||
}
|
||||
|
||||
/* ---------- Ed25519 (RFC 8032, with SHA-512), from Monocypher
|
||||
(port/third_party/monocypher): a run's key, from which its X25519 key also
|
||||
comes, signs the listing of a public game (p2p_lobby.c) */
|
||||
|
||||
void p2p_sha512(const void *data, int size, unsigned char *digest)
|
||||
{
|
||||
crypto_sha512(digest, data, (size_t)size);
|
||||
}
|
||||
|
||||
void p2p_ed25519_public(const unsigned char *seed, unsigned char *public_key, unsigned char *x25519_secret)
|
||||
{
|
||||
unsigned char copy[P2P_SEED_SIZE];
|
||||
unsigned char secret_key[64];
|
||||
unsigned char hash[64];
|
||||
|
||||
/* (the key pair's making wipes the seed it is given) */
|
||||
memcpy(copy, seed, sizeof(copy));
|
||||
crypto_ed25519_key_pair(secret_key, public_key, copy);
|
||||
if (x25519_secret)
|
||||
{
|
||||
/* the scalar Ed25519 signs with: X25519 clamps it the same way */
|
||||
p2p_sha512(seed, P2P_SEED_SIZE, hash);
|
||||
memcpy(x25519_secret, hash, P2P_KEY_SIZE);
|
||||
}
|
||||
crypto_wipe(secret_key, sizeof(secret_key));
|
||||
crypto_wipe(hash, sizeof(hash));
|
||||
}
|
||||
|
||||
void p2p_ed25519_sign(const unsigned char *seed, const unsigned char *public_key, const void *message, int size,
|
||||
unsigned char *signature)
|
||||
{
|
||||
unsigned char secret_key[64];
|
||||
|
||||
/* (Monocypher's secret key: the seed, then the public key) */
|
||||
memcpy(secret_key, seed, P2P_SEED_SIZE);
|
||||
memcpy(secret_key + P2P_SEED_SIZE, public_key, P2P_KEY_SIZE);
|
||||
crypto_ed25519_sign(signature, secret_key, message, (size_t)size);
|
||||
crypto_wipe(secret_key, sizeof(secret_key));
|
||||
}
|
||||
|
||||
int p2p_ed25519_to_x25519(const unsigned char *public_key, unsigned char *x25519_public)
|
||||
{
|
||||
static const unsigned char zero[P2P_KEY_SIZE];
|
||||
static const unsigned char scalar[P2P_KEY_SIZE] = { 1 };
|
||||
unsigned char product[P2P_KEY_SIZE];
|
||||
|
||||
crypto_eddsa_to_x25519(x25519_public, public_key);
|
||||
/* a point of small order (whose multiple by a clamped scalar, a
|
||||
multiple of 8, is 0) has signatures anyone can make, and secrets anyone
|
||||
knows */
|
||||
crypto_x25519(product, scalar, x25519_public);
|
||||
return !p2p_equal(product, zero, P2P_KEY_SIZE);
|
||||
}
|
||||
|
||||
/* ---------- passwords (a password-protected public game's listing holds
|
||||
its invite's token sealed with the password's key: p2p_lobby.c) */
|
||||
|
||||
/* (Argon2id of 4 MiB and three passes: tens of milliseconds, once for the
|
||||
host and once a guess for a joiner) */
|
||||
#define PASSWORD_KEY_BLOCKS 4096
|
||||
#define PASSWORD_KEY_PASSES 3
|
||||
|
||||
void p2p_password_key(const char *password, const unsigned char *salt, unsigned char *key)
|
||||
{
|
||||
crypto_argon2_config config = { CRYPTO_ARGON2_ID, PASSWORD_KEY_BLOCKS, PASSWORD_KEY_PASSES, 1 };
|
||||
crypto_argon2_inputs inputs;
|
||||
void *work_area = malloc((size_t)PASSWORD_KEY_BLOCKS * 1024);
|
||||
|
||||
inputs.pass = (const unsigned char *)password;
|
||||
inputs.pass_size = (unsigned int)strlen(password);
|
||||
inputs.salt = salt;
|
||||
inputs.salt_size = P2P_KEY_SIZE;
|
||||
if (!work_area)
|
||||
{
|
||||
/* (no key anyone could guess: nothing opens with it) */
|
||||
posix_random_bytes(key, P2P_PASSWORD_KEY_SIZE);
|
||||
return;
|
||||
}
|
||||
crypto_argon2(key, P2P_PASSWORD_KEY_SIZE, work_area, config, inputs, crypto_argon2_no_extras);
|
||||
crypto_wipe(work_area, (size_t)PASSWORD_KEY_BLOCKS * 1024);
|
||||
free(work_area);
|
||||
}
|
||||
|
||||
void p2p_seal_token(const unsigned char *key, const unsigned char *signing_key, const unsigned char *token,
|
||||
unsigned char *sealed)
|
||||
{
|
||||
/* (a nonce of its own each time: 24 random bytes never repeat) */
|
||||
posix_random_bytes(sealed, 24);
|
||||
crypto_aead_lock(sealed + 24 + 16, sealed + 24, key, sealed, signing_key, P2P_KEY_SIZE, token, P2P_TOKEN_SIZE);
|
||||
}
|
||||
|
||||
int p2p_unseal_token(const unsigned char *key, const unsigned char *signing_key, const unsigned char *sealed,
|
||||
unsigned char *token)
|
||||
{
|
||||
return crypto_aead_unlock(token, sealed + 24, key, sealed, signing_key, P2P_KEY_SIZE, sealed + 24 + 16,
|
||||
P2P_TOKEN_SIZE) == 0;
|
||||
}
|
||||
|
||||
int p2p_ed25519_verify(const unsigned char *public_key, const void *message, int size,
|
||||
const unsigned char *signature)
|
||||
{
|
||||
unsigned char x25519_public[P2P_KEY_SIZE];
|
||||
|
||||
/* (Monocypher's check turns away an S past the group's order: one
|
||||
signature a message) */
|
||||
return p2p_ed25519_to_x25519(public_key, x25519_public) &&
|
||||
crypto_ed25519_check(signature, public_key, message, (size_t)size) == 0;
|
||||
}
|
||||
@@ -10,6 +10,8 @@ p2p_discord.c; see p2p.c for the design).
|
||||
|
||||
#include "p2p.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
enum
|
||||
{
|
||||
/* a machine's identifier: from the hash of its public key (which is new
|
||||
@@ -31,6 +33,17 @@ enum
|
||||
P2P_MAXIMUM_PEERS = 127,
|
||||
};
|
||||
|
||||
typedef char p2p_listing_invite_size_assert[P2P_LISTING_INVITE_SIZE == P2P_LINK_SIZE ? 1 : -1];
|
||||
|
||||
/* the prefix of a public game's slot (a key hash in hex follows), and the
|
||||
topic of queries (p2p_lobby.c) */
|
||||
#define P2P_LOBBY_SLOT_PREFIX "hceu/3/lobby/s/"
|
||||
#define P2P_LOBBY_QUERY_TOPIC "hceu/3/lobby/q"
|
||||
|
||||
/* internet play's state (p2p.c), which the game's threads and the p2p
|
||||
thread share */
|
||||
extern pthread_mutex_t p2p_lock;
|
||||
|
||||
struct p2p_candidate
|
||||
{
|
||||
/* network byte order */
|
||||
@@ -57,6 +70,10 @@ int p2p_local_candidates(struct p2p_candidate *candidates, int maximum_count);
|
||||
/* this run's X25519 public key (P2P_KEY_SIZE bytes), whose hash the
|
||||
identifier is (p2p_identifier) */
|
||||
const unsigned char *p2p_public_key(void);
|
||||
/* this run's Ed25519 public key (the X25519 one's, p2p_ed25519_to_x25519),
|
||||
and a signature with it */
|
||||
const unsigned char *p2p_signing_key(void);
|
||||
void p2p_sign(const void *message, int size, unsigned char *signature);
|
||||
/* the identifier of the machine with this public key */
|
||||
void p2p_identifier_for(const unsigned char *public_key, unsigned char *identifier);
|
||||
/* the hash of a public key an invite holds (P2P_KEY_HASH_SIZE bytes), and
|
||||
@@ -87,6 +104,10 @@ int p2p_peer_reoffered(const unsigned char *identifier, const unsigned char *sec
|
||||
/* an invite that arrived on the p2p thread (from Discord, or another copy
|
||||
of the game) */
|
||||
void p2p_invite_received(const char *text);
|
||||
/* a new invite (token) for the game hosted, if its invite was listed in the
|
||||
server browser (going private: those who saw it must not get in); under
|
||||
p2p_lock */
|
||||
void p2p_new_invite_if_listed(void);
|
||||
|
||||
/* ---------- p2p_signal.c: signalling through public MQTT brokers */
|
||||
|
||||
@@ -154,6 +175,20 @@ const char *p2p_list_topic(void);
|
||||
int p2p_list_received(const char *topic, const unsigned char *payload, int size);
|
||||
void p2p_list_update(int hosting);
|
||||
|
||||
/* the server browser's topics: the own slot and the queries (a listed
|
||||
game), and every slot (browsing) */
|
||||
void p2p_signal_lobby_topics(int listed, int browsing);
|
||||
/* publishes a listing to the own slot on every broker, retained, and again
|
||||
on each broker that connects later; closing: a tombstone, after which the
|
||||
slot is cleared and nothing is published again */
|
||||
void p2p_signal_lobby_publish(const unsigned char *listing, int size, int closing);
|
||||
/* asks the hosts to publish again */
|
||||
void p2p_signal_lobby_query(void);
|
||||
/* the game is quitting: the tombstone published (p2p_signal_lobby_publish)
|
||||
and the slot cleared on every ready broker now, whatever their buckets, and
|
||||
the connections closed cleanly */
|
||||
void p2p_signal_lobby_quit(void);
|
||||
|
||||
/* ---------- p2p_crypto.c */
|
||||
|
||||
enum
|
||||
@@ -189,6 +224,67 @@ int p2p_equal(const void *first, const void *second, int size);
|
||||
key of the secret key scalar) */
|
||||
void p2p_x25519(unsigned char *result, const unsigned char *scalar, const unsigned char *point);
|
||||
|
||||
enum
|
||||
{
|
||||
/* an Ed25519 seed (a run's key comes from one) and signature */
|
||||
P2P_SEED_SIZE = 32,
|
||||
P2P_SIGNATURE_SIZE = 64,
|
||||
P2P_SHA512_SIZE = 64,
|
||||
};
|
||||
|
||||
void p2p_sha512(const void *data, int size, unsigned char *digest);
|
||||
/* Ed25519 (with SHA-512): a seed's public key (P2P_KEY_SIZE bytes) and,
|
||||
unless NULL, its X25519 secret key (the scalar it signs with, whose X25519
|
||||
public key is p2p_ed25519_to_x25519 of the Ed25519 one) */
|
||||
void p2p_ed25519_public(const unsigned char *seed, unsigned char *public_key, unsigned char *x25519_secret);
|
||||
void p2p_ed25519_sign(const unsigned char *seed, const unsigned char *public_key, const void *message, int size,
|
||||
unsigned char *signature);
|
||||
/* whether the signature is the key's, of the message (never for a key of
|
||||
small order, which anyone can sign for) */
|
||||
int p2p_ed25519_verify(const unsigned char *public_key, const void *message, int size,
|
||||
const unsigned char *signature);
|
||||
/* the X25519 public key of an Ed25519 one; 0 if it has a small order */
|
||||
int p2p_ed25519_to_x25519(const unsigned char *public_key, unsigned char *x25519_public);
|
||||
|
||||
enum
|
||||
{
|
||||
/* a password-protected listing's token, sealed (p2p_seal_token): its
|
||||
nonce (24), its tag (16), then the token sealed */
|
||||
P2P_PASSWORD_KEY_SIZE = 32,
|
||||
P2P_SEALED_TOKEN_SIZE = 24 + 16 + 16,
|
||||
};
|
||||
|
||||
/* the key of a password (Argon2id: P2P_PASSWORD_KEY_SIZE bytes), for the
|
||||
host whose Ed25519 key salt is (P2P_KEY_SIZE bytes): it takes a few
|
||||
milliseconds, so that guessing passwords at a listing takes long */
|
||||
void p2p_password_key(const char *password, const unsigned char *salt, unsigned char *key);
|
||||
/* a token (P2P_TOKEN_SIZE bytes) sealed with a password's key, bound to the
|
||||
host's Ed25519 key (P2P_SEALED_TOKEN_SIZE bytes); and opened: 0 if the key
|
||||
is not the one it was sealed with (a wrong password), or it was altered */
|
||||
void p2p_seal_token(const unsigned char *key, const unsigned char *signing_key, const unsigned char *token,
|
||||
unsigned char *sealed);
|
||||
int p2p_unseal_token(const unsigned char *key, const unsigned char *signing_key, const unsigned char *sealed,
|
||||
unsigned char *token);
|
||||
|
||||
/* ---------- p2p_lobby.c: public games' listings */
|
||||
|
||||
/* the p2p thread's pass: the token of the game hosted for the internet
|
||||
(NULL if none) and its player counts */
|
||||
void p2p_lobby_update(const unsigned char *token, int player_count, int maximum_player_count);
|
||||
/* whether the game hosted is listed now, and whether the browser is open */
|
||||
int p2p_lobby_listed(void);
|
||||
int p2p_lobby_browsing(void);
|
||||
/* a message on a slot (its key hash in hex) through a broker; retained: the
|
||||
slot's retained copy, sent on subscribing */
|
||||
void p2p_lobby_slot_heard(const char *hash_text, const unsigned char *payload, int size, int retained);
|
||||
/* a query was heard */
|
||||
void p2p_lobby_query_heard(void);
|
||||
/* the game is quitting: a listed game's tombstone, and its slot cleared,
|
||||
written to the brokers at once; under p2p_lock */
|
||||
void p2p_lobby_quit(void);
|
||||
/* a key hash's slot */
|
||||
void p2p_lobby_slot_topic(const unsigned char *key_hash, char *topic, int size);
|
||||
|
||||
/* ---------- p2p_discord.c: rich presence and invites through the Discord
|
||||
desktop client */
|
||||
|
||||
|
||||
@@ -0,0 +1,880 @@
|
||||
/*
|
||||
P2P_LOBBY.C
|
||||
|
||||
Internet play's public games (the server browser, Join Game > Server
|
||||
Browser): a public game's host publishes a signed listing of it through the
|
||||
signalling brokers (p2p_signal.c), and browsers gather the listings and join
|
||||
a game by the invite a listing holds, as an invite link would.
|
||||
|
||||
The listing (network byte order) is signed with the host's Ed25519 key,
|
||||
whose X25519 form's hash is the invite's host part (p2p.c), so no one but
|
||||
the host can list its invite, alter its listing, or list another's under
|
||||
false details:
|
||||
|
||||
"HL", format 1, the lobby version (2: HALO_PORT_NETWORK_VERSION; browsers
|
||||
hide others), flags (open, under way, teams, closed, password), sequence
|
||||
(4: newest wins), Unix time (4), the Ed25519 key (32), the invite's token
|
||||
(16; a password's game's sealed with the password's key, 56:
|
||||
p2p_seal_token; a tombstone's zero), players, most players, the
|
||||
gametype's engine (1 each), the game's name,
|
||||
map and gametype (a length byte, then up to 32, 32 and 24 characters of
|
||||
printable ASCII), a stamp (8, reserved: zero), and the signature (64) of
|
||||
"hceu-lobby-1" and all before it.
|
||||
|
||||
Each host has a slot, hceu/3/lobby/s/<its key's hash in hex>: its listing,
|
||||
retained on every broker (and expiring there after LISTING_EXPIRY seconds
|
||||
on MQTT 5), and the broker's will (set at the connection, p2p_signal.c)
|
||||
clears it if the host vanishes. Browsers subscribe to every slot and ask the
|
||||
hosts to publish again (hceu/3/lobby/q). Brokers are other people's: what
|
||||
one deletes or keeps is no authority, so
|
||||
- a host publishes every REPUBLISH_INTERVAL, and sooner (at most once each
|
||||
TRIGGER_INTERVAL) when its game changes, when asked, and when its slot is
|
||||
heard to hold anything but its listing (cleared, another's, or an older
|
||||
one of its own): a deletion is undone in seconds;
|
||||
- a browser takes only a signed listing whose key's hash is its slot's,
|
||||
keeps the newest of each host (by sequence), drops one not heard in
|
||||
GAME_EXPIRY (on its own clock; a retained copy is taken only if its time
|
||||
is within RETAINED_WINDOW of this machine's, from a host that died and
|
||||
left it), takes a host's closing listing (a tombstone) as its end, and
|
||||
ignores an emptied slot (a wipe is not a delete).
|
||||
A host that stops publishes a tombstone, then clears its slot. Going private
|
||||
makes a new invite (p2p.c), so a listing seen before lets no one in.
|
||||
|
||||
A game with a password (Server Setup's PASSWORD: p2p_set_hosting_password)
|
||||
is listed with its token sealed with the password's key (Argon2id of the
|
||||
password, salted with the host's key: p2p_password_key), so that only who
|
||||
knows the password can join it from the server browser
|
||||
(p2p_listing_unlock); its invite link, which holds the token, still joins it
|
||||
as any invite does. Setting or changing the password makes a new invite, as
|
||||
going private does.
|
||||
|
||||
Checking signatures takes work, and anyone can send listings: at most
|
||||
VERIFY_BUDGET milliseconds of it each pass of the p2p thread, from a queue
|
||||
of MAXIMUM_QUEUED; the rest is dropped (hosts publish again).
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "posix.h"
|
||||
#include "port_config.h"
|
||||
#include "p2p_internal.h"
|
||||
#include "halo_port_limits.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
enum
|
||||
{
|
||||
LISTING_FORMAT = 1,
|
||||
_listing_open = 1,
|
||||
_listing_in_progress = 2,
|
||||
_listing_has_teams = 4,
|
||||
/* a tombstone: the host stopped */
|
||||
_listing_closed = 8,
|
||||
/* its token sealed with a password's key */
|
||||
_listing_password = 16,
|
||||
STAMP_SIZE = 8,
|
||||
/* the signed part's end: everything but the signature */
|
||||
MAXIMUM_LISTING_SIZE = 2 + 1 + 2 + 1 + 4 + 4 + P2P_KEY_SIZE + P2P_SEALED_TOKEN_SIZE + 3 +
|
||||
(1 + P2P_LISTING_NAME_SIZE) + (1 + P2P_LISTING_MAP_SIZE) + (1 + P2P_LISTING_GAMETYPE_SIZE) + STAMP_SIZE +
|
||||
P2P_SIGNATURE_SIZE,
|
||||
MINIMUM_LISTING_SIZE = 2 + 1 + 2 + 1 + 4 + 4 + P2P_KEY_SIZE + P2P_TOKEN_SIZE + 3 + 3 + STAMP_SIZE +
|
||||
P2P_SIGNATURE_SIZE,
|
||||
MAXIMUM_GAMES = 256,
|
||||
MAXIMUM_TOMBSTONES = 256,
|
||||
MAXIMUM_QUEUED = 64,
|
||||
|
||||
/* milliseconds */
|
||||
REPUBLISH_INTERVAL = 30000,
|
||||
TRIGGER_INTERVAL = 5000,
|
||||
QUERY_JITTER = 2000,
|
||||
GAME_EXPIRY = 90000,
|
||||
TOMBSTONE_TIME = 600000,
|
||||
VERIFY_BUDGET = 2,
|
||||
/* seconds */
|
||||
RETAINED_WINDOW = 600,
|
||||
};
|
||||
|
||||
static const char signature_label[] = "hceu-lobby-1";
|
||||
|
||||
/* (p2p.h's sizes of a locked listing's are p2p_internal.h's) */
|
||||
typedef char check_listing_sizes[P2P_LISTING_SIGNING_KEY_SIZE == P2P_KEY_SIZE &&
|
||||
P2P_LISTING_KEY_HASH_SIZE == P2P_KEY_HASH_SIZE && P2P_LISTING_SEALED_TOKEN_SIZE == P2P_SEALED_TOKEN_SIZE ? 1 : -1];
|
||||
|
||||
/* a listing, read */
|
||||
struct listing
|
||||
{
|
||||
int version;
|
||||
int flags;
|
||||
unsigned long sequence;
|
||||
unsigned long time;
|
||||
unsigned char key[P2P_KEY_SIZE];
|
||||
unsigned char token[P2P_TOKEN_SIZE];
|
||||
/* (_listing_password: its token, sealed) */
|
||||
unsigned char sealed_token[P2P_SEALED_TOKEN_SIZE];
|
||||
int player_count, maximum_player_count, engine_type;
|
||||
char name[P2P_LISTING_NAME_SIZE + 1];
|
||||
char map[P2P_LISTING_MAP_SIZE + 1];
|
||||
char gametype[P2P_LISTING_GAMETYPE_SIZE + 1];
|
||||
/* the signed part's size */
|
||||
int signed_size;
|
||||
};
|
||||
|
||||
struct game
|
||||
{
|
||||
int used;
|
||||
unsigned char key_hash[P2P_KEY_HASH_SIZE];
|
||||
unsigned long sequence;
|
||||
unsigned long heard_time;
|
||||
/* as it came (one the same again needs no check) */
|
||||
unsigned char payload[MAXIMUM_LISTING_SIZE];
|
||||
int payload_size;
|
||||
struct p2p_listing listing;
|
||||
};
|
||||
|
||||
struct tombstone
|
||||
{
|
||||
unsigned char key_hash[P2P_KEY_HASH_SIZE];
|
||||
unsigned long sequence;
|
||||
unsigned long time;
|
||||
};
|
||||
|
||||
struct queued
|
||||
{
|
||||
unsigned char key_hash[P2P_KEY_HASH_SIZE];
|
||||
unsigned char payload[MAXIMUM_LISTING_SIZE];
|
||||
int size;
|
||||
int retained;
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
/* hosting: the game as the game's server tells it
|
||||
(p2p_set_game_listing), and whether it is public (p2p_set_hosting_public) */
|
||||
int public;
|
||||
char name[P2P_LISTING_NAME_SIZE + 1];
|
||||
char map[P2P_LISTING_MAP_SIZE + 1];
|
||||
char gametype[P2P_LISTING_GAMETYPE_SIZE + 1];
|
||||
int engine_type;
|
||||
int flags;
|
||||
int player_count, maximum_player_count;
|
||||
/* the password's key (p2p_set_hosting_password), if it has one */
|
||||
int has_password;
|
||||
unsigned char password_key[P2P_PASSWORD_KEY_SIZE];
|
||||
/* listed: with this token; its listing as last published */
|
||||
int listed;
|
||||
unsigned char token[P2P_TOKEN_SIZE];
|
||||
unsigned long sequence;
|
||||
unsigned char listing[MAXIMUM_LISTING_SIZE];
|
||||
int listing_size;
|
||||
unsigned long published_time;
|
||||
/* a publish wanted (the game changed, a query, the slot needs mending),
|
||||
not before this */
|
||||
int republish_wanted;
|
||||
unsigned long republish_time;
|
||||
|
||||
/* browsing */
|
||||
int browsing;
|
||||
int query_wanted;
|
||||
struct queued queue[MAXIMUM_QUEUED];
|
||||
int queue_count;
|
||||
struct game games[MAXIMUM_GAMES];
|
||||
struct tombstone tombstones[MAXIMUM_TOMBSTONES];
|
||||
int next_tombstone;
|
||||
/* the identifiers of games joining failed */
|
||||
unsigned char failed[MAXIMUM_GAMES][P2P_IDENTIFIER_SIZE];
|
||||
int failed_count;
|
||||
} lobby;
|
||||
|
||||
static int elapsed(unsigned long since, unsigned long time)
|
||||
{
|
||||
return (unsigned int)(p2p_now() - since) >= (unsigned int)time;
|
||||
}
|
||||
|
||||
/* printable ASCII, as the menus' font has it (others: '?'), cut to size */
|
||||
static void sanitize(char *destination, int size, const char *source, int source_size)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < size && index < source_size && source[index]; index++)
|
||||
{
|
||||
unsigned char character = (unsigned char)source[index];
|
||||
|
||||
destination[index] = character >= 0x20 && character < 0x7F ? (char)character : '?';
|
||||
}
|
||||
destination[index] = 0;
|
||||
}
|
||||
|
||||
void p2p_lobby_slot_topic(const unsigned char *key_hash, char *topic, int size)
|
||||
{
|
||||
char text[2 * P2P_KEY_HASH_SIZE + 1];
|
||||
|
||||
p2p_hex(key_hash, P2P_KEY_HASH_SIZE, text);
|
||||
snprintf(topic, (size_t)size, "%s%s", P2P_LOBBY_SLOT_PREFIX, text);
|
||||
}
|
||||
|
||||
/* the hash of an Ed25519 key's X25519 form (an invite's host part); 0 if
|
||||
the key has a small order */
|
||||
static int signing_key_hash(const unsigned char *key, unsigned char *hash)
|
||||
{
|
||||
unsigned char x25519[P2P_KEY_SIZE];
|
||||
|
||||
if (!p2p_ed25519_to_x25519(key, x25519))
|
||||
return 0;
|
||||
p2p_key_hash(x25519, hash);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ---------- the listing */
|
||||
|
||||
static void put_long(unsigned char *bytes, unsigned long value)
|
||||
{
|
||||
bytes[0] = (unsigned char)(value >> 24);
|
||||
bytes[1] = (unsigned char)(value >> 16);
|
||||
bytes[2] = (unsigned char)(value >> 8);
|
||||
bytes[3] = (unsigned char)value;
|
||||
}
|
||||
|
||||
static unsigned long get_long(const unsigned char *bytes)
|
||||
{
|
||||
return (unsigned long)bytes[0] << 24 | (unsigned long)bytes[1] << 16 | (unsigned long)bytes[2] << 8 | bytes[3];
|
||||
}
|
||||
|
||||
static int put_text(unsigned char *bytes, const char *text, int maximum)
|
||||
{
|
||||
int length = (int)strlen(text);
|
||||
|
||||
length = length > maximum ? maximum : length;
|
||||
bytes[0] = (unsigned char)length;
|
||||
memcpy(bytes + 1, text, (size_t)length);
|
||||
return 1 + length;
|
||||
}
|
||||
|
||||
/* the listing of the game hosted, signed: flags (_listing_closed for a
|
||||
tombstone) */
|
||||
static int listing_make(unsigned char *bytes, int flags)
|
||||
{
|
||||
unsigned char *signed_part = bytes;
|
||||
unsigned char data[sizeof(signature_label) - 1 + MAXIMUM_LISTING_SIZE];
|
||||
int size = 0;
|
||||
|
||||
if (lobby.has_password && !(flags & _listing_closed))
|
||||
flags |= _listing_password;
|
||||
bytes[size++] = 'H';
|
||||
bytes[size++] = 'L';
|
||||
bytes[size++] = LISTING_FORMAT;
|
||||
bytes[size++] = (unsigned char)(HALO_PORT_NETWORK_VERSION >> 8);
|
||||
bytes[size++] = (unsigned char)HALO_PORT_NETWORK_VERSION;
|
||||
bytes[size++] = (unsigned char)flags;
|
||||
put_long(bytes + size, ++lobby.sequence);
|
||||
size += 4;
|
||||
put_long(bytes + size, (unsigned long)time(NULL));
|
||||
size += 4;
|
||||
memcpy(bytes + size, p2p_signing_key(), P2P_KEY_SIZE);
|
||||
size += P2P_KEY_SIZE;
|
||||
if (flags & _listing_password)
|
||||
{
|
||||
p2p_seal_token(lobby.password_key, p2p_signing_key(), lobby.token, bytes + size);
|
||||
size += P2P_SEALED_TOKEN_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* (a tombstone's none: it may end a game with a password) */
|
||||
if (flags & _listing_closed)
|
||||
memset(bytes + size, 0, P2P_TOKEN_SIZE);
|
||||
else
|
||||
memcpy(bytes + size, lobby.token, P2P_TOKEN_SIZE);
|
||||
size += P2P_TOKEN_SIZE;
|
||||
}
|
||||
bytes[size++] = (unsigned char)(lobby.player_count > 255 ? 255 : lobby.player_count);
|
||||
bytes[size++] = (unsigned char)(lobby.maximum_player_count > 255 ? 255 : lobby.maximum_player_count);
|
||||
bytes[size++] = (unsigned char)lobby.engine_type;
|
||||
size += put_text(bytes + size, lobby.name, P2P_LISTING_NAME_SIZE);
|
||||
size += put_text(bytes + size, lobby.map, P2P_LISTING_MAP_SIZE);
|
||||
size += put_text(bytes + size, lobby.gametype, P2P_LISTING_GAMETYPE_SIZE);
|
||||
memset(bytes + size, 0, STAMP_SIZE);
|
||||
size += STAMP_SIZE;
|
||||
memcpy(data, signature_label, sizeof(signature_label) - 1);
|
||||
memcpy(data + sizeof(signature_label) - 1, signed_part, (size_t)size);
|
||||
p2p_sign(data, (int)(sizeof(signature_label) - 1) + size, bytes + size);
|
||||
return size + P2P_SIGNATURE_SIZE;
|
||||
}
|
||||
|
||||
static int get_text(const unsigned char *bytes, int size, int *offset, char *text, int maximum)
|
||||
{
|
||||
int length;
|
||||
|
||||
if (*offset >= size)
|
||||
return 0;
|
||||
length = bytes[(*offset)++];
|
||||
if (length > maximum || *offset + length > size)
|
||||
return 0;
|
||||
sanitize(text, maximum, (const char *)bytes + *offset, length);
|
||||
*offset += length;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* reads a listing (not its signature); 0 if it is malformed */
|
||||
static int listing_read(const unsigned char *bytes, int size, struct listing *listing)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
if (size < MINIMUM_LISTING_SIZE || size > MAXIMUM_LISTING_SIZE || bytes[0] != 'H' || bytes[1] != 'L' ||
|
||||
bytes[2] != LISTING_FORMAT)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
offset = 3;
|
||||
listing->version = bytes[offset] << 8 | bytes[offset + 1];
|
||||
offset += 2;
|
||||
listing->flags = bytes[offset++];
|
||||
listing->sequence = get_long(bytes + offset);
|
||||
offset += 4;
|
||||
listing->time = get_long(bytes + offset);
|
||||
offset += 4;
|
||||
memcpy(listing->key, bytes + offset, P2P_KEY_SIZE);
|
||||
offset += P2P_KEY_SIZE;
|
||||
if (listing->flags & _listing_password)
|
||||
{
|
||||
/* (its token sealed, which is longer: the counts after it too) */
|
||||
if (offset + P2P_SEALED_TOKEN_SIZE + 3 > size)
|
||||
return 0;
|
||||
memset(listing->token, 0, P2P_TOKEN_SIZE);
|
||||
memcpy(listing->sealed_token, bytes + offset, P2P_SEALED_TOKEN_SIZE);
|
||||
offset += P2P_SEALED_TOKEN_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(listing->token, bytes + offset, P2P_TOKEN_SIZE);
|
||||
offset += P2P_TOKEN_SIZE;
|
||||
}
|
||||
listing->player_count = bytes[offset++];
|
||||
listing->maximum_player_count = bytes[offset++];
|
||||
listing->engine_type = bytes[offset++];
|
||||
if (!get_text(bytes, size, &offset, listing->name, P2P_LISTING_NAME_SIZE) ||
|
||||
!get_text(bytes, size, &offset, listing->map, P2P_LISTING_MAP_SIZE) ||
|
||||
!get_text(bytes, size, &offset, listing->gametype, P2P_LISTING_GAMETYPE_SIZE))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
offset += STAMP_SIZE;
|
||||
if (offset + P2P_SIGNATURE_SIZE != size)
|
||||
return 0;
|
||||
listing->signed_size = offset;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int listing_signed(const unsigned char *bytes, const struct listing *listing)
|
||||
{
|
||||
unsigned char data[sizeof(signature_label) - 1 + MAXIMUM_LISTING_SIZE];
|
||||
|
||||
memcpy(data, signature_label, sizeof(signature_label) - 1);
|
||||
memcpy(data + sizeof(signature_label) - 1, bytes, (size_t)listing->signed_size);
|
||||
return p2p_ed25519_verify(listing->key, data, (int)(sizeof(signature_label) - 1) + listing->signed_size,
|
||||
bytes + listing->signed_size);
|
||||
}
|
||||
|
||||
/* ---------- hosting */
|
||||
|
||||
static void publish(void)
|
||||
{
|
||||
lobby.listing_size = listing_make(lobby.listing, lobby.flags);
|
||||
lobby.published_time = p2p_now();
|
||||
lobby.republish_wanted = 0;
|
||||
p2p_signal_lobby_publish(lobby.listing, lobby.listing_size, 0);
|
||||
}
|
||||
|
||||
/* a publish soon: at once if none was lately, else when TRIGGER_INTERVAL
|
||||
has passed (plus jitter) */
|
||||
static void republish_soon(unsigned long jitter)
|
||||
{
|
||||
unsigned long earliest = lobby.published_time + TRIGGER_INTERVAL;
|
||||
unsigned long when = p2p_now() + jitter;
|
||||
|
||||
if ((long)(earliest - when) > 0)
|
||||
when = earliest;
|
||||
if (!lobby.republish_wanted || (long)(lobby.republish_time - when) > 0)
|
||||
lobby.republish_time = when;
|
||||
lobby.republish_wanted = 1;
|
||||
}
|
||||
|
||||
static void stop_listing(void)
|
||||
{
|
||||
unsigned char tombstone[MAXIMUM_LISTING_SIZE];
|
||||
int size = listing_make(tombstone, _listing_closed);
|
||||
|
||||
lobby.listed = 0;
|
||||
lobby.republish_wanted = 0;
|
||||
p2p_signal_lobby_publish(tombstone, size, 1);
|
||||
p2p_signal_lobby_topics(0, lobby.browsing);
|
||||
platform_log("Internet play: the game is no longer listed in the server browser");
|
||||
}
|
||||
|
||||
static void update_hosting(const unsigned char *token, int player_count, int maximum_player_count)
|
||||
{
|
||||
int want = token && lobby.public && config_boolean("network.public_lobby");
|
||||
|
||||
if (lobby.listed && (!want || memcmp(token, lobby.token, P2P_TOKEN_SIZE)))
|
||||
stop_listing();
|
||||
if (!want)
|
||||
return;
|
||||
if (player_count != lobby.player_count || maximum_player_count != lobby.maximum_player_count)
|
||||
{
|
||||
lobby.player_count = player_count;
|
||||
lobby.maximum_player_count = maximum_player_count;
|
||||
if (lobby.listed)
|
||||
republish_soon(0);
|
||||
}
|
||||
if (!lobby.listed)
|
||||
{
|
||||
memcpy(lobby.token, token, P2P_TOKEN_SIZE);
|
||||
lobby.listed = 1;
|
||||
p2p_signal_lobby_topics(1, lobby.browsing);
|
||||
publish();
|
||||
platform_log("Internet play: the game is listed in everyone's server browser (public)");
|
||||
return;
|
||||
}
|
||||
if ((lobby.republish_wanted && (long)(p2p_now() - lobby.republish_time) >= 0) ||
|
||||
elapsed(lobby.published_time, REPUBLISH_INTERVAL))
|
||||
{
|
||||
publish();
|
||||
}
|
||||
}
|
||||
|
||||
void p2p_lobby_query_heard(void)
|
||||
{
|
||||
if (lobby.listed)
|
||||
{
|
||||
unsigned short jitter;
|
||||
|
||||
posix_random_bytes(&jitter, sizeof(jitter));
|
||||
republish_soon(jitter % QUERY_JITTER);
|
||||
}
|
||||
}
|
||||
|
||||
/* the host's own slot was heard: anything but its listing is mended */
|
||||
static void own_slot_heard(const unsigned char *payload, int size, int retained)
|
||||
{
|
||||
struct listing listing;
|
||||
|
||||
if (!lobby.listed || (size == lobby.listing_size && !memcmp(payload, lobby.listing, (size_t)size)))
|
||||
return;
|
||||
/* (an older listing of its own, forwarded live, is the echo of a publish
|
||||
before the last; as the slot's retained copy, the slot holds it) */
|
||||
if (!retained && listing_read(payload, size, &listing) && !memcmp(listing.key, p2p_signing_key(), P2P_KEY_SIZE) &&
|
||||
listing.sequence < lobby.sequence)
|
||||
{
|
||||
return;
|
||||
}
|
||||
republish_soon(0);
|
||||
}
|
||||
|
||||
/* ---------- browsing */
|
||||
|
||||
static struct game *find_game(const unsigned char *key_hash)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < MAXIMUM_GAMES; index++)
|
||||
{
|
||||
if (lobby.games[index].used && !memcmp(lobby.games[index].key_hash, key_hash, P2P_KEY_HASH_SIZE))
|
||||
return &lobby.games[index];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct tombstone *find_tombstone(const unsigned char *key_hash)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < MAXIMUM_TOMBSTONES; index++)
|
||||
{
|
||||
struct tombstone *tombstone = &lobby.tombstones[index];
|
||||
|
||||
if (tombstone->time && !elapsed(tombstone->time, TOMBSTONE_TIME) &&
|
||||
!memcmp(tombstone->key_hash, key_hash, P2P_KEY_HASH_SIZE))
|
||||
{
|
||||
return tombstone;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int identifier_failed(const unsigned char *identifier)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < lobby.failed_count; index++)
|
||||
{
|
||||
if (!memcmp(lobby.failed[index], identifier, P2P_IDENTIFIER_SIZE))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void p2p_lobby_slot_heard(const char *hash_text, const unsigned char *payload, int size, int retained)
|
||||
{
|
||||
unsigned char key_hash[P2P_KEY_HASH_SIZE];
|
||||
struct game *game;
|
||||
struct queued *queued;
|
||||
int index;
|
||||
|
||||
if (strlen(hash_text) != 2 * P2P_KEY_HASH_SIZE || strspn(hash_text, "0123456789abcdef") != 2 * P2P_KEY_HASH_SIZE)
|
||||
return;
|
||||
for (index = 0; index < P2P_KEY_HASH_SIZE; index++)
|
||||
{
|
||||
unsigned int byte;
|
||||
|
||||
sscanf(hash_text + 2 * index, "%2x", &byte);
|
||||
key_hash[index] = (unsigned char)byte;
|
||||
}
|
||||
{
|
||||
unsigned char own[P2P_KEY_HASH_SIZE];
|
||||
|
||||
p2p_key_hash(p2p_public_key(), own);
|
||||
if (!memcmp(own, key_hash, P2P_KEY_HASH_SIZE))
|
||||
own_slot_heard(payload, size, retained);
|
||||
}
|
||||
/* (an emptied slot is no news: a wipe is not a delete) */
|
||||
if (!lobby.browsing || size < MINIMUM_LISTING_SIZE || size > MAXIMUM_LISTING_SIZE)
|
||||
return;
|
||||
/* the same listing again: heard, no work */
|
||||
game = find_game(key_hash);
|
||||
if (game && game->payload_size == size && !memcmp(game->payload, payload, (size_t)size))
|
||||
{
|
||||
game->heard_time = p2p_now();
|
||||
return;
|
||||
}
|
||||
for (index = 0; index < lobby.queue_count; index++)
|
||||
{
|
||||
if (lobby.queue[index].size == size && !memcmp(lobby.queue[index].payload, payload, (size_t)size))
|
||||
return;
|
||||
}
|
||||
if (lobby.queue_count == MAXIMUM_QUEUED)
|
||||
return;
|
||||
queued = &lobby.queue[lobby.queue_count++];
|
||||
memcpy(queued->key_hash, key_hash, P2P_KEY_HASH_SIZE);
|
||||
memcpy(queued->payload, payload, (size_t)size);
|
||||
queued->size = size;
|
||||
queued->retained = retained;
|
||||
}
|
||||
|
||||
/* a queued listing, its signature checked: taken or not */
|
||||
static void listing_take(const struct queued *queued, const struct listing *listing)
|
||||
{
|
||||
struct tombstone *tombstone = find_tombstone(queued->key_hash);
|
||||
struct game *game = find_game(queued->key_hash);
|
||||
struct p2p_listing *shown;
|
||||
unsigned char bytes[P2P_KEY_HASH_SIZE + P2P_TOKEN_SIZE];
|
||||
char text[2 * (P2P_KEY_HASH_SIZE + P2P_TOKEN_SIZE) + 1];
|
||||
int index;
|
||||
|
||||
if (tombstone && listing->sequence <= tombstone->sequence)
|
||||
return;
|
||||
if (game && listing->sequence <= game->sequence)
|
||||
return;
|
||||
if (listing->flags & _listing_closed)
|
||||
{
|
||||
if (!tombstone)
|
||||
{
|
||||
tombstone = &lobby.tombstones[lobby.next_tombstone];
|
||||
lobby.next_tombstone = (lobby.next_tombstone + 1) % MAXIMUM_TOMBSTONES;
|
||||
memcpy(tombstone->key_hash, queued->key_hash, P2P_KEY_HASH_SIZE);
|
||||
}
|
||||
tombstone->sequence = listing->sequence;
|
||||
tombstone->time = p2p_now() ? p2p_now() : 1;
|
||||
if (game)
|
||||
game->used = 0;
|
||||
return;
|
||||
}
|
||||
if (!game)
|
||||
{
|
||||
/* the room of one gone longest, if there is none free */
|
||||
for (index = 0; index < MAXIMUM_GAMES && lobby.games[index].used; index++)
|
||||
;
|
||||
if (index == MAXIMUM_GAMES)
|
||||
{
|
||||
int oldest = 0;
|
||||
|
||||
for (index = 1; index < MAXIMUM_GAMES; index++)
|
||||
{
|
||||
if ((long)(lobby.games[index].heard_time - lobby.games[oldest].heard_time) < 0)
|
||||
oldest = index;
|
||||
}
|
||||
index = oldest;
|
||||
}
|
||||
game = &lobby.games[index];
|
||||
memset(game, 0, sizeof(*game));
|
||||
memcpy(game->key_hash, queued->key_hash, P2P_KEY_HASH_SIZE);
|
||||
game->used = 1;
|
||||
}
|
||||
game->sequence = listing->sequence;
|
||||
game->heard_time = p2p_now();
|
||||
memcpy(game->payload, queued->payload, (size_t)queued->size);
|
||||
game->payload_size = queued->size;
|
||||
shown = &game->listing;
|
||||
shown->locked = (listing->flags & _listing_password) != 0;
|
||||
if (shown->locked)
|
||||
{
|
||||
/* (its invite once the password opens its token: p2p_listing_unlock) */
|
||||
shown->invite[0] = 0;
|
||||
memcpy(shown->key_hash, queued->key_hash, P2P_KEY_HASH_SIZE);
|
||||
memcpy(shown->signing_key, listing->key, P2P_KEY_SIZE);
|
||||
memcpy(shown->sealed_token, listing->sealed_token, P2P_SEALED_TOKEN_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(bytes, queued->key_hash, P2P_KEY_HASH_SIZE);
|
||||
memcpy(bytes + P2P_KEY_HASH_SIZE, listing->token, P2P_TOKEN_SIZE);
|
||||
p2p_hex(bytes, sizeof(bytes), text);
|
||||
snprintf(shown->invite, sizeof(shown->invite), "halo://join/%s", text);
|
||||
}
|
||||
p2p_identifier_from_hash(queued->key_hash, shown->identifier);
|
||||
memcpy(shown->name, listing->name, sizeof(shown->name));
|
||||
memcpy(shown->map, listing->map, sizeof(shown->map));
|
||||
memcpy(shown->gametype, listing->gametype, sizeof(shown->gametype));
|
||||
shown->player_count = (unsigned char)listing->player_count;
|
||||
shown->maximum_player_count = (unsigned char)listing->maximum_player_count;
|
||||
shown->engine_type = (unsigned char)listing->engine_type;
|
||||
shown->open = (listing->flags & _listing_open) != 0;
|
||||
shown->in_progress = (listing->flags & _listing_in_progress) != 0;
|
||||
shown->has_teams = (listing->flags & _listing_has_teams) != 0;
|
||||
shown->ping = -1;
|
||||
}
|
||||
|
||||
static void update_browsing(void)
|
||||
{
|
||||
unsigned long start = p2p_now();
|
||||
int index;
|
||||
|
||||
if (lobby.query_wanted)
|
||||
{
|
||||
lobby.query_wanted = 0;
|
||||
p2p_signal_lobby_query();
|
||||
}
|
||||
/* the queue, within the budget (one at least) */
|
||||
while (lobby.queue_count && (p2p_now() == start || !elapsed(start, VERIFY_BUDGET)))
|
||||
{
|
||||
struct queued queued = lobby.queue[0];
|
||||
struct listing listing;
|
||||
unsigned char key_hash[P2P_KEY_HASH_SIZE];
|
||||
int good;
|
||||
|
||||
memmove(lobby.queue, lobby.queue + 1, sizeof(*lobby.queue) * (size_t)(--lobby.queue_count));
|
||||
if (!listing_read(queued.payload, queued.size, &listing) || listing.version != HALO_PORT_NETWORK_VERSION ||
|
||||
!signing_key_hash(listing.key, key_hash) || memcmp(key_hash, queued.key_hash, P2P_KEY_HASH_SIZE))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
/* a slot's retained copy: only one of about now (a host that died
|
||||
left it, and nothing cleared it) */
|
||||
if (queued.retained)
|
||||
{
|
||||
long difference = (long)(listing.time - (unsigned long)time(NULL));
|
||||
|
||||
if (difference > RETAINED_WINDOW || difference < -RETAINED_WINDOW)
|
||||
continue;
|
||||
}
|
||||
/* (the work, without the lock: the game's threads need not wait) */
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
good = listing_signed(queued.payload, &listing);
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
if (good && lobby.browsing)
|
||||
listing_take(&queued, &listing);
|
||||
}
|
||||
if (lobby.queue_count && !lobby.browsing)
|
||||
lobby.queue_count = 0;
|
||||
for (index = 0; index < MAXIMUM_GAMES; index++)
|
||||
{
|
||||
if (lobby.games[index].used && elapsed(lobby.games[index].heard_time, GAME_EXPIRY))
|
||||
lobby.games[index].used = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- p2p.c's side */
|
||||
|
||||
void p2p_lobby_update(const unsigned char *token, int player_count, int maximum_player_count)
|
||||
{
|
||||
update_hosting(token, player_count, maximum_player_count);
|
||||
update_browsing();
|
||||
}
|
||||
|
||||
int p2p_lobby_listed(void)
|
||||
{
|
||||
return lobby.listed;
|
||||
}
|
||||
|
||||
void p2p_lobby_quit(void)
|
||||
{
|
||||
if (!lobby.listed)
|
||||
return;
|
||||
stop_listing();
|
||||
/* (the game is ending: written now, not on the coming passes) */
|
||||
p2p_signal_lobby_quit();
|
||||
}
|
||||
|
||||
/* ---------- the game's side */
|
||||
|
||||
void p2p_set_hosting_public(int public)
|
||||
{
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
/* (a new invite going private: p2p.c) */
|
||||
if (lobby.public && !public)
|
||||
p2p_new_invite_if_listed();
|
||||
lobby.public = public ? 1 : 0;
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
}
|
||||
|
||||
void p2p_set_hosting_password(const char *password)
|
||||
{
|
||||
unsigned char key[P2P_PASSWORD_KEY_SIZE];
|
||||
int has_password = password && *password;
|
||||
|
||||
/* (the key takes a while: not under the lock) */
|
||||
if (has_password)
|
||||
p2p_password_key(password, p2p_signing_key(), key);
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
if (has_password != lobby.has_password ||
|
||||
(has_password && !p2p_equal(key, lobby.password_key, P2P_PASSWORD_KEY_SIZE)))
|
||||
{
|
||||
/* (a new invite, if one was listed: who saw it, with no password or
|
||||
another, cannot join with it) */
|
||||
p2p_new_invite_if_listed();
|
||||
lobby.has_password = has_password;
|
||||
if (has_password)
|
||||
memcpy(lobby.password_key, key, sizeof(key));
|
||||
else
|
||||
memset(lobby.password_key, 0, sizeof(lobby.password_key));
|
||||
if (lobby.listed)
|
||||
republish_soon(0);
|
||||
}
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
memset(key, 0, sizeof(key));
|
||||
}
|
||||
|
||||
void p2p_set_game_listing(const char *name, const char *map, const char *gametype, int engine_type, int open,
|
||||
int in_progress, int has_teams)
|
||||
{
|
||||
char new_name[P2P_LISTING_NAME_SIZE + 1];
|
||||
char new_map[P2P_LISTING_MAP_SIZE + 1];
|
||||
char new_gametype[P2P_LISTING_GAMETYPE_SIZE + 1];
|
||||
int flags = (open ? _listing_open : 0) | (in_progress ? _listing_in_progress : 0) |
|
||||
(has_teams ? _listing_has_teams : 0);
|
||||
|
||||
sanitize(new_name, P2P_LISTING_NAME_SIZE, name ? name : lobby.name, P2P_LISTING_NAME_SIZE);
|
||||
sanitize(new_map, P2P_LISTING_MAP_SIZE, map ? map : lobby.map, P2P_LISTING_MAP_SIZE);
|
||||
sanitize(new_gametype, P2P_LISTING_GAMETYPE_SIZE, gametype ? gametype : lobby.gametype,
|
||||
P2P_LISTING_GAMETYPE_SIZE);
|
||||
/* (only the game's server writes these: unchanged, it need not wait for
|
||||
the lock) */
|
||||
if (!strcmp(new_name, lobby.name) && !strcmp(new_map, lobby.map) && !strcmp(new_gametype, lobby.gametype) &&
|
||||
engine_type == lobby.engine_type && flags == lobby.flags)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
memcpy(lobby.name, new_name, sizeof(lobby.name));
|
||||
memcpy(lobby.map, new_map, sizeof(lobby.map));
|
||||
memcpy(lobby.gametype, new_gametype, sizeof(lobby.gametype));
|
||||
lobby.engine_type = engine_type;
|
||||
lobby.flags = flags;
|
||||
if (lobby.listed)
|
||||
republish_soon(0);
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
}
|
||||
|
||||
void p2p_lobby_browse(int on)
|
||||
{
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
on = on && config_boolean("network.public_lobby") ? 1 : 0;
|
||||
if (on != lobby.browsing)
|
||||
{
|
||||
lobby.browsing = on;
|
||||
if (!on)
|
||||
{
|
||||
memset(lobby.games, 0, sizeof(lobby.games));
|
||||
lobby.queue_count = 0;
|
||||
}
|
||||
lobby.query_wanted = on;
|
||||
p2p_signal_lobby_topics(lobby.listed, on);
|
||||
}
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
}
|
||||
|
||||
void p2p_lobby_refresh(void)
|
||||
{
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
if (lobby.browsing)
|
||||
lobby.query_wanted = 1;
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
}
|
||||
|
||||
int p2p_lobby_browsing(void)
|
||||
{
|
||||
return lobby.browsing;
|
||||
}
|
||||
|
||||
/* the order shown: the most players first; then those joining has not
|
||||
failed, the open ones, and by name */
|
||||
static int listing_order(const void *first, const void *second)
|
||||
{
|
||||
const struct p2p_listing *a = first, *b = second;
|
||||
|
||||
if (a->player_count != b->player_count)
|
||||
return b->player_count - a->player_count;
|
||||
if (a->failed != b->failed)
|
||||
return a->failed - b->failed;
|
||||
if (a->open != b->open)
|
||||
return b->open - a->open;
|
||||
return strcmp(a->name, b->name);
|
||||
}
|
||||
|
||||
int p2p_lobby_games(struct p2p_listing *games, int maximum_count)
|
||||
{
|
||||
int count = 0;
|
||||
int index;
|
||||
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
for (index = 0; index < MAXIMUM_GAMES && count < maximum_count; index++)
|
||||
{
|
||||
if (!lobby.games[index].used)
|
||||
continue;
|
||||
games[count] = lobby.games[index].listing;
|
||||
games[count].failed = (unsigned char)identifier_failed(games[count].identifier);
|
||||
count++;
|
||||
}
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
qsort(games, (size_t)count, sizeof(*games), listing_order);
|
||||
return count;
|
||||
}
|
||||
|
||||
int p2p_listing_unlock(struct p2p_listing *listing, const char *password)
|
||||
{
|
||||
unsigned char key[P2P_PASSWORD_KEY_SIZE];
|
||||
unsigned char bytes[P2P_KEY_HASH_SIZE + P2P_TOKEN_SIZE];
|
||||
char text[2 * (P2P_KEY_HASH_SIZE + P2P_TOKEN_SIZE) + 1];
|
||||
int opened;
|
||||
|
||||
if (!listing->locked)
|
||||
return 1;
|
||||
p2p_password_key(password ? password : "", listing->signing_key, key);
|
||||
memcpy(bytes, listing->key_hash, P2P_KEY_HASH_SIZE);
|
||||
opened = p2p_unseal_token(key, listing->signing_key, listing->sealed_token, bytes + P2P_KEY_HASH_SIZE);
|
||||
if (opened)
|
||||
{
|
||||
p2p_hex(bytes, sizeof(bytes), text);
|
||||
snprintf(listing->invite, sizeof(listing->invite), "halo://join/%s", text);
|
||||
}
|
||||
memset(key, 0, sizeof(key));
|
||||
memset(bytes, 0, sizeof(bytes));
|
||||
return opened;
|
||||
}
|
||||
|
||||
void p2p_lobby_mark_failed(const unsigned char *identifier)
|
||||
{
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
if (!identifier_failed(identifier) && lobby.failed_count < MAXIMUM_GAMES)
|
||||
memcpy(lobby.failed[lobby.failed_count++], identifier, P2P_IDENTIFIER_SIZE);
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
}
|
||||
@@ -3,9 +3,23 @@ P2P_SIGNAL.C
|
||||
|
||||
Internet play's signalling (p2p.c): how a joiner and the host of an invite
|
||||
tell each other where they can be reached, through public MQTT brokers
|
||||
(network.signalling_brokers; MQTT 3.1.1 over TCP). Every broker is used at
|
||||
once, so any one of them working is enough (an answer goes back through
|
||||
each broker a request came through).
|
||||
(those in brokers.txt, network.brokers_file; MQTT 5 over TCP, or 3.1.1 with
|
||||
a broker that refuses 5). Every broker is used at once, so any one of them
|
||||
working is enough (an answer goes back through each broker a request came
|
||||
through).
|
||||
They also carry the server browser's listings of public games (p2p_lobby.c):
|
||||
retained in each host's slot, published at least once (QoS 1, sent again
|
||||
until the broker acknowledges them), expiring at the broker after
|
||||
LISTING_EXPIRY seconds (MQTT 5), and cleared by the broker if the host's
|
||||
connection dies (the will every connection sets: harmless when not hosting).
|
||||
|
||||
A broker may drop a connection's publishes past about 10 a second without a
|
||||
word (EMQX), and a host's answers to a flood of JOINs would reach that: each
|
||||
broker's publishes spend from a bucket (PUBLISH_BURST at once, one more each
|
||||
PUBLISH_INTERVAL). Answers to proven joiners come first, then the listing
|
||||
(kept to publish later), then a joiner's requests and the browser's queries;
|
||||
answers to requests not proven yet only while some are left over (the
|
||||
joiner asks again).
|
||||
|
||||
Everything that passes through them is sealed with a key derived from the
|
||||
invite's token, and goes to topics that are hashes of it, so the brokers
|
||||
@@ -81,20 +95,43 @@ enum
|
||||
host takes at most a few new players a minute: this is hours of them;
|
||||
one is not forgotten while its host nonce lasts: USED_REQUEST_TIME) */
|
||||
MAXIMUM_USED_REQUESTS = 1024,
|
||||
TOPIC_SIZE = 7 + 32 + 1,
|
||||
/* (p2p_code.c's are as long) */
|
||||
TOPIC_SIZE_CHECK = 1 / (TOPIC_SIZE == P2P_CODE_TOPIC_SIZE),
|
||||
/* (a slot's: hceu/3/lobby/s/ and a key hash in hex) */
|
||||
TOPIC_SIZE = 64,
|
||||
NONCE_SIZE = 8,
|
||||
/* an ACCEPT's or a proven JOIN's tag: the first half of an HMAC-SHA256 */
|
||||
TAG_SIZE = 16,
|
||||
/* a proven JOIN's end: the host's nonce, and the tag */
|
||||
PROOF_SIZE = NONCE_SIZE + TAG_SIZE,
|
||||
BUFFER_SIZE = 4096,
|
||||
MAXIMUM_MESSAGE_SIZE = 256,
|
||||
MAXIMUM_MESSAGE_SIZE = 512,
|
||||
/* a listing's most (p2p_lobby.c's MAXIMUM_LISTING_SIZE, 268 with a
|
||||
password's sealed token, and some) */
|
||||
MAXIMUM_LISTING_SIZE = 320,
|
||||
/* the publishes awaiting acknowledgement on a broker */
|
||||
MAXIMUM_IN_FLIGHT = 4,
|
||||
/* the topics a broker is subscribed to (_topic_*) */
|
||||
NUMBER_OF_TOPICS = 8,
|
||||
/* a broker's publishes: at most PUBLISH_BURST at once, one more each
|
||||
PUBLISH_INTERVAL milliseconds (EMQX drops a connection's publishes past
|
||||
about 10 a second, without a word) */
|
||||
PUBLISH_BURST = 8,
|
||||
PUBLISH_INTERVAL = 125,
|
||||
/* what is kept back of the bucket for answers to proven joiners and the
|
||||
listing: a request's answer, and a query, need this many left */
|
||||
UNPROVEN_RESERVE = 3,
|
||||
/* seconds a listing lasts at the broker (MQTT 5's Message Expiry
|
||||
Interval): a dead host's goes even from a broker that kept it through a
|
||||
restart */
|
||||
LISTING_EXPIRY = 90,
|
||||
|
||||
/* milliseconds */
|
||||
CONNECT_TIMEOUT = 10000,
|
||||
/* a broker that failed is tried again after this, twice as long each
|
||||
failure after, to MAXIMUM_RETRY_INTERVAL */
|
||||
RETRY_INTERVAL = 15000,
|
||||
MAXIMUM_RETRY_INTERVAL = 120000,
|
||||
/* a publish at least once not acknowledged is sent again */
|
||||
RESEND_INTERVAL = 5000,
|
||||
KEEP_ALIVE_SECONDS = 60,
|
||||
PING_INTERVAL = 30000,
|
||||
SILENCE_TIMEOUT = 90000,
|
||||
@@ -130,6 +167,31 @@ enum
|
||||
_broker_ready,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
_topic_host,
|
||||
_topic_join,
|
||||
/* the server browser's (p2p_lobby.c): the own slot, queries, all slots */
|
||||
_topic_own_slot,
|
||||
_topic_query,
|
||||
_topic_slots,
|
||||
/* the VR port's: a hosted join code's, a looked up one's, the public
|
||||
games' (p2p_code.c, p2p_list.c) */
|
||||
_topic_code_host,
|
||||
_topic_code_look,
|
||||
_topic_list,
|
||||
};
|
||||
|
||||
/* MQTT 5's properties */
|
||||
enum
|
||||
{
|
||||
_property_message_expiry = 0x02,
|
||||
_property_server_keep_alive = 0x13,
|
||||
_property_receive_maximum = 0x21,
|
||||
_property_retain_available = 0x25,
|
||||
_property_wildcard_available = 0x28,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
_message_join = 'J',
|
||||
@@ -151,14 +213,41 @@ struct broker
|
||||
unsigned long heard_time;
|
||||
int failures;
|
||||
unsigned short packet_identifier;
|
||||
/* the topics it has been asked for */
|
||||
char host_topic[TOPIC_SIZE];
|
||||
char join_topic[TOPIC_SIZE];
|
||||
/* (join codes' topics: p2p_code.c) */
|
||||
char code_host_topic[TOPIC_SIZE];
|
||||
char code_look_topic[TOPIC_SIZE];
|
||||
/* (public games': p2p_list.c) */
|
||||
char list_topic[TOPIC_SIZE];
|
||||
/* 5 (MQTT 5), or 4 (3.1.1: the broker refused 5) */
|
||||
int protocol;
|
||||
/* as its CONNACK said (MQTT 5; 3.1.1 brokers have both): without
|
||||
either, it carries only signalling, not listings */
|
||||
int retain_available;
|
||||
int wildcard_available;
|
||||
/* seconds; its own if it said */
|
||||
int keep_alive;
|
||||
int receive_maximum;
|
||||
/* the bucket its publishes spend from */
|
||||
int publish_tokens;
|
||||
unsigned long publish_time;
|
||||
/* the topics it has been asked for (_topic_*) */
|
||||
char topics[NUMBER_OF_TOPICS][TOPIC_SIZE];
|
||||
/* the listing's version it was given (signalling.lobby_version); and
|
||||
whether it has yet to have its slot cleared (after a tombstone) */
|
||||
int lobby_version;
|
||||
int lobby_clear_pending;
|
||||
/* a query to send once subscribed to the slots */
|
||||
int query_pending;
|
||||
/* publishes at least once, awaiting PUBACK */
|
||||
struct
|
||||
{
|
||||
int used;
|
||||
unsigned short identifier;
|
||||
unsigned long sent_time;
|
||||
/* a listing, which a newer one replaces (not a tombstone or a
|
||||
clearing) */
|
||||
int listing;
|
||||
/* refused (MQTT 5's PUBACK said why): sent again as a new publish
|
||||
(the refusal ended the old one's identifier) */
|
||||
int refused;
|
||||
int size;
|
||||
unsigned char payload[MAXIMUM_LISTING_SIZE];
|
||||
} in_flight[MAXIMUM_IN_FLIGHT];
|
||||
unsigned char input[BUFFER_SIZE];
|
||||
int input_size;
|
||||
unsigned char output[BUFFER_SIZE];
|
||||
@@ -210,6 +299,18 @@ static struct
|
||||
int broker_count;
|
||||
char client_identifier[24];
|
||||
|
||||
/* the server browser (p2p_lobby.c): this machine's slot (its will
|
||||
clears it), whether its game is listed and whether it browses; the
|
||||
listing to publish (none: size 0), its version, and whether it is a
|
||||
tombstone (the slot is cleared after it) */
|
||||
char own_slot[TOPIC_SIZE];
|
||||
int lobby_listed;
|
||||
int lobby_browsing;
|
||||
unsigned char lobby_listing[MAXIMUM_LISTING_SIZE];
|
||||
int lobby_listing_size;
|
||||
int lobby_version;
|
||||
int lobby_closing;
|
||||
|
||||
/* hosting */
|
||||
int hosting;
|
||||
unsigned char host_token[P2P_TOKEN_SIZE];
|
||||
@@ -326,11 +427,12 @@ static void broker_close(struct broker *broker, int failed)
|
||||
broker->state_time = p2p_now();
|
||||
broker->input_size = 0;
|
||||
broker->output_size = 0;
|
||||
broker->host_topic[0] = 0;
|
||||
broker->join_topic[0] = 0;
|
||||
broker->code_host_topic[0] = 0;
|
||||
broker->code_look_topic[0] = 0;
|
||||
broker->list_topic[0] = 0;
|
||||
memset(broker->topics, 0, sizeof(broker->topics));
|
||||
memset(broker->in_flight, 0, sizeof(broker->in_flight));
|
||||
/* (the will cleared the slot: the listing again once connected) */
|
||||
broker->lobby_version = 0;
|
||||
broker->lobby_clear_pending = 0;
|
||||
broker->query_pending = 0;
|
||||
if (failed)
|
||||
broker->failures++;
|
||||
}
|
||||
@@ -354,23 +456,50 @@ static void broker_flush(struct broker *broker)
|
||||
}
|
||||
}
|
||||
|
||||
static int put_variable(unsigned char *bytes, int value)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
do
|
||||
{
|
||||
unsigned char byte = (unsigned char)(value & 127);
|
||||
|
||||
value >>= 7;
|
||||
bytes[size++] = (unsigned char)(value ? byte | 128 : byte);
|
||||
} while (value);
|
||||
return size;
|
||||
}
|
||||
|
||||
/* reads a variable byte integer; 0 if it does not fit */
|
||||
static int get_variable(const unsigned char *bytes, int size, int *offset, int *value)
|
||||
{
|
||||
int shift = 0;
|
||||
|
||||
*value = 0;
|
||||
for (;;)
|
||||
{
|
||||
unsigned char byte;
|
||||
|
||||
if (*offset >= size || shift > 21)
|
||||
return 0;
|
||||
byte = bytes[(*offset)++];
|
||||
*value |= (byte & 127) << shift;
|
||||
shift += 7;
|
||||
if (!(byte & 128))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* queues a packet: its fixed header's first byte, and its body */
|
||||
static void broker_send(struct broker *broker, unsigned char type, const unsigned char *body, int size)
|
||||
{
|
||||
unsigned char header[5];
|
||||
int header_size = 1;
|
||||
int remaining = size;
|
||||
int header_size;
|
||||
|
||||
if (broker->socket < 0)
|
||||
return;
|
||||
header[0] = type;
|
||||
do
|
||||
{
|
||||
unsigned char byte = (unsigned char)(remaining & 127);
|
||||
|
||||
remaining >>= 7;
|
||||
header[header_size++] = (unsigned char)(remaining ? byte | 128 : byte);
|
||||
} while (remaining);
|
||||
header_size = 1 + put_variable(header + 1, size);
|
||||
if (broker->output_size + header_size + size > BUFFER_SIZE)
|
||||
{
|
||||
broker_close(broker, 1);
|
||||
@@ -393,57 +522,170 @@ static int put_string(unsigned char *body, const char *text)
|
||||
return size + 2;
|
||||
}
|
||||
|
||||
static void broker_topic(struct broker *broker, const char *topic, int subscribe)
|
||||
static unsigned short next_packet_identifier(struct broker *broker)
|
||||
{
|
||||
unsigned char body[4 + TOPIC_SIZE + 1];
|
||||
int size = 0;
|
||||
|
||||
if (++broker->packet_identifier == 0)
|
||||
broker->packet_identifier = 1;
|
||||
body[size++] = (unsigned char)(broker->packet_identifier >> 8);
|
||||
body[size++] = (unsigned char)broker->packet_identifier;
|
||||
return broker->packet_identifier;
|
||||
}
|
||||
|
||||
/* whether the broker may publish now, spending from its bucket: reserve is
|
||||
how many must be left after (UNPROVEN_RESERVE for what may wait) */
|
||||
static int broker_may_publish(struct broker *broker, int reserve)
|
||||
{
|
||||
unsigned long now = p2p_now();
|
||||
int gained = (int)((now - broker->publish_time) / PUBLISH_INTERVAL);
|
||||
|
||||
if (gained > 0)
|
||||
{
|
||||
broker->publish_tokens = broker->publish_tokens + gained > PUBLISH_BURST ? PUBLISH_BURST :
|
||||
broker->publish_tokens + gained;
|
||||
broker->publish_time += (unsigned long)gained * PUBLISH_INTERVAL;
|
||||
if (broker->publish_tokens == PUBLISH_BURST)
|
||||
broker->publish_time = now;
|
||||
}
|
||||
if (broker->publish_tokens <= reserve)
|
||||
return 0;
|
||||
broker->publish_tokens--;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void broker_topic(struct broker *broker, const char *topic, int subscribe, int no_local)
|
||||
{
|
||||
unsigned char body[5 + TOPIC_SIZE + 1];
|
||||
unsigned short identifier = next_packet_identifier(broker);
|
||||
int size = 0;
|
||||
|
||||
body[size++] = (unsigned char)(identifier >> 8);
|
||||
body[size++] = (unsigned char)identifier;
|
||||
/* (MQTT 5: no properties) */
|
||||
if (broker->protocol == 5)
|
||||
body[size++] = 0;
|
||||
size += put_string(body + size, topic);
|
||||
/* at most once; MQTT 5: No Local, not this connection's own publishes */
|
||||
if (subscribe)
|
||||
body[size++] = 0; /* at most once */
|
||||
body[size++] = (unsigned char)(broker->protocol == 5 && no_local ? 0x04 : 0);
|
||||
broker_send(broker, subscribe ? 0x82 : 0xA2, body, size);
|
||||
}
|
||||
|
||||
/* a publish at most once, not retained: signalling's, and queries */
|
||||
static void broker_publish(struct broker *broker, const char *topic, const unsigned char *payload, int payload_size)
|
||||
{
|
||||
unsigned char body[2 + TOPIC_SIZE + MAXIMUM_MESSAGE_SIZE + P2P_SEAL_OVERHEAD];
|
||||
unsigned char body[3 + TOPIC_SIZE + MAXIMUM_MESSAGE_SIZE + P2P_SEAL_OVERHEAD];
|
||||
int size = put_string(body, topic);
|
||||
|
||||
if (broker->protocol == 5)
|
||||
body[size++] = 0;
|
||||
memcpy(body + size, payload, (size_t)payload_size);
|
||||
broker_send(broker, 0x30, body, size + payload_size);
|
||||
}
|
||||
|
||||
/* a publish at least once to the own slot, retained: a listing (expiring
|
||||
at the broker), or an empty one, which clears it; again (duplicate) if the
|
||||
first was not acknowledged */
|
||||
static void broker_publish_slot(struct broker *broker, unsigned short identifier, const unsigned char *payload,
|
||||
int payload_size, int duplicate)
|
||||
{
|
||||
unsigned char body[2 + TOPIC_SIZE + 2 + 8 + MAXIMUM_LISTING_SIZE];
|
||||
int size = put_string(body, signalling.own_slot);
|
||||
|
||||
body[size++] = (unsigned char)(identifier >> 8);
|
||||
body[size++] = (unsigned char)identifier;
|
||||
if (broker->protocol == 5)
|
||||
{
|
||||
if (payload_size)
|
||||
{
|
||||
body[size++] = 5;
|
||||
body[size++] = _property_message_expiry;
|
||||
body[size++] = 0;
|
||||
body[size++] = 0;
|
||||
body[size++] = 0;
|
||||
body[size++] = LISTING_EXPIRY;
|
||||
}
|
||||
else
|
||||
{
|
||||
body[size++] = 0;
|
||||
}
|
||||
}
|
||||
if (payload_size)
|
||||
memcpy(body + size, payload, (size_t)payload_size);
|
||||
/* PUBLISH, QoS 1, retained */
|
||||
broker_send(broker, (unsigned char)(0x30 | (duplicate ? 0x08 : 0) | 0x02 | 0x01), body, size + payload_size);
|
||||
broker->sent_time = p2p_now();
|
||||
}
|
||||
|
||||
/* a listing (or a clearing: size 0) to the own slot, at least once: 0 if
|
||||
there is no room for it yet */
|
||||
static int broker_publish_listing(struct broker *broker, const unsigned char *payload, int size, int listing)
|
||||
{
|
||||
int maximum = broker->receive_maximum < MAXIMUM_IN_FLIGHT ? broker->receive_maximum : MAXIMUM_IN_FLIGHT;
|
||||
int count = 0;
|
||||
int free_index = -1;
|
||||
int index;
|
||||
|
||||
/* (a listing replaces an older one not acknowledged yet) */
|
||||
for (index = 0; index < MAXIMUM_IN_FLIGHT; index++)
|
||||
{
|
||||
if (broker->in_flight[index].used && broker->in_flight[index].listing && listing)
|
||||
broker->in_flight[index].used = 0;
|
||||
if (broker->in_flight[index].used)
|
||||
count++;
|
||||
else if (free_index < 0)
|
||||
free_index = index;
|
||||
}
|
||||
if (free_index < 0 || count >= maximum || !broker_may_publish(broker, 0))
|
||||
return 0;
|
||||
broker->in_flight[free_index].used = 1;
|
||||
broker->in_flight[free_index].identifier = next_packet_identifier(broker);
|
||||
broker->in_flight[free_index].sent_time = p2p_now();
|
||||
broker->in_flight[free_index].listing = listing;
|
||||
broker->in_flight[free_index].refused = 0;
|
||||
broker->in_flight[free_index].size = size;
|
||||
if (size)
|
||||
memcpy(broker->in_flight[free_index].payload, payload, (size_t)size);
|
||||
broker_publish_slot(broker, broker->in_flight[free_index].identifier, payload, size, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* whether the broker carries the server browser: retained messages and
|
||||
wildcards */
|
||||
static int broker_carries_lobby(const struct broker *broker)
|
||||
{
|
||||
return broker->retain_available && broker->wildcard_available;
|
||||
}
|
||||
|
||||
/* the topics a ready broker should be subscribed to */
|
||||
static void broker_sync_topics(struct broker *broker)
|
||||
{
|
||||
const char *wanted[5];
|
||||
char *had[5];
|
||||
const char *wanted[NUMBER_OF_TOPICS];
|
||||
int lobby = broker_carries_lobby(broker);
|
||||
int index;
|
||||
|
||||
if (broker->state != _broker_ready)
|
||||
return;
|
||||
wanted[0] = signalling.hosting ? signalling.host_topic : "";
|
||||
wanted[1] = signalling.joining ? signalling.join_topic : "";
|
||||
p2p_code_topics(&wanted[2], &wanted[3]);
|
||||
wanted[4] = p2p_list_topic();
|
||||
had[0] = broker->host_topic;
|
||||
had[1] = broker->join_topic;
|
||||
had[2] = broker->code_host_topic;
|
||||
had[3] = broker->code_look_topic;
|
||||
had[4] = broker->list_topic;
|
||||
for (index = 0; index < 5; index++)
|
||||
wanted[_topic_host] = signalling.hosting ? signalling.host_topic : "";
|
||||
wanted[_topic_join] = signalling.joining ? signalling.join_topic : "";
|
||||
wanted[_topic_own_slot] = lobby && signalling.lobby_listed ? signalling.own_slot : "";
|
||||
wanted[_topic_query] = lobby && signalling.lobby_listed ? P2P_LOBBY_QUERY_TOPIC : "";
|
||||
wanted[_topic_slots] = lobby && signalling.lobby_browsing ? P2P_LOBBY_SLOT_PREFIX "+" : "";
|
||||
/* (the VR port's join codes and public games: p2p_code.c, p2p_list.c) */
|
||||
p2p_code_topics(&wanted[_topic_code_host], &wanted[_topic_code_look]);
|
||||
wanted[_topic_list] = p2p_list_topic();
|
||||
for (index = 0; index < NUMBER_OF_TOPICS; index++)
|
||||
{
|
||||
if (!strcmp(wanted[index], had[index]))
|
||||
char *had = broker->topics[index];
|
||||
|
||||
if (!strcmp(wanted[index], had))
|
||||
continue;
|
||||
if (had[index][0])
|
||||
broker_topic(broker, had[index], 0);
|
||||
if (had[0])
|
||||
broker_topic(broker, had, 0, 0);
|
||||
if (wanted[index][0])
|
||||
broker_topic(broker, wanted[index], 1);
|
||||
strcpy(had[index], wanted[index]);
|
||||
broker_topic(broker, wanted[index], 1, index == _topic_own_slot);
|
||||
/* (once subscribed to the slots, the hosts are asked to publish:
|
||||
retained copies come at once, but may be old) */
|
||||
if (index == _topic_slots && wanted[index][0])
|
||||
broker->query_pending = 1;
|
||||
strcpy(had, wanted[index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,22 +695,80 @@ static void publish_everywhere(const char *topic, const unsigned char *payload,
|
||||
|
||||
for (index = 0; index < signalling.broker_count; index++)
|
||||
{
|
||||
if (signalling.brokers[index].state == _broker_ready)
|
||||
broker_publish(&signalling.brokers[index], topic, payload, size);
|
||||
struct broker *broker = &signalling.brokers[index];
|
||||
|
||||
if (broker->state == _broker_ready && broker_may_publish(broker, 0))
|
||||
broker_publish(broker, topic, payload, size);
|
||||
}
|
||||
}
|
||||
|
||||
/* the listing's publishes due on a broker: the listing, or a tombstone and
|
||||
then the slot's clearing; acknowledgements not come sent again */
|
||||
static void broker_update_lobby(struct broker *broker)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (broker->state != _broker_ready || !broker_carries_lobby(broker))
|
||||
return;
|
||||
for (index = 0; index < MAXIMUM_IN_FLIGHT; index++)
|
||||
{
|
||||
if (broker->in_flight[index].used && elapsed(broker->in_flight[index].sent_time, RESEND_INTERVAL) &&
|
||||
broker_may_publish(broker, 0))
|
||||
{
|
||||
int duplicate = !broker->in_flight[index].refused;
|
||||
|
||||
if (!duplicate)
|
||||
broker->in_flight[index].identifier = next_packet_identifier(broker);
|
||||
broker->in_flight[index].refused = 0;
|
||||
broker->in_flight[index].sent_time = p2p_now();
|
||||
broker_publish_slot(broker, broker->in_flight[index].identifier, broker->in_flight[index].payload,
|
||||
broker->in_flight[index].size, duplicate);
|
||||
}
|
||||
}
|
||||
if (broker->lobby_version != signalling.lobby_version && signalling.lobby_listing_size &&
|
||||
broker_publish_listing(broker, signalling.lobby_listing, signalling.lobby_listing_size,
|
||||
!signalling.lobby_closing))
|
||||
{
|
||||
broker->lobby_version = signalling.lobby_version;
|
||||
broker->lobby_clear_pending = signalling.lobby_closing;
|
||||
}
|
||||
if (broker->lobby_clear_pending && broker->lobby_version == signalling.lobby_version &&
|
||||
broker_publish_listing(broker, NULL, 0, 0))
|
||||
{
|
||||
broker->lobby_clear_pending = 0;
|
||||
}
|
||||
if (broker->query_pending && broker->topics[_topic_slots][0] && broker_may_publish(broker, UNPROVEN_RESERVE))
|
||||
{
|
||||
unsigned char nonce[NONCE_SIZE];
|
||||
|
||||
posix_random_bytes(nonce, sizeof(nonce));
|
||||
broker_publish(broker, P2P_LOBBY_QUERY_TOPIC, nonce, sizeof(nonce));
|
||||
broker->query_pending = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void broker_connected(struct broker *broker)
|
||||
{
|
||||
unsigned char body[64];
|
||||
unsigned char body[32 + sizeof(signalling.client_identifier) + TOPIC_SIZE];
|
||||
int size = 0;
|
||||
|
||||
if (!broker->protocol)
|
||||
broker->protocol = 5;
|
||||
size += put_string(body, "MQTT");
|
||||
body[size++] = 4; /* 3.1.1 */
|
||||
body[size++] = 0x02; /* a clean session */
|
||||
body[size++] = (unsigned char)broker->protocol;
|
||||
/* a clean session, and a will: an empty retained message to this
|
||||
machine's slot, which clears its listing if the connection dies */
|
||||
body[size++] = 0x02 | 0x04 | 0x20;
|
||||
body[size++] = 0;
|
||||
body[size++] = KEEP_ALIVE_SECONDS;
|
||||
if (broker->protocol == 5)
|
||||
body[size++] = 0;
|
||||
size += put_string(body + size, signalling.client_identifier);
|
||||
if (broker->protocol == 5)
|
||||
body[size++] = 0;
|
||||
size += put_string(body + size, signalling.own_slot);
|
||||
body[size++] = 0;
|
||||
body[size++] = 0;
|
||||
broker->state = _broker_awaiting_acknowledgement;
|
||||
broker->state_time = p2p_now();
|
||||
broker_send(broker, 0x10, body, size);
|
||||
@@ -726,7 +1026,7 @@ static int request_used(const unsigned char *request)
|
||||
|
||||
/* the host's answer to a request, through the broker it came through */
|
||||
static void send_accept(struct broker *broker, const unsigned char *identifier, const unsigned char *nonce,
|
||||
const unsigned char *host_nonce, const unsigned char *base)
|
||||
const unsigned char *host_nonce, const unsigned char *base, int proven)
|
||||
{
|
||||
unsigned char answer[MAXIMUM_MESSAGE_SIZE];
|
||||
unsigned char sealed[MAXIMUM_MESSAGE_SIZE + P2P_SEAL_OVERHEAD];
|
||||
@@ -746,7 +1046,8 @@ static void send_accept(struct broker *broker, const unsigned char *identifier,
|
||||
size += TAG_SIZE;
|
||||
size = p2p_seal(signalling.host_key, answer, size, sealed);
|
||||
make_topic(signalling.host_token, "joiner", identifier, topic);
|
||||
if (broker->state == _broker_ready)
|
||||
/* (a proven joiner's first: its session is made; others ask again) */
|
||||
if (broker->state == _broker_ready && broker_may_publish(broker, proven ? 0 : UNPROVEN_RESERVE))
|
||||
broker_publish(broker, topic, sealed, size);
|
||||
}
|
||||
|
||||
@@ -799,7 +1100,7 @@ static void join_received(struct broker *broker, const unsigned char *message, i
|
||||
}
|
||||
joiner->answered_time = p2p_now();
|
||||
joiner->answered_broker_times[broker_index] = joiner->answered_time;
|
||||
send_accept(broker, identifier, joiner->nonce, joiner->host_nonce, joiner->base);
|
||||
send_accept(broker, identifier, joiner->nonce, joiner->host_nonce, joiner->base, proven);
|
||||
return;
|
||||
}
|
||||
memcpy(request, identifier, P2P_IDENTIFIER_SIZE);
|
||||
@@ -860,7 +1161,7 @@ static void join_received(struct broker *broker, const unsigned char *message, i
|
||||
asker->answered_nonce_brokers[slot] = (signed char)broker_index;
|
||||
asker->answered_nonce_times[slot] = asker->answered_time;
|
||||
host_nonce_for(public_key, nonce, p2p_now() / HOST_NONCE_PERIOD, host_nonce);
|
||||
send_accept(broker, identifier, nonce, host_nonce, asker->base);
|
||||
send_accept(broker, identifier, nonce, host_nonce, asker->base, 0);
|
||||
return;
|
||||
}
|
||||
/* proven: with a nonce the host answered the request with lately, and a
|
||||
@@ -897,7 +1198,7 @@ static void join_received(struct broker *broker, const unsigned char *message, i
|
||||
memset(joiner->answered_broker_times, 0, sizeof(joiner->answered_broker_times));
|
||||
joiner->answered_broker_times[broker_index] = joiner->answered_time;
|
||||
joiner->used = 1;
|
||||
send_accept(broker, identifier, nonce, host_nonce, base);
|
||||
send_accept(broker, identifier, nonce, host_nonce, base, 1);
|
||||
}
|
||||
|
||||
/* the joiner: the host answered */
|
||||
@@ -947,7 +1248,8 @@ static void accept_received(const unsigned char *message, int size)
|
||||
send_join();
|
||||
}
|
||||
|
||||
static void publish_received(struct broker *broker, const char *topic, const unsigned char *payload, int size)
|
||||
static void publish_received(struct broker *broker, const char *topic, const unsigned char *payload, int size,
|
||||
int retained)
|
||||
{
|
||||
unsigned char message[MAXIMUM_MESSAGE_SIZE];
|
||||
int message_size;
|
||||
@@ -956,6 +1258,16 @@ static void publish_received(struct broker *broker, const char *topic, const uns
|
||||
return;
|
||||
if (p2p_code_received(topic, payload, size) || p2p_list_received(topic, payload, size))
|
||||
return;
|
||||
if (!strncmp(topic, P2P_LOBBY_SLOT_PREFIX, sizeof(P2P_LOBBY_SLOT_PREFIX) - 1))
|
||||
{
|
||||
p2p_lobby_slot_heard(topic + sizeof(P2P_LOBBY_SLOT_PREFIX) - 1, payload, size, retained);
|
||||
return;
|
||||
}
|
||||
if (!strcmp(topic, P2P_LOBBY_QUERY_TOPIC))
|
||||
{
|
||||
p2p_lobby_query_heard();
|
||||
return;
|
||||
}
|
||||
if (signalling.hosting && !strcmp(topic, signalling.host_topic))
|
||||
{
|
||||
message_size = p2p_open(signalling.host_key, payload, size, message);
|
||||
@@ -970,6 +1282,112 @@ static void publish_received(struct broker *broker, const char *topic, const uns
|
||||
}
|
||||
}
|
||||
|
||||
/* a CONNACK: 0 if the connection is closed (refused, or to try 3.1.1) */
|
||||
static int broker_acknowledged(struct broker *broker, const unsigned char *body, int size)
|
||||
{
|
||||
int code = body[1];
|
||||
int offset = 2;
|
||||
int properties = 0;
|
||||
|
||||
broker->retain_available = 1;
|
||||
broker->wildcard_available = 1;
|
||||
broker->keep_alive = KEEP_ALIVE_SECONDS;
|
||||
broker->receive_maximum = MAXIMUM_IN_FLIGHT;
|
||||
/* a broker that has not MQTT 5 answers 0x84 (5's unsupported protocol
|
||||
version), or 3.1.1's 1 (unacceptable protocol version) */
|
||||
if (broker->protocol == 5 && (code == 0x84 || (size == 2 && code == 1)))
|
||||
{
|
||||
platform_log("Internet play: the signalling broker %s has not MQTT 5; using 3.1.1", broker->host);
|
||||
broker->protocol = 4;
|
||||
broker_close(broker, 0);
|
||||
/* (again at once) */
|
||||
broker->state_time = p2p_now() - MAXIMUM_RETRY_INTERVAL;
|
||||
return 0;
|
||||
}
|
||||
if (code != 0)
|
||||
{
|
||||
platform_log("Internet play: the signalling broker %s refused the connection", broker->host);
|
||||
broker_close(broker, 1);
|
||||
return 0;
|
||||
}
|
||||
if (broker->protocol == 5 && get_variable(body, size, &offset, &properties))
|
||||
{
|
||||
int end = offset + properties > size ? size : offset + properties;
|
||||
|
||||
while (offset < end)
|
||||
{
|
||||
int property = body[offset++];
|
||||
|
||||
switch (property)
|
||||
{
|
||||
/* a byte */
|
||||
case 0x01: case 0x17: case 0x19: case 0x24: case 0x25: case 0x28: case 0x29: case 0x2A:
|
||||
if (offset < end)
|
||||
{
|
||||
if (property == _property_retain_available)
|
||||
broker->retain_available = body[offset];
|
||||
else if (property == _property_wildcard_available)
|
||||
broker->wildcard_available = body[offset];
|
||||
}
|
||||
offset += 1;
|
||||
break;
|
||||
/* two */
|
||||
case 0x13: case 0x21: case 0x22: case 0x23:
|
||||
if (offset + 2 <= end)
|
||||
{
|
||||
int value = body[offset] << 8 | body[offset + 1];
|
||||
|
||||
if (property == _property_server_keep_alive && value > 0)
|
||||
broker->keep_alive = value;
|
||||
else if (property == _property_receive_maximum && value > 0)
|
||||
broker->receive_maximum = value;
|
||||
}
|
||||
offset += 2;
|
||||
break;
|
||||
/* four */
|
||||
case 0x02: case 0x11: case 0x18: case 0x27:
|
||||
offset += 4;
|
||||
break;
|
||||
/* a variable byte integer */
|
||||
case 0x0B:
|
||||
{
|
||||
int value;
|
||||
|
||||
if (!get_variable(body, end, &offset, &value))
|
||||
offset = end;
|
||||
break;
|
||||
}
|
||||
/* a string or binary data: a length, then that */
|
||||
case 0x03: case 0x08: case 0x09: case 0x12: case 0x15: case 0x16: case 0x1A: case 0x1C: case 0x1F:
|
||||
offset += offset + 2 <= end ? 2 + (body[offset] << 8 | body[offset + 1]) : 2;
|
||||
break;
|
||||
/* a pair of strings */
|
||||
case 0x26:
|
||||
{
|
||||
int pair;
|
||||
|
||||
for (pair = 0; pair < 2; pair++)
|
||||
offset += offset + 2 <= end ? 2 + (body[offset] << 8 | body[offset + 1]) : 2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* (unknown: the rest can't be read) */
|
||||
offset = end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
broker->state = _broker_ready;
|
||||
broker->failures = 0;
|
||||
broker->publish_tokens = PUBLISH_BURST;
|
||||
broker->publish_time = p2p_now();
|
||||
broker_sync_topics(broker);
|
||||
/* a joiner's first request need not wait for the next repeat */
|
||||
if (signalling.joining)
|
||||
send_join();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* the packets that arrived whole */
|
||||
static void broker_parse(struct broker *broker)
|
||||
{
|
||||
@@ -1009,36 +1427,61 @@ static void broker_parse(struct broker *broker)
|
||||
type = broker->input[0];
|
||||
if ((type & 0xF0) == 0x20 && remaining >= 2)
|
||||
{
|
||||
/* CONNACK */
|
||||
if (broker->input[header_size + 1] != 0)
|
||||
{
|
||||
platform_log("Internet play: the signalling broker %s refused the connection", broker->host);
|
||||
broker_close(broker, 1);
|
||||
if (!broker_acknowledged(broker, broker->input + header_size, remaining))
|
||||
return;
|
||||
}
|
||||
broker->state = _broker_ready;
|
||||
broker->failures = 0;
|
||||
broker_sync_topics(broker);
|
||||
/* a joiner's first request need not wait for the next repeat */
|
||||
if (signalling.joining)
|
||||
send_join();
|
||||
}
|
||||
else if ((type & 0xF0) == 0x30 && remaining >= 2)
|
||||
{
|
||||
/* PUBLISH */
|
||||
const unsigned char *body = broker->input + header_size;
|
||||
int topic_size = body[0] << 8 | body[1];
|
||||
int offset = 2 + topic_size + (((type >> 1) & 3) ? 2 : 0);
|
||||
int quality = (type >> 1) & 3;
|
||||
int offset = 2 + topic_size;
|
||||
int properties = 0;
|
||||
|
||||
if (quality)
|
||||
{
|
||||
/* (subscriptions ask for at most once; acknowledged all the
|
||||
same) */
|
||||
if (offset + 2 <= remaining && quality == 1)
|
||||
broker_send(broker, 0x40, body + offset, 2);
|
||||
offset += 2;
|
||||
}
|
||||
if (broker->protocol == 5 && get_variable(body, remaining, &offset, &properties))
|
||||
offset += properties;
|
||||
if (topic_size < TOPIC_SIZE && offset <= remaining)
|
||||
{
|
||||
char topic[TOPIC_SIZE];
|
||||
|
||||
memcpy(topic, body + 2, (size_t)topic_size);
|
||||
topic[topic_size] = 0;
|
||||
publish_received(broker, topic, body + offset, remaining - offset);
|
||||
publish_received(broker, topic, body + offset, remaining - offset, type & 1);
|
||||
}
|
||||
}
|
||||
else if ((type & 0xF0) == 0x40 && remaining >= 2)
|
||||
{
|
||||
/* PUBACK: MQTT 5's reason, if any, of 0x80 or more is a refusal
|
||||
(a quota, a rate): sent again later */
|
||||
const unsigned char *body = broker->input + header_size;
|
||||
unsigned short identifier = (unsigned short)(body[0] << 8 | body[1]);
|
||||
int refused = remaining >= 3 && body[2] >= 0x80;
|
||||
int index;
|
||||
|
||||
for (index = 0; index < MAXIMUM_IN_FLIGHT; index++)
|
||||
{
|
||||
if (broker->in_flight[index].used && broker->in_flight[index].identifier == identifier)
|
||||
{
|
||||
broker->in_flight[index].used = refused;
|
||||
broker->in_flight[index].refused = refused;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((type & 0xF0) == 0xE0)
|
||||
{
|
||||
/* DISCONNECT (MQTT 5): the broker's */
|
||||
broker_close(broker, 1);
|
||||
return;
|
||||
}
|
||||
/* (what it sent in answer may have closed it, emptying input) */
|
||||
if (broker->socket < 0)
|
||||
return;
|
||||
@@ -1080,8 +1523,50 @@ static void broker_readable(struct broker *broker)
|
||||
|
||||
/* ---------- p2p.c's side */
|
||||
|
||||
/* the brokers in network.brokers_file (beside config.toml, unless a full
|
||||
path: port/assets/network/brokers.txt, which the builds put there), one on
|
||||
each line, "#" starting a comment, into text: host:port entries separated by
|
||||
commas; empty if the file cannot be read */
|
||||
static void brokers_list(char *text, size_t size)
|
||||
{
|
||||
const char *name = config_string("network.brokers_file");
|
||||
char path[1024];
|
||||
char *file;
|
||||
size_t file_size = 0, index, length = 0;
|
||||
int comment = 0;
|
||||
|
||||
text[0] = 0;
|
||||
if (name[0] == '/' || name[0] == '\\' || (name[0] && name[1] == ':'))
|
||||
snprintf(path, sizeof(path), "%s", name);
|
||||
else
|
||||
{
|
||||
config_folder(path, sizeof(path));
|
||||
snprintf(path + strlen(path), sizeof(path) - strlen(path), "%s", name);
|
||||
}
|
||||
file = config_file_read(path, &file_size);
|
||||
if (!file)
|
||||
{
|
||||
platform_log("Internet play: the brokers' file %s cannot be read (network.brokers_file)", path);
|
||||
return;
|
||||
}
|
||||
for (index = 0; index < file_size && length + 1 < size; index++)
|
||||
{
|
||||
char character = file[index];
|
||||
|
||||
if (character == '\n' || character == '\r')
|
||||
comment = 0;
|
||||
else if (character == '#')
|
||||
comment = 1;
|
||||
if (!comment)
|
||||
text[length++] = character == '\n' || character == '\r' || character == '\t' ? ',' : character;
|
||||
}
|
||||
text[length] = 0;
|
||||
free(file);
|
||||
}
|
||||
|
||||
void p2p_signal_start(void)
|
||||
{
|
||||
char list[1024];
|
||||
const char *text;
|
||||
unsigned char random[8];
|
||||
char hex[17];
|
||||
@@ -1092,7 +1577,14 @@ void p2p_signal_start(void)
|
||||
posix_random_bytes(random, sizeof(random));
|
||||
p2p_hex(random, sizeof(random), hex);
|
||||
snprintf(signalling.client_identifier, sizeof(signalling.client_identifier), "hceu-%s", hex);
|
||||
text = config_string("network.signalling_brokers");
|
||||
{
|
||||
unsigned char hash[P2P_KEY_HASH_SIZE];
|
||||
|
||||
p2p_key_hash(p2p_public_key(), hash);
|
||||
p2p_lobby_slot_topic(hash, signalling.own_slot, sizeof(signalling.own_slot));
|
||||
}
|
||||
brokers_list(list, sizeof(list));
|
||||
text = list;
|
||||
while (*text && signalling.broker_count < MAXIMUM_BROKERS)
|
||||
{
|
||||
const char *end = text + strcspn(text, ",");
|
||||
@@ -1124,7 +1616,9 @@ void p2p_signal_start(void)
|
||||
text = *end ? end + 1 : end;
|
||||
}
|
||||
if (!signalling.broker_count)
|
||||
platform_log("Internet play: no signalling brokers (network.signalling_brokers), so invites cannot work");
|
||||
platform_log("Internet play: no signalling brokers (network.brokers_file), so invites cannot work");
|
||||
else if (text[strspn(text, ", ")])
|
||||
platform_log("Internet play: only the first %d signalling brokers are used", MAXIMUM_BROKERS);
|
||||
}
|
||||
|
||||
void p2p_signal_select_sets(int *read, int *read_count, int *write, int *write_count, int maximum_count)
|
||||
@@ -1164,7 +1658,8 @@ void p2p_signal_update(const int *read, int read_count, const int *write, int wr
|
||||
for (index = 0; index < signalling.broker_count; index++)
|
||||
{
|
||||
struct broker *broker = &signalling.brokers[index];
|
||||
int retry = RETRY_INTERVAL * (broker->failures < 4 ? broker->failures + 1 : 4);
|
||||
int retry = broker->failures < 1 ? RETRY_INTERVAL :
|
||||
broker->failures >= 4 ? MAXIMUM_RETRY_INTERVAL : RETRY_INTERVAL << (broker->failures - 1);
|
||||
|
||||
switch (broker->state)
|
||||
{
|
||||
@@ -1191,13 +1686,18 @@ void p2p_signal_update(const int *read, int read_count, const int *write, int wr
|
||||
broker_readable(broker);
|
||||
if (broker->state != _broker_ready)
|
||||
continue;
|
||||
if (elapsed(broker->heard_time, SILENCE_TIMEOUT))
|
||||
if (elapsed(broker->heard_time, (unsigned long)broker->keep_alive * 1500 > SILENCE_TIMEOUT ?
|
||||
(unsigned long)broker->keep_alive * 1500 : SILENCE_TIMEOUT))
|
||||
{
|
||||
broker_close(broker, 1);
|
||||
continue;
|
||||
}
|
||||
if (elapsed(broker->sent_time, PING_INTERVAL))
|
||||
if (elapsed(broker->sent_time, (unsigned long)broker->keep_alive * 500 < PING_INTERVAL ?
|
||||
(unsigned long)broker->keep_alive * 500 : PING_INTERVAL))
|
||||
{
|
||||
broker_send(broker, 0xC0, NULL, 0);
|
||||
}
|
||||
broker_update_lobby(broker);
|
||||
}
|
||||
if (signalling.joining && !signalling.join_answered && elapsed(signalling.join_nonce_time, UNANSWERED_TIME))
|
||||
{
|
||||
@@ -1244,7 +1744,7 @@ void p2p_signal_publish(const char *topic, const unsigned char *payload, int siz
|
||||
|
||||
void p2p_signal_publish_retained(const char *topic, const unsigned char *payload, int size)
|
||||
{
|
||||
unsigned char body[2 + TOPIC_SIZE + MAXIMUM_MESSAGE_SIZE];
|
||||
unsigned char body[3 + TOPIC_SIZE + MAXIMUM_MESSAGE_SIZE];
|
||||
int index;
|
||||
|
||||
if (size > MAXIMUM_MESSAGE_SIZE)
|
||||
@@ -1257,6 +1757,9 @@ void p2p_signal_publish_retained(const char *topic, const unsigned char *payload
|
||||
if (broker->state != _broker_ready)
|
||||
continue;
|
||||
body_size = put_string(body, topic);
|
||||
/* (MQTT 5: no properties) */
|
||||
if (broker->protocol == 5)
|
||||
body[body_size++] = 0;
|
||||
if (size)
|
||||
memcpy(body + body_size, payload, (size_t)size);
|
||||
/* (PUBLISH, at most once, retained: an empty one clears it) */
|
||||
@@ -1307,3 +1810,64 @@ void p2p_signal_stop_joining(void)
|
||||
signalling.joining = 0;
|
||||
sync_all_topics();
|
||||
}
|
||||
|
||||
void p2p_signal_lobby_topics(int listed, int browsing)
|
||||
{
|
||||
signalling.lobby_listed = listed;
|
||||
signalling.lobby_browsing = browsing;
|
||||
sync_all_topics();
|
||||
}
|
||||
|
||||
void p2p_signal_lobby_publish(const unsigned char *listing, int size, int closing)
|
||||
{
|
||||
if (size > MAXIMUM_LISTING_SIZE)
|
||||
return;
|
||||
memcpy(signalling.lobby_listing, listing, (size_t)size);
|
||||
signalling.lobby_listing_size = size;
|
||||
signalling.lobby_closing = closing;
|
||||
signalling.lobby_version++;
|
||||
/* (at once where the bucket allows; the rest in the coming passes) */
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < signalling.broker_count; index++)
|
||||
broker_update_lobby(&signalling.brokers[index]);
|
||||
}
|
||||
}
|
||||
|
||||
void p2p_signal_lobby_query(void)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < signalling.broker_count; index++)
|
||||
{
|
||||
if (signalling.brokers[index].topics[_topic_slots][0])
|
||||
signalling.brokers[index].query_pending = 1;
|
||||
broker_update_lobby(&signalling.brokers[index]);
|
||||
}
|
||||
}
|
||||
|
||||
void p2p_signal_lobby_quit(void)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < signalling.broker_count; index++)
|
||||
{
|
||||
struct broker *broker = &signalling.brokers[index];
|
||||
static const unsigned char disconnect[2] = { 0, 0 };
|
||||
|
||||
if (broker->state != _broker_ready)
|
||||
continue;
|
||||
/* (unless sent already: the tombstone and the clearing) */
|
||||
if (broker_carries_lobby(broker) && signalling.lobby_listing_size &&
|
||||
(broker->lobby_version != signalling.lobby_version || broker->lobby_clear_pending))
|
||||
{
|
||||
broker_publish_slot(broker, next_packet_identifier(broker), signalling.lobby_listing,
|
||||
signalling.lobby_listing_size, 0);
|
||||
broker_publish_slot(broker, next_packet_identifier(broker), NULL, 0, 0);
|
||||
}
|
||||
/* DISCONNECT (MQTT 5: a normal one, its reason and no properties) */
|
||||
broker_send(broker, 0xE0, disconnect, broker->protocol == 5 ? 2 : 0);
|
||||
broker_flush(broker);
|
||||
}
|
||||
}
|
||||