Files
moonwell-client-core/crates/benilla-protocol/examples/faction_probe.rs
T
Sam Sung 831e4d3afc The client reads its locale from Wow.ini, as 1.12.1 does (#1360)
benilla read every DBC string from the enUS column and answered enUS everywhere. 1.12.1 reads its locale from `Wow.ini` in the archives (`0x40249d`). It joins `Language` and `Country` into a tag at `0xc2a2a4` (`0x402513`). It looks the tag up in the eight locale names to get the index at `0xc0e080` (`0x402562`); enGB keeps index 0.

- The chain reads `Wow.ini` with the client's ini rules: no trimming, and the first value wins.
- Every localized DBC read takes column `first + index`.
- `GetLocale` and the TOC `Title-xxXX` pick follow the index (`0x48d8b0`, `0x46ce40`).
- The logon challenge (`0x5b2115`) and the name-cache header carry the tag, so this install sends enGB.

Tests:
- A synthetic WDBC per locale.
- 43 loader probes at an empty locale.
- A byte-exact golden for the challenge.
- GetLocale in glue and in game.

Smoke: green.

Fixes #1338

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 01:32:06 +07:00

84 lines
3.3 KiB
Rust

//! Diagnostic probe: prints each streamed unit's `UNIT_FIELD_FACTIONTEMPLATE`, with level and
//! display id, to check the descriptor decode against `creature_template.faction`.
//!
//! Run: `cargo run -p benilla-protocol --example faction_probe -- probeN <password> [host]`. The
//! account has no default, because a login kicks whoever is on the account.
use std::time::{Duration, Instant};
use anyhow::{Context, Result};
use benilla_protocol::{decode, EntityKind, SessionEvent, WorldSession, WORLD_PORT};
fn main() -> Result<()> {
let mut args = std::env::args().skip(1);
let user = args
.next()
.context("usage: faction_probe -- <probeN> <password> [host] (a probe account)")?;
let pass = args
.next()
.context("usage: faction_probe -- <probeN> <password> [host] (a probe account)")?;
let host = args.next().unwrap_or_else(|| "localhost".into());
let logon = benilla_protocol::logon(
&host,
&user,
&pass,
benilla_protocol::auth::LOCALE_TAG_EN_US,
)?;
let world_addr = logon
.realms
.first()
.map(|r| r.address.clone())
.unwrap_or_else(|| format!("{host}:{WORLD_PORT}"));
let mut session = WorldSession::connect(&world_addr, &user, logon.session_key)?;
let characters = session.char_enum()?;
let character = characters.first().context("no characters")?;
let self_guid = character.guid;
println!("logging in '{}' (guid {self_guid})", character.name);
session.player_login(self_guid)?;
session.set_active_mover(self_guid)?;
session.set_read_timeout(Some(Duration::from_secs(2)))?;
let deadline = Instant::now() + Duration::from_secs(8);
while Instant::now() < deadline {
let Ok(msg) = session.recv() else { continue };
for ev in decode(msg) {
match ev {
SessionEvent::ObjectCreate {
guid,
kind,
display_id,
fields,
..
} if matches!(kind, EntityKind::Unit | EntityKind::Player) => {
let me = if guid == self_guid { " (self)" } else { "" };
println!(
"{kind:?} guid={guid}{me} display={display_id:?} level={:?} faction_tpl={:?}",
fields.unit_level(),
fields.unit_faction_template(),
);
}
SessionEvent::ObjectValues { guid, fields } => {
if let Some(f) = fields.unit_faction_template() {
println!("Values guid={guid} faction_tpl={f}");
}
}
SessionEvent::Reputations { standings } => {
let set: Vec<(usize, u8, i32)> = standings
.iter()
.enumerate()
.filter(|(_, &(f, s))| f != 0 || s != 0)
.map(|(i, &(f, s))| (i, f, s))
.collect();
println!(
"Reputations: {} slots, non-zero (idx, flags, standing): {set:?}",
standings.len()
);
}
_ => {}
}
}
}
Ok(())
}