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 | ||
|
|
20861c06d2 | ||
|
|
fc7271fd52 | ||
|
|
c1305fa94f | ||
|
|
3d2c04d675 | ||
|
|
0fc85d6c67 | ||
|
|
c0a08f395e | ||
|
|
06cb70fb58 | ||
|
|
1709698053 | ||
|
|
cd747c23c5 | ||
|
|
f148dbd6d9 | ||
|
|
61623e68d5 | ||
|
|
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
|
||||
|
||||
|
||||
@@ -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: 24 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
@@ -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 155 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.
|
||||
@@ -315,9 +315,15 @@
|
||||
<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>
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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,21 +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="358" 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="101"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_invite" x="54" y="129"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_listing" x="54" y="157"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_game_type" x="54" y="185"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_player_options" x="54" y="213"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_item_options" x="54" y="241"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_vehicle_options" x="54" y="269"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_indicator_options" x="54" y="297"/>
|
||||
<child widget="main_menu/multiplayer_type_select/server_settings/op_team_options" x="54" y="325"/>
|
||||
<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">
|
||||
@@ -74,6 +80,74 @@
|
||||
<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"/>
|
||||
@@ -159,6 +233,12 @@
|
||||
<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=""/>
|
||||
@@ -173,5 +253,17 @@
|
||||
<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>
|
||||
@@ -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>
|
||||
@@ -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: 65 KiB |
|
After Width: | Height: | Size: 62 KiB |
@@ -17,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",
|
||||
@@ -53,7 +54,9 @@
|
||||
"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",
|
||||
|
||||
@@ -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,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,9 +96,11 @@ 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. In co-op with only one gamepad, that
|
||||
gamepad is controller 2 (player 2) and the keyboard and mouse stay
|
||||
controller 1. The profile's button layout (Settings > Gamepads) is the
|
||||
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) |
|
||||
@@ -163,9 +166,22 @@ 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. A co-op game does
|
||||
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
|
||||
@@ -204,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 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. |
|
||||
@@ -241,7 +264,13 @@ the setting for one start of the game. It has priority over the file.
|
||||
| `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.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.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, and that carry the listings of the 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. |
|
||||
@@ -433,18 +462,27 @@ Server Setup in Create Game > Internet has a LISTING row:
|
||||
- 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). A LAN game is never listed. `network.public_lobby = false` turns the server browser off.
|
||||
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. REFRESH
|
||||
asks the hosts for their listings again.
|
||||
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.signalling_brokers`), retained,
|
||||
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
|
||||
@@ -460,14 +498,27 @@ How it operates (`src/p2p_lobby.c`):
|
||||
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.
|
||||
|
||||
To use a broker of your own, add it to `network.signalling_brokers`. All the
|
||||
players must use the same broker to see each other's games. The game uses
|
||||
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.
|
||||
@@ -484,7 +535,7 @@ Only machines with the invite can find the game:
|
||||
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
|
||||
@@ -516,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
|
||||
@@ -594,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. |
|
||||
@@ -680,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; the main menu and Multiplayer clear co-op's controllers, so that a gamepad going back to controller 1 is not a controller unplugged. |
|
||||
| `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:
|
||||
|
||||
@@ -117,6 +117,10 @@ enum
|
||||
|
||||
/* ---------- structures */
|
||||
|
||||
/* (how many things to pick up it gives up at once, and for how long) */
|
||||
#define BOT_IGNORED_ITEMS 4
|
||||
#define BOT_IGNORE_ITEM_TICKS 600
|
||||
|
||||
struct bot
|
||||
{
|
||||
long player_index;
|
||||
@@ -141,8 +145,20 @@ struct bot
|
||||
while on that account: following a person, a thing to pick up */
|
||||
short path_failures;
|
||||
long follow_again_time;
|
||||
long ignored_item_index;
|
||||
long ignored_item_time;
|
||||
/* things to pick up given up for a while (no way to them, or there and
|
||||
not taken: on a ledge, out of reach), and how long it has stood by the
|
||||
one it goes for */
|
||||
long ignored_items[BOT_IGNORED_ITEMS];
|
||||
long ignored_item_times[BOT_IGNORED_ITEMS];
|
||||
short ignored_item_next;
|
||||
/* (the nearest it has come to the thing it goes for, and when) */
|
||||
long item_progress_index;
|
||||
real item_best_distance;
|
||||
long item_best_time;
|
||||
/* stuck again and again about the same place (as at the foot of a ramp
|
||||
or behind its rail): how often since when, to give the goal up */
|
||||
short stuck_count;
|
||||
long stuck_count_time;
|
||||
real wander_yaw;
|
||||
short weave_phase;
|
||||
/* where it is going, and the way there */
|
||||
@@ -231,6 +247,7 @@ static struct
|
||||
long switches;
|
||||
long stucks;
|
||||
long long_stucks;
|
||||
long gave_up;
|
||||
long fail_start;
|
||||
long fail_goal;
|
||||
long fail_search;
|
||||
@@ -540,18 +557,40 @@ the level between them at its knees */
|
||||
static boolean bot_clear_walk(
|
||||
long unit_index,
|
||||
real_point3d const *from,
|
||||
real_point3d const *to)
|
||||
real_point3d const *to,
|
||||
boolean wide)
|
||||
{
|
||||
struct collision_result collision;
|
||||
real_point3d start = *from;
|
||||
real_vector3d vector;
|
||||
real length;
|
||||
short line;
|
||||
|
||||
start.z += 0.3f;
|
||||
vector.i = to->x - from->x;
|
||||
vector.j = to->y - from->y;
|
||||
vector.k = to->z - from->z;
|
||||
return !collision_test_vector(FLAG(_collision_test_structure_bit) | FLAG(_collision_test_front_facing_surfaces_bit),
|
||||
&start, &vector, unit_index, &collision);
|
||||
length = (real)sqrt(vector.i * vector.i + vector.j * vector.j);
|
||||
/* (at its knees and at its chest: a rail with room under it, a slit in
|
||||
a wall, are not ways through; wide, along its shoulders too: a door it
|
||||
would pass the middle of but catch its frame) */
|
||||
for (line = 0; line < (wide && length > 0.001f ? 4 : 2); line++)
|
||||
{
|
||||
real_point3d start = *from;
|
||||
|
||||
start.z += line == 1 ? 1.0f : line ? 0.6f : 0.3f;
|
||||
if (line >= 2)
|
||||
{
|
||||
real side = line == 2 ? 0.35f : -0.35f;
|
||||
|
||||
start.x += -vector.j / length * side;
|
||||
start.y += vector.i / length * side;
|
||||
}
|
||||
if (collision_test_vector(FLAG(_collision_test_structure_bit) | FLAG(_collision_test_front_facing_surfaces_bit),
|
||||
&start, &vector, unit_index, &collision))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static boolean bot_next_point_now(
|
||||
@@ -592,7 +631,7 @@ static boolean bot_next_point_now(
|
||||
real dy = bot->goal.y - position->y;
|
||||
|
||||
if (dx * dx + dy * dy < 3.0f * 3.0f && fabsf(bot->goal.z - position->z) < 0.6f &&
|
||||
bot_clear_walk(unit_index, position, &bot->goal))
|
||||
bot_clear_walk(unit_index, position, &bot->goal, FALSE))
|
||||
{
|
||||
*point = bot->goal;
|
||||
return TRUE;
|
||||
@@ -620,7 +659,7 @@ static boolean bot_next_point_now(
|
||||
|
||||
/* (on its own level only: one above may be in view over a
|
||||
ledge that a ramp leads round to) */
|
||||
if (fabsf(next->z - position->z) < 0.6f && bot_clear_walk(unit_index, position, next))
|
||||
if (fabsf(next->z - position->z) < 0.6f && bot_clear_walk(unit_index, position, next, TRUE))
|
||||
{
|
||||
bot->path.step_index++;
|
||||
if (bot->path.step_index >= bot->path.step_count)
|
||||
@@ -642,17 +681,20 @@ static boolean bot_next_point_now(
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* a goal when none is in sight: the nearest enemy, or somewhere near
|
||||
someone at random */
|
||||
/* a goal when none is in sight: an enemy, or somewhere near someone at
|
||||
random. Not all the nearest: each bot one of the three nearest (by its
|
||||
number), and while it is far, a few metres beside them, so that a team
|
||||
spreads out over the ways there instead of going as one crowd */
|
||||
static void bot_choose_goal(
|
||||
struct bot *bot,
|
||||
struct player_datum const *player,
|
||||
real_point3d const *position)
|
||||
{
|
||||
boolean teams = game_engine_has_teams();
|
||||
real best_distance = 1000000.0f;
|
||||
real best_distance[3] = { 1000000.0f, 1000000.0f, 1000000.0f };
|
||||
real_point3d best_origin[3];
|
||||
short found = 0;
|
||||
short index;
|
||||
boolean found = FALSE;
|
||||
|
||||
for (index = 0; index < MAXIMUM_TRACKED_PLAYERS; index++)
|
||||
{
|
||||
@@ -660,6 +702,7 @@ static void bot_choose_goal(
|
||||
long unit_index;
|
||||
real_point3d origin;
|
||||
real distance;
|
||||
short rank;
|
||||
|
||||
if (!other || other == player || (teams && other->team_index == player->team_index))
|
||||
continue;
|
||||
@@ -668,14 +711,38 @@ static void bot_choose_goal(
|
||||
continue;
|
||||
object_get_origin(unit_index, &origin);
|
||||
distance = distance3d(position, &origin);
|
||||
if (distance < best_distance)
|
||||
/* (kept in order, nearest first) */
|
||||
for (rank = 0; rank < 3 && distance >= best_distance[rank]; rank++)
|
||||
;
|
||||
if (rank == 3)
|
||||
continue;
|
||||
found = (short)MIN(found + 1, 3);
|
||||
{
|
||||
best_distance = distance;
|
||||
bot->goal = origin;
|
||||
found = TRUE;
|
||||
short move;
|
||||
|
||||
for (move = 2; move > rank; move--)
|
||||
{
|
||||
best_distance[move] = best_distance[move - 1];
|
||||
best_origin[move] = best_origin[move - 1];
|
||||
}
|
||||
}
|
||||
best_distance[rank] = distance;
|
||||
best_origin[rank] = origin;
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
short pick = (short)(DATUM_INDEX_TO_ABSOLUTE_INDEX(bot->player_index) % found);
|
||||
|
||||
bot->goal = best_origin[pick];
|
||||
if (best_distance[pick] > 25.0f)
|
||||
{
|
||||
real angle = (real)DATUM_INDEX_TO_ABSOLUTE_INDEX(bot->player_index) * 2.4f;
|
||||
|
||||
bot->goal.x += (real)cos(angle) * 6.0f;
|
||||
bot->goal.y += (real)sin(angle) * 6.0f;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
else
|
||||
{
|
||||
/* (no enemy alive: a few metres off, somewhere) */
|
||||
real angle = bot_random() * 2.0f * _pi;
|
||||
@@ -817,7 +884,59 @@ static real bot_item_worth(
|
||||
}
|
||||
|
||||
/* the thing most worth going for near the bot, or NONE */
|
||||
static boolean bot_item_ignored(
|
||||
struct bot const *bot,
|
||||
long item_index)
|
||||
{
|
||||
short index;
|
||||
|
||||
for (index = 0; index < BOT_IGNORED_ITEMS; index++)
|
||||
{
|
||||
if (bot->ignored_items[index] == item_index &&
|
||||
game_time_get() - bot->ignored_item_times[index] < BOT_IGNORE_ITEM_TICKS &&
|
||||
game_time_get() >= bot->ignored_item_times[index])
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void bot_ignore_item(
|
||||
struct bot *bot,
|
||||
long item_index)
|
||||
{
|
||||
bot->ignored_items[bot->ignored_item_next] = item_index;
|
||||
bot->ignored_item_times[bot->ignored_item_next] = game_time_get();
|
||||
bot->ignored_item_next = (short)((bot->ignored_item_next + 1) % BOT_IGNORED_ITEMS);
|
||||
bot->item_progress_index = NONE;
|
||||
}
|
||||
|
||||
/* going for a thing to pick up: whether to give it up, coming no nearer
|
||||
(half a metre) for two and a half seconds: out of reach, past a rail, up
|
||||
where no way it finds goes, or in a crowd */
|
||||
static boolean bot_item_out_of_reach(
|
||||
struct bot *bot,
|
||||
real distance)
|
||||
{
|
||||
if (bot->item_progress_index != bot->item_index || game_time_get() < bot->item_best_time)
|
||||
{
|
||||
bot->item_progress_index = bot->item_index;
|
||||
bot->item_best_distance = distance;
|
||||
bot->item_best_time = game_time_get();
|
||||
return FALSE;
|
||||
}
|
||||
if (distance < bot->item_best_distance - 0.5f)
|
||||
{
|
||||
bot->item_best_distance = distance;
|
||||
bot->item_best_time = game_time_get();
|
||||
return FALSE;
|
||||
}
|
||||
return game_time_get() - bot->item_best_time > 75;
|
||||
}
|
||||
|
||||
static long bot_find_item(
|
||||
struct bot const *bot,
|
||||
struct unit_datum const *unit,
|
||||
real_point3d const *position,
|
||||
real range,
|
||||
@@ -840,7 +959,7 @@ static long bot_find_item(
|
||||
if (distance > range)
|
||||
continue;
|
||||
worth = bot_item_worth(unit, iterator.index);
|
||||
if (worth <= 0.0f || worth < least_worth)
|
||||
if (worth <= 0.0f || worth < least_worth || bot_item_ignored(bot, iterator.index))
|
||||
continue;
|
||||
/* (the strong ones worth a longer way) */
|
||||
score = worth * worth / (1.0f + distance / 15.0f);
|
||||
@@ -2393,7 +2512,7 @@ static void bot_think(
|
||||
game_time_get() < bot->item_look_time))
|
||||
{
|
||||
bot->item_look_time = game_time_get();
|
||||
bot->item_index = bot_find_item(unit, &position, 10.0f, 4.0f);
|
||||
bot->item_index = bot_find_item(bot, unit, &position, 10.0f, 4.0f);
|
||||
}
|
||||
if (bot->item_index != NONE && !bot->carrying && !bot->has_objective && object_try_and_get(bot->item_index) &&
|
||||
bot_item_worth(unit, bot->item_index) > 0.0f)
|
||||
@@ -2408,6 +2527,11 @@ static void bot_think(
|
||||
bot_walk_to(action, bot->yaw, &position, &point);
|
||||
if (distance3d(&position, &item_position) < 2.0f)
|
||||
bot_take_item(bot, player, unit, action);
|
||||
if (bot_item_out_of_reach(bot, distance3d(&position, &item_position)))
|
||||
{
|
||||
bot_ignore_item(bot, bot->item_index);
|
||||
bot->item_index = NONE;
|
||||
}
|
||||
}
|
||||
/* closes on it along its way, weaving, until near */
|
||||
else if (bot->has_objective && bot->objective_unit_index != bot->target_unit_index)
|
||||
@@ -2497,11 +2621,9 @@ static void bot_think(
|
||||
/* something worth having near: there first */
|
||||
else if (game_time_get() - bot->item_look_time >= ITEM_LOOK_TICKS || game_time_get() < bot->item_look_time)
|
||||
{
|
||||
long item = bot_find_item(unit, &position, BOT_ITEM_RANGE, 0.0f);
|
||||
long item = bot_find_item(bot, unit, &position, BOT_ITEM_RANGE, 0.0f);
|
||||
|
||||
bot->item_look_time = game_time_get();
|
||||
if (item == bot->ignored_item_index && game_time_get() - bot->ignored_item_time < 600)
|
||||
item = NONE;
|
||||
if (item != bot->item_index)
|
||||
{
|
||||
bot->item_index = item;
|
||||
@@ -2519,8 +2641,7 @@ static void bot_think(
|
||||
/* (taken or gone, or no way to it: on) */
|
||||
if (bot->path_failures >= 3)
|
||||
{
|
||||
bot->ignored_item_index = bot->item_index;
|
||||
bot->ignored_item_time = game_time_get();
|
||||
bot_ignore_item(bot, bot->item_index);
|
||||
bot->path_failures = 0;
|
||||
bot->item_index = NONE;
|
||||
bot->has_goal = FALSE;
|
||||
@@ -2536,6 +2657,14 @@ static void bot_think(
|
||||
bot->goal_time = game_time_get();
|
||||
if (distance3d(&position, &bot->goal) < 2.0f)
|
||||
bot_take_item(bot, player, unit, action);
|
||||
/* (no nearer a while: out of reach, as on a ledge, or not
|
||||
offered: given up for a while) */
|
||||
if (bot_item_out_of_reach(bot, distance3d(&position, &bot->goal)))
|
||||
{
|
||||
bot_ignore_item(bot, bot->item_index);
|
||||
bot->item_index = NONE;
|
||||
bot->has_goal = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* (in a team, every third bot with nothing to do keeps near the
|
||||
@@ -2590,7 +2719,15 @@ static void bot_think(
|
||||
bot->path_failures = 0;
|
||||
}
|
||||
wanted_yaw = bot->wander_yaw;
|
||||
if (bot_next_point(bot, player->unit_index, &position, &point))
|
||||
/* (holding a spot and near it: there, not pressing on into what may
|
||||
stand on it, a pillar, a wall) */
|
||||
if (bot->holding && bot->has_objective &&
|
||||
(bot->goal.x - position.x) * (bot->goal.x - position.x) +
|
||||
(bot->goal.y - position.y) * (bot->goal.y - position.y) < 1.5f * 1.5f)
|
||||
{
|
||||
bot->walking = FALSE;
|
||||
}
|
||||
else if (bot_next_point(bot, player->unit_index, &position, &point))
|
||||
{
|
||||
real dx = point.x - position.x;
|
||||
real dy = point.y - position.y;
|
||||
@@ -2680,7 +2817,8 @@ static void bot_think(
|
||||
boolean progress = distance < bot->walk_distance - 0.015f || moved > 0.06f;
|
||||
|
||||
bot->walk_distance = MIN(bot->walk_distance, distance);
|
||||
if (progress && moved > 0.02f)
|
||||
/* (at the point, as on a thing to pick up: there, not stuck) */
|
||||
if ((progress && moved > 0.02f) || distance < 0.5f)
|
||||
{
|
||||
bot->stuck_ticks = 0;
|
||||
}
|
||||
@@ -2689,8 +2827,27 @@ static void bot_think(
|
||||
bot->stuck_ticks++;
|
||||
if (bot->stuck_ticks == 6)
|
||||
{
|
||||
bot->sidestep = bot_random() < 0.5f ? 1.0f : -1.0f;
|
||||
/* (to the side that is open, as round a pillar; either, at
|
||||
random: left, the strafe's positive, bot_walk_to) */
|
||||
real_point3d left = position, right = position;
|
||||
boolean left_open, right_open;
|
||||
|
||||
left.x += -(real)sin(bot->yaw) * 1.2f;
|
||||
left.y += (real)cos(bot->yaw) * 1.2f;
|
||||
right.x -= -(real)sin(bot->yaw) * 1.2f;
|
||||
right.y -= (real)cos(bot->yaw) * 1.2f;
|
||||
left_open = bot_clear_walk(player->unit_index, &position, &left, FALSE);
|
||||
right_open = bot_clear_walk(player->unit_index, &position, &right, FALSE);
|
||||
bot->sidestep = left_open != right_open ? (left_open ? 1.0f : -1.0f) :
|
||||
bot_random() < 0.5f ? 1.0f : -1.0f;
|
||||
bot->sidestep_ticks = 10;
|
||||
/* (the point a little above and near, up a step or the lip of
|
||||
a ramp: a jump on towards it, not a step aside) */
|
||||
if (bot->walk_point.z - position.z > 0.3f && distance < 3.0f)
|
||||
{
|
||||
bot->sidestep_ticks = 0;
|
||||
SET_FLAG(action->control_flags, _unit_control_jump_bit, TRUE);
|
||||
}
|
||||
/* (near a point of its path it cannot reach, at a corner: the
|
||||
next one) */
|
||||
if (distance < 1.5f && bot->path.valid && bot->path.step_index < bot->path.step_count)
|
||||
@@ -2699,6 +2856,38 @@ static void bot_think(
|
||||
bot->sidestep_ticks = 4;
|
||||
}
|
||||
bots.stucks++;
|
||||
/* (the third time in five seconds: the goal given up, the
|
||||
thing to pick up for a while, and somewhere else, away from
|
||||
where it could not get) */
|
||||
if (game_time_get() - bot->stuck_count_time > 150 || game_time_get() < bot->stuck_count_time)
|
||||
{
|
||||
bot->stuck_count = 0;
|
||||
bot->stuck_count_time = game_time_get();
|
||||
}
|
||||
if (++bot->stuck_count >= 3)
|
||||
{
|
||||
real away = (real)atan2(position.y - bot->walk_point.y, position.x - bot->walk_point.x) +
|
||||
(bot_random() - 0.5f) * 1.5f;
|
||||
|
||||
bot->stuck_count = 0;
|
||||
if (bot->item_index != NONE)
|
||||
{
|
||||
bot_ignore_item(bot, bot->item_index);
|
||||
bot->item_index = NONE;
|
||||
}
|
||||
if (bot->holding)
|
||||
bot->path_failures = 3;
|
||||
else if (!bot->has_objective)
|
||||
{
|
||||
bot->goal = position;
|
||||
bot->goal.x += (real)cos(away) * 10.0f;
|
||||
bot->goal.y += (real)sin(away) * 10.0f;
|
||||
bot->has_goal = TRUE;
|
||||
bot->goal_time = game_time_get();
|
||||
bot->follow_again_time = game_time_get() + 150;
|
||||
}
|
||||
bots.gave_up++;
|
||||
}
|
||||
|
||||
bot->path_time = game_time_get() - PATH_REFRESH_TICKS;
|
||||
bot->walk_distance = 1000000.0f;
|
||||
@@ -2707,6 +2896,10 @@ static void bot_think(
|
||||
SET_FLAG(action->control_flags, _unit_control_jump_bit, TRUE);
|
||||
if (bot->stuck_ticks == 24)
|
||||
bots.long_stucks++;
|
||||
/* (a spot to hold it cannot get to: the place's centre instead,
|
||||
bot_hold_spot) */
|
||||
if (bot->stuck_ticks == 18 && bot->holding)
|
||||
bot->path_failures = 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2735,7 +2928,13 @@ static struct bot *bot_get(
|
||||
free_bot->player_index = player_index;
|
||||
free_bot->target_unit_index = NONE;
|
||||
free_bot->item_index = NONE;
|
||||
free_bot->ignored_item_index = NONE;
|
||||
free_bot->item_progress_index = NONE;
|
||||
{
|
||||
short ignored;
|
||||
|
||||
for (ignored = 0; ignored < BOT_IGNORED_ITEMS; ignored++)
|
||||
free_bot->ignored_items[ignored] = NONE;
|
||||
}
|
||||
free_bot->vehicle_index = NONE;
|
||||
free_bot->ignored_vehicle_index = NONE;
|
||||
free_bot->step_radius = BOT_STEP_RADIUS;
|
||||
@@ -2823,12 +3022,12 @@ void bots_tick(
|
||||
}
|
||||
}
|
||||
bots.logged_time = game_time_get();
|
||||
platform_log("bots: driving %d; paths found %ld, not %ld; weapon swaps asked %ld; grenades %ld; changes %ld; stuck %ld, long %ld (no start %ld, no goal %ld, no way %ld); vehicles: in %ld, out %ld",
|
||||
(int)count, bots.paths_found, bots.paths_failed, bots.pickups, bots.grenades, bots.switches, bots.stucks, bots.long_stucks, bots.fail_start, bots.fail_goal, bots.fail_search,
|
||||
platform_log("bots: driving %d; paths found %ld, not %ld; weapon swaps asked %ld; grenades %ld; changes %ld; stuck %ld, long %ld, gave up %ld (no start %ld, no goal %ld, no way %ld); vehicles: in %ld, out %ld",
|
||||
(int)count, bots.paths_found, bots.paths_failed, bots.pickups, bots.grenades, bots.switches, bots.stucks, bots.long_stucks, bots.gave_up, bots.fail_start, bots.fail_goal, bots.fail_search,
|
||||
bots.vehicle_entries, bots.vehicle_exits);
|
||||
bots.vehicle_entries = bots.vehicle_exits = 0;
|
||||
bots.fail_start = bots.fail_goal = bots.fail_search = 0;
|
||||
bots.paths_found = bots.paths_failed = bots.pickups = bots.grenades = bots.switches = bots.stucks = bots.long_stucks = 0;
|
||||
bots.paths_found = bots.paths_failed = bots.pickups = bots.grenades = bots.switches = bots.stucks = bots.long_stucks = bots.gave_up = 0;
|
||||
for (index = 0; index < MAXIMUM_TRACKED_PLAYERS; index++)
|
||||
{
|
||||
struct player_datum *player = distributed_player(index);
|
||||
|
||||
@@ -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
|
||||
@@ -45,6 +45,8 @@ no screen pauses the game (a network game's clock runs on).
|
||||
/* 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);
|
||||
@@ -341,8 +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",
|
||||
@@ -355,6 +361,8 @@ static char const *const port_function_names[] =
|
||||
/* (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
|
||||
@@ -372,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
|
||||
@@ -698,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));
|
||||
@@ -912,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 */
|
||||
@@ -1205,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;
|
||||
@@ -1575,9 +1627,8 @@ void menu_tags_loaded(
|
||||
{
|
||||
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)
|
||||
@@ -1641,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));
|
||||
|
||||
@@ -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,7 +362,9 @@ 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) */
|
||||
@@ -456,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) &&
|
||||
@@ -467,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:
|
||||
@@ -618,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++];
|
||||
@@ -706,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,
|
||||
@@ -725,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)
|
||||
@@ -738,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)
|
||||
{
|
||||
@@ -1078,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;
|
||||
@@ -1112,25 +1226,6 @@ static real distributed_player_deals(
|
||||
*kinds |= weapon_kinds;
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
/* (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)
|
||||
@@ -1152,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;
|
||||
}
|
||||
|
||||
@@ -1432,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 ?
|
||||
@@ -1639,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 ||
|
||||
@@ -1652,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 */
|
||||
@@ -1671,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
|
||||
@@ -1713,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 */
|
||||
@@ -1939,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)
|
||||
{
|
||||
@@ -1949,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();
|
||||
@@ -2057,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2102,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)
|
||||
{
|
||||
@@ -2121,8 +2320,8 @@ void network_damage_new_game(
|
||||
for (index = 0; index < MAXIMUM_RECENT_WEAPONS; index++)
|
||||
damage_players[player_index].definition_indices[index] = NONE;
|
||||
damage_players[player_index].unarmed_melee_damage_index = NONE;
|
||||
for (index = 0; index < NUMBER_OF_UNIT_GRENADE_TYPES; index++)
|
||||
damage_players[player_index].grenade_times[index] = -RECENT_WEAPON_TICKS - 1;
|
||||
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 */
|
||||
@@ -232,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>
|
||||
@@ -241,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;
|
||||
@@ -329,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;
|
||||
@@ -637,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,
|
||||
@@ -658,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(
|
||||
@@ -703,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;
|
||||
}
|
||||
|
||||
@@ -766,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(
|
||||
@@ -781,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;
|
||||
@@ -877,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
|
||||
@@ -889,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)
|
||||
@@ -916,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)
|
||||
@@ -968,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]);
|
||||
@@ -1001,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;
|
||||
@@ -1027,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
|
||||
{
|
||||
@@ -1496,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;
|
||||
@@ -1644,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 */
|
||||
@@ -1838,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) */
|
||||
{
|
||||
@@ -2092,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)
|
||||
@@ -2115,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;
|
||||
@@ -2147,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))
|
||||
{
|
||||
@@ -2177,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2598,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)
|
||||
{
|
||||
@@ -2625,6 +3029,7 @@ void network_objects_client_tick(
|
||||
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)
|
||||
@@ -2642,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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -2421,7 +2421,13 @@ int p2p_public_games(struct p2p_public_game *games, int maximum)
|
||||
listing_count = p2p_lobby_games(listings, 32);
|
||||
for (index = 0; index < listing_count && count < maximum; index++)
|
||||
{
|
||||
struct p2p_public_game *game = &games[count++];
|
||||
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);
|
||||
@@ -2533,7 +2539,8 @@ void p2p_new_invite_if_listed(void)
|
||||
if (!p2p.has_token || !p2p.token_listed)
|
||||
return;
|
||||
make_invite();
|
||||
platform_log("Internet play: the game is private now, with a new invite: %s", p2p.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);
|
||||
|
||||
@@ -149,6 +149,12 @@ 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) */
|
||||
@@ -167,10 +173,16 @@ enum
|
||||
/* 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];
|
||||
@@ -183,12 +195,20 @@ struct p2p_listing
|
||||
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
|
||||
|
||||
@@ -20,6 +20,7 @@ tunnel's packets are sealed with keys only its two machines have.
|
||||
#include "monocypher.h"
|
||||
#include "monocypher-ed25519.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* ---------- SHA-256 */
|
||||
@@ -649,6 +650,50 @@ int p2p_ed25519_to_x25519(const unsigned char *public_key, unsigned char *x25519
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -246,6 +246,26 @@ int p2p_ed25519_verify(const unsigned char *public_key, const void *message, int
|
||||
/* 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
|
||||
|
||||
@@ -12,9 +12,11 @@ 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), sequence (4: newest
|
||||
wins), Unix time (4), the Ed25519 key (32), the invite's token (16),
|
||||
players, most players, the gametype's engine (1 each), the game's name,
|
||||
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.
|
||||
@@ -38,6 +40,14 @@ one deletes or keeps is no authority, so
|
||||
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).
|
||||
@@ -62,11 +72,11 @@ enum
|
||||
_listing_has_teams = 4,
|
||||
/* a tombstone: the host stopped */
|
||||
_listing_closed = 8,
|
||||
/* (reserved) */
|
||||
/* 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_TOKEN_SIZE + 3 +
|
||||
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 +
|
||||
@@ -88,6 +98,10 @@ enum
|
||||
|
||||
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
|
||||
{
|
||||
@@ -97,6 +111,8 @@ struct listing
|
||||
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];
|
||||
@@ -143,6 +159,9 @@ static struct
|
||||
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];
|
||||
@@ -240,6 +259,8 @@ static int listing_make(unsigned char *bytes, int flags)
|
||||
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;
|
||||
@@ -252,8 +273,20 @@ static int listing_make(unsigned char *bytes, int flags)
|
||||
size += 4;
|
||||
memcpy(bytes + size, p2p_signing_key(), P2P_KEY_SIZE);
|
||||
size += P2P_KEY_SIZE;
|
||||
memcpy(bytes + size, lobby.token, P2P_TOKEN_SIZE);
|
||||
size += P2P_TOKEN_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;
|
||||
@@ -302,8 +335,20 @@ static int listing_read(const unsigned char *bytes, int size, struct listing *li
|
||||
offset += 4;
|
||||
memcpy(listing->key, bytes + offset, P2P_KEY_SIZE);
|
||||
offset += P2P_KEY_SIZE;
|
||||
memcpy(listing->token, bytes + offset, P2P_TOKEN_SIZE);
|
||||
offset += P2P_TOKEN_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++];
|
||||
@@ -569,10 +614,22 @@ static void listing_take(const struct queued *queued, const struct listing *list
|
||||
memcpy(game->payload, queued->payload, (size_t)queued->size);
|
||||
game->payload_size = queued->size;
|
||||
shown = &game->listing;
|
||||
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);
|
||||
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));
|
||||
@@ -669,6 +726,33 @@ void p2p_set_hosting_public(int public)
|
||||
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)
|
||||
{
|
||||
@@ -765,6 +849,28 @@ int p2p_lobby_games(struct p2p_listing *games, int maximum_count)
|
||||
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);
|
||||
|
||||
@@ -3,9 +3,10 @@ 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 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).
|
||||
(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
|
||||
@@ -103,8 +104,9 @@ enum
|
||||
PROOF_SIZE = NONCE_SIZE + TAG_SIZE,
|
||||
BUFFER_SIZE = 4096,
|
||||
MAXIMUM_MESSAGE_SIZE = 512,
|
||||
/* a listing's most (p2p_lobby.c's MAXIMUM_LISTING_SIZE, and some) */
|
||||
MAXIMUM_LISTING_SIZE = 256,
|
||||
/* 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_*) */
|
||||
@@ -1521,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];
|
||||
@@ -1539,7 +1583,8 @@ void p2p_signal_start(void)
|
||||
p2p_key_hash(p2p_public_key(), hash);
|
||||
p2p_lobby_slot_topic(hash, signalling.own_slot, sizeof(signalling.own_slot));
|
||||
}
|
||||
text = config_string("network.signalling_brokers");
|
||||
brokers_list(list, sizeof(list));
|
||||
text = list;
|
||||
while (*text && signalling.broker_count < MAXIMUM_BROKERS)
|
||||
{
|
||||
const char *end = text + strcspn(text, ",");
|
||||
@@ -1571,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)
|
||||
|
||||
@@ -66,15 +66,28 @@ struct config_setting
|
||||
static const struct config_setting config_settings[] =
|
||||
{
|
||||
{ "display.fullscreen", _config_boolean, "true", "HALO_FULLSCREEN", _environment_value, _platform_desktop,
|
||||
"Start fullscreen, drawing at the display's resolution and shape; false\n"
|
||||
"starts in a window, which draws the Xbox's 640x480. F11 switches." },
|
||||
"Where display.mode is empty: start borderless over the whole display;\n"
|
||||
"false starts in a window. F11 switches." },
|
||||
{ "display.mode", _config_string, "\"\"", "HALO_DISPLAY_MODE", _environment_value, _platform_desktop,
|
||||
"\"fullscreen\" takes the display at its desktop resolution, \"borderless\"\n"
|
||||
"is a window over the whole desktop (both draw at the display's\n"
|
||||
"resolution), \"windowed\" a window of the Xbox's 640x480, scaled. Empty:\n"
|
||||
"display.fullscreen's (true: borderless). F11 switches to the window and back." },
|
||||
"\"fullscreen\" takes the display (at display.resolution's mode),\n"
|
||||
"\"borderless\" is a window over the whole desktop, \"windowed\" a window\n"
|
||||
"(display.window_size). Empty: display.fullscreen's (true: borderless).\n"
|
||||
"F11 switches to the window and back." },
|
||||
{ "display.resolution", _config_string, "\"native\"", "HALO_RESOLUTION", _environment_value, _platform_desktop,
|
||||
"What fullscreen and borderless draw at: \"native\", the display's own, or\n"
|
||||
"\"<width>x<height>\" (\"1920x1080\"), 640x480 or more. Fullscreen sets the\n"
|
||||
"display to it; borderless draws it scaled to the display." },
|
||||
{ "display.resolution_scaling", _config_string, "\"native\"", "HALO_RESOLUTION_SCALING", _environment_value,
|
||||
_platform_desktop,
|
||||
"\"native\" draws at the window's resolution (fullscreen, the display's or\n"
|
||||
"display.resolution); \"original\" draws the Xbox's 640x480 and scales it\n"
|
||||
"up." },
|
||||
{ "display.window_size", _config_string, "\"\"", "HALO_WINDOW_SIZE", _environment_value, _platform_desktop,
|
||||
"The window's size, \"<width>x<height>\" (\"1920x1080\"), 640x480 or more (it\n"
|
||||
"can be resized). Empty: display.window_scale's." },
|
||||
{ "display.window_scale", _config_integer, "2", "HALO_WINDOW_SCALE", _environment_value, _platform_desktop,
|
||||
"The window's size as a multiple of 640x480 (it can be resized)." },
|
||||
"Where display.window_size is empty: the window's size as a multiple of\n"
|
||||
"640x480." },
|
||||
{ "display.screen_width", _config_integer, "0", "HALO_SCREEN_WIDTH", _environment_value, _platform_android,
|
||||
"Columns of the 480-line picture: 0 for the display's shape, 640 for the\n"
|
||||
"Xbox's 4:3." },
|
||||
@@ -83,6 +96,12 @@ static const struct config_setting config_settings[] =
|
||||
{ "display.max_fps", _config_integer, "0", "HALO_MAX_FPS", _environment_value, _platform_desktop,
|
||||
"With vsync off, the most frames a second: 0 for twice the display's\n"
|
||||
"refresh rate, -1 for no limit (which can hang some Intel graphics)." },
|
||||
{ "display.anti_aliasing", _config_string, "\"off\"", "HALO_ANTI_ALIASING", _environment_value, _platform_all,
|
||||
"Smoothing of jagged edges, which the Xbox did not have: \"off\"; \"fxaa\"\n"
|
||||
"or \"smaa\" smooth the 3D view once it is drawn (the HUD and menus stay\n"
|
||||
"sharp); \"ssaa2x\" draws at twice the resolution each way (four times\n"
|
||||
"the work); \"msaa2x\", \"msaa4x\" or \"msaa8x\" draw with that many samples\n"
|
||||
"a pixel. Android has \"fxaa\" for \"smaa\", and no \"ssaa2x\"." },
|
||||
{ "display.interpolation", _config_boolean, "true", "HALO_INTERPOLATION", _environment_value, _platform_all,
|
||||
"Draw a frame for every display refresh, blending between the game's 30\n"
|
||||
"ticks a second; false keeps the original 30 frames a second." },
|
||||
@@ -96,8 +115,12 @@ static const struct config_setting config_settings[] =
|
||||
"false draws the maps' own bitmaps." },
|
||||
{ "display.high_res_text", _config_boolean, "true", "HALO_HIGH_RES_TEXT", _environment_value, _platform_all,
|
||||
"Draw the menus' and HUD's text with the fonts in port/assets/fonts\n"
|
||||
"(Overpass) at the display's resolution, and the menus' titles from\n"
|
||||
"port/assets/titles; false draws the maps' bitmap fonts and titles." },
|
||||
"(Overpass) at the resolution the game draws at, and the menus' titles\n"
|
||||
"from port/assets/titles; false draws the maps' bitmap fonts and titles." },
|
||||
{ "display.shadow_resolution", _config_integer, "128", "HALO_SHADOW_RESOLUTION", _environment_value,
|
||||
_platform_all,
|
||||
"The size the objects' shadows are drawn at, in pixels each way: 128 as\n"
|
||||
"on the Xbox, or 256, 512 or 1024 for smoother edges, as soft." },
|
||||
{ "display.menus", _config_string, "\"pc\"", "HALO_MENUS", _environment_value, _platform_all,
|
||||
"The menus: \"pc\" for the PC version's main menu (port/assets/menus,\n"
|
||||
"and a menus folder here for your own), \"xbox\" for the Xbox's." },
|
||||
@@ -122,10 +145,19 @@ static const struct config_setting config_settings[] =
|
||||
_environment_value, _platform_all,
|
||||
"The scoreboard panel's colour: \"red, green, blue, alpha\", each 0 to 255\n"
|
||||
"(alpha 0 is see-through, 255 solid)." },
|
||||
{ "display.per_pixel_lighting", _config_boolean, "false", "HALO_PER_PIXEL_LIGHTING", _environment_value,
|
||||
_platform_all,
|
||||
"Light the models (characters, weapons, vehicles, scenery) for each\n"
|
||||
"pixel by the lights the game gives them, without the facets the light\n"
|
||||
"of each vertex shows across curved surfaces; false lights each vertex,\n"
|
||||
"as the Xbox does." },
|
||||
|
||||
{ "vr.enabled", _config_boolean, "true", "HALO_VR_ENABLED", _environment_value, _platform_android,
|
||||
"On a VR headset (Quest, Steam Frame), play in VR; false shows the game\n"
|
||||
"on a flat panel instead. Read when the app starts." },
|
||||
{ "vr.menus", _config_string, "\"pc\"", "HALO_VR_MENUS", _environment_value, _platform_android,
|
||||
"The menus in VR: \"pc\" for the PC version's (as display.menus), \"xbox\"\n"
|
||||
"for the Xbox's. Read when the menus' map loads." },
|
||||
{ "vr.resolution_scale", _config_real, "1.0", "HALO_VR_RESOLUTION_SCALE", _environment_value, _platform_android,
|
||||
"The eye images' size as a multiple of what the headset recommends;\n"
|
||||
"lower is faster. Read when the app starts." },
|
||||
@@ -285,6 +317,10 @@ static const struct config_setting config_settings[] =
|
||||
{ "audio.effects_volume", _config_real, "1.0", "HALO_EFFECTS_VOLUME", _environment_value, _platform_all,
|
||||
"The volume of every other sound (effects and speech), 0.0 to 1.0 (of\n"
|
||||
"audio.volume)." },
|
||||
{ "audio.reverb", _config_boolean, "true", "HALO_REVERB", _environment_value, _platform_all,
|
||||
"Reverberate the world's sounds as the place the player is in does (the\n"
|
||||
"maps' sound environments, as the Xbox's I3DL2 reverb did); false keeps\n"
|
||||
"them dry." },
|
||||
|
||||
{ "input.mouse_sensitivity", _config_real, "1.0", "HALO_MOUSE_SENSITIVITY", _environment_value, _platform_desktop,
|
||||
"How far the view turns for the mouse's movement." },
|
||||
@@ -399,11 +435,45 @@ static const struct config_setting config_settings[] =
|
||||
"in everyone's server browser: anyone can see and join it) or, false,\n"
|
||||
"PRIVATE (only players with its invite link can join). Server Setup's\n"
|
||||
"LISTING changes it for each game." },
|
||||
{ "network.signalling_brokers", _config_string,
|
||||
"\"broker.emqx.io:1883,broker.hivemq.com:1883,test.mosquitto.org:1883\"",
|
||||
"HALO_NET_BROKERS", _environment_value, _platform_all,
|
||||
"Public MQTT brokers through which the machines of an invite find each\n"
|
||||
"other (its messages are encrypted); comma-separated host:port." },
|
||||
{ "network.coop_public", _config_boolean, "false", "HALO_NET_COOP_PUBLIC", _environment_value, _platform_all,
|
||||
"Whether an online co-op game (Create Game > Internet, a SINGLEPLAYER\n"
|
||||
"map) starts as PUBLIC or, false, PRIVATE: Server Setup's LISTING in\n"
|
||||
"co-op, which writes its choice here." },
|
||||
{ "network.coop_friendly_fire", _config_string, "\"on\"", "HALO_NET_COOP_FRIENDLY_FIRE", _environment_value,
|
||||
_platform_all,
|
||||
"Whether the players of an online co-op game hurt each other: \"off\",\n"
|
||||
"\"on\", \"shields_only\" or \"explosives_only\" (Server Setup's FRIENDLY\n"
|
||||
"FIRE in co-op, which writes its choice here). Their AI allies they\n"
|
||||
"always can, as in the campaign." },
|
||||
{ "network.coop_player_collisions", _config_boolean, "true", "HALO_NET_COOP_PLAYER_COLLISIONS", _environment_value,
|
||||
_platform_all,
|
||||
"Whether the players of an online co-op game bump into each other;\n"
|
||||
"false, they walk through each other (the AI's characters they still\n"
|
||||
"bump into). Server Setup's PLAYER COLLISIONS in co-op writes its\n"
|
||||
"choice here." },
|
||||
{ "network.coop_enemies_mode", _config_string, "\"per_player\"", "HALO_NET_COOP_ENEMIES_MODE", _environment_value,
|
||||
_platform_all,
|
||||
"Online co-op's extra enemies: \"none\", \"per_player\" (each squad of\n"
|
||||
"enemies grows by coop_enemies for each player past the first) or\n"
|
||||
"\"multiplier\" (each is coop_enemies_multiplier times as large, for any\n"
|
||||
"number of players). Server Setup's EXTRA ENEMIES in co-op writes its\n"
|
||||
"choice here." },
|
||||
{ "network.coop_enemies", _config_integer, "50", "HALO_NET_COOP_ENEMIES", _environment_value, _platform_all,
|
||||
"Online co-op's extra enemies per player, a percentage: for each player\n"
|
||||
"past the first, each squad of enemies a level places gets this much of\n"
|
||||
"itself more (100: as many again; 25 to 200). Server Setup's PER PLAYER\n"
|
||||
"in co-op writes its choice here." },
|
||||
{ "network.coop_enemies_multiplier", _config_integer, "2", "HALO_NET_COOP_ENEMIES_MULTIPLIER", _environment_value,
|
||||
_platform_all,
|
||||
"Online co-op's static multiplier of its enemies: each squad of enemies\n"
|
||||
"a level places is this many times as large (2 to 32). Server Setup's\n"
|
||||
"MULTIPLIER in co-op writes its choice here." },
|
||||
{ "network.brokers_file", _config_string, "\"brokers.txt\"",
|
||||
"HALO_NET_BROKERS_FILE", _environment_value, _platform_all,
|
||||
"The file of the public MQTT brokers through which the machines of an\n"
|
||||
"invite find each other (its messages are encrypted), beside this file\n"
|
||||
"unless a full path: one host:port on each line, up to 4. Updates\n"
|
||||
"replace brokers.txt: keep a list of your own under another name." },
|
||||
{ "network.stun_servers", _config_string, "\"stun.l.google.com:19302,stun.cloudflare.com:3478\"",
|
||||
"HALO_NET_STUN", _environment_value, _platform_all,
|
||||
"Public STUN servers that tell this machine its internet address;\n"
|
||||
@@ -461,6 +531,17 @@ static const struct config_setting config_settings[] =
|
||||
"machines of twice it), to test the netcode as over the internet; 0 none." },
|
||||
{ "debug.network_loss", _config_real, "0.0", "HALO_NETWORK_LOSS", _environment_value, _platform_all,
|
||||
"Percent of datagrams received that are dropped, for the same; 0 none." },
|
||||
{ "debug.multiview_steamvr", _config_boolean, "false", "HALO_MULTIVIEW_STEAMVR", _environment_value,
|
||||
_platform_android,
|
||||
"On SteamVR (the Steam Frame) the eyes are drawn one by one, whatever\n"
|
||||
"vr.multiview says: true draws them at once there too, for testing." },
|
||||
{ "debug.gl_thread", _config_integer, "-1", "HALO_GL_THREAD", _environment_value, _platform_android,
|
||||
"Mesa's GL thread (its drivers: the Steam Frame's): 1 on, 0 off, -1 as the\n"
|
||||
"driver chooses. Read when the app starts." },
|
||||
{ "debug.xr_deferred_copies", _config_integer, "-1", "HALO_XR_DEFERRED", _environment_value, _platform_android,
|
||||
"The headset's layer copies: 1 deferred (no waits for the GL thread or the\n"
|
||||
"GPU in the middle of the frame), 0 each one restored and released at once,\n"
|
||||
"-1 as the runtime needs (deferred on SteamVR). Read when the app starts." },
|
||||
{ "debug.test_input", _config_string, "\"\"", "HALO_TEST_INPUT", _environment_value, _platform_all,
|
||||
"\"bot:<seed>\" plays controller 1 with a scripted pattern (automated\n"
|
||||
"network tests); \"look:<seed>\" stands still, only turning and looking\n"
|
||||
@@ -1250,6 +1331,11 @@ int config_write_integer(const char *name, long value)
|
||||
|
||||
/* ---------- public code */
|
||||
|
||||
char *config_file_read(const char *path, size_t *size)
|
||||
{
|
||||
return config_read_file(path, size);
|
||||
}
|
||||
|
||||
unsigned long config_changes(void)
|
||||
{
|
||||
return config_change_count;
|
||||
|
||||
@@ -30,6 +30,9 @@ such setting */
|
||||
int config_text(const char *name, char *text, size_t size);
|
||||
/* the folder config.toml is in, with its separator */
|
||||
void config_folder(char *path, size_t size);
|
||||
/* a whole file (a UTF-8 path), NUL terminated, or NULL; free() it (the Android
|
||||
guest has no SDL_LoadFile) */
|
||||
char *config_file_read(const char *path, size_t *size);
|
||||
/* a setting's default, as text; 0 if there is no such setting */
|
||||
int config_default(const char *name, char *text, size_t size);
|
||||
/* how many times config_write has changed a setting: what keeps one reads
|
||||
|
||||
@@ -62,6 +62,10 @@ gone, ends: else the keyboard stays held from the game) */
|
||||
static Uint64 binding_polled_ms;
|
||||
#define BINDING_ABANDONED_MS 500
|
||||
static unsigned mouse_buttons_down;
|
||||
#ifdef HALO_ANDROID
|
||||
/* the mouse's place, flat (platform_flat_mouse) */
|
||||
static float flat_mouse_x, flat_mouse_y;
|
||||
#endif
|
||||
/* (an input taken that nothing asks for is let go after this) */
|
||||
#define BINDING_UNCLAIMED_MS 2000
|
||||
/* the multiplayer scoreboard is open (platform_scoreboard_scroll): the wheel
|
||||
@@ -379,38 +383,43 @@ static BOOL platform_fullscreen_setting(void)
|
||||
return !config_boolean("debug.hidden_window") && platform_display_mode() != _display_mode_windowed;
|
||||
}
|
||||
|
||||
/* the window's fullscreen kind (display.mode): borderless, a window over
|
||||
the whole desktop (SDL's fullscreen without a mode), or fullscreen, the
|
||||
display taken at its desktop resolution. Either draws at the display's
|
||||
resolution (platform_screen_mode); F11 switches to the kind set. */
|
||||
static void platform_fullscreen_kind_apply(void)
|
||||
/* a size as a setting has it, "<width>x<height>": whether it is one, and
|
||||
the Xbox's 640x480 or more */
|
||||
static BOOL platform_size_parse(const char *text, long *width, long *height)
|
||||
{
|
||||
static int applied = -1;
|
||||
int exclusive = platform_display_mode() == _display_mode_fullscreen ? 1 : 0;
|
||||
SDL_DisplayID display;
|
||||
char *end;
|
||||
|
||||
if (!platform_window || exclusive == applied)
|
||||
return;
|
||||
applied = exclusive;
|
||||
display = SDL_GetDisplayForWindow(platform_window);
|
||||
SDL_SetWindowFullscreenMode(platform_window,
|
||||
exclusive && display ? SDL_GetDesktopDisplayMode(display) : NULL);
|
||||
*width = strtol(text, &end, 10);
|
||||
*height = *end == 'x' || *end == 'X' ? strtol(end + 1, &end, 10) : 0;
|
||||
return !*end && *width >= 640 && *height >= 480;
|
||||
}
|
||||
|
||||
/* whether the game is, or is to be, fullscreen, and if so the size in
|
||||
pixels of the display it fills (d3d8_gl.c draws at that resolution) */
|
||||
BOOL platform_screen_mode(long *width, long *height)
|
||||
/* display.resolution in pixels, or 0x0 for the display's own ("native"),
|
||||
as for one the game cannot draw at */
|
||||
static void platform_resolution_setting(long *width, long *height)
|
||||
{
|
||||
SDL_DisplayID display;
|
||||
const SDL_DisplayMode *mode;
|
||||
if (!platform_size_parse(config_string("display.resolution"), width, height))
|
||||
*width = *height = 0;
|
||||
}
|
||||
|
||||
if (platform_window ? !(SDL_GetWindowFlags(platform_window) & SDL_WINDOW_FULLSCREEN) :
|
||||
!platform_fullscreen_setting() || !platform_sdl_initialize())
|
||||
/* the window's size (display.window_size), else the Xbox's 640x480 times
|
||||
display.window_scale, as older versions set it */
|
||||
static void platform_window_size_setting(long *width, long *height)
|
||||
{
|
||||
long scale = config_integer("display.window_scale");
|
||||
|
||||
if (!platform_size_parse(config_string("display.window_size"), width, height))
|
||||
{
|
||||
return FALSE;
|
||||
*width = 640 * (scale < 1 ? 1 : scale);
|
||||
*height = 480 * (scale < 1 ? 1 : scale);
|
||||
}
|
||||
display = platform_window ? SDL_GetDisplayForWindow(platform_window) : SDL_GetPrimaryDisplay();
|
||||
mode = display ? SDL_GetDesktopDisplayMode(display) : NULL;
|
||||
}
|
||||
|
||||
/* a display's own size in pixels (its desktop mode) */
|
||||
static BOOL platform_display_size(SDL_DisplayID display, long *width, long *height)
|
||||
{
|
||||
const SDL_DisplayMode *mode = display ? SDL_GetDesktopDisplayMode(display) : NULL;
|
||||
|
||||
if (!mode)
|
||||
return FALSE;
|
||||
*width = (long)(mode->w * mode->pixel_density + 0.5f);
|
||||
@@ -418,23 +427,263 @@ BOOL platform_screen_mode(long *width, long *height)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* the window's fullscreen kind (display.mode): borderless, a window over
|
||||
the whole desktop (SDL's fullscreen without a mode), or fullscreen, the
|
||||
display taken at display.resolution's mode (the one nearest it), else at its
|
||||
desktop one. F11 switches to the kind set. */
|
||||
static void platform_fullscreen_kind_apply(void)
|
||||
{
|
||||
static int applied = -1;
|
||||
static long applied_width, applied_height;
|
||||
int exclusive = platform_display_mode() == _display_mode_fullscreen ? 1 : 0;
|
||||
long width = 0, height = 0;
|
||||
SDL_DisplayID display;
|
||||
SDL_DisplayMode closest;
|
||||
const SDL_DisplayMode *mode = NULL;
|
||||
|
||||
if (!platform_window)
|
||||
return;
|
||||
if (exclusive)
|
||||
platform_resolution_setting(&width, &height);
|
||||
if (exclusive == applied && width == applied_width && height == applied_height)
|
||||
return;
|
||||
applied = exclusive;
|
||||
applied_width = width;
|
||||
applied_height = height;
|
||||
display = SDL_GetDisplayForWindow(platform_window);
|
||||
if (exclusive && display)
|
||||
{
|
||||
if (width && SDL_GetClosestFullscreenDisplayMode(display, (int)width, (int)height, 0.0f, false, &closest))
|
||||
mode = &closest;
|
||||
else
|
||||
mode = SDL_GetDesktopDisplayMode(display);
|
||||
}
|
||||
SDL_SetWindowFullscreenMode(platform_window, mode);
|
||||
}
|
||||
|
||||
/* whether the game last asked for the window to be fullscreen */
|
||||
static BOOL platform_fullscreen_requested = FALSE;
|
||||
|
||||
static void platform_window_set_fullscreen(BOOL fullscreen)
|
||||
{
|
||||
platform_fullscreen_requested = fullscreen;
|
||||
SDL_SetWindowFullscreen(platform_window, fullscreen ? true : false);
|
||||
}
|
||||
|
||||
/* whether the window is fullscreen. SDL sets its flag when the window
|
||||
manager confirms the request, and some never do: gamescope (the Steam
|
||||
Deck's Game Mode) makes the window the size of the display but leaves the
|
||||
flag unset, so the game drew 640x480 and gamescope stretched it. A window
|
||||
that was asked to be fullscreen and covers its display counts too. */
|
||||
static BOOL platform_window_fullscreen(void)
|
||||
{
|
||||
SDL_DisplayID display;
|
||||
const SDL_DisplayMode *mode;
|
||||
int width, height;
|
||||
|
||||
if (SDL_GetWindowFlags(platform_window) & SDL_WINDOW_FULLSCREEN)
|
||||
return TRUE;
|
||||
if (!platform_fullscreen_requested)
|
||||
return FALSE;
|
||||
display = SDL_GetDisplayForWindow(platform_window);
|
||||
mode = display ? SDL_GetDesktopDisplayMode(display) : NULL;
|
||||
if (!mode || !SDL_GetWindowSizeInPixels(platform_window, &width, &height))
|
||||
return FALSE;
|
||||
return width >= (int)(mode->w * mode->pixel_density + 0.5f) &&
|
||||
height >= (int)(mode->h * mode->pixel_density + 0.5f);
|
||||
}
|
||||
|
||||
/* the size in pixels the game draws its picture at (d3d8_gl.c): the
|
||||
window's, the display's while fullscreen, or display.resolution's while
|
||||
fullscreen (either kind) where the display has room for it; before the
|
||||
window opens, what it will be. FALSE where display.resolution_scaling is
|
||||
"original": the Xbox's 640x480, scaled to the window. */
|
||||
BOOL platform_screen_mode(long *width, long *height)
|
||||
{
|
||||
/* (the size last given, for a window that has none: minimized) */
|
||||
static long last_width, last_height;
|
||||
long resolution_width, resolution_height;
|
||||
BOOL fullscreen;
|
||||
|
||||
if (!strcmp(config_string("display.resolution_scaling"), "original"))
|
||||
return FALSE;
|
||||
if (platform_window)
|
||||
{
|
||||
int pixel_width = 0, pixel_height = 0;
|
||||
|
||||
SDL_GetWindowSizeInPixels(platform_window, &pixel_width, &pixel_height);
|
||||
if (pixel_width <= 0 || pixel_height <= 0)
|
||||
{
|
||||
*width = last_width;
|
||||
*height = last_height;
|
||||
return last_width > 0;
|
||||
}
|
||||
*width = pixel_width;
|
||||
*height = pixel_height;
|
||||
fullscreen = platform_window_fullscreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!platform_sdl_initialize())
|
||||
return FALSE;
|
||||
fullscreen = platform_fullscreen_setting();
|
||||
platform_window_size_setting(width, height);
|
||||
if (fullscreen && !platform_display_size(SDL_GetPrimaryDisplay(), width, height))
|
||||
return FALSE;
|
||||
}
|
||||
/* (fullscreen's display is at the resolution already, where it has that
|
||||
mode: platform_fullscreen_kind_apply; borderless's is scaled to) */
|
||||
platform_resolution_setting(&resolution_width, &resolution_height);
|
||||
if (fullscreen && resolution_width && resolution_width <= *width && resolution_height <= *height)
|
||||
{
|
||||
*width = resolution_width;
|
||||
*height = resolution_height;
|
||||
}
|
||||
last_width = *width;
|
||||
last_height = *height;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* the size added to the list unless it has it already; the count */
|
||||
static int platform_resolution_add(long *widths, long *heights, int count, int maximum, long width, long height)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
if (widths[index] == width && heights[index] == height)
|
||||
return count;
|
||||
}
|
||||
if (count < maximum)
|
||||
{
|
||||
widths[count] = width;
|
||||
heights[count] = height;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int platform_display_resolutions(long *widths, long *heights, int maximum)
|
||||
{
|
||||
SDL_DisplayID display;
|
||||
SDL_DisplayMode **modes;
|
||||
long display_width, display_height, width, height;
|
||||
int mode_count = 0, count = 0, index;
|
||||
|
||||
if (maximum < 1 || !platform_sdl_initialize())
|
||||
return 0;
|
||||
display = platform_window ? SDL_GetDisplayForWindow(platform_window) : 0;
|
||||
if (!display)
|
||||
display = SDL_GetPrimaryDisplay();
|
||||
if (!platform_display_size(display, &display_width, &display_height))
|
||||
return 0;
|
||||
modes = SDL_GetFullscreenDisplayModes(display, &mode_count);
|
||||
for (index = 0; modes && index < mode_count; index++)
|
||||
{
|
||||
width = (long)(modes[index]->w * modes[index]->pixel_density + 0.5f);
|
||||
height = (long)(modes[index]->h * modes[index]->pixel_density + 0.5f);
|
||||
if (width >= 640 && height >= 480 && width <= display_width && height <= display_height &&
|
||||
(width != display_width || height != display_height))
|
||||
{
|
||||
count = platform_resolution_add(widths, heights, count, maximum, width, height);
|
||||
}
|
||||
}
|
||||
SDL_free(modes);
|
||||
/* (the one set, though this display has no such mode, so that Video
|
||||
Setup shows it) */
|
||||
platform_resolution_setting(&width, &height);
|
||||
if (width && (width != display_width || height != display_height))
|
||||
count = platform_resolution_add(widths, heights, count, maximum, width, height);
|
||||
/* largest first */
|
||||
for (index = 1; index < count; index++)
|
||||
{
|
||||
int place;
|
||||
|
||||
width = widths[index];
|
||||
height = heights[index];
|
||||
for (place = index; place > 0 && (widths[place - 1] < width ||
|
||||
(widths[place - 1] == width && heights[place - 1] < height)); place--)
|
||||
{
|
||||
widths[place] = widths[place - 1];
|
||||
heights[place] = heights[place - 1];
|
||||
}
|
||||
widths[place] = width;
|
||||
heights[place] = height;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Video Setup's window sizes, by shape (4:3, 16:10, 16:9, 21:9), each from
|
||||
the smallest */
|
||||
static const short platform_window_sizes_offered[][2] =
|
||||
{
|
||||
{ 640, 480 }, { 800, 600 }, { 1024, 768 }, { 1280, 960 }, { 1600, 1200 }, { 1920, 1440 }, { 2560, 1920 },
|
||||
{ 1280, 800 }, { 1440, 900 }, { 1680, 1050 }, { 1920, 1200 }, { 2560, 1600 },
|
||||
{ 1280, 720 }, { 1600, 900 }, { 1920, 1080 }, { 2560, 1440 }, { 3840, 2160 },
|
||||
{ 2560, 1080 }, { 3440, 1440 }, { 3840, 1600 }, { 5120, 2160 },
|
||||
};
|
||||
|
||||
int platform_window_sizes(long *widths, long *heights, int maximum)
|
||||
{
|
||||
SDL_DisplayID display;
|
||||
SDL_Rect usable;
|
||||
long width, height;
|
||||
int count = 0, index;
|
||||
|
||||
if (maximum < 1 || !platform_sdl_initialize())
|
||||
return 0;
|
||||
display = platform_window ? SDL_GetDisplayForWindow(platform_window) : 0;
|
||||
if (!display)
|
||||
display = SDL_GetPrimaryDisplay();
|
||||
if (!display || !SDL_GetDisplayUsableBounds(display, &usable))
|
||||
usable.w = usable.h = 0;
|
||||
for (index = 0; index < (int)(sizeof(platform_window_sizes_offered) / sizeof(*platform_window_sizes_offered));
|
||||
index++)
|
||||
{
|
||||
width = platform_window_sizes_offered[index][0];
|
||||
height = platform_window_sizes_offered[index][1];
|
||||
/* (the Xbox's own whatever the desktop's size) */
|
||||
if (!index || (width <= usable.w && height <= usable.h))
|
||||
count = platform_resolution_add(widths, heights, count, maximum, width, height);
|
||||
}
|
||||
/* (the one set, though it is none of them or too big for this desktop,
|
||||
so that Video Setup shows it) */
|
||||
platform_window_size_setting(&width, &height);
|
||||
return platform_resolution_add(widths, heights, count, maximum, width, height);
|
||||
}
|
||||
|
||||
#else
|
||||
int platform_display_resolutions(long *widths, long *heights, int maximum)
|
||||
{
|
||||
(void)widths;
|
||||
(void)heights;
|
||||
(void)maximum;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int platform_window_sizes(long *widths, long *heights, int maximum)
|
||||
{
|
||||
(void)widths;
|
||||
(void)heights;
|
||||
(void)maximum;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef HALO_ANDROID
|
||||
/* the window's size (platform_window_size_setting), as the window was made
|
||||
or last resized: platform_display_apply */
|
||||
static long platform_window_width = -1, platform_window_height = -1;
|
||||
#endif
|
||||
/* the window's scale (display.window_scale, as the window was made or last
|
||||
resized: platform_display_apply) */
|
||||
static long platform_window_scale = -1;
|
||||
|
||||
BOOL platform_video_initialize(unsigned long width, unsigned long height)
|
||||
{
|
||||
int scale = (int)config_integer("display.window_scale");
|
||||
int version;
|
||||
|
||||
if (platform_window)
|
||||
return TRUE;
|
||||
if (!platform_sdl_initialize())
|
||||
return FALSE;
|
||||
if (scale < 1)
|
||||
scale = 1;
|
||||
platform_window_scale = scale;
|
||||
|
||||
#ifdef HALO_ANDROID
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
@@ -459,14 +708,23 @@ BOOL platform_video_initialize(unsigned long width, unsigned long height)
|
||||
#endif
|
||||
|
||||
#ifdef HALO_ANDROID
|
||||
platform_window = SDL_CreateWindow("Halo", (int)(width * scale), (int)(height * scale),
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN);
|
||||
{
|
||||
int scale = (int)config_integer("display.window_scale");
|
||||
|
||||
if (scale < 1)
|
||||
scale = 1;
|
||||
platform_window = SDL_CreateWindow("Halo", (int)(width * scale), (int)(height * scale),
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN);
|
||||
}
|
||||
#else
|
||||
/* fullscreen at the desktop's resolution unless display.fullscreen is
|
||||
false, where the game draws the display's shape at its resolution
|
||||
(d3d8_gl.c); the window size is the windowed mode F11 switches to and
|
||||
from, where it draws 640x480 */
|
||||
platform_window = SDL_CreateWindow("Halo", (int)(width * scale), (int)(height * scale),
|
||||
/* fullscreen (either kind) unless display.mode is the window, which F11
|
||||
switches to and from: display.window_size, whatever shape the fullscreen
|
||||
picture has. The game draws at the size platform_screen_mode gives
|
||||
(d3d8_gl.c). */
|
||||
(void)width;
|
||||
(void)height;
|
||||
platform_window_size_setting(&platform_window_width, &platform_window_height);
|
||||
platform_window = SDL_CreateWindow("Halo", (int)platform_window_width, (int)platform_window_height,
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY |
|
||||
(config_boolean("debug.hidden_window") ? SDL_WINDOW_HIDDEN : 0) |
|
||||
(platform_fullscreen_setting() ? SDL_WINDOW_FULLSCREEN : 0));
|
||||
@@ -477,6 +735,7 @@ BOOL platform_video_initialize(unsigned long width, unsigned long height)
|
||||
return FALSE;
|
||||
}
|
||||
#ifndef HALO_ANDROID
|
||||
platform_fullscreen_requested = platform_fullscreen_setting();
|
||||
platform_fullscreen_kind_apply();
|
||||
#endif
|
||||
platform_gl_context = SDL_GL_CreateContext(platform_window);
|
||||
@@ -512,23 +771,28 @@ BOOL platform_video_initialize(unsigned long width, unsigned long height)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* display.fullscreen, display.window_scale (when it changes: the window can
|
||||
be resized) and display.vsync, as Settings has written them */
|
||||
/* display.mode, display.resolution (fullscreen's display mode),
|
||||
display.window_size (when it changes: the window can be resized) and
|
||||
display.vsync, as Settings has written them; display.resolution_scaling
|
||||
and borderless's resolution are taken up between frames
|
||||
(halo_screen_commit) */
|
||||
void platform_display_apply(void)
|
||||
{
|
||||
#ifndef HALO_ANDROID
|
||||
BOOL fullscreen = platform_fullscreen_setting();
|
||||
long scale = config_integer("display.window_scale");
|
||||
long width, height;
|
||||
|
||||
if (!platform_window)
|
||||
return;
|
||||
platform_fullscreen_kind_apply();
|
||||
if (((SDL_GetWindowFlags(platform_window) & SDL_WINDOW_FULLSCREEN) != 0) != (fullscreen != FALSE))
|
||||
SDL_SetWindowFullscreen(platform_window, fullscreen ? true : false);
|
||||
if (scale != platform_window_scale && scale >= 1)
|
||||
if (platform_window_fullscreen() != (fullscreen != FALSE))
|
||||
platform_window_set_fullscreen(fullscreen);
|
||||
platform_window_size_setting(&width, &height);
|
||||
if (width != platform_window_width || height != platform_window_height)
|
||||
{
|
||||
platform_window_scale = scale;
|
||||
SDL_SetWindowSize(platform_window, (int)(640 * scale), (int)(480 * scale));
|
||||
platform_window_width = width;
|
||||
platform_window_height = height;
|
||||
SDL_SetWindowSize(platform_window, (int)width, (int)height);
|
||||
}
|
||||
#else
|
||||
if (!platform_window)
|
||||
@@ -911,13 +1175,13 @@ static void platform_show_pending_message(void)
|
||||
#else
|
||||
{
|
||||
/* (a box cannot show above a fullscreen game) */
|
||||
int fullscreen = (SDL_GetWindowFlags(platform_window) & SDL_WINDOW_FULLSCREEN) != 0;
|
||||
BOOL fullscreen = platform_window_fullscreen();
|
||||
|
||||
if (fullscreen)
|
||||
SDL_SetWindowFullscreen(platform_window, false);
|
||||
platform_window_set_fullscreen(FALSE);
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, title, text, platform_window);
|
||||
if (fullscreen)
|
||||
SDL_SetWindowFullscreen(platform_window, true);
|
||||
platform_window_set_fullscreen(TRUE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -925,8 +1189,10 @@ static void platform_show_pending_message(void)
|
||||
/* ---------- events */
|
||||
|
||||
/* quits as closing the window does, when the events are next read (the
|
||||
menus' Quit: port/linux/game/menu_functions.c); Android's menus have none,
|
||||
as the system closes its apps */
|
||||
menus' Quit: port/linux/game/menu_functions.c); on Android, where the
|
||||
system closes its apps, the VR options' Quit (ui_widget.c) ends the process
|
||||
at once: on the Steam Frame, Steam cannot end the game, which runs in
|
||||
Lepton's container (port/android/STEAM_FRAME.md) */
|
||||
void platform_request_quit(void)
|
||||
{
|
||||
#ifndef HALO_ANDROID
|
||||
@@ -935,6 +1201,20 @@ void platform_request_quit(void)
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.type = SDL_EVENT_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
#else
|
||||
{
|
||||
/* (and says so beside the game's data: the Steam Frame's launcher
|
||||
does not then take it for a start that failed and start it again) */
|
||||
char path[512];
|
||||
FILE *file;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/quit_requested.txt", platform_data_root());
|
||||
file = fopen(path, "wb");
|
||||
if (file)
|
||||
fclose(file);
|
||||
}
|
||||
platform_log("quit: the player asked");
|
||||
exit(EXIT_SUCCESS);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1032,13 +1312,15 @@ void platform_pump_events(void)
|
||||
window's size and place while fullscreen) */
|
||||
if (event.key.down && !event.key.repeat && event.key.scancode == SDL_SCANCODE_F11)
|
||||
{
|
||||
SDL_SetWindowFullscreen(platform_window,
|
||||
(SDL_GetWindowFlags(platform_window) & SDL_WINDOW_FULLSCREEN) ? false : true);
|
||||
platform_window_set_fullscreen(!platform_window_fullscreen());
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
#ifndef HALO_ANDROID
|
||||
#ifdef HALO_ANDROID
|
||||
flat_mouse_x = event.motion.x;
|
||||
flat_mouse_y = event.motion.y;
|
||||
#else
|
||||
/* in the menus the mouse moves the pointer, not the view */
|
||||
if (input_state.ui_pointer)
|
||||
{
|
||||
@@ -1198,6 +1480,23 @@ int platform_binding_capture_poll(int *input)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef HALO_ANDROID
|
||||
/* flat, not in VR (the emulator, for testing the menus): the mouse's place
|
||||
in the window and whether its left button is down, polled */
|
||||
BOOL platform_flat_mouse(float *x, float *y)
|
||||
{
|
||||
BOOL down;
|
||||
|
||||
pthread_mutex_lock(&input_lock);
|
||||
*x = flat_mouse_x;
|
||||
*y = flat_mouse_y;
|
||||
/* (an injected mouse's, adb shell input mouse: button 0) */
|
||||
down = (mouse_buttons_down & ((1u << SDL_BUTTON_LEFT) | 1u)) != 0;
|
||||
pthread_mutex_unlock(&input_lock);
|
||||
return down;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HALO_ANDROID
|
||||
/* ---------- the menus' pointer */
|
||||
|
||||
@@ -1248,12 +1547,17 @@ BOOL platform_ui_pointer_read(struct platform_ui_pointer *pointer)
|
||||
return active;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void platform_video_window_size(int *width, int *height)
|
||||
{
|
||||
#ifdef HALO_ANDROID
|
||||
SDL_GetWindowSizeInPixels(platform_window, width, height);
|
||||
#else
|
||||
SDL_GetWindowSize(platform_window, width, height);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
void platform_input_read(struct platform_input_state *state, BOOL consume_motion)
|
||||
{
|
||||
pthread_mutex_lock(&input_lock);
|
||||
|
||||
@@ -62,6 +62,15 @@ BOOL platform_video_initialize(unsigned long width, unsigned long height);
|
||||
#ifndef HALO_ANDROID
|
||||
BOOL platform_screen_mode(long *width, long *height);
|
||||
#endif
|
||||
/* Video Setup's resolutions (port/linux/game/menu_tags.c), in pixels: the
|
||||
display's modes the game can draw at, largest first, each once, but the
|
||||
display's own (Native), and display.resolution's where it is none of them;
|
||||
how many. None on Android. */
|
||||
int platform_display_resolutions(long *widths, long *heights, int maximum);
|
||||
/* Video Setup's window sizes: those of each shape (4:3, 16:10, 16:9, 21:9)
|
||||
that fit the desktop, and display.window_size's; how many. None on
|
||||
Android. */
|
||||
int platform_window_sizes(long *widths, long *heights, int maximum);
|
||||
void platform_video_drawable_size(int *width, int *height);
|
||||
/* the window's mode and size and V-Sync, from config.toml as Settings has
|
||||
just written it (the main thread's) */
|
||||
@@ -89,8 +98,8 @@ struct platform_ui_pointer
|
||||
};
|
||||
void platform_ui_pointer_set_active(BOOL active);
|
||||
BOOL platform_ui_pointer_read(struct platform_ui_pointer *pointer);
|
||||
void platform_video_window_size(int *width, int *height);
|
||||
#endif
|
||||
void platform_video_window_size(int *width, int *height);
|
||||
BOOL platform_next_keystroke(struct platform_keystroke *keystroke);
|
||||
/* the multiplayer scoreboard (game_engine.c) open or not: while it is, the
|
||||
mouse wheel and Page Up/Down scroll it instead of switching weapons; how
|
||||
|
||||
@@ -69,6 +69,14 @@ static struct
|
||||
unsigned long long wait_us;
|
||||
int report_frames;
|
||||
int report_stereo_frames;
|
||||
/* (the frame's parts, halo_vr_phase: when each ended, and the game's
|
||||
ticks in it; summed apart for frames with ticks and without, with how
|
||||
many took longer than the headset's frame) */
|
||||
unsigned long long phase_end_us[HALO_VR_PHASE_COUNT];
|
||||
int frame_ticks;
|
||||
unsigned long long phase_us[2][HALO_VR_PHASE_COUNT + 1];
|
||||
int phase_frames[2];
|
||||
int phase_late[2];
|
||||
|
||||
/* the view's turning, gathered for halo_vr_look_delta */
|
||||
float look_yaw;
|
||||
@@ -228,9 +236,20 @@ int d3d8_multiview_supported(void);
|
||||
int d3d8_multiview_begin(const float rows[4][4], const float resolve_rect[2][4]);
|
||||
void d3d8_multiview_rows(const float rows[4][4]);
|
||||
void d3d8_multiview_depth(float a, float b);
|
||||
void d3d8_multiview_projected_depth(int projected);
|
||||
unsigned int d3d8_multiview_end(void);
|
||||
void d3d8_clear_back_buffer(float red, float green, float blue, float alpha);
|
||||
void d3d8_clear_back_buffer_region(float left, float top, float right, float bottom);
|
||||
void d3d8_host_state_changed(void);
|
||||
|
||||
/* a layer copied (host_xr_copy_layer): 2 is a deferred copy, which left GL
|
||||
as it drew, for the renderer to set again */
|
||||
static int vr_copied(int result)
|
||||
{
|
||||
if (result == 2)
|
||||
d3d8_host_state_changed();
|
||||
return result != 0;
|
||||
}
|
||||
|
||||
/* The motion tracker, the HUD's one element at its bottom left, moves from
|
||||
the HUD to the left wrist (host_xr.c draws it there): this part of the
|
||||
@@ -495,6 +514,16 @@ void halo_vr_initialize(void)
|
||||
vr.active = 1;
|
||||
platform_log("VR: %s, eyes %dx%d at %.0f Hz", vr.info.system_name, vr.info.eye_width, vr.info.eye_height,
|
||||
vr.info.refresh_rate);
|
||||
/* SteamVR (the Steam Frame): each eye drawn apart. With both drawn at
|
||||
once the eyes' pictures did not fuse, now and then: each alone was
|
||||
sharp, the two together doubled as the head turned (2026-10-05), and
|
||||
one by one costs it no more (its time goes to the driver either way).
|
||||
debug.multiview_steamvr draws them at once there again, for finding why */
|
||||
if (vr.multiview && strstr(vr.info.system_name, "SteamVR") && !config_boolean("debug.multiview_steamvr"))
|
||||
{
|
||||
vr.multiview = 0;
|
||||
platform_log("VR: SteamVR: the eyes drawn one by one (debug.multiview_steamvr)");
|
||||
}
|
||||
}
|
||||
|
||||
int halo_vr_active(void)
|
||||
@@ -502,6 +531,11 @@ int halo_vr_active(void)
|
||||
return vr.active;
|
||||
}
|
||||
|
||||
int halo_vr_controller_layout(void)
|
||||
{
|
||||
return vr.active ? vr.frame.controller_layout : HALO_XR_LAYOUT_TOUCH;
|
||||
}
|
||||
|
||||
int halo_vr_eye_size(int *width, int *height)
|
||||
{
|
||||
const char *eye_width = getenv("HALO_VR_EYE_WIDTH");
|
||||
@@ -525,10 +559,47 @@ static unsigned long long now_us(void)
|
||||
/* vr.log_performance: every five seconds, the frames the game gave the
|
||||
headset, and where their time went: waiting for the headset (xrWaitFrame),
|
||||
drawing the eyes, and the rest (the game's update, the overlay, the copies) */
|
||||
void halo_vr_phase(int phase, int ticks)
|
||||
{
|
||||
if (!vr.active || !vr.log_performance || phase < 0 || phase >= HALO_VR_PHASE_COUNT)
|
||||
return;
|
||||
vr.phase_end_us[phase] = now_us();
|
||||
if (phase == HALO_VR_PHASE_TICKS)
|
||||
vr.frame_ticks = ticks;
|
||||
}
|
||||
|
||||
/* the frame's parts, from the marks halo_vr_phase left (a part not marked
|
||||
this frame: none) */
|
||||
static void performance_phases(unsigned long long now)
|
||||
{
|
||||
int kind = vr.frame_ticks > 0;
|
||||
unsigned long long last = vr.frame_start_us;
|
||||
int phase;
|
||||
|
||||
for (phase = 0; phase < HALO_VR_PHASE_COUNT; phase++)
|
||||
{
|
||||
unsigned long long end = vr.phase_end_us[phase];
|
||||
|
||||
if (end >= last && end <= now)
|
||||
{
|
||||
vr.phase_us[kind][phase] += end - last;
|
||||
last = end;
|
||||
}
|
||||
}
|
||||
vr.phase_us[kind][HALO_VR_PHASE_COUNT] += now - last;
|
||||
vr.phase_frames[kind]++;
|
||||
/* (late: longer than the headset's frame, less a millisecond) */
|
||||
if (vr.info.refresh_rate > 1.0f && (float)(now - vr.frame_start_us + 1000) > 1e6f / vr.info.refresh_rate)
|
||||
vr.phase_late[kind]++;
|
||||
memset(vr.phase_end_us, 0, sizeof(vr.phase_end_us));
|
||||
vr.frame_ticks = 0;
|
||||
}
|
||||
|
||||
static void performance_report(int stereo)
|
||||
{
|
||||
unsigned long long now = now_us();
|
||||
|
||||
performance_phases(now);
|
||||
vr.work_us += now - vr.frame_start_us;
|
||||
vr.report_frames++;
|
||||
vr.report_stereo_frames += stereo != 0;
|
||||
@@ -543,6 +614,25 @@ static void performance_report(int stereo)
|
||||
platform_log("VR: %.1f fps (%d%% stereo); per frame %.1f ms working (eyes %.1f ms), %.1f ms waiting "
|
||||
"for the headset", frames / seconds, (int)(100.0f * vr.report_stereo_frames / frames),
|
||||
vr.work_us * 1e-3f / frames, vr.eyes_us * 1e-3f / frames, vr.wait_us * 1e-3f / frames);
|
||||
{
|
||||
int kind;
|
||||
|
||||
for (kind = 1; kind >= 0; kind--)
|
||||
{
|
||||
float count = (float)(vr.phase_frames[kind] ? vr.phase_frames[kind] : 1);
|
||||
|
||||
platform_log("VR: %s: %d frames, %d late; ms input %.1f, ticks %.1f, camera %.1f, draw %.1f, "
|
||||
"present %.1f", kind ? "with ticks" : "no ticks", vr.phase_frames[kind], vr.phase_late[kind],
|
||||
vr.phase_us[kind][HALO_VR_PHASE_INPUT] * 1e-3f / count,
|
||||
vr.phase_us[kind][HALO_VR_PHASE_TICKS] * 1e-3f / count,
|
||||
vr.phase_us[kind][HALO_VR_PHASE_CAMERA] * 1e-3f / count,
|
||||
vr.phase_us[kind][HALO_VR_PHASE_DRAW] * 1e-3f / count,
|
||||
vr.phase_us[kind][HALO_VR_PHASE_COUNT] * 1e-3f / count);
|
||||
}
|
||||
}
|
||||
memset(vr.phase_us, 0, sizeof(vr.phase_us));
|
||||
memset(vr.phase_frames, 0, sizeof(vr.phase_frames));
|
||||
memset(vr.phase_late, 0, sizeof(vr.phase_late));
|
||||
}
|
||||
vr.report_start_us = now;
|
||||
vr.report_frames = vr.report_stereo_frames = 0;
|
||||
@@ -1243,9 +1333,8 @@ void halo_vr_present(unsigned int back_buffer_texture)
|
||||
if (vr.overlay_mode == HALO_XR_OVERLAY_HEAD_LOCKED && vr.motion_tracker_on_wrist && vr.aim_with_controller)
|
||||
{
|
||||
/* the motion tracker to the wrist, and out of the HUD */
|
||||
submit.wrist = host_xr_copy_layer_region(HALO_XR_LAYER_WRIST, back_buffer_texture, HALO_XR_COPY_ALPHA,
|
||||
WRIST_REGION_LEFT,
|
||||
WRIST_REGION_TOP, WRIST_REGION_RIGHT, WRIST_REGION_BOTTOM);
|
||||
submit.wrist = vr_copied(host_xr_copy_layer_region(HALO_XR_LAYER_WRIST, back_buffer_texture,
|
||||
HALO_XR_COPY_ALPHA, WRIST_REGION_LEFT, WRIST_REGION_TOP, WRIST_REGION_RIGHT, WRIST_REGION_BOTTOM));
|
||||
submit.wrist_size = vr.motion_tracker_size;
|
||||
submit.wrist_turn = vr.motion_tracker_turn;
|
||||
submit.wrist_right = vr.motion_tracker_right;
|
||||
@@ -1276,8 +1365,8 @@ void halo_vr_present(unsigned int back_buffer_texture)
|
||||
submit.scope_size = vr.scope_size;
|
||||
submit.scope_pose = vr.scope_pose;
|
||||
}
|
||||
host_xr_copy_layer(HALO_XR_LAYER_OVERLAY, back_buffer_texture,
|
||||
vr.overlay_blend ? HALO_XR_COPY_ALPHA : HALO_XR_COPY_OPAQUE);
|
||||
vr_copied(host_xr_copy_layer(HALO_XR_LAYER_OVERLAY, back_buffer_texture,
|
||||
vr.overlay_blend ? HALO_XR_COPY_ALPHA : HALO_XR_COPY_OPAQUE));
|
||||
host_xr_end_frame(&submit);
|
||||
vr.last_overlay_mode = vr.overlay_mode;
|
||||
vr.last_frame_stereo = submit.eyes;
|
||||
@@ -1475,6 +1564,15 @@ void halo_vr_multiview_projection(float projection_22, float projection_32)
|
||||
d3d8_multiview_depth(-projection_22, projection_32);
|
||||
}
|
||||
|
||||
/* lens flares are being drawn (rasterizer_lights.c): each eye's by the
|
||||
flare's depth, as the flare's test was, not at infinity (a weapon's own,
|
||||
the plasma pistol's at its prongs, half a metre away: a ball each eye saw
|
||||
elsewhere); the sun's are far enough for infinity either way */
|
||||
void halo_vr_multiview_lens_flares(int drawing)
|
||||
{
|
||||
d3d8_multiview_projected_depth(drawing && multiview_drawing);
|
||||
}
|
||||
|
||||
/* the sky is being drawn (render.c): as though infinitely far */
|
||||
void halo_vr_multiview_sky(int sky)
|
||||
{
|
||||
@@ -1490,9 +1588,9 @@ void halo_vr_capture_multiview(void)
|
||||
if (!multiview_drawing)
|
||||
return;
|
||||
multiview_drawing = 0;
|
||||
if (host_xr_copy_layer_array(HALO_XR_LAYER_EYE_LEFT, layers, 0))
|
||||
if (vr_copied(host_xr_copy_layer_array(HALO_XR_LAYER_EYE_LEFT, layers, 0)))
|
||||
vr.eyes_captured |= 1;
|
||||
if (host_xr_copy_layer_array(HALO_XR_LAYER_EYE_RIGHT, layers, 1))
|
||||
if (vr_copied(host_xr_copy_layer_array(HALO_XR_LAYER_EYE_RIGHT, layers, 1)))
|
||||
vr.eyes_captured |= 2;
|
||||
if (vr.eyes_start_us)
|
||||
vr.eyes_us += now_us() - vr.eyes_start_us;
|
||||
@@ -1502,7 +1600,7 @@ void halo_vr_capture_eye(int eye)
|
||||
{
|
||||
if (!vr.active || eye < 0 || eye >= HALO_XR_EYE_COUNT)
|
||||
return;
|
||||
if (host_xr_copy_layer(HALO_XR_LAYER_EYE_LEFT + eye, d3d8_back_buffer_texture(), 1))
|
||||
if (vr_copied(host_xr_copy_layer(HALO_XR_LAYER_EYE_LEFT + eye, d3d8_back_buffer_texture(), 1)))
|
||||
vr.eyes_captured |= 1 << eye;
|
||||
if (eye == HALO_XR_EYE_COUNT - 1 && vr.eyes_start_us)
|
||||
vr.eyes_us += now_us() - vr.eyes_start_us;
|
||||
@@ -2333,9 +2431,9 @@ void halo_vr_capture_names(void)
|
||||
{
|
||||
if (vr.name_count > 0)
|
||||
{
|
||||
vr.names_captured = host_xr_copy_layer_region(HALO_XR_LAYER_NAMES, d3d8_back_buffer_texture(),
|
||||
vr.names_captured = vr_copied(host_xr_copy_layer_region(HALO_XR_LAYER_NAMES, d3d8_back_buffer_texture(),
|
||||
HALO_XR_COPY_ALPHA, NAME_SLOT_LEFT / 640.0f, 0.0f, (NAME_SLOT_LEFT + NAME_SLOT_WIDTH) / 640.0f,
|
||||
HALO_XR_MAXIMUM_NAMES * NAME_SLOT_HEIGHT / 480.0f);
|
||||
HALO_XR_MAXIMUM_NAMES * NAME_SLOT_HEIGHT / 480.0f));
|
||||
}
|
||||
d3d8_clear_back_buffer(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
@@ -2443,8 +2541,8 @@ int halo_vr_scope_pass(void)
|
||||
void halo_vr_capture_scope(float left, float top, float right, float bottom)
|
||||
{
|
||||
vr.scope_pass = 0;
|
||||
vr.scope_captured = host_xr_copy_layer_region(HALO_XR_LAYER_SCOPE, d3d8_back_buffer_texture(), HALO_XR_COPY_DISC,
|
||||
left, top, right, bottom);
|
||||
vr.scope_captured = vr_copied(host_xr_copy_layer_region(HALO_XR_LAYER_SCOPE, d3d8_back_buffer_texture(),
|
||||
HALO_XR_COPY_DISC, left, top, right, bottom));
|
||||
}
|
||||
|
||||
int halo_vr_hide_crosshair(void)
|
||||
@@ -2461,9 +2559,9 @@ int halo_vr_crosshair_apart(void)
|
||||
|
||||
void halo_vr_capture_crosshair(void)
|
||||
{
|
||||
vr.crosshair_captured = host_xr_copy_layer_region(HALO_XR_LAYER_CROSSHAIR, d3d8_back_buffer_texture(),
|
||||
vr.crosshair_captured = vr_copied(host_xr_copy_layer_region(HALO_XR_LAYER_CROSSHAIR, d3d8_back_buffer_texture(),
|
||||
HALO_XR_COPY_ALPHA, CROSSHAIR_REGION_LEFT, CROSSHAIR_REGION_TOP, CROSSHAIR_REGION_RIGHT,
|
||||
CROSSHAIR_REGION_BOTTOM);
|
||||
CROSSHAIR_REGION_BOTTOM));
|
||||
d3d8_clear_back_buffer(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
@@ -2479,6 +2577,7 @@ int halo_vr_controllers(struct halo_xr_hand hands[HALO_XR_HAND_COUNT], int *menu
|
||||
|
||||
#else
|
||||
|
||||
int halo_vr_controller_layout(void) { return 0; }
|
||||
int halo_vr_active(void) { return 0; }
|
||||
int halo_vr_stereo_frame(void) { return 0; }
|
||||
int halo_vr_stereo_player(short local_player_index, int cinematic) { (void)local_player_index; (void)cinematic; return 0; }
|
||||
@@ -2497,6 +2596,7 @@ void halo_vr_center_camera(const float game_position[3], float position[3], floa
|
||||
}
|
||||
void halo_vr_capture_multiview(void) {}
|
||||
void halo_vr_multiview_sky(int sky) { (void)sky; }
|
||||
void halo_vr_multiview_lens_flares(int drawing) { (void)drawing; }
|
||||
void halo_vr_multiview_projection(float projection_22, float projection_32)
|
||||
{
|
||||
(void)projection_22; (void)projection_32;
|
||||
|
||||
@@ -656,6 +656,10 @@ struct texture_entry
|
||||
unsigned long last_used_frame;
|
||||
/* the high-res HUD texture drawn in its place (hud_hires.h), or -1 */
|
||||
long override;
|
||||
/* the newest generation of its pages (memory_watch_generation) as of the
|
||||
memory watch serial read before it was found: the same while no watched
|
||||
page has been written since (0: never found) */
|
||||
unsigned long watched_serial, watched_generation;
|
||||
};
|
||||
|
||||
#define TEXTURE_BUCKET_COUNT 4096
|
||||
@@ -668,7 +672,7 @@ static struct texture_entry *texture_buckets[TEXTURE_BUCKET_COUNT];
|
||||
texture that is not palettized is remembered with the memory watch serial it
|
||||
started at: while no watched page has been written since, and no texture
|
||||
has been dropped, the same lookup finds the same current texture. */
|
||||
#define RECENT_TEXTURE_COUNT 64
|
||||
#define RECENT_TEXTURE_COUNT 512
|
||||
|
||||
static struct
|
||||
{
|
||||
@@ -680,9 +684,14 @@ static struct
|
||||
static unsigned long texture_drop_serial = 1;
|
||||
static unsigned long texture_frame = 0;
|
||||
|
||||
/* (every bit of the three mixed into the top ones: textures are aligned,
|
||||
and few sizes and formats are common) */
|
||||
static unsigned long bucket_index(DWORD data, DWORD format_word, DWORD size_word)
|
||||
{
|
||||
return ((data >> 7) ^ (format_word * 2654435761UL) ^ size_word) % TEXTURE_BUCKET_COUNT;
|
||||
unsigned long hash = (unsigned long)data * 2654435761UL ^ (unsigned long)format_word * 2246822519UL ^
|
||||
(unsigned long)size_word * 3266489917UL;
|
||||
|
||||
return ((hash & 0xffffffffUL) >> 20) % TEXTURE_BUCKET_COUNT;
|
||||
}
|
||||
|
||||
/* palettized textures are cached per palette contents: the game rewrites
|
||||
@@ -757,25 +766,33 @@ GLuint xgpu_texture_get(const DWORD *resource, const D3DCOLOR *palette, GLenum *
|
||||
unsigned long recent = bucket_index(data, format_word, size_word) % RECENT_TEXTURE_COUNT;
|
||||
unsigned long watch_serial = memory_watch_serial();
|
||||
|
||||
/* (a texture that is not palettized has the one entry, until one is
|
||||
dropped: remembered, a page written since only means checking it) */
|
||||
entry = NULL;
|
||||
if (!palettized && recent_textures[recent].entry && recent_textures[recent].data == data &&
|
||||
recent_textures[recent].format_word == format_word && recent_textures[recent].size_word == size_word &&
|
||||
recent_textures[recent].watch_serial == watch_serial &&
|
||||
recent_textures[recent].drop_serial == texture_drop_serial)
|
||||
{
|
||||
entry = recent_textures[recent].entry;
|
||||
entry->last_used_frame = texture_frame;
|
||||
return texture_entry_result(entry, target, description);
|
||||
if (recent_textures[recent].watch_serial == watch_serial)
|
||||
{
|
||||
entry->last_used_frame = texture_frame;
|
||||
return texture_entry_result(entry, target, description);
|
||||
}
|
||||
}
|
||||
|
||||
for (entry = *bucket; entry; entry = entry->next)
|
||||
if (!entry)
|
||||
{
|
||||
if (entry->data == data && entry->format_word == format_word && entry->size_word == size_word)
|
||||
for (entry = *bucket; entry; entry = entry->next)
|
||||
{
|
||||
if (entry->palette_hash == hash)
|
||||
break;
|
||||
variant_count++;
|
||||
if (!oldest_variant || entry->last_used_frame < oldest_variant->last_used_frame)
|
||||
oldest_variant = entry;
|
||||
if (entry->data == data && entry->format_word == format_word && entry->size_word == size_word)
|
||||
{
|
||||
if (entry->palette_hash == hash)
|
||||
break;
|
||||
variant_count++;
|
||||
if (!oldest_variant || entry->last_used_frame < oldest_variant->last_used_frame)
|
||||
oldest_variant = entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!entry && variant_count >= MAXIMUM_PALETTE_VARIANTS)
|
||||
@@ -806,7 +823,17 @@ GLuint xgpu_texture_get(const DWORD *resource, const D3DCOLOR *palette, GLenum *
|
||||
|
||||
if (no_cache < 0)
|
||||
no_cache = config_boolean("debug.texture_no_cache");
|
||||
generation = memory_watch_generation(entry->address, entry->size);
|
||||
/* (its pages' newest generation, found again only once a watched page
|
||||
has been written: a large texture's pages, scanned for every draw that
|
||||
bound it, were much of a frame with many objects) */
|
||||
if (entry->watched_serial && entry->watched_serial == watch_serial)
|
||||
generation = entry->watched_generation;
|
||||
else
|
||||
{
|
||||
generation = memory_watch_generation(entry->address, entry->size);
|
||||
entry->watched_serial = watch_serial;
|
||||
entry->watched_generation = generation;
|
||||
}
|
||||
if (!entry->generation || generation > entry->generation || no_cache)
|
||||
{
|
||||
/* protect first, so a write racing with the upload is noticed */
|
||||
|
||||
@@ -53,6 +53,11 @@ must call this afterwards. */
|
||||
|
||||
void xgpu_gl_state_invalidate(void);
|
||||
|
||||
/* a compiled shader, or a linked program of two, or 0 with the log
|
||||
written */
|
||||
GLuint xgpu_compile_shader(GLenum type, const char *code, const char *what);
|
||||
GLuint xgpu_link_program(GLuint vertex_shader, GLuint fragment_shader, const char *what);
|
||||
|
||||
/* ---------- generated source text */
|
||||
|
||||
struct xgpu_text
|
||||
@@ -71,14 +76,34 @@ void xgpu_text_append(struct xgpu_text *text, const char *format, ...) __attribu
|
||||
/* D3D constant register -96 is hardware register 0 */
|
||||
#define XGPU_VERTEX_CONSTANT_BIAS 96
|
||||
|
||||
/* where one of the game's model lighting programs (d3d8_gl.c
|
||||
halo_vertex_shader_lighting) has the normal, and the world position, that it
|
||||
lights the diffuse color by: the temporary register that holds each before
|
||||
the instruction given */
|
||||
struct nv2a_vertex_lighting
|
||||
{
|
||||
/* 1 by the ambient and distant lights, 2 by the point lights too */
|
||||
int lights;
|
||||
unsigned long normal_instruction, normal_register;
|
||||
/* (with the point lights only) */
|
||||
unsigned long position_instruction, position_register;
|
||||
};
|
||||
|
||||
/* finds them in a model lighting program, checking that it lights its
|
||||
diffuse color as nv2a_psh.c does for each pixel; FALSE if it does not */
|
||||
BOOL nv2a_vertex_shader_lighting(const DWORD *instructions, unsigned long instruction_count,
|
||||
struct nv2a_vertex_lighting *lighting);
|
||||
|
||||
/* GLSL for an NV2A vertex program (the instruction words after the program
|
||||
header). Attributes whose bit is set in packed_attribute_mask are fed as
|
||||
NORMPACKED3 32-bit integers and unpacked in the shader. Returns a malloc'd
|
||||
string. */
|
||||
NORMPACKED3 32-bit integers and unpacked in the shader. With lighting (else
|
||||
NULL), the normal and world position go to the pixel shader too, which
|
||||
lights the diffuse color for each pixel (nv2a_pixel_shader_key
|
||||
per_pixel_lighting). Returns a malloc'd string. */
|
||||
/* multiview: for a two-view (GL_OVR_multiview2) target, each view's
|
||||
position corrected from the shared one by mv_rows (d3d8_gl.c, VR) */
|
||||
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);
|
||||
|
||||
/* ---------- pixel shaders */
|
||||
|
||||
@@ -114,6 +139,15 @@ struct nv2a_pixel_shader_key
|
||||
behind it only where it covers it (the Xbox's point-sampled meters stop
|
||||
at their texels' edges; filtered ones have a fringe of faint texels) */
|
||||
unsigned char coverage_alpha;
|
||||
/* a model lighting program's draw lit for each pixel
|
||||
(display.per_pixel_lighting): nv2a_vertex_lighting's lights, or 0 for
|
||||
the diffuse color the vertex shader computed */
|
||||
unsigned char per_pixel_lighting;
|
||||
/* drawn into a multisampled target (display.anti_aliasing's
|
||||
multisampling), its samples a pixel: the alpha test covers samples in
|
||||
proportion to how far alpha is past the reference, not all of the pixel
|
||||
or none of it, so that cut-out edges (foliage, grates) are smoothed too */
|
||||
unsigned char alpha_test_samples;
|
||||
};
|
||||
|
||||
char *nv2a_pixel_shader_to_glsl(const struct nv2a_pixel_shader_key *key);
|
||||
@@ -140,6 +174,13 @@ C0/C1 of each stage and the final combiner, and texture constants */
|
||||
"uniform vec4 texture_scale[4];\n" \
|
||||
XGPU_PIXEL_UNIFORMS_ES
|
||||
|
||||
/* the vertex constants the per-pixel model lighting reads, in a uniform of
|
||||
their own (the vertex shader's 192 would pass OpenGL ES's least fragment
|
||||
uniform space): [0] c[-82] (the translucency in z), [1] to [11] c[-79] to
|
||||
c[-69] (rasterizer_set_model_lighting's two point lights, two distant
|
||||
lights and the ambient light) */
|
||||
#define XGPU_MODEL_LIGHT_COUNT 12
|
||||
|
||||
/* ---------- textures */
|
||||
|
||||
struct xgpu_texture_description
|
||||
@@ -178,9 +219,33 @@ struct xgpu_render_target
|
||||
targets when the game draws at the display's resolution (d3d8_gl.c) */
|
||||
float scale[2];
|
||||
unsigned long gl_width, gl_height;
|
||||
/* with multisampling, the multisampled renderbuffer draws go to, its
|
||||
samples a pixel (0 when it has none), and whether it has been drawn into
|
||||
since the texture last had its pixels (d3d8_gl.c,
|
||||
render_target_multisample) */
|
||||
GLuint multisample;
|
||||
int samples;
|
||||
BOOL unresolved;
|
||||
};
|
||||
|
||||
/* the GL texture holding a render target with this physical address, or 0 */
|
||||
struct xgpu_render_target *xgpu_render_target_find(unsigned long data);
|
||||
|
||||
/* ---------- anti-aliasing
|
||||
|
||||
display.anti_aliasing's passes (xgpu_post.c): FXAA or SMAA antialias each
|
||||
window's 3D view in place before the HUD and menus are drawn over it, so
|
||||
that their text stays sharp. Supersampling and multisampling are the
|
||||
device's (d3d8_gl.c). */
|
||||
|
||||
/* the programs and textures of FXAA, or of SMAA, made now; FALSE if they
|
||||
cannot be (once FALSE, it stays so) */
|
||||
BOOL xgpu_post_prepare(BOOL smaa);
|
||||
|
||||
/* FXAA, or SMAA, on the corners x0, y0 to x1, y1 (from row 0) of a render
|
||||
target's framebuffer, width by height, GL_RGBA8; FALSE if its programs do
|
||||
not build */
|
||||
BOOL xgpu_post_anti_alias(BOOL smaa, GLuint framebuffer, unsigned long width, unsigned long height,
|
||||
const GLint corners[4]);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,524 @@
|
||||
/*
|
||||
XGPU_POST.C
|
||||
|
||||
The post-process passes of display.anti_aliasing (xgpu.h): FXAA and SMAA,
|
||||
run on a render target in place, over the rectangle of a window's 3D view.
|
||||
Each pass draws one triangle covering the rectangle (its corners from
|
||||
gl_VertexID, with no vertex data) and finds its texels from gl_FragCoord: a
|
||||
target's rows are the picture's from the top, as the passes' own textures'
|
||||
are, so no coordinate is turned over. The target's pixels are copied first,
|
||||
so that no pass reads what it writes, and only colour is written back: the
|
||||
game keeps values of its own in destination alpha. The programs are built
|
||||
when the setting is chosen (xgpu_post_prepare), not in the middle of a frame.
|
||||
|
||||
FXAA is written here, after Timothy Lottes' description: the direction of an
|
||||
edge from the luma around a pixel, the edge's ends found by stepping along
|
||||
it, and the pixel blended across it by where it lies between them, or by how
|
||||
much it stands out from its neighbours. SMAA is port/third_party/smaa's,
|
||||
compiled as GLSL at its HIGH preset: edges from luma, blending weights from
|
||||
its lookup textures, then the blend. Android has FXAA only (d3d8_gl.c's
|
||||
anti_aliasing_values).
|
||||
*/
|
||||
|
||||
#include "xgpu.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef HALO_ANDROID
|
||||
#include "memory/zlib/zlib.h"
|
||||
|
||||
/* port/third_party/smaa, embedded by tools/embed_assets.py: the shader's
|
||||
text (ending in a NUL), and the lookup textures' bytes compressed with
|
||||
zlib; each size 0 where the build had no such file */
|
||||
extern const unsigned int xgpu_smaa_shader[];
|
||||
extern const unsigned long xgpu_smaa_shader_size;
|
||||
extern const unsigned int xgpu_smaa_area_texture[];
|
||||
extern const unsigned long xgpu_smaa_area_texture_size;
|
||||
extern const unsigned int xgpu_smaa_search_texture[];
|
||||
extern const unsigned long xgpu_smaa_search_texture_size;
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
_post_program_fxaa,
|
||||
_post_program_smaa_edges,
|
||||
_post_program_smaa_weights,
|
||||
_post_program_smaa_blend,
|
||||
NUMBER_OF_POST_PROGRAMS
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
GLuint vertex_shader;
|
||||
GLuint programs[NUMBER_OF_POST_PROGRAMS];
|
||||
/* each program's metrics uniform, and FXAA's bounds */
|
||||
GLint metrics[NUMBER_OF_POST_PROGRAMS];
|
||||
GLint bounds;
|
||||
/* FXAA's, and SMAA's, programs or textures could not be made */
|
||||
BOOL failed[2];
|
||||
/* the size of the textures below */
|
||||
unsigned long width, height;
|
||||
/* the target's pixels before the pass, and SMAA's edges and blending
|
||||
weights */
|
||||
GLuint color, edges, weights;
|
||||
GLuint color_framebuffer, edges_framebuffer, weights_framebuffer;
|
||||
/* SMAA's lookup textures */
|
||||
GLuint area, search;
|
||||
/* linear and clamped, as FXAA and SMAA sample */
|
||||
GLuint sampler;
|
||||
/* no attributes: the triangle comes from gl_VertexID */
|
||||
GLuint vertex_array;
|
||||
} post;
|
||||
|
||||
/* ---------- programs */
|
||||
|
||||
static void shader_header(struct xgpu_text *text)
|
||||
{
|
||||
#ifdef HALO_ANDROID
|
||||
xgpu_text_append(text,
|
||||
"#version %s\n"
|
||||
"precision highp float;\n"
|
||||
"precision highp int;\n"
|
||||
"precision highp sampler2D;\n",
|
||||
xgpu_capabilities.shading_language);
|
||||
#else
|
||||
xgpu_text_append(text, "#version 450 core\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* one triangle over the whole viewport */
|
||||
static const char vertex_source[] =
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"\tgl_Position = vec4(float((gl_VertexID & 1) << 2) - 1.0, float((gl_VertexID & 2) << 1) - 1.0, 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char fxaa_source[] =
|
||||
"uniform sampler2D color_texture;\n"
|
||||
"/* 1 / width, 1 / height, width, height */\n"
|
||||
"uniform vec4 metrics;\n"
|
||||
"/* the rectangle's outermost texel centres, as texture coordinates */\n"
|
||||
"uniform vec4 bounds;\n"
|
||||
"out vec4 result;\n"
|
||||
"\n"
|
||||
"const float EDGE_THRESHOLD = 0.125;\n"
|
||||
"const float EDGE_THRESHOLD_MINIMUM = 0.0312;\n"
|
||||
"const float SUBPIXEL_QUALITY = 0.75;\n"
|
||||
"const int STEPS = 12;\n"
|
||||
"const float STEP_LENGTHS[12] = float[12](1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 4.0, 8.0);\n"
|
||||
"\n"
|
||||
"vec3 color_at(vec2 position)\n"
|
||||
"{\n"
|
||||
"\treturn textureLod(color_texture, clamp(position, bounds.xy, bounds.zw), 0.0).rgb;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float luma_at(vec2 position)\n"
|
||||
"{\n"
|
||||
"\treturn dot(color_at(position), vec3(0.299, 0.587, 0.114));\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"\tvec2 position = gl_FragCoord.xy * metrics.xy;\n"
|
||||
"\tfloat luma = luma_at(position);\n"
|
||||
"\tfloat up = luma_at(position + vec2(0.0, -metrics.y));\n"
|
||||
"\tfloat down = luma_at(position + vec2(0.0, metrics.y));\n"
|
||||
"\tfloat left = luma_at(position + vec2(-metrics.x, 0.0));\n"
|
||||
"\tfloat right = luma_at(position + vec2(metrics.x, 0.0));\n"
|
||||
"\tfloat highest = max(luma, max(max(up, down), max(left, right)));\n"
|
||||
"\tfloat range = highest - min(luma, min(min(up, down), min(left, right)));\n"
|
||||
"\n"
|
||||
"\t/* no edge: the target has the pixel already */\n"
|
||||
"\tif (range < max(EDGE_THRESHOLD_MINIMUM, highest * EDGE_THRESHOLD))\n"
|
||||
"\t\tdiscard;\n"
|
||||
"\tfloat up_left = luma_at(position + vec2(-metrics.x, -metrics.y));\n"
|
||||
"\tfloat up_right = luma_at(position + vec2(metrics.x, -metrics.y));\n"
|
||||
"\tfloat down_left = luma_at(position + vec2(-metrics.x, metrics.y));\n"
|
||||
"\tfloat down_right = luma_at(position + vec2(metrics.x, metrics.y));\n"
|
||||
"\n"
|
||||
"\t/* how much the pixel stands out from its neighbourhood (a feature\n"
|
||||
"\tthinner than a pixel) */\n"
|
||||
"\tfloat average = (2.0 * (up + down + left + right) + up_left + up_right + down_left + down_right) / 12.0;\n"
|
||||
"\tfloat subpixel = smoothstep(0.0, 1.0, clamp(abs(average - luma) / range, 0.0, 1.0));\n"
|
||||
"\tsubpixel = subpixel * subpixel * SUBPIXEL_QUALITY;\n"
|
||||
"\n"
|
||||
"\t/* an edge along the rows where the luma changes more from row to row\n"
|
||||
"\tthan from column to column; across it, the side it changes more to */\n"
|
||||
"\tbool horizontal = abs(up_left + down_left - 2.0 * left) + 2.0 * abs(up + down - 2.0 * luma) +\n"
|
||||
"\t\tabs(up_right + down_right - 2.0 * right) >=\n"
|
||||
"\t\tabs(up_left + up_right - 2.0 * up) + 2.0 * abs(left + right - 2.0 * luma) +\n"
|
||||
"\t\tabs(down_left + down_right - 2.0 * down);\n"
|
||||
"\tfloat before = horizontal ? up : left;\n"
|
||||
"\tfloat after = horizontal ? down : right;\n"
|
||||
"\tbool before_steeper = abs(before - luma) >= abs(after - luma);\n"
|
||||
"\tfloat gradient = 0.25 * max(abs(before - luma), abs(after - luma));\n"
|
||||
"\tfloat edge_luma = 0.5 * ((before_steeper ? before : after) + luma);\n"
|
||||
"\tvec2 across = (horizontal ? vec2(0.0, metrics.y) : vec2(metrics.x, 0.0)) * (before_steeper ? -1.0 : 1.0);\n"
|
||||
"\tvec2 along = horizontal ? vec2(metrics.x, 0.0) : vec2(0.0, metrics.y);\n"
|
||||
"\n"
|
||||
"\t/* along the edge, half a pixel across, to where its luma ends either way */\n"
|
||||
"\tvec2 end_before = position + 0.5 * across - along;\n"
|
||||
"\tvec2 end_after = position + 0.5 * across + along;\n"
|
||||
"\tfloat luma_before = luma_at(end_before) - edge_luma;\n"
|
||||
"\tfloat luma_after = luma_at(end_after) - edge_luma;\n"
|
||||
"\tbool reached_before = abs(luma_before) >= gradient;\n"
|
||||
"\tbool reached_after = abs(luma_after) >= gradient;\n"
|
||||
"\tfor (int index = 1; index < STEPS && !(reached_before && reached_after); index++)\n"
|
||||
"\t{\n"
|
||||
"\t\tif (!reached_before)\n"
|
||||
"\t\t{\n"
|
||||
"\t\t\tend_before -= along * STEP_LENGTHS[index];\n"
|
||||
"\t\t\tluma_before = luma_at(end_before) - edge_luma;\n"
|
||||
"\t\t\treached_before = abs(luma_before) >= gradient;\n"
|
||||
"\t\t}\n"
|
||||
"\t\tif (!reached_after)\n"
|
||||
"\t\t{\n"
|
||||
"\t\t\tend_after += along * STEP_LENGTHS[index];\n"
|
||||
"\t\t\tluma_after = luma_at(end_after) - edge_luma;\n"
|
||||
"\t\t\treached_after = abs(luma_after) >= gradient;\n"
|
||||
"\t\t}\n"
|
||||
"\t}\n"
|
||||
"\n"
|
||||
"\t/* blended across the edge the more, the nearer the pixel is to an end;\n"
|
||||
"\tonly where the luma at that end changes the way the pixel's does */\n"
|
||||
"\tfloat distance_before = horizontal ? position.x - end_before.x : position.y - end_before.y;\n"
|
||||
"\tfloat distance_after = horizontal ? end_after.x - position.x : end_after.y - position.y;\n"
|
||||
"\tfloat pixel_offset = 0.5 - min(distance_before, distance_after) / (distance_before + distance_after);\n"
|
||||
"\tbool varies = ((distance_before < distance_after ? luma_before : luma_after) < 0.0) != (luma < edge_luma);\n"
|
||||
"\tresult = vec4(color_at(position + max(varies ? pixel_offset : 0.0, subpixel) * across), 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
#ifndef HALO_ANDROID
|
||||
/* the main functions of SMAA's passes, after SMAA.hlsl; its vertex
|
||||
functions' offsets are found for each pixel */
|
||||
static const char *const smaa_mains[] =
|
||||
{
|
||||
/* edges */
|
||||
"uniform sampler2D color_texture;\n"
|
||||
"out vec4 result;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"\tvec2 texcoord = gl_FragCoord.xy * metrics.xy;\n"
|
||||
"\tvec4 offset[3];\n"
|
||||
"\tSMAAEdgeDetectionVS(texcoord, offset);\n"
|
||||
"\tresult = vec4(SMAALumaEdgeDetectionPS(texcoord, offset, color_texture), 0.0, 0.0);\n"
|
||||
"}\n",
|
||||
/* weights */
|
||||
"uniform sampler2D edges_texture;\n"
|
||||
"uniform sampler2D area_texture;\n"
|
||||
"uniform sampler2D search_texture;\n"
|
||||
"out vec4 result;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"\tvec2 texcoord = gl_FragCoord.xy * metrics.xy;\n"
|
||||
"\tvec2 pixcoord;\n"
|
||||
"\tvec4 offset[3];\n"
|
||||
"\tSMAABlendingWeightCalculationVS(texcoord, pixcoord, offset);\n"
|
||||
"\tresult = SMAABlendingWeightCalculationPS(texcoord, pixcoord, offset, edges_texture, area_texture,\n"
|
||||
"\t\tsearch_texture, vec4(0.0));\n"
|
||||
"}\n",
|
||||
/* blend */
|
||||
"uniform sampler2D color_texture;\n"
|
||||
"uniform sampler2D weights_texture;\n"
|
||||
"out vec4 result;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"\tvec2 texcoord = gl_FragCoord.xy * metrics.xy;\n"
|
||||
"\tvec4 offset;\n"
|
||||
"\tSMAANeighborhoodBlendingVS(texcoord, offset);\n"
|
||||
"\tresult = SMAANeighborhoodBlendingPS(texcoord, offset, color_texture, weights_texture);\n"
|
||||
"}\n",
|
||||
};
|
||||
#endif
|
||||
|
||||
/* a program, its samplers given their texture units; 0 if it does not
|
||||
build */
|
||||
static GLuint program_build(int which)
|
||||
{
|
||||
static const char *const names[NUMBER_OF_POST_PROGRAMS] =
|
||||
{
|
||||
"FXAA", "SMAA edge detection", "SMAA blending weight", "SMAA neighborhood blending"
|
||||
};
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
GLint unit;
|
||||
} units[] =
|
||||
{
|
||||
{ "color_texture", 0 }, { "edges_texture", 0 }, { "area_texture", 1 },
|
||||
{ "search_texture", 2 }, { "weights_texture", 1 },
|
||||
};
|
||||
struct xgpu_text text = { 0 };
|
||||
GLuint fragment_shader, program;
|
||||
unsigned long index;
|
||||
|
||||
if (!post.vertex_shader)
|
||||
{
|
||||
shader_header(&text);
|
||||
xgpu_text_append(&text, "%s", vertex_source);
|
||||
post.vertex_shader = xgpu_compile_shader(GL_VERTEX_SHADER, text.buffer, "post-process");
|
||||
text.length = 0;
|
||||
}
|
||||
shader_header(&text);
|
||||
if (which == _post_program_fxaa)
|
||||
{
|
||||
xgpu_text_append(&text, "%s", fxaa_source);
|
||||
}
|
||||
#ifndef HALO_ANDROID
|
||||
else if (xgpu_smaa_shader_size)
|
||||
{
|
||||
xgpu_text_append(&text,
|
||||
"#define SMAA_GLSL_4 1\n"
|
||||
"uniform vec4 metrics;\n"
|
||||
"#define SMAA_RT_METRICS metrics\n"
|
||||
"#define SMAA_PRESET_HIGH 1\n"
|
||||
"%s\n%s",
|
||||
(const char *)xgpu_smaa_shader, smaa_mains[which - _post_program_smaa_edges]);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
platform_log("anti-aliasing: the build has no SMAA");
|
||||
free(text.buffer);
|
||||
return 0;
|
||||
}
|
||||
fragment_shader = post.vertex_shader ?
|
||||
xgpu_compile_shader(GL_FRAGMENT_SHADER, text.buffer, names[which]) :
|
||||
0;
|
||||
free(text.buffer);
|
||||
if (!fragment_shader)
|
||||
return 0;
|
||||
program = xgpu_link_program(post.vertex_shader, fragment_shader, names[which]);
|
||||
glDeleteShader(fragment_shader);
|
||||
if (!program)
|
||||
return 0;
|
||||
glUseProgram(program);
|
||||
/* (a name the program does not have is location -1, which is ignored) */
|
||||
for (index = 0; index < sizeof(units) / sizeof(units[0]); index++)
|
||||
glUniform1i(glGetUniformLocation(program, units[index].name), units[index].unit);
|
||||
post.metrics[which] = glGetUniformLocation(program, "metrics");
|
||||
if (which == _post_program_fxaa)
|
||||
post.bounds = glGetUniformLocation(program, "bounds");
|
||||
return program;
|
||||
}
|
||||
|
||||
/* ---------- textures */
|
||||
|
||||
static GLuint texture_new(GLenum format, unsigned long width, unsigned long height, GLenum data_format,
|
||||
const void *data)
|
||||
{
|
||||
GLuint texture;
|
||||
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, (GLint)format, (GLsizei)width, (GLsizei)height, 0, data_format,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
return texture;
|
||||
}
|
||||
|
||||
static GLuint framebuffer_new(GLuint texture)
|
||||
{
|
||||
GLuint framebuffer;
|
||||
GLenum draw_buffer = GL_COLOR_ATTACHMENT0;
|
||||
|
||||
glGenFramebuffers(1, &framebuffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
|
||||
glDrawBuffers(1, &draw_buffer);
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
/* the passes' textures, of the target's size (SMAA's only for SMAA); color
|
||||
is the target's format, so that the copy is exact */
|
||||
static void textures_fit(BOOL smaa, unsigned long width, unsigned long height)
|
||||
{
|
||||
if (post.width != width || post.height != height)
|
||||
{
|
||||
GLuint textures[3] = { post.color, post.edges, post.weights };
|
||||
GLuint framebuffers[3] = { post.color_framebuffer, post.edges_framebuffer, post.weights_framebuffer };
|
||||
|
||||
glDeleteFramebuffers(3, framebuffers);
|
||||
glDeleteTextures(3, textures);
|
||||
post.color = post.edges = post.weights = 0;
|
||||
post.width = width;
|
||||
post.height = height;
|
||||
post.color = texture_new(GL_RGBA8, width, height, GL_RGBA, NULL);
|
||||
post.color_framebuffer = framebuffer_new(post.color);
|
||||
}
|
||||
if (smaa && !post.edges)
|
||||
{
|
||||
post.edges = texture_new(GL_RG8, width, height, GL_RG, NULL);
|
||||
post.weights = texture_new(GL_RGBA8, width, height, GL_RGBA, NULL);
|
||||
post.edges_framebuffer = framebuffer_new(post.edges);
|
||||
post.weights_framebuffer = framebuffer_new(post.weights);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HALO_ANDROID
|
||||
/* a lookup texture of SMAA's from its zlib stream; 0 if it does not
|
||||
inflate */
|
||||
static GLuint lookup_texture(const unsigned int *stream, unsigned long stream_size, GLenum format,
|
||||
GLenum data_format, unsigned long width, unsigned long height, unsigned long texel_size)
|
||||
{
|
||||
uLongf size = (uLongf)(width * height * texel_size);
|
||||
unsigned char *texels = malloc(size);
|
||||
GLuint texture = 0;
|
||||
int result;
|
||||
|
||||
if (!texels)
|
||||
return 0;
|
||||
result = uncompress(texels, &size, (const Bytef *)stream, (uLong)stream_size);
|
||||
/* (the game's zlib is 1.1, which can stop short of saying the stream
|
||||
has ended: the size says whether it is whole) */
|
||||
if ((result == Z_OK || result == Z_BUF_ERROR) && size == (uLongf)(width * height * texel_size))
|
||||
{
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
texture = texture_new(format, width, height, data_format, texels);
|
||||
}
|
||||
free(texels);
|
||||
return texture;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ---------- the passes */
|
||||
|
||||
static void texture_bind(GLuint unit, GLuint texture)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + unit);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glBindSampler(unit, post.sampler);
|
||||
}
|
||||
|
||||
/* a program's triangle drawn into a framebuffer over the rectangle;
|
||||
color_only keeps the framebuffer's alpha */
|
||||
static void pass_draw(int which, GLuint framebuffer, const GLint corners[4], BOOL color_only)
|
||||
{
|
||||
float metrics[4];
|
||||
|
||||
metrics[0] = 1.0f / (float)post.width;
|
||||
metrics[1] = 1.0f / (float)post.height;
|
||||
metrics[2] = (float)post.width;
|
||||
metrics[3] = (float)post.height;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
glViewport(corners[0], corners[1], corners[2] - corners[0], corners[3] - corners[1]);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, color_only ? GL_FALSE : GL_TRUE);
|
||||
glUseProgram(post.programs[which]);
|
||||
glUniform4fv(post.metrics[which], 1, metrics);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
||||
/* an intermediate emptied, all of it, so that no edge of another window's
|
||||
pass is found: SMAA's passes write only where there is an edge */
|
||||
static void intermediate_clear(GLuint framebuffer)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
BOOL xgpu_post_prepare(BOOL smaa)
|
||||
{
|
||||
int first = smaa ? _post_program_smaa_edges : _post_program_fxaa;
|
||||
int last = smaa ? _post_program_smaa_blend : _post_program_fxaa;
|
||||
int which;
|
||||
|
||||
if (post.failed[smaa != FALSE])
|
||||
return FALSE;
|
||||
for (which = first; which <= last; which++)
|
||||
{
|
||||
if (!post.programs[which] && !(post.programs[which] = program_build(which)))
|
||||
{
|
||||
post.failed[smaa != FALSE] = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#ifndef HALO_ANDROID
|
||||
if (smaa && !post.area)
|
||||
{
|
||||
post.area = lookup_texture(xgpu_smaa_area_texture, xgpu_smaa_area_texture_size, GL_RG8, GL_RG,
|
||||
160, 560, 2);
|
||||
post.search = lookup_texture(xgpu_smaa_search_texture, xgpu_smaa_search_texture_size, GL_R8, GL_RED,
|
||||
64, 16, 1);
|
||||
if (!post.area || !post.search)
|
||||
{
|
||||
platform_log("anti-aliasing: cannot inflate SMAA's lookup textures");
|
||||
post.failed[1] = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!post.sampler)
|
||||
{
|
||||
glGenSamplers(1, &post.sampler);
|
||||
glSamplerParameteri(post.sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(post.sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(post.sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(post.sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glGenVertexArrays(1, &post.vertex_array);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL xgpu_post_anti_alias(BOOL smaa, GLuint framebuffer, unsigned long width, unsigned long height,
|
||||
const GLint corners[4])
|
||||
{
|
||||
/* (made already, as the setting was chosen) */
|
||||
if (!xgpu_post_prepare(smaa))
|
||||
return FALSE;
|
||||
textures_fit(smaa, width, height);
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
#ifndef HALO_ANDROID
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
#endif
|
||||
glBindVertexArray(post.vertex_array);
|
||||
|
||||
/* the target's pixels, read while the target is drawn into */
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, post.color_framebuffer);
|
||||
glBlitFramebuffer(corners[0], corners[1], corners[2], corners[3], corners[0], corners[1], corners[2], corners[3],
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
if (!smaa)
|
||||
{
|
||||
float bounds[4];
|
||||
|
||||
/* (split screen: no texel of the next window is read) */
|
||||
bounds[0] = ((float)corners[0] + 0.5f) / (float)width;
|
||||
bounds[1] = ((float)corners[1] + 0.5f) / (float)height;
|
||||
bounds[2] = ((float)corners[2] - 0.5f) / (float)width;
|
||||
bounds[3] = ((float)corners[3] - 0.5f) / (float)height;
|
||||
texture_bind(0, post.color);
|
||||
glUseProgram(post.programs[_post_program_fxaa]);
|
||||
glUniform4fv(post.bounds, 1, bounds);
|
||||
pass_draw(_post_program_fxaa, framebuffer, corners, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
intermediate_clear(post.edges_framebuffer);
|
||||
texture_bind(0, post.color);
|
||||
pass_draw(_post_program_smaa_edges, post.edges_framebuffer, corners, FALSE);
|
||||
|
||||
intermediate_clear(post.weights_framebuffer);
|
||||
texture_bind(0, post.edges);
|
||||
texture_bind(1, post.area);
|
||||
texture_bind(2, post.search);
|
||||
pass_draw(_post_program_smaa_weights, post.weights_framebuffer, corners, FALSE);
|
||||
|
||||
texture_bind(0, post.color);
|
||||
texture_bind(1, post.weights);
|
||||
pass_draw(_post_program_smaa_blend, framebuffer, corners, TRUE);
|
||||
}
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -55,9 +55,9 @@ drive the controller.
|
||||
|
||||
/* main/console.c */
|
||||
extern unsigned char console_is_active(void);
|
||||
/* port/linux/game/menu_functions.c: two players on this machine (the
|
||||
campaign's co-op) */
|
||||
extern unsigned char pc_menu_coop_players(void);
|
||||
/* port/linux/game/menu_functions.c: two or more players on this machine
|
||||
(co-op, or split screen in a network game) */
|
||||
extern unsigned char pc_menu_split_players(void);
|
||||
|
||||
/* ---------- device tables */
|
||||
|
||||
@@ -638,13 +638,43 @@ static int sdl_gamepads(SDL_Gamepad *gamepads[PORT_COUNT])
|
||||
return found;
|
||||
}
|
||||
|
||||
/* whether one gamepad is port 1's (port_gamepad) */
|
||||
static BOOL lone_gamepad_split;
|
||||
|
||||
/* no button of the gamepad held, its sticks and triggers at rest */
|
||||
static BOOL gamepad_idle(SDL_Gamepad *gamepad)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < SDL_GAMEPAD_BUTTON_COUNT; index++)
|
||||
{
|
||||
if (SDL_GetGamepadButton(gamepad, (SDL_GamepadButton)index))
|
||||
return FALSE;
|
||||
}
|
||||
for (index = 0; index < SDL_GAMEPAD_AXIS_COUNT; index++)
|
||||
{
|
||||
if (abs(SDL_GetGamepadAxis(gamepad, (SDL_GamepadAxis)index)) > 8000)
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* the gamepad of a port: the first shares port 0 with the keyboard, but for
|
||||
two players with one gamepad (co-op), port 1 has it (the keyboard's player
|
||||
is 1, the gamepad's 2) */
|
||||
two or more players with one gamepad (co-op, split screen), port 1 has it
|
||||
(the keyboard's player is 1, the gamepad's 2). It changes port only at rest:
|
||||
a button held across the change would be pressed again on the other port
|
||||
(the B that leaves a profile screen leaving the game as player 1's) */
|
||||
static SDL_Gamepad *port_gamepad(SDL_Gamepad *gamepads[PORT_COUNT], int count, int port)
|
||||
{
|
||||
if (count == 1 && pc_menu_coop_players())
|
||||
return port == 1 ? gamepads[0] : NULL;
|
||||
if (count == 1)
|
||||
{
|
||||
BOOL split = pc_menu_split_players() != 0;
|
||||
|
||||
if (split != lone_gamepad_split && gamepad_idle(gamepads[0]))
|
||||
lone_gamepad_split = split;
|
||||
if (lone_gamepad_split)
|
||||
return port == 1 ? gamepads[0] : NULL;
|
||||
}
|
||||
return port < count ? gamepads[port] : NULL;
|
||||
}
|
||||
|
||||
@@ -862,6 +892,12 @@ static void vr_gamepad_state(XINPUT_GAMEPAD *pad)
|
||||
value = vr_stick(left->thumbstick[1]);
|
||||
if (abs(value) > abs(pad->sThumbLY)) pad->sThumbLY = value;
|
||||
if (left->buttons & HALO_XR_BUTTON_MENU) pad->wButtons |= XINPUT_GAMEPAD_START;
|
||||
/* (the Steam Frame's controllers: the left one's View button and D-pad) */
|
||||
if (left->buttons & HALO_XR_BUTTON_VIEW) pad->wButtons |= XINPUT_GAMEPAD_BACK;
|
||||
if (left->buttons & HALO_XR_BUTTON_DPAD_UP) pad->wButtons |= XINPUT_GAMEPAD_DPAD_UP;
|
||||
if (left->buttons & HALO_XR_BUTTON_DPAD_DOWN) pad->wButtons |= XINPUT_GAMEPAD_DPAD_DOWN;
|
||||
if (left->buttons & HALO_XR_BUTTON_DPAD_LEFT) pad->wButtons |= XINPUT_GAMEPAD_DPAD_LEFT;
|
||||
if (left->buttons & HALO_XR_BUTTON_DPAD_RIGHT) pad->wButtons |= XINPUT_GAMEPAD_DPAD_RIGHT;
|
||||
if (left->buttons & HALO_XR_BUTTON_THUMBSTICK) pad->wButtons |= XINPUT_GAMEPAD_LEFT_THUMB;
|
||||
if (right->buttons & HALO_XR_BUTTON_THUMBSTICK) pad->wButtons |= XINPUT_GAMEPAD_RIGHT_THUMB;
|
||||
/* (in the menus the triggers click the pointer: halo_vr_menu_pointer) */
|
||||
@@ -897,6 +933,10 @@ static void vr_gamepad_state(XINPUT_GAMEPAD *pad)
|
||||
merge_button(pad, XINPUT_GAMEPAD_B,
|
||||
((right->buttons & HALO_XR_BUTTON_SQUEEZE) != 0 && !halo_vr_wheel_held()) || halo_vr_melee());
|
||||
merge_button(pad, XINPUT_GAMEPAD_Y, (left->buttons & HALO_XR_BUTTON_B) != 0);
|
||||
/* (the Steam Frame's bumpers: the left switches grenades, the right is
|
||||
the flashlight) */
|
||||
merge_button(pad, XINPUT_GAMEPAD_BLACK, (left->buttons & HALO_XR_BUTTON_BUMPER) != 0);
|
||||
merge_button(pad, XINPUT_GAMEPAD_WHITE, (right->buttons & HALO_XR_BUTTON_BUMPER) != 0);
|
||||
{
|
||||
/* B: a tap is the flashlight, holding it switches grenades; the
|
||||
game sees a short press of either */
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com)
|
||||
Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com)
|
||||
Copyright (C) 2013 Belen Masia (bmasia@unizar.es)
|
||||
Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com)
|
||||
Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software. As clarification, there is no
|
||||
requirement that the copyright notice and permission be included in binary
|
||||
distributions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,20 @@
|
||||
# SMAA
|
||||
|
||||
Enhanced Subpixel Morphological Antialiasing, by Jorge Jimenez, Jose I.
|
||||
Echevarria, Belen Masia, Fernando Navarro and Diego Gutierrez, MIT licensed
|
||||
(see `LICENSE`).
|
||||
|
||||
Upstream: https://github.com/iryoku/smaa, commit
|
||||
71c806a838bdd7d517df19192a20f0c61b3ca29d. `SMAA.hlsl` is copied
|
||||
unchanged. `area_tex.zlib` and `search_tex.zlib` are the bytes of
|
||||
`Textures/AreaTex.h` (160x560, two channels) and `Textures/SearchTex.h`
|
||||
(64x16, one channel), compressed with zlib:
|
||||
|
||||
python -c "import re, sys, zlib; t = open(sys.argv[1]).read(); \
|
||||
open(sys.argv[2], 'wb').write(zlib.compress(bytes(int(h, 16) for h in \
|
||||
re.findall(r'0x([0-9a-fA-F]{2})', t[t.index('{'):])), 9))" AreaTex.h area_tex.zlib
|
||||
|
||||
`display.anti_aliasing = "smaa"` antialiases the 3D view with it, compiled
|
||||
as GLSL (`port/linux/src/xgpu_post.c`); the files are embedded in the Linux
|
||||
and Windows platform layers by `tools/embed_assets.py`. Android has FXAA in
|
||||
its place.
|
||||
@@ -52,6 +52,7 @@ The game finds the game data as on Linux. Refer to "Start the game" in
|
||||
| Settings | `config.toml` next to `halo.exe` |
|
||||
| Saved games | `%APPDATA%\halo`, or `paths.saves` in `config.toml` |
|
||||
| Log | `debug.txt` in the data root (the folder that contains `maps\`) |
|
||||
| Log of the port | The console. The release build has no console: `halo.log` next to `halo.exe` |
|
||||
|
||||
## How the port operates
|
||||
|
||||
|
||||
@@ -37,6 +37,24 @@ static void windows_startup(void)
|
||||
/* Sleep() waits in 1 ms steps rather than the default 15.6 ms: the
|
||||
game's frame pacing sleeps for short intervals */
|
||||
timeBeginPeriod(1);
|
||||
/* a release build has no console (/SUBSYSTEM:WINDOWS), so the platform
|
||||
layer's log (platform_log's stderr: invite links, the data root, crash
|
||||
reports) goes to halo.log next to halo.exe, unless stderr already goes
|
||||
somewhere (a pipe or a file the game was started with) */
|
||||
if (_fileno(stderr) < 0)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
DWORD length = GetModuleFileNameA(NULL, path, sizeof(path));
|
||||
char *slash;
|
||||
|
||||
if (length && length < sizeof(path) && (slash = strrchr(path, '\\')) &&
|
||||
(size_t)(slash + 1 - path) + sizeof("halo.log") <= sizeof(path))
|
||||
{
|
||||
strcpy(slash + 1, "halo.log");
|
||||
if (freopen(path, "w", stderr))
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int errno_from_windows_error(DWORD error)
|
||||
|
||||
@@ -317,6 +317,7 @@ symbols in this file:
|
||||
#include "units/units.h"
|
||||
#include "units/vehicle_definitions.h"
|
||||
#include "units/vehicles.h"
|
||||
#include "networking/network_game_globals.h"
|
||||
|
||||
/* ---------- constants */
|
||||
|
||||
@@ -2224,6 +2225,12 @@ long actor_new(
|
||||
long actor_definition_index;
|
||||
long actor_index = NONE;
|
||||
|
||||
/* port: a client of the distributed netcode runs no AI: it has the host's
|
||||
actors' units, driven as the host sends them (port/linux/game/network_actors.c),
|
||||
and its own (placed at the map's start or by its scripts) would be extras
|
||||
the host doesn't have */
|
||||
if (network_game_distributed_client())
|
||||
return NONE;
|
||||
if (actor_variant_definition_index != NONE)
|
||||
{
|
||||
actor_variant_definition = actor_variant_definition_get(actor_variant_definition_index);
|
||||
@@ -2662,6 +2669,9 @@ long actor_place(
|
||||
long unit_index;
|
||||
|
||||
match_assert("c:\\halo\\SOURCE\\ai\\actors.c", 603, starting_location);
|
||||
/* port: none on a client of the distributed netcode (actor_new) */
|
||||
if (network_game_distributed_client())
|
||||
return NONE;
|
||||
objects_garbage_collection();
|
||||
|
||||
actor_variant_definition =
|
||||
@@ -2831,7 +2841,8 @@ short actors_spawn_from_unit(
|
||||
{
|
||||
short spawned_actor_count = 0;
|
||||
|
||||
if (actor_variant_definition_index != NONE && actor_count > 0)
|
||||
/* port: none on a client of the distributed netcode (actor_new) */
|
||||
if (actor_variant_definition_index != NONE && actor_count > 0 && !network_game_distributed_client())
|
||||
{
|
||||
struct unit_datum *source_unit = unit_get(unit_index);
|
||||
long source_actor_index = source_unit->unit.swarm_actor_index != NONE ?
|
||||
|
||||
@@ -25,9 +25,10 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
MAXIMUM_ACTORS = 256,
|
||||
MAXIMUM_SWARMS = 32,
|
||||
MAXIMUM_SWARM_COMPONENTS = 256,
|
||||
/* port: the native builds' larger pools (halo_port_capacity.h) */
|
||||
MAXIMUM_ACTORS = HALO_PORT_MAXIMUM_ACTORS,
|
||||
MAXIMUM_SWARMS = HALO_PORT_MAXIMUM_SWARMS,
|
||||
MAXIMUM_SWARM_COMPONENTS = HALO_PORT_MAXIMUM_SWARM_COMPONENTS,
|
||||
SWARM_COMPONENT_DATUM_SIZE = 0x40,
|
||||
};
|
||||
|
||||
@@ -255,7 +256,11 @@ enum
|
||||
NUMBER_OF_ACTOR_PERCEPTION_TYPES,
|
||||
};
|
||||
|
||||
#define MAXIMUM_NUMBER_OF_ACTORS 256
|
||||
/* port: the debug information's actors (ai_debug.c's actor_debug_array,
|
||||
by actor index): every actor of the native builds' larger pool
|
||||
(halo_port_capacity.h), else one past the Xbox's 256 is written past its
|
||||
end */
|
||||
#define MAXIMUM_NUMBER_OF_ACTORS HALO_PORT_MAXIMUM_ACTORS
|
||||
#define MAXIMUM_NUMBER_OF_ACTOR_PATHS 32
|
||||
|
||||
#define MAXIMUM_UNIT_INDICES_PER_SWARM 16
|
||||
|
||||
@@ -465,7 +465,8 @@ typedef char ai_prop_unopposable_enemy_offset_assert[
|
||||
static void ai_place_pending_mounted_weapons(
|
||||
void);
|
||||
static boolean ai_enemies_endanger_player(
|
||||
boolean must_be_attacking);
|
||||
boolean must_be_attacking,
|
||||
long unit_index);
|
||||
static void ai_flush_spatial_effects(
|
||||
void);
|
||||
|
||||
@@ -1971,8 +1972,11 @@ void ai_update(
|
||||
return;
|
||||
}
|
||||
|
||||
/* port: unit_index NONE is any player's unit (the game's own check); else
|
||||
only enemies of that unit count (network co-op's respawn, players.c) */
|
||||
static boolean ai_enemies_endanger_player(
|
||||
boolean must_be_attacking)
|
||||
boolean must_be_attacking,
|
||||
long unit_index)
|
||||
{
|
||||
long current_time = game_time_get();
|
||||
struct data_iterator iterator;
|
||||
@@ -1985,7 +1989,8 @@ static boolean ai_enemies_endanger_player(
|
||||
{
|
||||
if (prop->player &&
|
||||
prop->enemy &&
|
||||
unit_get(prop->unit_index)->unit.player_index != NONE)
|
||||
unit_get(prop->unit_index)->unit.player_index != NONE &&
|
||||
(unit_index == NONE || prop->unit_index == unit_index))
|
||||
{
|
||||
struct actor_datum *actor = actor_get(prop->owner_actor_index);
|
||||
long object_index = actor->meta.swarm
|
||||
@@ -2068,13 +2073,27 @@ static boolean ai_enemies_endanger_player(
|
||||
boolean ai_enemies_can_see_player(
|
||||
void)
|
||||
{
|
||||
return ai_enemies_endanger_player(FALSE);
|
||||
return ai_enemies_endanger_player(FALSE, NONE);
|
||||
}
|
||||
|
||||
boolean ai_enemies_attacking_player(
|
||||
void)
|
||||
{
|
||||
return ai_enemies_endanger_player(TRUE);
|
||||
return ai_enemies_endanger_player(TRUE, NONE);
|
||||
}
|
||||
|
||||
/* port: whether enemies can see this player's unit */
|
||||
boolean ai_port_enemies_can_see_unit(
|
||||
long unit_index)
|
||||
{
|
||||
return ai_enemies_endanger_player(FALSE, unit_index);
|
||||
}
|
||||
|
||||
/* port: whether enemies are attacking this player's unit */
|
||||
boolean ai_port_enemies_attacking_unit(
|
||||
long unit_index)
|
||||
{
|
||||
return ai_enemies_endanger_player(TRUE, unit_index);
|
||||
}
|
||||
|
||||
long ai_get_race_from_team_index(
|
||||
|
||||
@@ -142,6 +142,12 @@ boolean ai_consider_major_upgrade(
|
||||
short squad_index,
|
||||
real chance);
|
||||
|
||||
/* port: network co-op's respawn (players.c) */
|
||||
/* port: whether enemies can see this player's unit */
|
||||
boolean ai_port_enemies_can_see_unit(
|
||||
long unit_index);
|
||||
boolean ai_port_enemies_attacking_unit(
|
||||
long unit_index);
|
||||
boolean ai_enemies_attacking_player(
|
||||
void);
|
||||
boolean ai_enemies_can_see_player(
|
||||
|
||||
@@ -298,7 +298,7 @@ void ai_profile_display(
|
||||
ai_profile.meters[_ai_meter_units_updated].current_value,
|
||||
ai_profile.meters[_ai_meter_units].current_value,
|
||||
ai_profile.meters[_ai_meter_props].current_value,
|
||||
768);
|
||||
HALO_PORT_MAXIMUM_PROPS);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -450,7 +450,7 @@ static void ai_profile_render_encounters(
|
||||
ai_profile.meters[_ai_meter_encounters_updated].current_value,
|
||||
ai_profile.meters[_ai_meter_encounters].current_value,
|
||||
ai_profile.meters[_ai_meter_props].current_value,
|
||||
768);
|
||||
HALO_PORT_MAXIMUM_PROPS);
|
||||
ai_profile_draw_string(profilestring, NUMBEROF(tab_stops), tab_stops, global_real_argb_white);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3255,7 +3255,8 @@ void ai_scripting_attach_unit(
|
||||
squad_index,
|
||||
struct squad_definition);
|
||||
|
||||
if (squad_definition->actor_palette_index != NONE)
|
||||
/* port: an entry the palette has (a map's index), as the others here */
|
||||
if (VALID_INDEX(squad_definition->actor_palette_index, scenario->ai_actor_palette.count))
|
||||
{
|
||||
struct tag_reference *actor_palette_entry = TAG_BLOCK_GET_ELEMENT(
|
||||
&scenario->ai_actor_palette,
|
||||
|
||||
@@ -311,6 +311,7 @@ symbols in this file:
|
||||
#include "scenario/scenario_definitions.h"
|
||||
#include "structures/structure_bsp_definitions.h"
|
||||
#include "units/units.h"
|
||||
#include "coop_enemies.h" /* port: port/linux/game/coop_enemies.c */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -540,7 +541,8 @@ static boolean encounter_place_actor(
|
||||
long encounter_index,
|
||||
short squad_index,
|
||||
short initial_variant,
|
||||
boolean spawning);
|
||||
boolean spawning,
|
||||
short extra_number);
|
||||
static void encounterless_deactivate(
|
||||
long actor_index);
|
||||
static void encounters_test_activation(
|
||||
@@ -1836,7 +1838,7 @@ boolean encounter_spawn_actor(
|
||||
{
|
||||
if (ai_globals->ai_initialized_for_map)
|
||||
{
|
||||
if (encounter_place_actor(encounter_index, squad_index, 0, TRUE))
|
||||
if (encounter_place_actor(encounter_index, squad_index, 0, TRUE, 0))
|
||||
{
|
||||
struct encounter_datum *encounter = encounter_get(encounter_index);
|
||||
struct encounter_definition *encounter_definition = TAG_BLOCK_GET_ELEMENT(
|
||||
@@ -2245,9 +2247,17 @@ void encounter_create(
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
encounter_place_actor(encounter_index, squad_index, initial_variant, FALSE);
|
||||
encounter_place_actor(encounter_index, squad_index, initial_variant, FALSE, 0);
|
||||
initial_variant = 0;
|
||||
}
|
||||
/* port: network co-op's extra enemies, for its players
|
||||
(coop_enemies.c) */
|
||||
{
|
||||
short extra_count = coop_enemies_extra_count(encounter_index, count);
|
||||
|
||||
for (i = 0; i < extra_count; ++i)
|
||||
encounter_place_actor(encounter_index, squad_index, 0, FALSE, (short)(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
encounter_update_status(encounter_index);
|
||||
@@ -2996,18 +3006,25 @@ static void encounter_post_combat(
|
||||
return;
|
||||
}
|
||||
|
||||
/* port: extra_number, counting from 1, places one of network co-op's extra
|
||||
enemies (coop_enemies.c), spread around the squad's starting locations in
|
||||
turn; 0 places the squad's own actor, as on the Xbox */
|
||||
static boolean encounter_place_actor(
|
||||
long encounter_index,
|
||||
short squad_index,
|
||||
short initial_variant,
|
||||
boolean spawning)
|
||||
boolean spawning,
|
||||
short extra_number)
|
||||
{
|
||||
boolean placed = FALSE;
|
||||
struct encounter_definition *encounter_definition = TAG_BLOCK_GET_ELEMENT(
|
||||
&global_scenario_get()->ai_encounters, DATUM_INDEX_TO_ABSOLUTE_INDEX(encounter_index), struct encounter_definition);
|
||||
struct squad_definition *squad_definition = TAG_BLOCK_GET_ELEMENT(
|
||||
&encounter_definition->squads, squad_index, struct squad_definition);
|
||||
short starting_location_index = encounter_get_actor_starting_location(encounter_index, squad_index, spawning);
|
||||
short starting_location_index = extra_number > 0 && squad_definition->starting_locations.count > 0 ?
|
||||
(short)((extra_number - 1) % squad_definition->starting_locations.count) :
|
||||
encounter_get_actor_starting_location(encounter_index, squad_index, spawning);
|
||||
struct actor_starting_location spread_location;
|
||||
|
||||
if (starting_location_index != NONE)
|
||||
{
|
||||
@@ -3016,6 +3033,61 @@ static boolean encounter_place_actor(
|
||||
short actor_palette_index = squad_definition->actor_palette_index;
|
||||
struct scenario *scenario = global_scenario_get();
|
||||
|
||||
/* port: an extra enemy goes on free ground around its starting
|
||||
location, else around the squad's others in turn */
|
||||
if (extra_number > 0)
|
||||
{
|
||||
/* (what was found taken around the starting locations while this
|
||||
squad's extra enemies are placed, not tried again for the rest of
|
||||
them: placing actors only takes room, and each enemy would try
|
||||
every taken place again, and every place of a full location) */
|
||||
static struct
|
||||
{
|
||||
long encounter_index;
|
||||
long time;
|
||||
short squad_index;
|
||||
unsigned long full;
|
||||
long taken[32][BIT_VECTOR_SIZE_IN_LONGS(COOP_ENEMIES_SPREAD_SPOTS)];
|
||||
} full_locations = { NONE, NONE, NONE, 0 };
|
||||
short count = squad_definition->starting_locations.count;
|
||||
short tried;
|
||||
|
||||
if (extra_number == 1 || full_locations.encounter_index != encounter_index ||
|
||||
full_locations.squad_index != squad_index || full_locations.time != game_time_get())
|
||||
{
|
||||
full_locations.encounter_index = encounter_index;
|
||||
full_locations.squad_index = squad_index;
|
||||
full_locations.time = game_time_get();
|
||||
full_locations.full = 0;
|
||||
csmemset(full_locations.taken, 0, sizeof(full_locations.taken));
|
||||
}
|
||||
for (tried = 0; tried < count; tried++)
|
||||
{
|
||||
short candidate_index = (short)((starting_location_index + tried) % count);
|
||||
struct actor_starting_location *candidate = TAG_BLOCK_GET_ELEMENT(&squad_definition->starting_locations,
|
||||
candidate_index, struct actor_starting_location);
|
||||
|
||||
if (candidate_index < 32 && TEST_FLAG(full_locations.full, candidate_index))
|
||||
continue;
|
||||
spread_location = *candidate;
|
||||
if (coop_enemies_spread_position(&candidate->position, extra_number,
|
||||
candidate_index < 32 ? full_locations.taken[candidate_index] : NULL, &spread_location.position))
|
||||
break;
|
||||
if (candidate_index < 32)
|
||||
SET_FLAG(full_locations.full, candidate_index, TRUE);
|
||||
}
|
||||
/* (with no room anywhere, as extra enemies were placed before:
|
||||
on rings around the squad's starting location in turn, else on
|
||||
it) */
|
||||
if (tried == count)
|
||||
{
|
||||
spread_location = *starting_location;
|
||||
coop_enemies_fallback_position(&starting_location->position,
|
||||
(short)((extra_number - 1) / MAX(count, 1) + 1), &spread_location.position);
|
||||
}
|
||||
starting_location = &spread_location;
|
||||
}
|
||||
|
||||
if (starting_location->actor_variant_index != NONE)
|
||||
actor_palette_index = starting_location->actor_variant_index;
|
||||
|
||||
|
||||
@@ -95,7 +95,8 @@ static long last_prop_data_full_warn_time = NONE;
|
||||
void props_initialize(
|
||||
void)
|
||||
{
|
||||
prop_data = game_state_data_new("prop", 768, sizeof(struct prop_datum));
|
||||
/* port: the native builds' larger pool (halo_port_capacity.h) */
|
||||
prop_data = game_state_data_new("prop", HALO_PORT_MAXIMUM_PROPS, sizeof(struct prop_datum));
|
||||
|
||||
match_assert("c:\\halo\\SOURCE\\ai\\props.c", 0x24, prop_data);
|
||||
|
||||
@@ -141,7 +142,7 @@ static void prop_add(
|
||||
error(
|
||||
_error_silent,
|
||||
"AI knowledge database (%d entries) is full (warns once every 30 sec)",
|
||||
768);
|
||||
HALO_PORT_MAXIMUM_PROPS);
|
||||
last_prop_data_full_warn_time = game_time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,16 @@ symbols in this file:
|
||||
|
||||
/* ---------- constants */
|
||||
|
||||
enum
|
||||
{
|
||||
/* port: a vertex or index buffer in a cache file (a D3DResource: Common,
|
||||
Data, Lock), as cache_files_disable_writes counts them */
|
||||
CACHE_FILE_BUFFER_SIZE = 12,
|
||||
/* port: what cache_file_read rounds a read's size up to a multiple of
|
||||
(cache_files_windows.c) */
|
||||
CACHE_FILE_SECTOR_SIZE = 512,
|
||||
};
|
||||
|
||||
/* ---------- macros */
|
||||
|
||||
#define STRUCTURE_BSP_TAG 'sbsp'
|
||||
@@ -221,6 +231,18 @@ typedef char verify_cache_file_header_size[
|
||||
|
||||
static struct cache_file_tag_instance *cache_get_tag_instance(
|
||||
long tag_index);
|
||||
static boolean cache_file_region_contains(
|
||||
void const *region,
|
||||
unsigned long region_size,
|
||||
void const *address,
|
||||
long count,
|
||||
long element_size);
|
||||
static boolean cache_file_tag_header_verify(
|
||||
struct cache_file_tag_header *tag_header,
|
||||
long tag_data_size,
|
||||
char const *scenario_name);
|
||||
static boolean cache_file_structure_bsp_reference_verify(
|
||||
struct scenario_structure_bsp_reference *reference);
|
||||
|
||||
/* ---------- globals */
|
||||
|
||||
@@ -270,6 +292,156 @@ static struct cache_file_tag_instance *cache_get_tag_instance(
|
||||
return tag_instance;
|
||||
}
|
||||
|
||||
/* port: whether count elements of element_size bytes at address all lie in
|
||||
the region_size bytes at region (no elements always do): a map's pointers
|
||||
and counts are checked so before anything follows them */
|
||||
static boolean cache_file_region_contains(
|
||||
void const *region,
|
||||
unsigned long region_size,
|
||||
void const *address,
|
||||
long count,
|
||||
long element_size)
|
||||
{
|
||||
unsigned long offset = (unsigned long)address - (unsigned long)region;
|
||||
|
||||
if (count == 0)
|
||||
return TRUE;
|
||||
|
||||
return count > 0 &&
|
||||
(unsigned long)address >= (unsigned long)region &&
|
||||
offset <= region_size &&
|
||||
(unsigned long)count <= (region_size - offset) / (unsigned long)element_size;
|
||||
}
|
||||
|
||||
/* port: whether the tag header of the tags just read (tag_data_size bytes
|
||||
at the tag cache's base) can be trusted, as everything after trusts it:
|
||||
its tag table and vertex and index buffers lie in the tag data, its tags'
|
||||
count fits a tag index's absolute index, and it names a scenario tag */
|
||||
static boolean cache_file_tag_header_verify(
|
||||
struct cache_file_tag_header *tag_header,
|
||||
long tag_data_size,
|
||||
char const *scenario_name)
|
||||
{
|
||||
char const *problem = NULL;
|
||||
|
||||
if (tag_header->signature != CACHE_FILE_TAG_HEADER_SIGNATURE)
|
||||
{
|
||||
problem = "signature";
|
||||
}
|
||||
else if (tag_header->tag_count <= 0 || tag_header->tag_count > UNSIGNED_SHORT_MAX)
|
||||
{
|
||||
problem = "tag count";
|
||||
}
|
||||
else if (!cache_file_region_contains(
|
||||
tag_header,
|
||||
tag_data_size,
|
||||
tag_header->tag_instances,
|
||||
tag_header->tag_count,
|
||||
sizeof(struct cache_file_tag_instance)))
|
||||
{
|
||||
problem = "tag table";
|
||||
}
|
||||
else if (!cache_file_region_contains(
|
||||
tag_header,
|
||||
tag_data_size,
|
||||
tag_header->vertex_buffers,
|
||||
tag_header->vertex_buffer_count,
|
||||
CACHE_FILE_BUFFER_SIZE))
|
||||
{
|
||||
problem = "vertex buffers";
|
||||
}
|
||||
else if (!cache_file_region_contains(
|
||||
tag_header,
|
||||
tag_data_size,
|
||||
tag_header->index_buffers,
|
||||
tag_header->index_buffer_count,
|
||||
CACHE_FILE_BUFFER_SIZE))
|
||||
{
|
||||
problem = "index buffers";
|
||||
}
|
||||
else
|
||||
{
|
||||
long scenario_absolute_index = DATUM_INDEX_TO_ABSOLUTE_INDEX(tag_header->scenario_tag_index);
|
||||
|
||||
if (scenario_absolute_index >= tag_header->tag_count ||
|
||||
tag_header->tag_instances[scenario_absolute_index].tag_index != tag_header->scenario_tag_index ||
|
||||
tag_header->tag_instances[scenario_absolute_index].group_tag != SCENARIO_TAG)
|
||||
{
|
||||
problem = "scenario tag";
|
||||
}
|
||||
}
|
||||
|
||||
if (problem)
|
||||
{
|
||||
error(_error_silent, "the cache file '%s' is damaged: its tag header's %s is wrong", scenario_name, problem);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* port: whether a structure bsp reference (the scenario's) may be loaded:
|
||||
its bytes lie in the map and fit the tag cache after the tag data, where
|
||||
they are read to (rounded up to whole sectors, as the read is), and it
|
||||
names a structure bsp tag */
|
||||
static boolean cache_file_structure_bsp_reference_verify(
|
||||
struct scenario_structure_bsp_reference *reference)
|
||||
{
|
||||
byte *tag_cache_base_address = physical_memory_get_tag_cache_base_address();
|
||||
long tag_data_size = cache_file_globals.header.tag_data_size;
|
||||
long absolute_index = DATUM_INDEX_TO_ABSOLUTE_INDEX(reference->structure_bsp.index);
|
||||
long read_size;
|
||||
|
||||
if (reference->file_offset < 0 ||
|
||||
reference->file_size < (long)sizeof(struct cache_file_structure_bsp_header) ||
|
||||
reference->file_size > TAG_CACHE_SIZE ||
|
||||
reference->file_offset > cache_file_globals.header.file_length - reference->file_size)
|
||||
{
|
||||
error(
|
||||
_error_silent,
|
||||
"a structure bsp is damaged: %08x bytes at %08x, in %08x bytes",
|
||||
reference->file_size,
|
||||
reference->file_offset,
|
||||
cache_file_globals.header.file_length);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
read_size = (reference->file_size + CACHE_FILE_SECTOR_SIZE - 1) & ~(CACHE_FILE_SECTOR_SIZE - 1);
|
||||
if (!cache_file_region_contains(
|
||||
tag_cache_base_address + tag_data_size,
|
||||
TAG_CACHE_SIZE - tag_data_size,
|
||||
reference->base_address,
|
||||
read_size,
|
||||
1))
|
||||
{
|
||||
error(
|
||||
_error_silent,
|
||||
"a structure bsp is damaged: its %08x bytes at %08x would load to %08lx, outside the tag cache",
|
||||
reference->file_size,
|
||||
reference->file_offset,
|
||||
(unsigned long)reference->base_address);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (reference->structure_bsp.index == NONE ||
|
||||
absolute_index >= cache_file_globals.tag_header->tag_count ||
|
||||
global_tag_instances[absolute_index].tag_index != reference->structure_bsp.index ||
|
||||
global_tag_instances[absolute_index].group_tag != STRUCTURE_BSP_TAG)
|
||||
{
|
||||
error(
|
||||
_error_silent,
|
||||
"a structure bsp is damaged: %08x is not a structure bsp tag",
|
||||
reference->structure_bsp.index);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ---------- public code */
|
||||
|
||||
char const *cache_files_map_directory(
|
||||
@@ -444,7 +616,9 @@ long tag_loaded(
|
||||
long group_tag,
|
||||
char const *name)
|
||||
{
|
||||
short absolute_index;
|
||||
/* port: a long, as the tags' count is (a short wrapped on a count past
|
||||
0x7FFF, and the walk never ended) */
|
||||
long absolute_index;
|
||||
long result = NONE;
|
||||
|
||||
if (cache_file_globals.tags_loaded)
|
||||
@@ -651,6 +825,27 @@ boolean cache_file_header_verify(
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* port: the map holds at least its header, and its tag data lies in it
|
||||
and fits the tag cache, which it is read into whole (a size rounded up
|
||||
to whole sectors still fits, the cache being whole sectors). Checked
|
||||
without overflow: the offset and size are each checked first */
|
||||
if (header->file_length < (long)sizeof(struct cache_file_header) ||
|
||||
header->tag_data_offset < 0 ||
|
||||
header->tag_data_size < 0 ||
|
||||
header->tag_data_size > TAG_CACHE_SIZE ||
|
||||
header->tag_data_offset > header->file_length - header->tag_data_size)
|
||||
{
|
||||
error(
|
||||
_error_silent,
|
||||
"the cache file '%s' is damaged: %08x bytes of tag data at %08x, in %08x bytes",
|
||||
scenario_name,
|
||||
header->tag_data_size,
|
||||
header->tag_data_offset,
|
||||
header->file_length);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -846,6 +1041,26 @@ long scenario_tags_load(
|
||||
SwitchToThread();
|
||||
}
|
||||
|
||||
/* port: tags that did not all read, or whose header cannot be
|
||||
trusted, are not loaded: the map is refused, as one whose header
|
||||
is wrong is, and closed for the next to open */
|
||||
if (read_complete != TRUE)
|
||||
{
|
||||
error(_error_silent, "the cache file '%s' could not be read", scenario_name);
|
||||
cache_file_close();
|
||||
|
||||
return NONE;
|
||||
}
|
||||
if (!cache_file_tag_header_verify(
|
||||
tag_cache_base_address,
|
||||
cache_file_globals.header.tag_data_size,
|
||||
scenario_name))
|
||||
{
|
||||
cache_file_close();
|
||||
|
||||
return NONE;
|
||||
}
|
||||
|
||||
cache_file_globals.tag_header = tag_cache_base_address;
|
||||
match_vassert(
|
||||
"c:\\halo\\SOURCE\\cache\\cache_files.c",
|
||||
@@ -885,6 +1100,11 @@ long scenario_tags_load(
|
||||
}
|
||||
result = cache_file_globals.tag_header->scenario_tag_index;
|
||||
}
|
||||
/* port: a map refused is closed for the next to open */
|
||||
else
|
||||
{
|
||||
cache_file_close();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -895,6 +1115,18 @@ boolean scenario_structure_bsp_load(
|
||||
{
|
||||
struct cache_file_tag_instance *tag_instance;
|
||||
byte *tag_cache_base_address;
|
||||
/* port: the bsp's header, once read and checked */
|
||||
struct cache_file_structure_bsp_header *structure_bsp_header;
|
||||
|
||||
/* port: the tag data's size was checked as the map loaded
|
||||
(cache_file_header_verify); the bsp's reference is the map's, and is
|
||||
checked before anything is read where it says */
|
||||
if (cache_file_globals.header.tag_data_size < 0 ||
|
||||
cache_file_globals.header.tag_data_size > TAG_CACHE_SIZE ||
|
||||
!cache_file_structure_bsp_reference_verify(reference))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
tag_cache_base_address = physical_memory_get_tag_cache_base_address();
|
||||
csmemset(
|
||||
@@ -919,9 +1151,43 @@ boolean scenario_structure_bsp_load(
|
||||
sound_idle();
|
||||
}
|
||||
}
|
||||
|
||||
/* port: a bsp that did not all read, or whose header's pointers
|
||||
leave what was read, is not loaded */
|
||||
structure_bsp_header = reference->base_address;
|
||||
if (read_complete != TRUE ||
|
||||
structure_bsp_header->signature != CACHE_FILE_STRUCTURE_BSP_HEADER_SIGNATURE ||
|
||||
!cache_file_region_contains(
|
||||
reference->base_address,
|
||||
reference->file_size,
|
||||
structure_bsp_header->base_address,
|
||||
1,
|
||||
1) ||
|
||||
!cache_file_region_contains(
|
||||
reference->base_address,
|
||||
reference->file_size,
|
||||
structure_bsp_header->vertex_buffers,
|
||||
structure_bsp_header->vertex_buffer_count,
|
||||
CACHE_FILE_BUFFER_SIZE) ||
|
||||
!cache_file_region_contains(
|
||||
reference->base_address,
|
||||
reference->file_size,
|
||||
structure_bsp_header->index_buffers,
|
||||
structure_bsp_header->index_buffer_count,
|
||||
CACHE_FILE_BUFFER_SIZE))
|
||||
{
|
||||
error(
|
||||
_error_silent,
|
||||
"a structure bsp is damaged: its %08x bytes at %08x %s",
|
||||
reference->file_size,
|
||||
reference->file_offset,
|
||||
read_complete != TRUE ? "could not be read" : "have a wrong header");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
cache_file_globals.structure_bsp_header = reference->base_address;
|
||||
cache_file_globals.structure_bsp_header = structure_bsp_header;
|
||||
match_assert(
|
||||
"c:\\halo\\SOURCE\\cache\\cache_files.c",
|
||||
0xE0,
|
||||
|
||||