Files
benilla-octo/crates/benilla-ui/src/script/follow.rs
T
gromandClaude Opus 5 81d96af35d Everwood: the HD/OctoWoW line of benilla, imported onto upstream
This checkout had no git history at all, so this one commit carries the whole
of the Everwood work as a single import on top of chairmanpow/benilla-octo's
`main` (706cd71). The two trees have genuinely diverged — each has files the
other does not — so this is a fork point, not a catch-up.

Today's work, which is the reason a baseline exists at all:

- Booth previews no longer cast world shadows (`NO_BOOTH_SHADOW`). Portrait
  characters were entering the sun's shadow cascades, so every skinned-rig
  shadow specialization compiled live mid-frame; the hitch detector logged
  "main thread blocked 1316 ms" beside a `compiled LIVE` warning. This was
  the Fashion/Tmog stutter.
- Per-pane dress-up: each `DressUpModel` pane assembles and stages its own
  tried-on look instead of every pane mirroring the live player.
- Item template cache is append-only JSONL written on the IO pool, replacing
  an 11.6 MB whole-map JSON rewrite on the main thread every 10 s.
- `WOW_SYSTEM_TIMING` rebuilt per-thread: it took 2 mutexes per system enter
  and 4 per exit, costing 15 ms a frame (590 fps -> 60) and corrupting the
  measurements it was taken to produce.
- The visibility-churn sweep moved to its own `WOW_FLASH_CHURN` switch, so a
  frame-cost reading no longer pays 2.7 ms a frame for it.

Local state (`benilla-config/`, `logs/`, `target/`) is excluded by the
existing .gitignore; the account credential it holds is not in this commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SgstFWtn1RxEJ5kVrpgYwn
2026-10-15 15:01:14 -06:00

64 lines
2.4 KiB
Rust

//! `FollowUnit` and `FollowByName`; each call queues a [`FollowRequest`] the app drains.
//! `FollowUnit("target")` is a bare `/follow` and the `FOLLOWTARGET` binding. `FollowByName`
//! (`0x489ec0`) calls the by-name resolver `0x493aa0` for players (`0x10`) who `CanAssist` and are
//! alive, with its second argument as the exact-only flag: `UnitPopup.lua:623` passes 1, so the
//! menu never prefix-matches someone else, while `/follow rag` may. benilla parses `/follow` in
//! Rust, so these globals serve the stock UI and addons.
use mlua::Lua;
use super::Model;
/// A follow intent queued by the globals.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum FollowRequest {
/// `FollowUnit(unit)`: whoever the token names, of any type; the reference applies no
/// typemask here.
ByUnit(String),
/// `FollowByName(name, exactMatch)`: with `exact`, the resolver skips its longest-prefix tier
/// and takes only a whole-name, case-insensitive match.
ByName { name: String, exact: bool },
}
impl super::UiScript {
/// Drain the follow intents queued since the last call.
pub fn take_follow_requests(&mut self) -> Vec<FollowRequest> {
std::mem::take(&mut self.model_mut().follow_requests)
}
}
/// Register the follow globals.
pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
let g = lua.globals();
g.set(
"FollowUnit",
lua.create_function(|lua, unit: String| {
let mut model = lua.app_data_mut::<Model>().expect("model app_data");
model.follow_requests.push(FollowRequest::ByUnit(unit));
Ok(())
})?,
)?;
g.set(
"FollowByName",
lua.create_function(|lua, (name, exact): (String, Option<mlua::Value>)| {
// The reference reads this with `GetBoolOrDefault` (`0x6f1c10`), default false; here
// nil, false and 0 are false and any other value is true.
let exact = match exact {
None | Some(mlua::Value::Nil) | Some(mlua::Value::Boolean(false)) => false,
Some(mlua::Value::Integer(n)) => n != 0,
Some(mlua::Value::Number(n)) => n != 0.0,
Some(_) => true,
};
let mut model = lua.app_data_mut::<Model>().expect("model app_data");
model
.follow_requests
.push(FollowRequest::ByName { name, exact });
Ok(())
})?,
)?;
Ok(())
}