Streamline GPS momentum plugin
This commit is contained in:
@@ -1,40 +1,41 @@
|
||||
# EdgeWeightGPS
|
||||
# MomentumGPS
|
||||
|
||||
Cyberpunk 2077 RED4ext plugin that improves player GPS routing by penalizing
|
||||
short-segment churn in the native GPS solver. The current validated default
|
||||
pushes the GPS toward smoother, higher-momentum driving corridors without
|
||||
globally forcing every route onto highways.
|
||||
short-segment churn in the native GPS solver. The validated default pushes the
|
||||
GPS toward smoother, higher-momentum driving corridors without globally forcing
|
||||
every route onto highways.
|
||||
|
||||
## Current Status
|
||||
|
||||
Working prototype, validated in-game.
|
||||
Working RED4ext plugin, validated in-game.
|
||||
|
||||
- Route scoring patch: enabled.
|
||||
- Live tuning file: enabled.
|
||||
- Current default fixed-edge penalty: `80.0`.
|
||||
- Highway multiplier: neutral `1.0`; the earlier highway-speed/class
|
||||
experiments are not part of the playable default.
|
||||
- Current fixed ordinary-edge penalty: `80.0`.
|
||||
- Live tuning: removed from the release build.
|
||||
- Highway multiplier/class weighting experiments: not part of the playable
|
||||
default.
|
||||
|
||||
The active package is a RED4ext plugin only:
|
||||
|
||||
```text
|
||||
red4ext/plugins/EdgeWeightGPS/EdgeWeightGPS.dll
|
||||
red4ext/plugins/EdgeWeightGPS/momentum_weights.bin
|
||||
red4ext/plugins/EdgeWeightGPS/solver_weights.bin
|
||||
red4ext/plugins/MomentumGPS/MomentumGPS.dll
|
||||
red4ext/plugins/MomentumGPS/README.txt
|
||||
```
|
||||
|
||||
## What It Patches
|
||||
|
||||
Reverse engineering found the player GPS route search loop around the native
|
||||
solver relaxation cluster. The useful patch surface is not the script-facing
|
||||
`RunGPSQuery`/`UpdateGPSQuery` helpers and not the generated traffic
|
||||
`maxSpeed` fields. The playable hook patches the two ordinary adjacency
|
||||
expansion sites feeding the native relax/update routine at `0x40ba58`.
|
||||
`RunGPSQuery`/`UpdateGPSQuery` helpers and not generated traffic `maxSpeed`
|
||||
fields. The playable hook patches the two ordinary adjacency expansion sites
|
||||
feeding the native relax/update routine at `0x40ba58`.
|
||||
|
||||
The plugin adds a nonnegative fixed cost to ordinary edge expansion. In
|
||||
practice, this makes many tiny street segments and repeated 90-degree
|
||||
stair-steps less attractive, while still allowing local roads when they are the
|
||||
right path.
|
||||
The plugin adds a fixed cost to ordinary edge expansion. In practice, this makes
|
||||
many tiny street segments and repeated 90-degree stair-steps less attractive,
|
||||
while still allowing local roads when they are the right path.
|
||||
|
||||
This is an inline native patch against tested Cyberpunk 2077 executable RVAs. A
|
||||
future game update may require fresh verification.
|
||||
|
||||
## Validation Summary
|
||||
|
||||
@@ -69,7 +70,7 @@ toolbox run -c 2077 ./tools/build_red4ext_shim.sh
|
||||
This writes:
|
||||
|
||||
```text
|
||||
build/red4ext/EdgeWeightGPS-mingw64/EdgeWeightGPS.dll
|
||||
build/red4ext/MomentumGPS-mingw64/MomentumGPS.dll
|
||||
```
|
||||
|
||||
## Install Locally
|
||||
@@ -80,13 +81,9 @@ Only install while the game is cold.
|
||||
toolbox run -c 2077 ./tools/install_red4ext_shim.sh
|
||||
```
|
||||
|
||||
The install script builds the DLL, installs it into the Flatpak Steam Cyberpunk
|
||||
2077 folder, and writes the validated defaults:
|
||||
|
||||
- `momentum_weights.bin = 80.0`
|
||||
- `solver_weights.bin = 1.0`
|
||||
|
||||
Override the game directory with `CYBERPUNK2077_GAME_DIR` if needed.
|
||||
The install script builds the DLL and installs it into the Flatpak Steam
|
||||
Cyberpunk 2077 folder. Override the game directory with
|
||||
`CYBERPUNK2077_GAME_DIR` if needed.
|
||||
|
||||
## Package
|
||||
|
||||
@@ -99,26 +96,6 @@ toolbox run -c 2077 ./tools/package_red4ext_mod.sh
|
||||
The package is written under `dist/` and contains the `red4ext/` folder layout
|
||||
expected by the game.
|
||||
|
||||
## Live Tuning
|
||||
|
||||
`momentum_weights.bin` is a single little-endian float32 and is hot-reloaded
|
||||
every 500 ms while the game is running.
|
||||
|
||||
Useful presets:
|
||||
|
||||
```bash
|
||||
python3 tools/write_momentum_weights.py vanilla # 0.0
|
||||
python3 tools/write_momentum_weights.py default # 80.0
|
||||
python3 tools/write_momentum_weights.py overstrong # 160.0, known too high
|
||||
```
|
||||
|
||||
`solver_weights.bin` is still present for older highway multiplier experiments,
|
||||
but the playable default keeps it neutral:
|
||||
|
||||
```bash
|
||||
python3 tools/write_solver_weights.py vanilla # 1.0
|
||||
```
|
||||
|
||||
## Repository Notes
|
||||
|
||||
This repository also contains older experiments and reverse-engineering tools:
|
||||
@@ -127,6 +104,7 @@ This repository also contains older experiments and reverse-engineering tools:
|
||||
- Traffic lane and connection probability patchers.
|
||||
- Static disassembly helpers.
|
||||
- RED4ext logging probes.
|
||||
- Earlier live-tuning helpers and presets.
|
||||
|
||||
Those tools are retained because they explain the route-finding system and
|
||||
document failed approaches, but they are not part of the current playable
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
EdgeWeightGPS RED4ext package
|
||||
|
||||
Install:
|
||||
Copy the red4ext folder from this package into the Cyberpunk 2077 game folder.
|
||||
The final layout should include:
|
||||
|
||||
Cyberpunk 2077/red4ext/plugins/EdgeWeightGPS/EdgeWeightGPS.dll
|
||||
Cyberpunk 2077/red4ext/plugins/EdgeWeightGPS/momentum_weights.bin
|
||||
Cyberpunk 2077/red4ext/plugins/EdgeWeightGPS/solver_weights.bin
|
||||
|
||||
Default tuning:
|
||||
momentum_weights.bin = 80.0 fixed ordinary-edge penalty
|
||||
solver_weights.bin = 1.0 neutral highway multiplier
|
||||
|
||||
Notes:
|
||||
The plugin changes player GPS route scoring by adding a fixed cost to ordinary
|
||||
edge expansion in the native GPS solver. This favors smoother routes with fewer
|
||||
short-segment stair-steps and was validated in-game on long highway routes,
|
||||
City Center routes, and local Watson/Westbrook routes.
|
||||
|
||||
Tuning:
|
||||
momentum_weights.bin is a single little-endian float32 and is hot-reloaded while
|
||||
the game is running. Set it to 0.0 to disable the fixed-edge penalty. Values
|
||||
around 80.0 are the current validated default. 160.0 was tested and is too high:
|
||||
it can trigger bad hairpins or fallback-style routing.
|
||||
@@ -0,0 +1,22 @@
|
||||
MomentumGPS RED4ext package
|
||||
|
||||
Install:
|
||||
Copy the red4ext folder from this package into the Cyberpunk 2077 game folder.
|
||||
The final layout should include:
|
||||
|
||||
Cyberpunk 2077/red4ext/plugins/MomentumGPS/MomentumGPS.dll
|
||||
Cyberpunk 2077/red4ext/plugins/MomentumGPS/README.txt
|
||||
|
||||
What it does:
|
||||
The plugin changes player GPS route scoring by adding a fixed 80.0 cost to
|
||||
ordinary edge expansion in the native GPS solver. This favors smoother routes
|
||||
with fewer short-segment stair-steps and was validated in-game on long highway
|
||||
routes, City Center routes, and local Watson/Westbrook routes.
|
||||
|
||||
Notes:
|
||||
This release has no live tuning file. To change the fixed penalty, rebuild the
|
||||
plugin with a different kFixedEdgePenalty value.
|
||||
|
||||
The patch is version-specific native code. If a future Cyberpunk 2077 update
|
||||
changes the executable around the patched RVAs, the plugin should fail closed
|
||||
instead of patching unexpected bytes.
|
||||
@@ -1,25 +1,25 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
|
||||
project(EdgeWeightGPS VERSION 0.1.0 LANGUAGES CXX)
|
||||
project(MomentumGPS VERSION 0.2.0 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
add_library(EdgeWeightGPS SHARED src/Main.cpp)
|
||||
add_library(MomentumGPS SHARED src/Main.cpp)
|
||||
target_include_directories(
|
||||
EdgeWeightGPS
|
||||
MomentumGPS
|
||||
PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../../vendor/RED4ext.SDK/include"
|
||||
)
|
||||
target_compile_definitions(EdgeWeightGPS PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||
target_compile_options(EdgeWeightGPS PRIVATE -fmax-errors=12)
|
||||
target_link_options(EdgeWeightGPS PRIVATE -static -static-libgcc -static-libstdc++)
|
||||
target_compile_definitions(MomentumGPS PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||
target_compile_options(MomentumGPS PRIVATE -fmax-errors=12)
|
||||
target_link_options(MomentumGPS PRIVATE -static -static-libgcc -static-libstdc++)
|
||||
|
||||
set_target_properties(
|
||||
EdgeWeightGPS
|
||||
MomentumGPS
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME "EdgeWeightGPS"
|
||||
OUTPUT_NAME "MomentumGPS"
|
||||
)
|
||||
|
||||
+109
-6086
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
plugin_dir="$repo_root/red4ext/EdgeWeightGPS"
|
||||
build_dir="$repo_root/build/red4ext/EdgeWeightGPS-mingw64"
|
||||
build_dir="$repo_root/build/red4ext/MomentumGPS-mingw64"
|
||||
sdk_dir="$repo_root/vendor/RED4ext.SDK"
|
||||
|
||||
if [[ ! -f "$sdk_dir/include/RED4ext/Api/v1/PluginInfo.hpp" ]]; then
|
||||
@@ -16,4 +16,4 @@ cmake -S "$plugin_dir" -B "$build_dir" \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
cmake --build "$build_dir" --parallel
|
||||
|
||||
printf '%s\n' "$build_dir/EdgeWeightGPS.dll"
|
||||
printf '%s\n' "$build_dir/MomentumGPS.dll"
|
||||
|
||||
@@ -3,14 +3,10 @@ set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
game_dir="${CYBERPUNK2077_GAME_DIR:-/var/home/salt/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/Cyberpunk 2077}"
|
||||
plugin_out="$game_dir/red4ext/plugins/EdgeWeightGPS"
|
||||
plugin_out="$game_dir/red4ext/plugins/MomentumGPS"
|
||||
|
||||
dll_path="$("$repo_root/tools/build_red4ext_shim.sh" | tail -n 1)"
|
||||
mkdir -p "$plugin_out"
|
||||
install -m 0644 "$dll_path" "$plugin_out/EdgeWeightGPS.dll"
|
||||
install -m 0644 "$repo_root/presets/momentum/default.bin" "$plugin_out/momentum_weights.bin"
|
||||
install -m 0644 "$repo_root/presets/solver_weights/vanilla.bin" "$plugin_out/solver_weights.bin"
|
||||
install -m 0644 "$dll_path" "$plugin_out/MomentumGPS.dll"
|
||||
|
||||
printf 'Installed %s\n' "$plugin_out/EdgeWeightGPS.dll"
|
||||
printf 'Installed %s\n' "$plugin_out/momentum_weights.bin"
|
||||
printf 'Installed %s\n' "$plugin_out/solver_weights.bin"
|
||||
printf 'Installed %s\n' "$plugin_out/MomentumGPS.dll"
|
||||
|
||||
@@ -3,18 +3,16 @@ set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
timestamp="$(date +%Y%m%d-%H%M%S)"
|
||||
staging="$repo_root/build/package/EdgeWeightGPS-$timestamp"
|
||||
staging="$repo_root/build/package/MomentumGPS-$timestamp"
|
||||
dist_dir="$repo_root/dist"
|
||||
zip_path="$dist_dir/EdgeWeightGPS-red4ext-$timestamp.zip"
|
||||
zip_path="$dist_dir/MomentumGPS-red4ext-$timestamp.zip"
|
||||
|
||||
dll_path="$("$repo_root/tools/build_red4ext_shim.sh" | tail -n 1)"
|
||||
plugin_out="$staging/red4ext/plugins/EdgeWeightGPS"
|
||||
plugin_out="$staging/red4ext/plugins/MomentumGPS"
|
||||
|
||||
mkdir -p "$plugin_out" "$dist_dir"
|
||||
install -m 0644 "$dll_path" "$plugin_out/EdgeWeightGPS.dll"
|
||||
install -m 0644 "$repo_root/presets/momentum/default.bin" "$plugin_out/momentum_weights.bin"
|
||||
install -m 0644 "$repo_root/presets/solver_weights/vanilla.bin" "$plugin_out/solver_weights.bin"
|
||||
install -m 0644 "$repo_root/packaging/EdgeWeightGPS-README.txt" "$plugin_out/README.txt"
|
||||
install -m 0644 "$dll_path" "$plugin_out/MomentumGPS.dll"
|
||||
install -m 0644 "$repo_root/packaging/MomentumGPS-README.txt" "$plugin_out/README.txt"
|
||||
|
||||
(
|
||||
cd "$staging"
|
||||
|
||||
Reference in New Issue
Block a user