The Craft window reads live and signals at its packets (#2801)
The Craft window answered from a copy a feed refreshed once a frame, and rebuilt and signalled there. **Reference** - The build (`0x4f60c0`) zeroes its counts and, with no craft type open or no player, leaves before CRAFT_UPDATE (`0x4f661a`). The open, SMSG_PET_SPELLS, the record callback, learn and unlearn, and the item watchers rebuild it. - The getters read at the call (`0x4f6c3b`, `0x4f6d52`, `0x4f6fe6`, `0x4f76b2`, `0x4f7a3c`). - GetCraftDescription falls back to the taught spell's text (effect 36 or 57), with the pet flag (`0x4f7b53`). **Changed** - The build and the getters read through the host, and a build with no player empties silently. - The description takes the fallback and the pet flag; the VM fills its templates in the call. - `feed_craft` is gone; the trainer and the window share one token helper. **Tests:** each getter read between two packets, CRAFT_UPDATE between its neighbours, the silent build, the description fallback. Part of #2168 and #2217. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -190,8 +190,8 @@ pub(super) const HOST_HELD_UNREAD: &[&str] = &[
|
||||
// Quiet: the craft and profession windows' open type and line, which an opener's cast
|
||||
// toggles and signals inside its call (`0x4fc910`, `0x4f6000`), the closes zero in theirs, and
|
||||
// the disconnect handlers (`ui_craft::on_session_end`, `ui_tradeskill::on_session_end`) clear
|
||||
// without a signal; the profession builds read the line through the host at their places,
|
||||
// and the craft feed pushes its list off the type, silently.
|
||||
// without a signal; the profession and craft builds and getters read the line and the type
|
||||
// through the host at their places.
|
||||
"::ui_craft::CraftOpen",
|
||||
"::ui_tradeskill::TradeSkillOpen",
|
||||
// Quiet: the profession openers a cast intercepted (`0x6e4bd7`), which the call host toggles
|
||||
@@ -379,12 +379,6 @@ pub(super) const READS_FRAME_FINAL: &[(&str, &[&str])] = &[
|
||||
("::ui_items::locks::forget_gone_item_locks", &["net::GuidIndex"]),
|
||||
("::ui_items::feed::feed_item_stats", &["items::Items", "net::HomeBind", "net::ObjectStore",
|
||||
"spell::mods::SpellModifiers"]),
|
||||
// Beast Training reads the pet off its bar and its family off the creature record as the frame
|
||||
// left them (#2217).
|
||||
("::ui_craft::feed_craft", &["items::Countdowns", "items::Items", "names::NameCache",
|
||||
"net::GuidIndex", "net::ObjectStore", "spell::mods::SpellModifiers",
|
||||
"ui_action::PlayerActions", "ui_craft::CraftOpen",
|
||||
"ui_pet::PetBar"]),
|
||||
// The resolution list's `widescreen` filter (`0x48bcac`), which a listener's `SetCVar` moves
|
||||
// inside its call; the reference builds the list at the first resolution verb (`0x48bc90`).
|
||||
("::video::publish_display_modes", &["video::Widescreen"]),
|
||||
|
||||
@@ -43,8 +43,8 @@ use crate::game_plugins::schedule_tests::{census, type_names_available, SyncPoin
|
||||
|
||||
/// The most rows [`super::guard_tests::READS_FRAME_FINAL`] may hold, and the most inputs across
|
||||
/// them: each only falls, so lower it when a row or an input goes.
|
||||
const FRAME_FINAL_FEEDS: usize = 13;
|
||||
const FRAME_FINAL_INPUTS: usize = 83;
|
||||
const FRAME_FINAL_FEEDS: usize = 12;
|
||||
const FRAME_FINAL_INPUTS: usize = 74;
|
||||
|
||||
/// The systems that may run after the dispatch (`apply_net_updates`) and run ahead of the drain
|
||||
/// (`fire_in_order`), by a suffix of the system's name, with what each writes of the state a
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
//! chunk that opens and closes leaves the window shut. The book's builds and getters read the
|
||||
//! player, the bags and the item cache as they stand at their call (`0x4fca20`, `0x4fdd40`,
|
||||
//! `0x4ff7a2`), and the item answers run the lists' callbacks inside their handler
|
||||
//! (`ItemCacheReceive` `0x55bdb0`: `0x4fdc30`, `0x4fc8e0`).
|
||||
//! (`ItemCacheReceive` `0x55bdb0`: `0x4fdc30`, `0x4fc8e0`, `0x4f7710`). The craft window's do the
|
||||
//! same (`0x4f60c0`, `0x4f6c10`, `0x4f6cb0`, `0x4f6fe6`, `0x4f74d0`, `0x4f78b0`, `0x4f7a90`).
|
||||
|
||||
use benilla_formats::{
|
||||
SlaInfo, SpellDisplay, SPELL_ATTR_IS_TRADESKILL, SPELL_EFFECT_CREATE_ITEM,
|
||||
@@ -15,10 +16,11 @@ use benilla_formats::{
|
||||
use benilla_ui::script::UiScript;
|
||||
use bevy::prelude::*;
|
||||
|
||||
use benilla_protocol::messages::FIELD_PLAYER_SKILL_INFO_1_1;
|
||||
use benilla_protocol::SessionEvent;
|
||||
use benilla_protocol::field::{FIELD_ITEM_STACK_COUNT, FIELD_PLAYER_INV_SLOT_HEAD};
|
||||
use benilla_protocol::messages::{ObjectType, FIELD_PLAYER_SKILL_INFO_1_1};
|
||||
use benilla_protocol::{EntityKind, ObjectFields, SessionEvent};
|
||||
|
||||
use super::unit_view_tests::{client, fall, frame, values};
|
||||
use super::unit_view_tests::{client, created, fall, frame, values, wire_packets};
|
||||
use crate::ui_craft::CraftOpen;
|
||||
use crate::ui_tradeskill::{TradeSkillOpen, TradeSkillOpens};
|
||||
|
||||
@@ -37,6 +39,19 @@ const LINEN: u32 = 2589;
|
||||
const ME: u64 = 0x7;
|
||||
const ENCHANT: u32 = 7411;
|
||||
const MINOR_HEALTH: u32 = 7420;
|
||||
/// Strange Dust, the enchant's reagent, not cached, and a Runed Copper Rod, its totem, cached.
|
||||
const DUST: u32 = 10_940;
|
||||
const ROD: u32 = 6_218;
|
||||
/// Made-up labels: a Beast Training opener, its one row, the pet spell that row teaches, the pet
|
||||
/// line that holds it, and a wolf for the pet bar.
|
||||
const BEASTS: u32 = 90_001;
|
||||
const BEAST_ROW: u32 = 90_002;
|
||||
const PET_SPELL: u32 = 90_003;
|
||||
const BEAST_TRAINING: u32 = 261;
|
||||
const PET_LINE: u32 = 208;
|
||||
const WOLF_FAMILY: u32 = 1;
|
||||
const WOLF_ENTRY: u32 = 299;
|
||||
const PET: u64 = 0xF140_0000_0000_0042;
|
||||
|
||||
/// [`client`] knowing the Tailoring and Enchanting openers and one recipe of each, Bolt of Linen
|
||||
/// Cloth's product cached, and the windows' events added to its spy.
|
||||
@@ -63,9 +78,28 @@ fn crafter() -> App {
|
||||
attributes: SPELL_ATTR_IS_TRADESKILL,
|
||||
..Default::default()
|
||||
};
|
||||
let mut dust = [(0, 0); 8];
|
||||
dust[0] = (DUST, 1);
|
||||
let health = SpellDisplay {
|
||||
name: "Enchant Chest - Minor Health".into(),
|
||||
cast_ui: 3,
|
||||
reagents: dust,
|
||||
totems: [ROD, 0],
|
||||
description: Some("Returns you to $z.".into()),
|
||||
..Default::default()
|
||||
};
|
||||
// A Beast Training row: `LEARN_SPELL` aimed at the pet (`+0x148` 5).
|
||||
let beast_row = SpellDisplay {
|
||||
name: "Growl".into(),
|
||||
cast_ui: 1,
|
||||
effects: [benilla_formats::SPELL_EFFECT_LEARN_SPELL, 0, 0],
|
||||
effect_implicit_target_a: [5, 0, 0],
|
||||
effect_trigger_spell: [PET_SPELL, 0, 0],
|
||||
..Default::default()
|
||||
};
|
||||
let pet_spell = SpellDisplay {
|
||||
name: "Growl".into(),
|
||||
spell_level: 4,
|
||||
..Default::default()
|
||||
};
|
||||
let sla = |line| SlaInfo {
|
||||
@@ -84,6 +118,9 @@ fn crafter() -> App {
|
||||
(BANDAGE, bandage),
|
||||
(ENCHANT, opener("Enchanting", 3)),
|
||||
(MINOR_HEALTH, health),
|
||||
(BEASTS, opener("Beast Training", 1)),
|
||||
(BEAST_ROW, beast_row),
|
||||
(PET_SPELL, pet_spell),
|
||||
]
|
||||
.into(),
|
||||
),
|
||||
@@ -96,19 +133,33 @@ fn crafter() -> App {
|
||||
(BANDAGE, sla(TAILORING)),
|
||||
(ENCHANT, sla(ENCHANTING)),
|
||||
(MINOR_HEALTH, sla(ENCHANTING)),
|
||||
(BEASTS, sla(BEAST_TRAINING)),
|
||||
(BEAST_ROW, sla(BEAST_TRAINING)),
|
||||
])
|
||||
.with_line_names([(TAILORING, "Tailoring"), (ENCHANTING, "Enchanting")]),
|
||||
.with_line_names([(TAILORING, "Tailoring"), (ENCHANTING, "Enchanting")])
|
||||
.with_line_abilities([(
|
||||
PET_LINE,
|
||||
PET_SPELL,
|
||||
benilla_formats::LineAbility {
|
||||
superseded_by: 0,
|
||||
train_points: 5,
|
||||
},
|
||||
)]),
|
||||
});
|
||||
{
|
||||
let mut actions = world.resource_mut::<crate::ui_action::PlayerActions>();
|
||||
actions.spells.extend([TAILOR, BOLT, ENCHANT, MINOR_HEALTH]);
|
||||
actions
|
||||
.spells
|
||||
.extend([TAILOR, BOLT, ENCHANT, MINOR_HEALTH, BEASTS, BEAST_ROW]);
|
||||
actions.profession_order.push(BOLT);
|
||||
actions.craft_order.push(MINOR_HEALTH);
|
||||
actions.craft_order.extend([MINOR_HEALTH, BEAST_ROW]);
|
||||
}
|
||||
world.resource_mut::<crate::items::Items>().insert_template(
|
||||
let mut items = world.resource_mut::<crate::items::Items>();
|
||||
items.insert_template(
|
||||
2996,
|
||||
Some(crate::items::test_template("Bolt of Linen Cloth")),
|
||||
);
|
||||
items.insert_template(ROD, Some(crate::items::test_template("Runed Copper Rod")));
|
||||
world
|
||||
.non_send_resource::<UiScript>()
|
||||
.run(
|
||||
@@ -386,3 +437,304 @@ fn a_products_record_answer_rebuilds_the_book_after_a_reload() {
|
||||
.unwrap();
|
||||
assert!(rows > 0, "{rows}");
|
||||
}
|
||||
|
||||
/// A fall's listener that records `expr`'s answer at its call as `tag:answer`.
|
||||
fn listen(app: &mut App, tag: &str, expr: &str) {
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.run(&format!(
|
||||
r#"
|
||||
local f = CreateFrame("Frame")
|
||||
f:RegisterEvent("UNIT_COMBAT")
|
||||
f:SetScript("OnEvent", function()
|
||||
table.insert(Seen, "{tag}:" .. tostring({expr}))
|
||||
end)
|
||||
"#
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// What `seen` recorded under `tag`.
|
||||
fn tagged<'a>(seen: &'a [String], tag: &str) -> Vec<&'a str> {
|
||||
seen.iter()
|
||||
.map(String::as_str)
|
||||
.filter(|e| e.strip_prefix(tag).is_some_and(|r| r.starts_with(':')))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The player's first skill slot holding Enchanting at `value` of 75.
|
||||
fn enchanting(value: u32) -> SessionEvent {
|
||||
values(
|
||||
ME,
|
||||
&[
|
||||
(FIELD_PLAYER_SKILL_INFO_1_1, ENCHANTING),
|
||||
(FIELD_PLAYER_SKILL_INFO_1_1 + 1, (75 << 16) | value),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
/// `expr`'s answer as a string, read with the host lent.
|
||||
fn read(app: &mut App, expr: &str) -> String {
|
||||
crate::script_calls::with_hosted_vm(app.world_mut(), |s| {
|
||||
s.expect("a VM")
|
||||
.eval::<String>(&format!("return tostring({expr})"))
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// `packets` through their handlers, each one packet, with no frame: the world as they leave it.
|
||||
fn handle(app: &mut App, packets: Vec<Vec<SessionEvent>>) {
|
||||
crate::net::handlers::dispatch(app.world_mut(), wire_packets(packets));
|
||||
}
|
||||
|
||||
/// `GetCraftName` reads the player's effect slot of the open type at its call (`0x4f6c3b` →
|
||||
/// `0x5ea360`): a learn of the Enchanting opener writes slot 3 inside its handler (`0x5e9e1c`-
|
||||
/// `0x5e9e36`), and the next call reads its name, with no frame between to push it.
|
||||
#[test]
|
||||
fn the_craft_name_reads_the_effect_slot_at_its_call() {
|
||||
let mut app = crafter();
|
||||
quietly(&mut app, r#"CastSpellByName("Enchanting")"#);
|
||||
assert_eq!(read(&mut app, "GetCraftName()"), "nil");
|
||||
handle(
|
||||
&mut app,
|
||||
vec![vec![SessionEvent::SpellLearned { spell_id: ENCHANT }]],
|
||||
);
|
||||
assert_eq!(read(&mut app, "GetCraftName()"), "Enchanting");
|
||||
}
|
||||
|
||||
/// `GetCraftDisplaySkillLine` finds its slot and reads its words at the call (`0x4f6d52`,
|
||||
/// `0x4f6d99`, `0x4f6e08`): between a packet that raises Enchanting to 5 and one that raises it to
|
||||
/// 6, it reads 5, where the open's build held none.
|
||||
#[test]
|
||||
fn the_display_line_reads_the_rank_its_packet_left() {
|
||||
let mut app = crafter();
|
||||
quietly(&mut app, r#"CastSpellByName("Enchanting")"#);
|
||||
listen(
|
||||
&mut app,
|
||||
"rank",
|
||||
"(function() local n, r, m = GetCraftDisplaySkillLine() return n .. r .. '/' .. m end)()",
|
||||
);
|
||||
let seen = frame(&mut app, vec![enchanting(5), fall(5), enchanting(6)]);
|
||||
assert_eq!(tagged(&seen, "rank"), ["rank:Enchanting5/75"], "{seen:?}");
|
||||
}
|
||||
|
||||
/// An item of `entry` at `guid`, `stack` of it, ours.
|
||||
fn item(guid: u64, entry: u32, stack: u32) -> SessionEvent {
|
||||
SessionEvent::ItemCreate {
|
||||
guid,
|
||||
container: false,
|
||||
fields: ObjectFields::from_pairs(&[
|
||||
(2, 0x3),
|
||||
(3, entry),
|
||||
(6, ME as u32),
|
||||
(8, ME as u32),
|
||||
(FIELD_ITEM_STACK_COUNT, stack),
|
||||
])
|
||||
.into_created(ObjectType::Item),
|
||||
}
|
||||
}
|
||||
|
||||
/// `GetCraftReagentInfo` counts the reagent in the bags at its call (`0x4f76b2` → `0x622130`) and
|
||||
/// `GetCraftSpellFocus` asks whether they hold the totem at its call (`0x4f7a3c` → `0x622270`):
|
||||
/// a fall ahead of the packets that bring both reads none, one behind them both, where the open's
|
||||
/// build counted none.
|
||||
#[test]
|
||||
fn the_craft_counts_read_the_bags_their_packet_left() {
|
||||
const DUST_ITEM: u64 = 0x4000_0000_0000_0001;
|
||||
const ROD_ITEM: u64 = 0x4000_0000_0000_0002;
|
||||
let mut app = crafter();
|
||||
quietly(&mut app, r#"CastSpellByName("Enchanting")"#);
|
||||
listen(
|
||||
&mut app,
|
||||
"count",
|
||||
"(function() local _, _, _, have = GetCraftReagentInfo(1, 1) \
|
||||
local _, tool = GetCraftSpellFocus(1) return have .. '/' .. tostring(tool) end)()",
|
||||
);
|
||||
// The first two backpack slots (`PLAYER_FIELD_PACK_SLOT_1`, inventory slots 23 and 24).
|
||||
let seat = |slot: u16, guid: u64| {
|
||||
let field = FIELD_PLAYER_INV_SLOT_HEAD + 2 * slot;
|
||||
[(field, guid as u32), (field + 1, (guid >> 32) as u32)]
|
||||
};
|
||||
let seen = frame(
|
||||
&mut app,
|
||||
vec![
|
||||
fall(5),
|
||||
item(DUST_ITEM, DUST, 2),
|
||||
item(ROD_ITEM, ROD, 1),
|
||||
values(ME, &[seat(23, DUST_ITEM), seat(24, ROD_ITEM)].concat()),
|
||||
fall(6),
|
||||
],
|
||||
);
|
||||
assert_eq!(
|
||||
tagged(&seen, "count"),
|
||||
["count:0/nil", "count:2/1"],
|
||||
"{seen:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// `GetCraftInfo`'s cost and level read the pet bar's unit at the call (`0xb714a0` at `0x4f6fe6`,
|
||||
/// `0x468460` at `0x4f7010`): before the packet that brings the wolf, 0 and 0; after its handler,
|
||||
/// with no frame or rebuild between, its line's training points (`+0x38`, `0x4f704b`) and the
|
||||
/// taught spell's level (`0x60c840`).
|
||||
#[test]
|
||||
fn the_craft_cost_reads_the_pet_at_its_call() {
|
||||
let mut app = crafter();
|
||||
{
|
||||
let world = app.world_mut();
|
||||
world.insert_resource(crate::ui_pet_stats::PetFamilyTables {
|
||||
families: benilla_formats::CreatureFamilies::from_skill_lines([(
|
||||
WOLF_FAMILY,
|
||||
[PET_LINE, 0],
|
||||
)]),
|
||||
foods: Default::default(),
|
||||
});
|
||||
world
|
||||
.resource_mut::<crate::names::NameCache>()
|
||||
.insert_creature(
|
||||
WOLF_ENTRY,
|
||||
Some(crate::names::CreatureRecord {
|
||||
name: "Wolf".into(),
|
||||
subname: None,
|
||||
creature_type: 1,
|
||||
pet_family: WOLF_FAMILY,
|
||||
rank: 0,
|
||||
type_flags: 0,
|
||||
pet_spell_list: 0,
|
||||
civilian: false,
|
||||
racial_leader: false,
|
||||
display_id: 0,
|
||||
}),
|
||||
);
|
||||
world
|
||||
.resource_mut::<crate::ui_pet::PetBar>()
|
||||
.spells
|
||||
.pet_guid = PET;
|
||||
}
|
||||
quietly(&mut app, r#"CastSpellByName("Beast Training")"#);
|
||||
let cost =
|
||||
"(function() local _, _, _, _, _, tp, l = GetCraftInfo(1) return tp .. '/' .. l end)()";
|
||||
assert_eq!(read(&mut app, cost), "0/0");
|
||||
handle(
|
||||
&mut app,
|
||||
vec![vec![created(PET, EntityKind::Unit, &[(3, WOLF_ENTRY)])]],
|
||||
);
|
||||
assert_eq!(read(&mut app, cost), "5/4");
|
||||
}
|
||||
|
||||
/// `GetCraftDescription` expands the row's text at its call (`0x4f7b53` → `0x5075f0`), whose `$z`
|
||||
/// reads the bind point there (`0x5ed420` at `0x507f07`) and the `HOME_INN` template from the VM's
|
||||
/// strings without one (`0x507f3a`): the inn before the bind point's packet, the area after its
|
||||
/// handler, with no frame between; a rewrite of the template reaches the next call.
|
||||
#[test]
|
||||
fn the_craft_description_reads_the_bind_point_at_its_call() {
|
||||
let mut app = crafter();
|
||||
app.insert_resource(crate::ui_quest_log::QuestHeaderNamesRes(
|
||||
benilla_formats::QuestHeaderNames::from_zones([(12, "Elwynn Forest")]),
|
||||
));
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.run("HOME_INN = 'your inn'")
|
||||
.unwrap();
|
||||
quietly(&mut app, r#"CastSpellByName("Enchanting")"#);
|
||||
let desc = "GetCraftDescription(1)";
|
||||
assert_eq!(read(&mut app, desc), "Returns you to your inn.");
|
||||
quietly(&mut app, "HOME_INN = 'the inn'");
|
||||
assert_eq!(read(&mut app, desc), "Returns you to the inn.");
|
||||
handle(&mut app, vec![vec![SessionEvent::BindPoint { area: 12 }]]);
|
||||
assert_eq!(read(&mut app, desc), "Returns you to Elwynn Forest.");
|
||||
}
|
||||
|
||||
/// `SMSG_PET_SPELLS` rebuilds the open craft list inside its handler (`0x4bdafa` → `0x4f60c0`),
|
||||
/// whose build bands each row on the skill as it stands there (`0x4f620e` → `0x5ea520`,
|
||||
/// `0x4f6215`-`0x4f6267`) and signals `CRAFT_UPDATE` at its tail (`0x4f661a`): between the falls
|
||||
/// around it, its listener reads the band the rank before it gives, not the open's.
|
||||
#[test]
|
||||
fn a_pet_book_rebuilds_the_craft_list_at_its_packet() {
|
||||
let mut app = crafter();
|
||||
quietly(&mut app, r#"CastSpellByName("Enchanting")"#);
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.run(
|
||||
r#"
|
||||
local f = CreateFrame("Frame")
|
||||
f:RegisterEvent("CRAFT_UPDATE")
|
||||
f:SetScript("OnEvent", function()
|
||||
local _, _, kind = GetCraftInfo(1)
|
||||
table.insert(Seen, "kind:" .. kind)
|
||||
end)
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
let seen = frame(
|
||||
&mut app,
|
||||
vec![
|
||||
fall(5),
|
||||
enchanting(5),
|
||||
SessionEvent::PetSpells(Box::default()),
|
||||
fall(6),
|
||||
],
|
||||
);
|
||||
let craft: Vec<&String> = seen
|
||||
.iter()
|
||||
.filter(|e| *e == FELL || e.starts_with("CRAFT") || e.starts_with("kind:"))
|
||||
.collect();
|
||||
assert_eq!(
|
||||
craft,
|
||||
[FELL, "CRAFT_UPDATE", "kind:trivial", FELL],
|
||||
"{seen:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// A craft build that finds no player (the lookup `0x468460` at `0x4f60ff`) has zeroed the counts
|
||||
/// first (`0x4f60d1`-`0x4f60dd`) and leaves past its signal (`0x4f6109` → `0x4f661f`): a reagent's
|
||||
/// answer while our player is gone runs the callback `0x4f7710` (`0x4f771a`), which empties the
|
||||
/// list and signals nothing.
|
||||
#[test]
|
||||
fn a_craft_build_with_no_player_empties_the_list_silently() {
|
||||
let mut app = crafter();
|
||||
quietly(&mut app, r#"CastSpellByName("Enchanting")"#);
|
||||
quietly(&mut app, "GetCraftReagentInfo(1, 1)");
|
||||
let me = app.world().resource::<crate::net::GuidIndex>().0[&ME];
|
||||
app.world_mut()
|
||||
.entity_mut(me)
|
||||
.remove::<crate::net::SelfPlayer>();
|
||||
let answer = SessionEvent::ItemTemplate {
|
||||
entry: DUST,
|
||||
info: Some(Box::new(crate::items::test_template("Strange Dust"))),
|
||||
};
|
||||
let seen = frame(&mut app, vec![fall(5), answer, fall(6)]);
|
||||
assert!(!seen.iter().any(|e| e == "CRAFT_UPDATE"), "{seen:?}");
|
||||
let script = app.world().non_send_resource::<UiScript>();
|
||||
assert_eq!(script.eval::<i64>("return GetNumCrafts()").unwrap(), 0);
|
||||
assert_eq!(
|
||||
script
|
||||
.eval::<Option<String>>("return (GetCraftInfo(1))")
|
||||
.unwrap(),
|
||||
None,
|
||||
"the rows are gone"
|
||||
);
|
||||
}
|
||||
|
||||
/// With our player in place, the same answer's callback rebuilds the list at its packet and
|
||||
/// signals `CRAFT_UPDATE` between the falls around it (`0x4f771a` → `0x4f661a`), and the getter
|
||||
/// then reads the record.
|
||||
#[test]
|
||||
fn a_craft_reagents_record_answer_signals_the_update_at_its_packet() {
|
||||
let mut app = crafter();
|
||||
quietly(&mut app, r#"CastSpellByName("Enchanting")"#);
|
||||
quietly(&mut app, "GetCraftReagentInfo(1, 1)");
|
||||
let answer = SessionEvent::ItemTemplate {
|
||||
entry: DUST,
|
||||
info: Some(Box::new(crate::items::test_template("Strange Dust"))),
|
||||
};
|
||||
assert_eq!(
|
||||
frame(&mut app, vec![fall(5), answer, fall(6)]),
|
||||
[FELL, "CRAFT_UPDATE", FELL]
|
||||
);
|
||||
let name = crate::script_calls::with_hosted_vm(app.world_mut(), |s| {
|
||||
s.expect("a VM")
|
||||
.eval::<String>("return (GetCraftReagentInfo(1, 1))")
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(name, "Strange Dust");
|
||||
}
|
||||
|
||||
@@ -122,6 +122,10 @@ live_reads! {
|
||||
/// The open profession book as a build reads it, a recipe's reagents, tools and icon, and
|
||||
/// its line's rank; absent in a harness without the window.
|
||||
trade_skill: Option<crate::ui_tradeskill::TradeSkillLive<'static, 'static>>,
|
||||
/// The open craft type's book as a build reads it, a recipe's reagents, tools, cost, level
|
||||
/// and description, the effect slot's name and the display line; absent in a harness
|
||||
/// without the window.
|
||||
craft: Option<crate::ui_craft::CraftLive<'static, 'static>>,
|
||||
/// The tabard designer's guild record and save latch.
|
||||
tabard: crate::ui_tabard::TabardLive<'static, 'static>,
|
||||
/// The stable's records, counts and the summoned pet's display.
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::net::Objects;
|
||||
|
||||
/// A unit as `0x468460` finds it by guid with type mask 8: its guid, and its creature family's two
|
||||
/// skill lines when its creature record names a family row.
|
||||
pub(crate) struct PetUnit {
|
||||
@@ -83,7 +81,11 @@ impl<'a> PetView<'a> {
|
||||
}
|
||||
|
||||
/// The unit behind `guid`, when it is a streamed unit.
|
||||
pub(crate) fn unit(&self, objects: &Objects, guid: u64) -> Option<PetUnit> {
|
||||
pub(crate) fn unit(
|
||||
&self,
|
||||
objects: &(impl crate::ui_items::ItemObjects + ?Sized),
|
||||
guid: u64,
|
||||
) -> Option<PetUnit> {
|
||||
let fields = objects.object(guid).filter(|_| guid != 0)?;
|
||||
if !matches!(
|
||||
fields.object_type(),
|
||||
|
||||
@@ -259,6 +259,71 @@ pub(crate) fn pet_skill_value(pet: Option<&benilla_protocol::ObjectFields>) -> u
|
||||
.saturating_mul(5)
|
||||
}
|
||||
|
||||
/// The `$`-token contexts of the player and of its pet, which the expander's pet flag picks
|
||||
/// between ([`with_token_contexts`]).
|
||||
pub(crate) type TokenContexts<'c, 'a> = (
|
||||
&'c benilla_formats::TokenContext<'a>,
|
||||
&'c benilla_formats::TokenContext<'a>,
|
||||
);
|
||||
|
||||
/// `f` over the `$`-token contexts a description expands over (`0x5075f0`, as the spell tooltip's
|
||||
/// call `0x52f717` makes it): the player `me`'s and its pet `pet`'s, the two casters the
|
||||
/// expander's pet flag picks between for its level and its `$c` and `$p` terms (`0x6e3130`,
|
||||
/// `0x6e31b0`, `0x6e3300`), with `home_area` the bind point's area `$z` names. No template is
|
||||
/// read here: each is left to the reader of the VM's strings.
|
||||
pub(crate) fn with_token_contexts<R>(
|
||||
spells: &crate::ui_action::Spells,
|
||||
skills: PlayerSkills<'_>,
|
||||
mods: &SpellModifiers,
|
||||
(me, pet): (
|
||||
Option<&crate::net::ObjectStore>,
|
||||
Option<&crate::net::ObjectStore>,
|
||||
),
|
||||
home_area: Option<&str>,
|
||||
f: impl FnOnce(TokenContexts<'_, '_>) -> R,
|
||||
) -> R {
|
||||
let gender = me.and_then(|s| s.0.unit_gender()).unwrap_or(0);
|
||||
let player_level = |d: &benilla_formats::SpellDisplay| player_spell_level(me, skills, d);
|
||||
let pet_skill_level =
|
||||
|d: &benilla_formats::SpellDisplay| d.skill_level(pet_skill_value(pet.map(|p| &p.0)));
|
||||
// `$c` and `$p` (`0x6e31b0`, `0x6e3300`) at the same caster's level and fields.
|
||||
let player_cost = |d: &benilla_formats::SpellDisplay| {
|
||||
me.map_or(-1, |s| usable::power_cost(d, s, skills, mods))
|
||||
};
|
||||
let player_per_second = |d: &benilla_formats::SpellDisplay| {
|
||||
usable::per_second_cost(d, SpellLevel::Player { me, skills })
|
||||
};
|
||||
let pet_level = |d: &benilla_formats::SpellDisplay| SpellLevel::Known(pet_skill_level(d));
|
||||
let pet_cost = |d: &benilla_formats::SpellDisplay| {
|
||||
pet.map_or(-1, |p| usable::power_cost_at(d, &p.0, pet_level(d), mods))
|
||||
};
|
||||
let pet_per_second =
|
||||
|d: &benilla_formats::SpellDisplay| usable::per_second_cost(d, pet_level(d));
|
||||
let player_ctx = benilla_formats::TokenContext {
|
||||
durations: &spells.durations,
|
||||
radii: &spells.radii,
|
||||
ranges: Some(&spells.ranges),
|
||||
level: &player_level,
|
||||
lookup: &|id| spells.catalog.get(id),
|
||||
mods: Some(mods),
|
||||
power_cost: &player_cost,
|
||||
power_per_second: &player_per_second,
|
||||
unmodified_points: false,
|
||||
gender: &|| gender,
|
||||
home_area: &|| home_area,
|
||||
// Never read: the parts leave each template to the reader of the VM's strings.
|
||||
global: &|_| None,
|
||||
printf: &crate::ui_script::token_printf,
|
||||
};
|
||||
let pet_ctx = benilla_formats::TokenContext {
|
||||
level: &pet_skill_level,
|
||||
power_cost: &pet_cost,
|
||||
power_per_second: &pet_per_second,
|
||||
..player_ctx
|
||||
};
|
||||
f((&player_ctx, &pet_ctx))
|
||||
}
|
||||
|
||||
/// The player's skill in `line`, [`spell_skill_value`]'s second half: 0 without a player or a
|
||||
/// slot for it.
|
||||
pub(crate) fn skill_line_value(me: Option<&crate::net::ObjectStore>, line: u32) -> u32 {
|
||||
|
||||
+394
-280
@@ -1,29 +1,32 @@
|
||||
//! The Craft window feed: the client-built book of a craft type (Enchanting, Beast Training),
|
||||
//! opened by its opener spell with no packet. Reagents and tools come off `Spell.dbc`, and the
|
||||
//! description's `$` tokens resolve as a tooltip's do. An enchant is an item-targeted cast
|
||||
//! (`Targets = 0x10`) whose pick is the ordinary targeting cursor ([`crate::spell::targeting`]).
|
||||
//! The Craft window: the client-built book of a craft type (Enchanting, Beast Training), opened by
|
||||
//! its opener spell with no packet, whose builds and getters read it here as it stands
|
||||
//! ([`CraftLive`]). Reagents and tools come off `Spell.dbc`, and the description's `$` tokens
|
||||
//! resolve as a tooltip's do. An enchant is an item-targeted cast (`Targets = 0x10`) whose pick is
|
||||
//! the ordinary targeting cursor ([`crate::spell::targeting`]).
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
use benilla_formats::{
|
||||
SPELL_ATTR_IS_TRADESKILL, SPELL_EFFECT_CREATE_ITEM, SPELL_EFFECT_ENCHANT_ITEM,
|
||||
SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY, SPELL_EFFECT_LEARN_PET_SPELL, SPELL_EFFECT_LEARN_SPELL,
|
||||
substitute_parts, ExpandAt, SPELL_ATTR_IS_TRADESKILL, SPELL_EFFECT_CREATE_ITEM,
|
||||
SPELL_EFFECT_ENCHANT_ITEM, SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY, SPELL_EFFECT_LEARN_PET_SPELL,
|
||||
SPELL_EFFECT_LEARN_SPELL,
|
||||
};
|
||||
use benilla_protocol::messages::PLAYER_SKILL_SLOTS;
|
||||
use benilla_protocol::{SessionEvent, SessionEventKind};
|
||||
use benilla_ui::script::{CraftDifficulty, CraftReagent, CraftRecipe, CraftState, CraftTooltip};
|
||||
use benilla_ui::script::{
|
||||
CraftDifficulty, CraftReagent, CraftRecipe, CraftState, CraftTooltip, TooltipText,
|
||||
};
|
||||
|
||||
use crate::entities::ItemDisplays;
|
||||
use crate::items::Items;
|
||||
use crate::net::{NetCommands, NetHandlerApp, ObjectStore, Objects, SelfPlayer};
|
||||
use crate::net::{NetCommands, NetHandlerApp, ObjectStore, Objects};
|
||||
use crate::query_cache::Ask;
|
||||
use crate::spell::known::{PetReads, PetView};
|
||||
use crate::spell::CastCommit;
|
||||
use crate::ui_action::{PlayerActions, Spells};
|
||||
use crate::ui_items::{count_of, item_icon, InventoryScope};
|
||||
use crate::ui_items::{count_of, item_icon, InventoryScope, ItemObjects};
|
||||
use crate::ui_spellbook::SkillLines;
|
||||
use crate::ui_tradeskill::SpellFocus;
|
||||
use crate::ui_unit::UnitFeed;
|
||||
|
||||
/// The open Craft window, client-local. A nonzero opener `EffectMiscValue[0]` routes here
|
||||
/// (`Spell_C::TryCast` `0x6e4b60`) and is the craft type (1 Beast Training, 3 Enchanting) the
|
||||
@@ -54,8 +57,7 @@ pub(crate) struct UiCraftPlugin;
|
||||
impl Plugin for UiCraftPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.net_handler(SessionEventKind::Disconnected, on_session_end);
|
||||
app.init_resource::<CraftOpen>()
|
||||
.add_systems(Update, feed_craft.in_set(UnitFeed));
|
||||
app.init_resource::<CraftOpen>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +91,7 @@ fn skill_total(store: &ObjectStore, skill_id: u32) -> i32 {
|
||||
fn cost_and_level(
|
||||
pet: &PetView,
|
||||
d: &benilla_formats::SpellDisplay,
|
||||
objects: &Objects,
|
||||
objects: &impl ItemObjects,
|
||||
) -> (u32, i32) {
|
||||
let Some(unit) = pet.unit(objects, pet.bar_guid) else {
|
||||
return (0, 0);
|
||||
@@ -128,7 +130,7 @@ fn craft_bucket(
|
||||
store: &ObjectStore,
|
||||
known: &std::collections::BTreeSet<u32>,
|
||||
pet: Option<&PetView>,
|
||||
objects: &Objects,
|
||||
objects: &impl ItemObjects,
|
||||
) -> CraftDifficulty {
|
||||
if let Some(sla) = sla.filter(|a| a.trivial_high != 0) {
|
||||
let high = sla.trivial_high as i32;
|
||||
@@ -183,10 +185,10 @@ fn skill_slot(
|
||||
/// the line of the first spell of the player's type-3 list (`0x4f6d0c`) by its ability row
|
||||
/// (`0x4f6d14`, `+0x04`, 0 failing at `0x4f6d26`), named by `SkillLine.dbc` (`0x4f6d61`), with the
|
||||
/// slot's rank and maximum, each plus the permanent bonus word when above 0 (`0x4f6d9d`,
|
||||
/// `0x4f6e10`). The known spells are a set here, so the first is the lowest id. A player with no
|
||||
/// slot for the line gives the slot -1, which the reads do not test (`0x4f6d52`): the words 12
|
||||
/// bytes below the first slot, `PLAYER_XP` for the rank and maximum and `PLAYER_NEXT_LEVEL_XP`'s
|
||||
/// high word for the bonus.
|
||||
/// `0x4f6e10`). The list is in learn order (`0x5e9e0f`), so the first is the first learned. A
|
||||
/// player with no slot for the line gives the slot -1, which the reads do not test (`0x4f6d52`):
|
||||
/// the words 12 bytes below the first slot, `PLAYER_XP` for the rank and maximum and
|
||||
/// `PLAYER_NEXT_LEVEL_XP`'s high word for the bonus.
|
||||
fn display_line(
|
||||
first: Option<u32>,
|
||||
skill_lines: &SkillLines,
|
||||
@@ -237,8 +239,47 @@ fn craft_tooltip(spell_id: u32, d: &benilla_formats::SpellDisplay) -> CraftToolt
|
||||
CraftTooltip::Spell(spell_id)
|
||||
}
|
||||
|
||||
/// What the craft list's build reads (`0x4f60c0`): the player's known spells, the catalogs, the
|
||||
/// player object, the bags, the item cache and the pet.
|
||||
/// `GetCraftDescription`'s text (`0x4f7a90`) for a row of `open_type`: the spell's own
|
||||
/// description when it is not empty (`0x4f7b21`-`0x4f7b2f`), expanded with the pet flag set for
|
||||
/// craft type 1 (`0x4f7b3d`, `0x4f7b53`); else the description of the spell the first
|
||||
/// `LEARN_SPELL` or `LEARN_PET_SPELL` effect teaches, when it has a record (`0x4f7b71`-
|
||||
/// `0x4f7ba3`), expanded with the pet flag set for 57 (`0x4f7bce`, `0x4f7be6`); else `None`, the
|
||||
/// nil (`0x4f7bae`). Each template a token names is left to the getter's read of the VM's
|
||||
/// strings; the expansion is the spell tooltip's (level 0, stack 1, `ExpandAt::default`).
|
||||
fn craft_description(
|
||||
d: &benilla_formats::SpellDisplay,
|
||||
spells: &benilla_formats::SpellCatalog,
|
||||
open_type: u32,
|
||||
(player, pet): crate::spell::TokenContexts<'_, '_>,
|
||||
) -> Option<TooltipText> {
|
||||
let expand = |text: &str, d: &benilla_formats::SpellDisplay, at_pet: bool| {
|
||||
let ctx = if at_pet { pet } else { player };
|
||||
crate::ui_tooltip::tooltip_text(substitute_parts(text, d, ctx, ExpandAt::default()))
|
||||
};
|
||||
if let Some(text) = d.description.as_deref().filter(|t| !t.is_empty()) {
|
||||
return Some(expand(text, d, open_type == CRAFT_TYPE_BEAST_TRAINING));
|
||||
}
|
||||
(0..3).find_map(|i| {
|
||||
let effect = d.effects[i];
|
||||
if !matches!(
|
||||
effect,
|
||||
SPELL_EFFECT_LEARN_SPELL | SPELL_EFFECT_LEARN_PET_SPELL
|
||||
) {
|
||||
return None;
|
||||
}
|
||||
let taught = spells.get(d.effect_trigger_spell[i])?;
|
||||
let text = taught.description.as_deref().unwrap_or("");
|
||||
Some(expand(text, taught, effect == SPELL_EFFECT_LEARN_PET_SPELL))
|
||||
})
|
||||
}
|
||||
|
||||
/// Beast Training's craft type, which sets the expander's pet flag for a row's own text
|
||||
/// (`cmp esi,1` at `0x4f7b3d`).
|
||||
const CRAFT_TYPE_BEAST_TRAINING: u32 = 1;
|
||||
|
||||
/// What the craft list's build and getters read (`0x4f60c0`, `0x4f6c10`-`0x4f7be6`): the
|
||||
/// player's known spells and lists, the catalogs, the player object and the bags as of the drain's
|
||||
/// place ([`crate::ui_unit::views::ViewStores`]), the item cache, the pet and the bind point.
|
||||
#[derive(bevy::ecs::system::SystemParam)]
|
||||
pub(crate) struct CraftReads<'w, 's> {
|
||||
pet: PetReads<'w>,
|
||||
@@ -248,183 +289,82 @@ pub(crate) struct CraftReads<'w, 's> {
|
||||
skill_lines: Option<Res<'w, SkillLines>>,
|
||||
focus: Option<Res<'w, SpellFocus>>,
|
||||
icons: Option<Res<'w, ItemDisplays>>,
|
||||
self_store: Query<'w, 's, &'static ObjectStore, With<SelfPlayer>>,
|
||||
/// The `$z` token: the bind point's area (`0x5ed420` at `0x507f07`), named through
|
||||
/// `AreaTable` (`0x507f2b`).
|
||||
home_bind: Option<Res<'w, crate::net::HomeBind>>,
|
||||
area_names: Option<Res<'w, crate::ui_quest_log::QuestHeaderNamesRes>>,
|
||||
objects: Objects<'w, 's>,
|
||||
stores: crate::ui_unit::views::ViewStores<'w, 's>,
|
||||
items: Res<'w, Items>,
|
||||
}
|
||||
|
||||
impl CraftReads<'_, '_> {
|
||||
/// The names of the spells in the player's four effect slots, `None` with no player.
|
||||
fn slot_names(&self) -> Option<[Option<String>; 4]> {
|
||||
self.self_store.single().ok()?;
|
||||
Some(effect_slot_names(&self.actions, self.spells.as_deref()?))
|
||||
/// The active player's store as of here (`0x468460`).
|
||||
fn player(&self) -> Option<&ObjectStore> {
|
||||
self.objects.player().and_then(|e| self.stores.get(e).ok())
|
||||
}
|
||||
|
||||
/// The list of `craft_type`, opened by an opener of `line`, its descriptions expanded against
|
||||
/// `script`'s strings; `None` while a catalog or our player is missing. The list only reads
|
||||
/// the item cache: the build asks nothing (`0x4f60c0`), and a reagent or a totem is asked by
|
||||
/// its getter's call, inside it (`0x4f75f2`, `0x4f7a0a`).
|
||||
pub(crate) fn state(
|
||||
/// The bind point's area name, `None` before it resolves, where `$z` reads `HOME_INN`.
|
||||
fn home_area(&self) -> Option<&str> {
|
||||
self.home_bind
|
||||
.as_deref()
|
||||
.and_then(|b| b.0)
|
||||
.and_then(|id| self.area_names.as_deref()?.0.resolve(id as i32))
|
||||
}
|
||||
|
||||
/// `f` over the `$`-token contexts of the player `store` and of its pet, the two casters the
|
||||
/// expander's pet flag picks between for its level and cost terms (`0x6e3130`, `0x6e31b0`,
|
||||
/// `0x6e3300`): the pet is the charm, else the summon, as of here.
|
||||
fn with_contexts<R>(
|
||||
&self,
|
||||
script: &benilla_ui::script::UiScript,
|
||||
line: u32,
|
||||
craft_type: u32,
|
||||
) -> Option<CraftState> {
|
||||
let spells = self.spells.as_deref()?;
|
||||
let skill_lines = self.skill_lines.as_deref()?;
|
||||
let store = self.self_store.single().ok()?;
|
||||
let name = skill_lines
|
||||
.catalog
|
||||
.line(line)
|
||||
.map(|l| l.name.clone())
|
||||
.unwrap_or_else(|| format!("Skill {line}"));
|
||||
let global = |key: &str| benilla_ui::strings::global(script.lua(), key);
|
||||
// The `$z` token: the bind area the items feed pushed for `GetBindLocation`, so the
|
||||
// two agree (`0x507f07`-`0x507f45`, `0x48dae0`).
|
||||
let bind = script.bind_location();
|
||||
let home_area: Option<&str> = bind.as_deref();
|
||||
// The player's level for a spell and its cost (`0x6e3130`, `0x6e31b0`, `0x6e3300`).
|
||||
spells: &Spells,
|
||||
skill_lines: &SkillLines,
|
||||
store: &ObjectStore,
|
||||
f: impl FnOnce(crate::spell::TokenContexts<'_, '_>) -> R,
|
||||
) -> R {
|
||||
let pet = store
|
||||
.0
|
||||
.unit_pet_guid()
|
||||
.and_then(|guid| self.stores.by_guid(guid, self.objects.store(guid)));
|
||||
let skills = crate::spell::PlayerSkills {
|
||||
lines: Some(&skill_lines.catalog),
|
||||
spells: Some(&spells.catalog),
|
||||
items: Some(&self.items),
|
||||
};
|
||||
let ctx = benilla_formats::TokenContext {
|
||||
durations: &spells.durations,
|
||||
radii: &spells.radii,
|
||||
ranges: Some(&spells.ranges),
|
||||
level: &|d| crate::spell::player_spell_level(Some(store), skills, d),
|
||||
lookup: &|id| spells.catalog.get(id),
|
||||
mods: Some(&*self.spell_mods),
|
||||
power_cost: &|d| crate::spell::usable::power_cost(d, store, skills, &self.spell_mods),
|
||||
power_per_second: &|d| {
|
||||
let level = crate::spell::SpellLevel::Player {
|
||||
me: Some(store),
|
||||
skills,
|
||||
};
|
||||
crate::spell::usable::per_second_cost(d, level)
|
||||
},
|
||||
unmodified_points: false,
|
||||
gender: &|| store.0.unit_gender().unwrap_or(0),
|
||||
home_area: &|| home_area,
|
||||
global: &global,
|
||||
printf: &crate::ui_script::token_printf,
|
||||
};
|
||||
// Admission (`0x5e9c20`): known, not hidden (`Attributes & 0x20`), and `castUI` equal
|
||||
// to the craft type. The client walks its per-type list (`CGPlayer_C + 0x1cd0 +
|
||||
// 0x10*type`), in learn order (`0x5e9e0f`), and never consults `SkillLineAbility` for
|
||||
// membership.
|
||||
let listed: Vec<u32> = self
|
||||
.actions
|
||||
.craft_order
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|&s| {
|
||||
spells.catalog.get(s).is_some_and(|d| {
|
||||
d.cast_ui == craft_type && d.attributes & SPELL_ATTR_IS_TRADESKILL == 0
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
crate::spell::with_token_contexts(
|
||||
spells,
|
||||
skills,
|
||||
&self.spell_mods,
|
||||
(Some(store), pet),
|
||||
self.home_area(),
|
||||
f,
|
||||
)
|
||||
}
|
||||
|
||||
/// The book of `craft_type`, opened by an opener of `line`, as a build reads it; `None` while
|
||||
/// a catalog or our player is missing. The list only reads the item cache: the build asks
|
||||
/// nothing (`0x4f60c0`), and a reagent or a totem is asked by its getter's call, inside it
|
||||
/// (`0x4f75f2`, `0x4f7a0a`).
|
||||
pub(crate) fn state(&self, line: u32, craft_type: u32) -> Option<CraftState> {
|
||||
let spells = self.spells.as_deref()?;
|
||||
let skill_lines = self.skill_lines.as_deref()?;
|
||||
let store = self.player()?;
|
||||
let name = skill_lines
|
||||
.catalog
|
||||
.line(line)
|
||||
.map(|l| l.name.clone())
|
||||
.unwrap_or_else(|| format!("Skill {line}"));
|
||||
let listed = self.listed(spells, craft_type);
|
||||
let (display_line, rank, max_rank) = (craft_type == 3)
|
||||
.then(|| display_line(listed.first().copied(), skill_lines, store))
|
||||
.flatten()
|
||||
.map_or((None, 0, 0), |(n, r, m)| (Some(n), r, m));
|
||||
let pet = self.pet.view(&skill_lines.catalog, &spells.catalog);
|
||||
let recipes: Vec<CraftRecipe> = listed
|
||||
.iter()
|
||||
.filter_map(|&s| {
|
||||
let d = spells.catalog.get(s)?;
|
||||
// A spell with no ability row keeps its row, in group 0 (`0x4f61b6`).
|
||||
let (race, class) = store.race_class();
|
||||
let sla = skill_lines.catalog.ability(s, race, class);
|
||||
let mut reagents = Vec::new();
|
||||
let mut num_available = u32::MAX;
|
||||
for &(entry, need) in d.reagents.iter().filter(|&&(e, n)| e != 0 && n != 0) {
|
||||
let have = count_of(&store.0, &self.objects, entry, InventoryScope::DEFAULT);
|
||||
// A reagent's icon is the shared item chain (`0x5d88b0`) through its
|
||||
// display.
|
||||
let (name, icon) = match self.items.template(entry, 0, Ask::Read) {
|
||||
Some(t) => (
|
||||
Some(t.name.clone()),
|
||||
item_icon(self.icons.as_deref(), t.display_info_id),
|
||||
),
|
||||
None => (None, None),
|
||||
};
|
||||
reagents.push(CraftReagent {
|
||||
item: entry,
|
||||
name,
|
||||
icon,
|
||||
need,
|
||||
have,
|
||||
});
|
||||
num_available = num_available.min(have / need);
|
||||
}
|
||||
if reagents.is_empty() {
|
||||
num_available = 0;
|
||||
}
|
||||
// Focus first, then the totems (`0x4ff980`), the list `GetCraftSpellFocus`
|
||||
// (`0x4f78b0`) returns. The focus's flag is a literal `1.0`, never reddened.
|
||||
let mut tools = Vec::new();
|
||||
if d.requires_spell_focus != 0 {
|
||||
if let Some(n) = self
|
||||
.focus
|
||||
.as_deref()
|
||||
.and_then(|f| f.catalog.name(d.requires_spell_focus))
|
||||
{
|
||||
tools.push((n.to_string(), true));
|
||||
}
|
||||
}
|
||||
let mut tools_pending = Vec::new();
|
||||
for &t in d.totems.iter().filter(|&&t| t != 0) {
|
||||
let have = count_of(&store.0, &self.objects, t, InventoryScope::DEFAULT) > 0;
|
||||
match self.items.template(t, 0, Ask::Read) {
|
||||
Some(info) => tools.push((info.name.clone(), have)),
|
||||
None => tools_pending.push(t),
|
||||
}
|
||||
}
|
||||
let needs_item_target = matches!(
|
||||
d.effects[0],
|
||||
SPELL_EFFECT_ENCHANT_ITEM | SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY
|
||||
);
|
||||
let icon = craft_icon(d);
|
||||
let (training_point_cost, required_level) = pet
|
||||
.as_ref()
|
||||
.map_or((0, 0), |p| cost_and_level(p, d, &self.objects));
|
||||
Some(CraftRecipe {
|
||||
spell_id: s,
|
||||
name: d.name.clone(),
|
||||
sub_name: d.rank.clone().unwrap_or_default(),
|
||||
difficulty: craft_bucket(
|
||||
d,
|
||||
sla,
|
||||
store,
|
||||
&self.actions.spells,
|
||||
pet.as_ref(),
|
||||
&self.objects,
|
||||
),
|
||||
num_available,
|
||||
icon,
|
||||
description: d
|
||||
.description
|
||||
.as_deref()
|
||||
.map(|t| benilla_formats::substitute(t, d, &ctx)),
|
||||
needs_item_target,
|
||||
reagents,
|
||||
tools,
|
||||
tooltip: craft_tooltip(s, d),
|
||||
// `spellLevel` at `+0x74` (column 29), not `baseLevel` (column 28).
|
||||
spell_level: d.spell_level,
|
||||
// The group key is the ability row's line (`0x4f61b1`), 0 with none.
|
||||
group: sla.map_or(0, |a| a.skill_id),
|
||||
skill_line: sla
|
||||
.and_then(|a| skill_lines.catalog.line(a.skill_id))
|
||||
.map(|l| l.name.clone()),
|
||||
training_point_cost,
|
||||
required_level,
|
||||
tools_pending,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let recipes: Vec<CraftRecipe> = self.with_contexts(spells, skill_lines, store, |ctxs| {
|
||||
listed
|
||||
.iter()
|
||||
.filter_map(|&s| self.recipe(s, spells, skill_lines, store, craft_type, ctxs))
|
||||
.collect()
|
||||
});
|
||||
// No sort here: the engine orders the rows by the craft type's own comparator
|
||||
// (`benilla_ui::script::craft::recipe_order`).
|
||||
Some(CraftState {
|
||||
@@ -436,62 +376,187 @@ impl CraftReads<'_, '_> {
|
||||
recipes,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Keep the VM's craft list as the engine holds it, silently; the open and the closes signal in
|
||||
/// their calls ([`crate::ui_tradeskill::TradeSkillSteps`]), the rebuilds at their packets.
|
||||
fn feed_craft(
|
||||
mut vm: crate::script_calls::VmWith<(CraftReads<'static, 'static>, Res<'static, CraftOpen>)>,
|
||||
mut memo: Local<crate::ui_script::VmMemo<CraftMemo>>,
|
||||
) {
|
||||
vm.turn(|script, (reads, open)| {
|
||||
let Some(script) = script else {
|
||||
return;
|
||||
};
|
||||
let memo = memo.get(script);
|
||||
// `GetCraftName` reads the player's effect slot of the open type, 0 when closed (`0x4f6c32`).
|
||||
script.set_craft_slot_names(reads.slot_names().unwrap_or_default());
|
||||
let fresh = open
|
||||
.line
|
||||
.and_then(|line| reads.state(script, line, open.craft_type));
|
||||
// The type stays open while a frame cannot resolve its book (a worldport's purge of our
|
||||
// own player): only a close or the world-enter init ends it (`0x4f5fe0`, `0x4f5ee0`).
|
||||
let fresh = match fresh {
|
||||
None if open.line.is_some() => memo.state.clone(),
|
||||
f => f,
|
||||
};
|
||||
// Every push is silent: the rebuilds signal, and the getters read the state at their call.
|
||||
if fresh != memo.state {
|
||||
script.set_craft(fresh.clone());
|
||||
// The reagent templates `GetCraftReagentItemLink` reads, off the cache: the link
|
||||
// passes no callback (`0x4f780a`).
|
||||
if let Some(f) = &fresh {
|
||||
script.read_item_templates(
|
||||
f.recipes
|
||||
.iter()
|
||||
.flat_map(|r| r.reagents.iter().map(|re| re.item)),
|
||||
);
|
||||
/// The build's book of the open window: `Some(None)` with no type open or no player, as the
|
||||
/// build's leaves (`0x4f60e3`, `0x4f6109`); `None` while a catalog is missing.
|
||||
fn book(&self, open: &CraftOpen) -> Option<Option<CraftState>> {
|
||||
self.spells.as_deref()?;
|
||||
self.skill_lines.as_deref()?;
|
||||
Some(open.line.and_then(|line| self.state(line, open.craft_type)))
|
||||
}
|
||||
|
||||
/// The player's list of `craft_type` (`CGPlayer_C + 0x1cd0 + 0x10*type`, `0x5ea330`), in learn
|
||||
/// order (`0x5e9e0f`): admitted at the learn (`0x5e9c20`) when known, not a profession spell
|
||||
/// (`Attributes & 0x20`) and `castUI` equal to the type; `SkillLineAbility` decides no
|
||||
/// membership.
|
||||
fn listed(&self, spells: &Spells, craft_type: u32) -> Vec<u32> {
|
||||
self.actions
|
||||
.craft_order
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|&s| {
|
||||
spells.catalog.get(s).is_some_and(|d| {
|
||||
d.cast_ui == craft_type && d.attributes & SPELL_ATTR_IS_TRADESKILL == 0
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// `spell_id`'s row as its getters read it at the call, `open_type` the window's type
|
||||
/// (`[0xbdcfb8]`, 0 while closed) for the description's pet flag; `None` declines, with a
|
||||
/// catalog, our player or the spell's record missing.
|
||||
fn recipe_now(&self, spell_id: u32, open_type: u32) -> Option<CraftRecipe> {
|
||||
let spells = self.spells.as_deref()?;
|
||||
let skill_lines = self.skill_lines.as_deref()?;
|
||||
let store = self.player()?;
|
||||
self.with_contexts(spells, skill_lines, store, |ctxs| {
|
||||
self.recipe(spell_id, spells, skill_lines, store, open_type, ctxs)
|
||||
})
|
||||
}
|
||||
|
||||
/// `GetCraftName`'s answer for `craft_type` (`0x4f6c10`): the name of the spell in the
|
||||
/// player's effect slot of the type (`0x5ea360`), which a learn writes by the spell's misc
|
||||
/// value (`0x5e9e1c`-`0x5e9e36`) and an unlearn leaves; `Some(None)` with no player or no such
|
||||
/// spell, `None` while the spells are missing.
|
||||
fn name_now(&self, craft_type: u32) -> Option<Option<String>> {
|
||||
let spells = self.spells.as_deref()?;
|
||||
Some(self.player().and_then(|_| {
|
||||
let slot = (*self
|
||||
.actions
|
||||
.effect_slots
|
||||
.get(usize::try_from(craft_type).ok()?)?)?;
|
||||
spells.catalog.get(slot).map(|d| d.name.clone())
|
||||
}))
|
||||
}
|
||||
|
||||
/// `GetCraftDisplaySkillLine`'s answer past its type test (`0x4f6ce3`); `Some(None)` with no
|
||||
/// player, `None` while a catalog is missing.
|
||||
fn display_line_now(&self) -> Option<Option<(String, u32, u32)>> {
|
||||
let spells = self.spells.as_deref()?;
|
||||
let skill_lines = self.skill_lines.as_deref()?;
|
||||
Some(self.player().and_then(|store| {
|
||||
display_line(self.listed(spells, 3).first().copied(), skill_lines, store)
|
||||
}))
|
||||
}
|
||||
|
||||
/// One row of the list (`0x4f6146`-`0x4f63cc`) beside what its getters read: the bucket and
|
||||
/// count the build stores, and the reagents, tools, cost, level and description the getters
|
||||
/// read at their calls. `open_type` sets the description's pet flag (`0x4f7b31`).
|
||||
fn recipe(
|
||||
&self,
|
||||
s: u32,
|
||||
spells: &Spells,
|
||||
skill_lines: &SkillLines,
|
||||
store: &ObjectStore,
|
||||
open_type: u32,
|
||||
ctxs: crate::spell::TokenContexts<'_, '_>,
|
||||
) -> Option<CraftRecipe> {
|
||||
let d = spells.catalog.get(s)?;
|
||||
let objects = self.stores.item_objects(&self.objects);
|
||||
let pet = self.pet.view(&skill_lines.catalog, &spells.catalog);
|
||||
// A spell with no ability row keeps its row, in group 0 (`0x4f61b6`).
|
||||
let (race, class) = store.race_class();
|
||||
let sla = skill_lines.catalog.ability(s, race, class);
|
||||
let mut reagents = Vec::new();
|
||||
let mut num_available = u32::MAX;
|
||||
for &(entry, need) in d.reagents.iter().filter(|&&(e, n)| e != 0 && n != 0) {
|
||||
let have = count_of(&store.0, &objects, entry, InventoryScope::DEFAULT);
|
||||
// A reagent's icon is the shared item chain (`0x5d88b0`) through its display.
|
||||
let (name, icon) = match self.items.template(entry, 0, Ask::Read) {
|
||||
Some(t) => (
|
||||
Some(t.name.clone()),
|
||||
item_icon(self.icons.as_deref(), t.display_info_id),
|
||||
),
|
||||
None => (None, None),
|
||||
};
|
||||
reagents.push(CraftReagent {
|
||||
item: entry,
|
||||
name,
|
||||
icon,
|
||||
need,
|
||||
have,
|
||||
});
|
||||
num_available = num_available.min(have / need);
|
||||
}
|
||||
if reagents.is_empty() {
|
||||
num_available = 0;
|
||||
}
|
||||
// Focus first, then the totems (`0x4ff980`), the list `GetCraftSpellFocus` (`0x4f78b0`)
|
||||
// returns. The focus's flag is a literal `1.0`, never reddened.
|
||||
let mut tools = Vec::new();
|
||||
if d.requires_spell_focus != 0 {
|
||||
if let Some(n) = self
|
||||
.focus
|
||||
.as_deref()
|
||||
.and_then(|f| f.catalog.name(d.requires_spell_focus))
|
||||
{
|
||||
tools.push((n.to_string(), true));
|
||||
}
|
||||
}
|
||||
memo.state = fresh;
|
||||
})
|
||||
let mut tools_pending = Vec::new();
|
||||
for &t in d.totems.iter().filter(|&&t| t != 0) {
|
||||
let have = count_of(&store.0, &objects, t, InventoryScope::DEFAULT) > 0;
|
||||
match self.items.template(t, 0, Ask::Read) {
|
||||
Some(info) => tools.push((info.name.clone(), have)),
|
||||
None => tools_pending.push(t),
|
||||
}
|
||||
}
|
||||
let needs_item_target = matches!(
|
||||
d.effects[0],
|
||||
SPELL_EFFECT_ENCHANT_ITEM | SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY
|
||||
);
|
||||
let (training_point_cost, required_level) = pet
|
||||
.as_ref()
|
||||
.map_or((0, 0), |p| cost_and_level(p, d, &objects));
|
||||
Some(CraftRecipe {
|
||||
spell_id: s,
|
||||
name: d.name.clone(),
|
||||
sub_name: d.rank.clone().unwrap_or_default(),
|
||||
difficulty: craft_bucket(d, sla, store, &self.actions.spells, pet.as_ref(), &objects),
|
||||
num_available,
|
||||
icon: craft_icon(d),
|
||||
description: craft_description(d, &spells.catalog, open_type, ctxs),
|
||||
needs_item_target,
|
||||
reagents,
|
||||
tools,
|
||||
tooltip: craft_tooltip(s, d),
|
||||
// `spellLevel` at `+0x74` (column 29), not `baseLevel` (column 28).
|
||||
spell_level: d.spell_level,
|
||||
// The group key is the ability row's line (`0x4f61b1`), 0 with none.
|
||||
group: sla.map_or(0, |a| a.skill_id),
|
||||
skill_line: sla
|
||||
.and_then(|a| skill_lines.catalog.line(a.skill_id))
|
||||
.map(|l| l.name.clone()),
|
||||
training_point_cost,
|
||||
required_level,
|
||||
tools_pending,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// The names of the spells in the player's four effect slots (`CGPlayer_C+0x1d10`, `0x5ea360`),
|
||||
/// which `GetCraftName` reads at the open craft type (`0x4f6c32`); a learn writes them
|
||||
/// ([`PlayerActions::effect_slots`]), an unlearn leaves them.
|
||||
fn effect_slot_names(actions: &PlayerActions, spells: &Spells) -> [Option<String>; 4] {
|
||||
actions.effect_slots.map(|slot| {
|
||||
slot.and_then(|id| spells.catalog.get(id))
|
||||
.map(|d| d.name.clone())
|
||||
})
|
||||
/// The craft getters' and builds' reads as they run, the call host's half of
|
||||
/// [`benilla_ui::script::CraftBookQuery`], [`benilla_ui::script::CraftRecipeQuery`],
|
||||
/// [`benilla_ui::script::CraftNameQuery`] and [`benilla_ui::script::CraftDisplayLineQuery`], over
|
||||
/// the open type `[0xbdcfb8]`.
|
||||
#[derive(bevy::ecs::system::SystemParam)]
|
||||
pub(crate) struct CraftLive<'w, 's> {
|
||||
open: Res<'w, CraftOpen>,
|
||||
reads: CraftReads<'w, 's>,
|
||||
}
|
||||
|
||||
/// What [`feed_craft`] remembers from its last frame.
|
||||
#[derive(Default)]
|
||||
struct CraftMemo {
|
||||
/// The state it last pushed.
|
||||
state: Option<CraftState>,
|
||||
impl crate::script_calls::live::LiveFamily for CraftLive<'_, '_> {
|
||||
fn answer(&mut self, ask: &mut benilla_ui::script::live::LiveAsk<'_>) -> bool {
|
||||
use benilla_ui::script::{
|
||||
CraftBookQuery, CraftDisplayLineQuery, CraftNameQuery, CraftRecipeQuery,
|
||||
};
|
||||
let (open, reads) = (&*self.open, &self.reads);
|
||||
// The type a close zeroes (`0x4f5fe0`).
|
||||
let open_type = open.line.map_or(0, |_| open.craft_type);
|
||||
ask.answer(|_: &CraftBookQuery| reads.book(open))
|
||||
|| ask.answer(|q: &CraftRecipeQuery| reads.recipe_now(q.0, open_type))
|
||||
|| ask.answer(|q: &CraftNameQuery| reads.name_now(q.0))
|
||||
|| ask.answer(|_: &CraftDisplayLineQuery| reads.display_line_now())
|
||||
}
|
||||
}
|
||||
|
||||
/// `DoCraft(index)` past its row (`0x4f7d10`): the row's cast through `CastSpellAsActivePlayer`
|
||||
@@ -525,12 +590,12 @@ impl CraftSteps<'_> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::net::SelfPlayer;
|
||||
use benilla_formats::SpellDisplay;
|
||||
use benilla_ui::script::UiScript;
|
||||
|
||||
/// `CloseCraft` signals `CRAFT_CLOSE` in the verb (`0x4f5fef`), so the feed that finds the
|
||||
/// window closed a frame later signals no second close; the opener's toggle signals its own
|
||||
/// (`0x4f6017`).
|
||||
/// `CloseCraft` signals `CRAFT_CLOSE` in the verb (`0x4f5fef`) and nothing signals a second
|
||||
/// close a frame later; the opener's toggle signals its own (`0x4f6017`).
|
||||
#[test]
|
||||
fn a_verbs_close_is_signalled_once() {
|
||||
let (tx, _rx) = crossbeam_channel::unbounded();
|
||||
@@ -556,7 +621,6 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
app.insert_non_send_resource(script);
|
||||
app.add_systems(Update, feed_craft);
|
||||
let closes = |app: &App| {
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
@@ -574,7 +638,7 @@ mod tests {
|
||||
// The host's half, which this harness has none of.
|
||||
app.world_mut().resource_mut::<CraftOpen>().line = None;
|
||||
app.update();
|
||||
assert_eq!(closes(&app), 1, "no second signal from the feed");
|
||||
assert_eq!(closes(&app), 1, "no second signal");
|
||||
|
||||
toggle(&mut app, 333, 3);
|
||||
app.update();
|
||||
@@ -710,13 +774,8 @@ mod tests {
|
||||
.spawn((SelfPlayer, ObjectStore(Default::default())))
|
||||
.id();
|
||||
app.insert_non_send_resource(UiScript::new().unwrap());
|
||||
app.add_systems(Update, feed_craft);
|
||||
{
|
||||
let mut open = app.world_mut().resource_mut::<CraftOpen>();
|
||||
open.line = Some(333);
|
||||
open.craft_type = 3;
|
||||
}
|
||||
// Where the dust and the rod sit: player slots, 17 worn, 81 the keyring, 39 the bank.
|
||||
// Where the dust and the rod sit: player slots, 17 worn, 81 the keyring, 39 the bank;
|
||||
// each read opens the window again, whose build counts them.
|
||||
let mut read = |dust_slot: u16, rod_slot: u16| -> (i64, bool) {
|
||||
let seat = |slot: u16, guid: u64| {
|
||||
let lo = 486 + 2 * slot;
|
||||
@@ -731,7 +790,7 @@ mod tests {
|
||||
]
|
||||
.concat(),
|
||||
)));
|
||||
app.update();
|
||||
reopen(&mut app, 333, 3);
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.eval::<(i64, bool)>(
|
||||
@@ -796,23 +855,18 @@ mod tests {
|
||||
let script = UiScript::new().unwrap();
|
||||
script.run("HOME_INN = 'your inn'").unwrap();
|
||||
app.insert_non_send_resource(script);
|
||||
app.add_systems(Update, feed_craft);
|
||||
{
|
||||
let mut open = app.world_mut().resource_mut::<CraftOpen>();
|
||||
open.line = Some(333);
|
||||
open.craft_type = 3;
|
||||
}
|
||||
let described = |app: &mut App| {
|
||||
app.update();
|
||||
reopen(app, 333, 3);
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.eval::<String>("return GetCraftDescription(1)")
|
||||
.unwrap()
|
||||
};
|
||||
assert_eq!(described(&mut app), "Returns you to your inn.");
|
||||
app.world_mut()
|
||||
.non_send_resource_mut::<UiScript>()
|
||||
.set_bind_location(Some("Elwynn Forest"));
|
||||
app.insert_resource(crate::net::HomeBind(Some(12)));
|
||||
app.insert_resource(crate::ui_quest_log::QuestHeaderNamesRes(
|
||||
benilla_formats::QuestHeaderNames::from_zones([(12, "Elwynn Forest")]),
|
||||
));
|
||||
assert_eq!(described(&mut app), "Returns you to Elwynn Forest.");
|
||||
}
|
||||
|
||||
@@ -897,7 +951,8 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// The feed over `displays`, the player knowing `known`, with no pet; [`seat_pet`] adds one.
|
||||
/// The window's reads over `displays`, the player knowing `known`, with no pet; [`seat_pet`]
|
||||
/// adds one.
|
||||
fn craft_feed(
|
||||
displays: Vec<(u32, SpellDisplay)>,
|
||||
known: &[u32],
|
||||
@@ -940,7 +995,6 @@ mod tests {
|
||||
let mut script = UiScript::new().unwrap();
|
||||
script.keep_calls();
|
||||
app.insert_non_send_resource(script);
|
||||
app.add_systems(Update, feed_craft);
|
||||
app
|
||||
}
|
||||
|
||||
@@ -968,6 +1022,15 @@ mod tests {
|
||||
toggle(app, line, craft_type);
|
||||
}
|
||||
|
||||
/// The window of `craft_type` closed if open and opened again, whose build reads the world as
|
||||
/// it stands.
|
||||
fn reopen(app: &mut App, line: u32, craft_type: u32) {
|
||||
if app.world().resource::<CraftOpen>().line.is_some() {
|
||||
toggle(app, line, craft_type);
|
||||
}
|
||||
toggle(app, line, craft_type);
|
||||
}
|
||||
|
||||
/// [`crate::ui_tradeskill::TradeSkillSteps::toggle_craft`] on `app`'s VM.
|
||||
fn toggle(app: &mut App, line: u32, craft_type: u32) {
|
||||
use bevy::ecs::system::RunSystemOnce;
|
||||
@@ -1028,7 +1091,6 @@ mod tests {
|
||||
|
||||
/// Each row's `(name rank, craftType, trainingPointCost, requiredLevel)`, in display order.
|
||||
fn craft_rows(app: &mut App) -> Vec<(String, String, i64, i64)> {
|
||||
app.update();
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.eval::<Vec<Vec<String>>>(
|
||||
@@ -1167,9 +1229,15 @@ mod tests {
|
||||
#[test]
|
||||
fn beast_training_rows_read_none_and_used_once_known() {
|
||||
let known = [4195, 4196, 9000, 9001];
|
||||
let feed = || {
|
||||
// The window opens over the pet as it stands: the build reads the bucket (`0x4f6369`).
|
||||
let feed = |pet: Option<(u64, u64, &[u32])>| {
|
||||
let (displays, catalog) = beast_training();
|
||||
craft_feed_open(displays, &known, catalog, 1, &[])
|
||||
let mut app = craft_feed(displays, &known, catalog, &[]);
|
||||
if let Some((summon, bar, book)) = pet {
|
||||
seat_pet(&mut app, summon, bar, book);
|
||||
}
|
||||
open_type(&mut app, 1);
|
||||
app
|
||||
};
|
||||
let kinds = |app: &mut App| -> Vec<(String, String)> {
|
||||
craft_rows(app)
|
||||
@@ -1180,7 +1248,7 @@ mod tests {
|
||||
};
|
||||
let pair = |n: &str, k: &str| (n.to_string(), k.to_string());
|
||||
|
||||
let mut app = feed();
|
||||
let mut app = feed(None);
|
||||
assert_eq!(
|
||||
kinds(&mut app),
|
||||
[
|
||||
@@ -1191,8 +1259,7 @@ mod tests {
|
||||
"no pet: only the player's own learn reads used"
|
||||
);
|
||||
|
||||
let mut app = feed();
|
||||
seat_pet(&mut app, PET, PET, &[4187]);
|
||||
let mut app = feed(Some((PET, PET, &[4187])));
|
||||
assert_eq!(
|
||||
kinds(&mut app),
|
||||
[
|
||||
@@ -1203,8 +1270,7 @@ mod tests {
|
||||
"the pet knows rank 1"
|
||||
);
|
||||
|
||||
let mut app = feed();
|
||||
seat_pet(&mut app, PET, PET, &[4188]);
|
||||
let mut app = feed(Some((PET, PET, &[4188])));
|
||||
assert_eq!(
|
||||
kinds(&mut app),
|
||||
[
|
||||
@@ -1215,8 +1281,7 @@ mod tests {
|
||||
"rank 2 is a higher rank of rank 1"
|
||||
);
|
||||
|
||||
let mut app = feed();
|
||||
seat_pet(&mut app, OTHER_PET, PET, &[4187, 4188]);
|
||||
let mut app = feed(Some((OTHER_PET, PET, &[4187, 4188])));
|
||||
assert_eq!(
|
||||
kinds(&mut app),
|
||||
[
|
||||
@@ -1237,9 +1302,14 @@ mod tests {
|
||||
#[test]
|
||||
fn a_pet_learn_row_answers_its_training_point_cost_and_required_level() {
|
||||
let known = [4195, 4196, 9000, 9100, 9200, 9300];
|
||||
let feed = || {
|
||||
let feed = |pet: bool| {
|
||||
let (displays, catalog) = beast_training();
|
||||
craft_feed_open(displays, &known, catalog, 1, &[])
|
||||
let mut app = craft_feed(displays, &known, catalog, &[]);
|
||||
if pet {
|
||||
seat_pet(&mut app, PET, PET, &[]);
|
||||
}
|
||||
open_type(&mut app, 1);
|
||||
app
|
||||
};
|
||||
let costs = |app: &mut App| -> Vec<(String, i64, i64)> {
|
||||
let mut rows: Vec<_> = craft_rows(app)
|
||||
@@ -1250,13 +1320,12 @@ mod tests {
|
||||
rows
|
||||
};
|
||||
let row = |n: &str, tp: i64, l: i64| (n.to_string(), tp, l);
|
||||
let mut app = feed();
|
||||
let mut app = feed(false);
|
||||
assert!(
|
||||
costs(&mut app).iter().all(|r| (r.1, r.2) == (0, 0)),
|
||||
"no pet"
|
||||
);
|
||||
let mut app = feed();
|
||||
seat_pet(&mut app, PET, PET, &[]);
|
||||
let mut app = feed(true);
|
||||
assert_eq!(
|
||||
costs(&mut app),
|
||||
[
|
||||
@@ -1292,7 +1361,6 @@ mod tests {
|
||||
.with_line_names([(ENCHANTING, "Enchanting")])
|
||||
};
|
||||
let triple = |app: &mut App| {
|
||||
app.update();
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.eval::<(Option<String>, i64, i64)>("return GetCraftDisplaySkillLine()")
|
||||
@@ -1337,8 +1405,7 @@ mod tests {
|
||||
(7420, ability(TAILORING, 1, 70)),
|
||||
])
|
||||
.with_line_names([(ENCHANTING, "Enchanting"), (TAILORING, "Tailoring")]);
|
||||
let mut app = craft_feed_open(displays, &[7420, 7418], catalog, 3, &[]);
|
||||
app.update();
|
||||
let app = craft_feed_open(displays, &[7420, 7418], catalog, 3, &[]);
|
||||
let name = app
|
||||
.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
@@ -1347,10 +1414,58 @@ mod tests {
|
||||
assert_eq!(name.as_deref(), Some("Tailoring"));
|
||||
}
|
||||
|
||||
/// `GetCraftDescription` (`0x4f7a90`) falls back from an empty text of the row's own
|
||||
/// (`0x4f7b2a`, `0x4f7b2f`) to the text of the spell its first `LEARN_SPELL` or
|
||||
/// `LEARN_PET_SPELL` effect teaches (`0x4f7b71`-`0x4f7ba3`, expanded at `0x4f7be6`), and with
|
||||
/// neither answers nil (`0x4f7bae`).
|
||||
#[test]
|
||||
fn a_craft_description_falls_back_to_the_taught_spells_text() {
|
||||
let displays = vec![
|
||||
(
|
||||
9100,
|
||||
learner("Bond", "Rank 1", 1, [57, 0, 0], [0; 3], [4187, 0, 0]),
|
||||
),
|
||||
(
|
||||
9000,
|
||||
learner("Track", "Rank 1", 1, [0, 0, 0], [0; 3], [0, 0, 0]),
|
||||
),
|
||||
(
|
||||
4187,
|
||||
SpellDisplay {
|
||||
description: Some("Taunts the target.".into()),
|
||||
..pet_spell("Great Stamina", 4)
|
||||
},
|
||||
),
|
||||
];
|
||||
let catalog = benilla_formats::SkillLineCatalog::from_abilities(
|
||||
[9100, 9000].map(|s| (s, ability(BEAST_TRAINING, 0, 0))),
|
||||
);
|
||||
let app = craft_feed_open(displays, &[9100, 9000], catalog, 1, &[]);
|
||||
let described: Vec<(String, Option<String>)> = app
|
||||
.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.eval::<Vec<Vec<String>>>(
|
||||
"local t = {} for i = 1, GetNumCrafts() do \
|
||||
t[i] = { (GetCraftInfo(i)), GetCraftDescription(i) or 'nil' } end return t",
|
||||
)
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|r| (r[0].clone(), (r[1] != "nil").then(|| r[1].clone())))
|
||||
.collect();
|
||||
assert_eq!(
|
||||
described,
|
||||
[
|
||||
("Bond".into(), Some("Taunts the target.".into())),
|
||||
("Track".into(), None),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/// The window's open runs the build (`0x4f6036` → `0x4f60c0`), whose tail signals
|
||||
/// `CRAFT_UPDATE` (`0x4f661a`), then `CRAFT_SHOW` (`0x4f6040`); a change between rebuilds, as a
|
||||
/// skill's rank, which no watcher rebuilds the craft list on (`0x5de434` is the profession
|
||||
/// window's alone), signals nothing.
|
||||
/// window's alone), signals nothing, and the row keeps the bucket its build stored
|
||||
/// (`0x4f623f`), which `GetCraftInfo` reads (`0x4f6fbc`).
|
||||
#[test]
|
||||
fn the_open_signals_update_then_show_and_a_bare_change_signals_nothing() {
|
||||
let displays = vec![(
|
||||
@@ -1394,12 +1509,12 @@ mod tests {
|
||||
]);
|
||||
assert!(heard(&mut app).is_empty());
|
||||
assert_eq!(
|
||||
app.world()
|
||||
.non_send_resource::<UiScript>()
|
||||
.eval::<String>("local _, _, k = GetCraftInfo(1) return k")
|
||||
.unwrap(),
|
||||
"trivial",
|
||||
"pushed, silently"
|
||||
crate::script_calls::with_hosted_vm(app.world_mut(), |s| s
|
||||
.expect("a VM")
|
||||
.eval::<String>("local _, _, k = GetCraftInfo(1) return k"))
|
||||
.unwrap(),
|
||||
"medium",
|
||||
"the build's bucket, at rank 1 of 1-70"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1565,7 +1680,6 @@ mod tests {
|
||||
script
|
||||
};
|
||||
app.insert_non_send_resource(listening());
|
||||
app.add_systems(Update, feed_craft);
|
||||
let world_enter = |app: &mut App| {
|
||||
app.world_mut()
|
||||
.run_system_cached(crate::ui_tradeskill::reset_crafts_on_world_enter)
|
||||
|
||||
@@ -909,14 +909,9 @@ impl TradeSkillSteps<'_, '_> {
|
||||
}
|
||||
debug!("ui_tradeskill: the opener opens the CraftFrame (line {line}, type {craft_type})");
|
||||
(open.line, open.craft_type) = (Some(line), craft_type);
|
||||
// With no list to build (`0x4f60e3`, `0x4f6109`), the build leaves before its signal.
|
||||
if let Some(fresh) = self
|
||||
.craft
|
||||
.as_ref()
|
||||
.and_then(|c| c.state(script, line, craft_type))
|
||||
{
|
||||
script.set_craft(Some(fresh));
|
||||
script.craft_opened();
|
||||
// With no player to build for (`0x4f6109`), the build leaves before its signal.
|
||||
let fresh = self.craft.as_ref().and_then(|c| c.state(line, craft_type));
|
||||
if script.open_craft(craft_type, fresh) {
|
||||
script.fire_event("CRAFT_UPDATE", vec![]);
|
||||
}
|
||||
script.fire_event("CRAFT_SHOW", vec![]);
|
||||
|
||||
@@ -124,9 +124,9 @@ pub(super) fn service_tooltip(wire_spell: u32, spells: &SpellCatalog) -> Trainer
|
||||
/// The `$`-token contexts a service description expands over, picked per row by the caster the
|
||||
/// expander's level terms read (`0x6e3130`'s selector): the active player's, or the pet's, which
|
||||
/// a `LEARN_PET_SPELL` wrapper selects.
|
||||
pub(super) struct ServiceText<'a> {
|
||||
pub(super) player: &'a TokenContext<'a>,
|
||||
pub(super) pet: &'a TokenContext<'a>,
|
||||
pub(super) struct ServiceText<'c, 'a> {
|
||||
pub(super) player: &'c TokenContext<'a>,
|
||||
pub(super) pet: &'c TokenContext<'a>,
|
||||
}
|
||||
|
||||
/// `GetTrainerServiceDescription 0x4d9b40`: the text the stock window shows under the service's
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use benilla_formats::{
|
||||
LearnEffect, SkillLineCatalog, SpellCatalog, TokenContext, SPELL_EFFECT_LEARN_PET_SPELL,
|
||||
LearnEffect, SkillLineCatalog, SpellCatalog, SPELL_EFFECT_LEARN_PET_SPELL,
|
||||
SPELL_EFFECT_LEARN_SPELL, SPELL_EFFECT_SKILL_STEP,
|
||||
};
|
||||
use benilla_protocol::messages::{trainer_spell_state, TrainerSpell};
|
||||
@@ -609,13 +609,13 @@ pub(crate) struct DescriptionReads<'w> {
|
||||
}
|
||||
|
||||
/// What a service's resolve reads, built once over the world ([`TrainerReads::with`]).
|
||||
struct Resolver<'a> {
|
||||
struct Resolver<'a, 't> {
|
||||
spells: &'a SpellCatalog,
|
||||
skill_lines: &'a SkillLineCatalog,
|
||||
books: &'a ReqBooks<'a>,
|
||||
icons: Option<&'a ItemDisplays>,
|
||||
items: &'a Items,
|
||||
text: &'a ServiceText<'a>,
|
||||
text: &'a ServiceText<'a, 't>,
|
||||
}
|
||||
|
||||
/// Everything a list's or a pass's push and a getter's per-call read resolve the services from:
|
||||
@@ -647,7 +647,6 @@ impl TrainerReads<'_, '_> {
|
||||
let pet = store
|
||||
.and_then(|s| s.0.unit_pet_guid())
|
||||
.and_then(|guid| self.player.store(guid));
|
||||
let gender = store.and_then(|s| s.0.unit_gender()).unwrap_or(0);
|
||||
let home_area: Option<&str> = self
|
||||
.desc
|
||||
.home_bind
|
||||
@@ -659,52 +658,6 @@ impl TrainerReads<'_, '_> {
|
||||
spells: Some(&spells.catalog),
|
||||
items: Some(items),
|
||||
};
|
||||
let player_level =
|
||||
|d: &benilla_formats::SpellDisplay| crate::spell::player_spell_level(store, skills, d);
|
||||
let pet_skill_level = |d: &benilla_formats::SpellDisplay| {
|
||||
d.skill_level(crate::spell::pet_skill_value(pet.map(|p| &p.0)))
|
||||
};
|
||||
// `$c` and `$p` (`0x6e31b0`, `0x6e3300`) at the same caster's level and fields.
|
||||
let player_cost = |d: &benilla_formats::SpellDisplay| {
|
||||
store.map_or(-1, |s| crate::spell::usable::power_cost(d, s, skills, mods))
|
||||
};
|
||||
let player_per_second = |d: &benilla_formats::SpellDisplay| {
|
||||
let level = crate::spell::SpellLevel::Player { me: store, skills };
|
||||
crate::spell::usable::per_second_cost(d, level)
|
||||
};
|
||||
let pet_level =
|
||||
|d: &benilla_formats::SpellDisplay| crate::spell::SpellLevel::Known(pet_skill_level(d));
|
||||
let pet_cost = |d: &benilla_formats::SpellDisplay| {
|
||||
pet.map_or(-1, |p| {
|
||||
let level = pet_level(d);
|
||||
crate::spell::usable::power_cost_at(d, &p.0, level, mods)
|
||||
})
|
||||
};
|
||||
let pet_per_second = |d: &benilla_formats::SpellDisplay| {
|
||||
crate::spell::usable::per_second_cost(d, pet_level(d))
|
||||
};
|
||||
let ctx = TokenContext {
|
||||
durations: &spells.durations,
|
||||
radii: &spells.radii,
|
||||
ranges: Some(&spells.ranges),
|
||||
level: &player_level,
|
||||
lookup: &|id| spells.catalog.get(id),
|
||||
mods: Some(mods),
|
||||
power_cost: &player_cost,
|
||||
power_per_second: &player_per_second,
|
||||
unmodified_points: false,
|
||||
gender: &|| gender,
|
||||
home_area: &|| home_area,
|
||||
// Never read: the text leaves each template to the getter's read of the VM's strings.
|
||||
global: &|_| None,
|
||||
printf: &crate::ui_script::token_printf,
|
||||
};
|
||||
let pet_ctx = TokenContext {
|
||||
level: &pet_skill_level,
|
||||
power_cost: &pet_cost,
|
||||
power_per_second: &pet_per_second,
|
||||
..ctx
|
||||
};
|
||||
// `UNIT_FIELD_SUMMON`'s unit (`0x4d9860`-`0x4d987d`), its book read only as the pet bar's
|
||||
// (`0x60c77a`).
|
||||
let pet_book: Option<BTreeSet<u32>> = store
|
||||
@@ -731,17 +684,23 @@ impl TrainerReads<'_, '_> {
|
||||
race_class: store.map_or((0, 0), |s| s.race_class()),
|
||||
skills: skill_slots.as_deref(),
|
||||
};
|
||||
Some(f(&Resolver {
|
||||
spells: &spells.catalog,
|
||||
skill_lines: &skill_lines.catalog,
|
||||
books: &books,
|
||||
icons: self.icons.as_deref(),
|
||||
items,
|
||||
text: &ServiceText {
|
||||
player: &ctx,
|
||||
pet: &pet_ctx,
|
||||
Some(crate::spell::with_token_contexts(
|
||||
spells,
|
||||
skills,
|
||||
mods,
|
||||
(store, pet),
|
||||
home_area,
|
||||
|(player, pet)| {
|
||||
f(&Resolver {
|
||||
spells: &spells.catalog,
|
||||
skill_lines: &skill_lines.catalog,
|
||||
books: &books,
|
||||
icons: self.icons.as_deref(),
|
||||
items,
|
||||
text: &ServiceText { player, pet },
|
||||
})
|
||||
},
|
||||
}))
|
||||
))
|
||||
}
|
||||
|
||||
/// The window's services resolved for the VM, the header labels read through `get`; `None`
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use super::*;
|
||||
use crate::names::NameCache;
|
||||
use benilla_formats::{
|
||||
ItemDisplay, ItemDisplayCatalog, SpellDisplay, SPELL_ATTR_IS_TRADESKILL,
|
||||
ItemDisplay, ItemDisplayCatalog, SpellDisplay, TokenContext, SPELL_ATTR_IS_TRADESKILL,
|
||||
SPELL_EFFECT_CREATE_ITEM, SPELL_EFFECT_LEARN_PET_SPELL, SPELL_EFFECT_LEARN_SPELL,
|
||||
SPELL_EFFECT_SKILL_STEP,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
//! The craft bindings the stock `Blizzard_CraftUI` window calls, over the recipe snapshot the app
|
||||
//! pushes ([`UiScript::set_craft`]); `DoCraft` and `CloseCraft` queue intents the app drains. The
|
||||
//! window has one action button, `DoCraft(GetCraftSelectionIndex())` (`Blizzard_CraftUI.xml:667`),
|
||||
//! and no Create All, so a craft intent is a bare spell id.
|
||||
//! The craft bindings the stock `Blizzard_CraftUI` window calls: each build reads the open type's
|
||||
//! book from the lent host as it stands ([`CraftBookQuery`]), the getters read what the reference
|
||||
//! reads at the call the same way ([`CraftRecipeQuery`], [`CraftNameQuery`],
|
||||
//! [`CraftDisplayLineQuery`]), a harness pushes a snapshot ([`UiScript::set_craft`]), and the host
|
||||
//! applies the calls `DoCraft` and `CloseCraft` make. The window has one action button,
|
||||
//! `DoCraft(GetCraftSelectionIndex())` (`Blizzard_CraftUI.xml:667`), and no Create All, so a craft
|
||||
//! intent is a bare spell id.
|
||||
//!
|
||||
//! The engine owns the row array (`0x4f60c0`): the recipes in the list's learn order, then a
|
||||
//! header row per group once there are two, sorted by the craft type's comparator; every Lua
|
||||
@@ -11,7 +14,56 @@ use mlua::{Lua, MultiValue, Value};
|
||||
|
||||
use super::binding_abi::{self, number_arg};
|
||||
use super::item_stats::item_link;
|
||||
use super::live::LiveQuery;
|
||||
use super::Model;
|
||||
use super::TooltipText;
|
||||
|
||||
/// The open type's book as the build reads it there (`0x4f60c0`): the player's list of the type
|
||||
/// (`0x5ea330`), each spell's ability row and skill total (`0x60c7c0`, `0x5ea520`), the bags
|
||||
/// (`0x622130`) and the pet as they stand. The lent host answers `Some(None)` for a build that
|
||||
/// finds no player (the lookup `0x468460` at `0x4f60ff`, its miss at `0x4f6109`), which leaves
|
||||
/// past its signal (`0x4f661f`); it declines where it lacks the catalogs, and the build keeps the
|
||||
/// list the VM holds.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct CraftBookQuery;
|
||||
|
||||
impl LiveQuery for CraftBookQuery {
|
||||
type Answer = Option<CraftState>;
|
||||
}
|
||||
|
||||
/// One recipe of the open type as its getters read it at the call: the reagents' carried counts
|
||||
/// (`0x4f76b2`), the totems held (`0x4f7a3c`), the names and icons off the item cache as it
|
||||
/// stands (`0x4f75f2`, `0x4f7a0a`), none asked, the pet bar unit's cost and level
|
||||
/// (`0x4f6fe6`-`0x4f7093`) and the description's parts (`0x4f7b53`, `0x4f7be6`), whose templates
|
||||
/// the getter reads from the VM's strings. `None` declines, where the getter reads the row the
|
||||
/// last build left.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct CraftRecipeQuery(pub u32);
|
||||
|
||||
impl LiveQuery for CraftRecipeQuery {
|
||||
type Answer = CraftRecipe;
|
||||
}
|
||||
|
||||
/// `GetCraftName` at the call (`0x4f6c10`): the name of the spell the player stores in the effect
|
||||
/// slot of craft type `.0` (`0x5ea360` at `0x4f6c3b`, `+0x1e0` at `0x4f6c5f`); `None`, the nil,
|
||||
/// with no player (`0x4f6c30`), no such slot or no such spell (`0x4f6c42`-`0x4f6c57`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct CraftNameQuery(pub u32);
|
||||
|
||||
impl LiveQuery for CraftNameQuery {
|
||||
type Answer = Option<String>;
|
||||
}
|
||||
|
||||
/// `GetCraftDisplaySkillLine` at the call past its type test (`0x4f6ce3`): the line of the first
|
||||
/// spell of the player's type-3 list (`0x4f6cf4`-`0x4f6d21`), its name, and the slot's rank and
|
||||
/// maximum with the permanent bonus (`0x4f6d52`-`0x4f6e17`); `None`, the failure triple
|
||||
/// (`0x4f6e40`), with no player, an empty list, no ability row or no `SkillLine` row.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct CraftDisplayLineQuery;
|
||||
|
||||
impl LiveQuery for CraftDisplayLineQuery {
|
||||
type Answer = Option<(String, u32, u32)>;
|
||||
}
|
||||
|
||||
/// One reagent a recipe consumes (`GetCraftReagentInfo`); name and icon are `None` until the item
|
||||
/// template answer lands.
|
||||
@@ -109,9 +161,10 @@ pub struct CraftRecipe {
|
||||
/// `numAvailable`: the least `floor(have / need)` over the reagents.
|
||||
pub num_available: u32,
|
||||
pub icon: Option<String>,
|
||||
/// `GetCraftDescription`, `$`-tokens substituted by the app; `None` paints a blank line
|
||||
/// (`Blizzard_CraftUI.lua:316`).
|
||||
pub description: Option<String>,
|
||||
/// `GetCraftDescription`'s text, its `$`-tokens expanded by the app and each `GlobalStrings`
|
||||
/// template they name read from the VM at the call (`0x4f7b53`, `0x4f7be6`); `None` paints a
|
||||
/// blank line (`Blizzard_CraftUI.lua:316`).
|
||||
pub description: Option<TooltipText>,
|
||||
/// An `ENCHANT_ITEM` effect (`TARGET_FLAG_ITEM`, `TARGET_FLAG_TRADE_ITEM`): `DoCraft` then arms
|
||||
/// an app-side item pick. No Lua getter reads it.
|
||||
pub needs_item_target: bool,
|
||||
@@ -137,7 +190,7 @@ pub struct CraftRecipe {
|
||||
pub tools_pending: Vec<u32>,
|
||||
}
|
||||
|
||||
/// The open craft window, pushed whole by the app.
|
||||
/// The open craft window's book as a build reads it ([`CraftBookQuery`]), or a harness's push.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct CraftState {
|
||||
/// The window's identity for the app's open detection; `GetCraftName` reads the effect slot
|
||||
@@ -277,7 +330,22 @@ pub(crate) fn build(model: &mut Model) {
|
||||
recount(model);
|
||||
}
|
||||
|
||||
/// The counts a closed window's build zeroes ahead of its open check (`0x4f60d1`-`0x4f60e3`).
|
||||
/// Seat `s` as the list the build refills its rows from, and read the reagent templates the link
|
||||
/// getter reads off the cache: it passes no callback (`0x4f780a`).
|
||||
fn seat(model: &mut Model, s: CraftState) {
|
||||
for id in s
|
||||
.recipes
|
||||
.iter()
|
||||
.flat_map(|r| r.reagents.iter().map(|re| re.item))
|
||||
{
|
||||
if id != 0 && !model.item_templates.contains_key(&id) {
|
||||
model.item_stat_reads.insert(id);
|
||||
}
|
||||
}
|
||||
model.craft = Some(s);
|
||||
}
|
||||
|
||||
/// The counts a build zeroes ahead of its open and player checks (`0x4f60d1`-`0x4f60e3`).
|
||||
fn clear(model: &mut Model) {
|
||||
model.craft_rows.clear();
|
||||
model.craft_headers.clear();
|
||||
@@ -381,14 +449,47 @@ impl super::UiScript {
|
||||
let mut model = self.model_mut();
|
||||
model.craft_open = state.is_some();
|
||||
if let Some(s) = state {
|
||||
model.craft = Some(s);
|
||||
seat(&mut model, s);
|
||||
build(&mut model);
|
||||
}
|
||||
}
|
||||
|
||||
/// Push the names of the spells in the player's four effect slots (`CGPlayer_C+0x1d10`),
|
||||
/// `ToggleCraftWindow`'s open of `craft_type` (`0x4f601c`-`0x4f6036`): the type stored, the
|
||||
/// selection cleared and every group expanded, then the build over `state`, the open type's
|
||||
/// book as the build reads it. With none, as a build that finds no player, the counts are
|
||||
/// zeroed and it leaves before its signal (`0x4f60d1`-`0x4f60e3`, `0x4f6109`). Whether its
|
||||
/// `CRAFT_UPDATE` follows (`0x4f661a`).
|
||||
pub fn open_craft(&mut self, craft_type: u32, state: Option<CraftState>) -> bool {
|
||||
let mut model = self.model_mut();
|
||||
model.craft_open = true;
|
||||
model.craft_selection = 0;
|
||||
model.craft_fold_mask = u32::MAX;
|
||||
match state {
|
||||
Some(s) => {
|
||||
seat(&mut model, s);
|
||||
build(&mut model);
|
||||
true
|
||||
}
|
||||
None => {
|
||||
let c = model.craft.get_or_insert_with(|| CraftState {
|
||||
name: String::new(),
|
||||
display_line: None,
|
||||
rank: 0,
|
||||
max_rank: 0,
|
||||
craft_type,
|
||||
recipes: Vec::new(),
|
||||
});
|
||||
c.craft_type = craft_type;
|
||||
clear(&mut model);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A harness's names of the spells in the player's four effect slots (`CGPlayer_C+0x1d10`),
|
||||
/// which a learn writes by the spell's misc value (`0x5e9e1c`-`0x5e9e36`); `GetCraftName`
|
||||
/// answers the one at the open craft type, slot 0 while none is open.
|
||||
/// answers the one at the open craft type, slot 0 while none is open, when no host answers
|
||||
/// [`CraftNameQuery`].
|
||||
pub fn set_craft_slot_names(&mut self, names: [Option<String>; 4]) {
|
||||
let mut model = self.model_mut();
|
||||
if model.craft_slot_names != names {
|
||||
@@ -396,28 +497,30 @@ impl super::UiScript {
|
||||
}
|
||||
}
|
||||
|
||||
/// The open's resets (`0x4f601c`-`0x4f602c`): the selection cleared and every group expanded,
|
||||
/// then the build (`0x4f6036`).
|
||||
pub fn craft_opened(&mut self) {
|
||||
let mut model = self.model_mut();
|
||||
model.craft_selection = 0;
|
||||
model.craft_fold_mask = u32::MAX;
|
||||
build(&mut model);
|
||||
}
|
||||
|
||||
/// A rebuild of the craft list (`0x4f60c0`), as the bag and item watchers run one on each of
|
||||
/// their runs: while a craft window is open, the state read again where `refresh` brings the
|
||||
/// watcher's change in, and the rows built again. Whether the window is open, for the caller's
|
||||
/// `CRAFT_UPDATE` (`0x4f661a`), signalled whether or not anything changed; a closed window
|
||||
/// zeroes the counts and builds nothing (`0x4f60d1`-`0x4f60e3`).
|
||||
/// their runs: the counts zeroed (`0x4f60d1`-`0x4f60dd`), then while a craft window is open the
|
||||
/// book read again as it stands ([`CraftBookQuery`]; with no host to ask, the VM's copy where
|
||||
/// `refresh` brings the caller's change in) and the rows built again. Whether its
|
||||
/// `CRAFT_UPDATE` follows (`0x4f661a`), signalled whether or not anything changed: a closed
|
||||
/// window (`0x4f60e3`) and a build that finds no player (`0x4f6109`) leave before it.
|
||||
pub fn rebuild_craft(&mut self, refresh: &mut dyn FnMut(&mut CraftState)) -> bool {
|
||||
let mut model = self.model_mut();
|
||||
if !model.craft_open {
|
||||
clear(&mut model);
|
||||
if !self.model_ref().craft_open {
|
||||
clear(&mut self.model_mut());
|
||||
return false;
|
||||
}
|
||||
if let Some(c) = model.craft.as_mut() {
|
||||
refresh(c);
|
||||
let fresh = super::live::ask(&self.lua, &CraftBookQuery);
|
||||
let mut model = self.model_mut();
|
||||
match fresh {
|
||||
Some(Some(s)) => seat(&mut model, s),
|
||||
Some(None) => {
|
||||
clear(&mut model);
|
||||
return false;
|
||||
}
|
||||
None => {
|
||||
if let Some(c) = model.craft.as_mut() {
|
||||
refresh(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
build(&mut model);
|
||||
true
|
||||
@@ -463,6 +566,17 @@ pub(crate) fn recipe(model: &Model, index: usize) -> Option<&CraftRecipe> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The recipe at the 1-based `index` of the last build's rows, its reagents, tools, cost, level
|
||||
/// and description read as they stand at the call ([`CraftRecipeQuery`]); with no host to ask,
|
||||
/// the row's copy. `None` on a header or past the rows.
|
||||
fn recipe_now(lua: &Lua, index: usize) -> Option<CraftRecipe> {
|
||||
let held = {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
recipe(&model, index)?.clone()
|
||||
};
|
||||
Some(super::live::ask(lua, &CraftRecipeQuery(held.spell_id)).unwrap_or(held))
|
||||
}
|
||||
|
||||
/// Whether a 1-based index names a row, a header included (`0xbdcfc0`).
|
||||
pub(crate) fn has_row(model: &Model, index: usize) -> bool {
|
||||
index
|
||||
@@ -509,17 +623,23 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
|
||||
// GetCraftName() (`0x4f6c10`) → the name of the player's effect-slot spell for the open craft
|
||||
// type (`GetEffectSlotSpell 0x5ea360`, the marker `[0xbdcfb8]`, set at `0x4f601c`), type 0 with
|
||||
// no window open; nil with no player, no such slot or no such spell (`0x4f6c74`).
|
||||
// no window open; nil with no player, no such slot or no such spell (`0x4f6c74`). It reads the
|
||||
// player at the call ([`CraftNameQuery`]); with no host to ask, the names a harness pushed.
|
||||
g.set(
|
||||
"GetCraftName",
|
||||
lua.create_function(|lua, ()| {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
let marker = model.open_professions().craft.unwrap_or(0);
|
||||
let name = usize::try_from(marker)
|
||||
.ok()
|
||||
.and_then(|m| model.craft_slot_names.get(m))
|
||||
.and_then(|n| n.as_deref());
|
||||
opt_str(lua, name.map(str::to_string).as_ref())
|
||||
let marker = {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
model.open_professions().craft.unwrap_or(0)
|
||||
};
|
||||
let name = super::live::ask(lua, &CraftNameQuery(marker)).unwrap_or_else(|| {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
usize::try_from(marker)
|
||||
.ok()
|
||||
.and_then(|m| model.craft_slot_names.get(m))
|
||||
.and_then(|n| n.clone())
|
||||
});
|
||||
opt_str(lua, name.as_ref())
|
||||
})?,
|
||||
)?;
|
||||
|
||||
@@ -539,17 +659,29 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
// GetCraftDisplaySkillLine() (`0x4f6cb0`) → name, rank, maxRank, only while the open craft
|
||||
// type is 3, Enchanting (`0x4f6ce3`); any other type, a closed window or a line the first
|
||||
// spell lacks answers nil, 0, 0 (`0x4f6e40`), and the nil hides the stock rank bar
|
||||
// (`Blizzard_CraftUI.lua:108-122`).
|
||||
// (`Blizzard_CraftUI.lua:108-122`). The line and the slot are read at the call
|
||||
// ([`CraftDisplayLineQuery`]); with no host to ask, the snapshot's.
|
||||
g.set(
|
||||
"GetCraftDisplaySkillLine",
|
||||
lua.create_function(|lua, ()| {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
let enchanting = model.open_professions().craft == Some(CRAFT_TYPE_ENCHANTING);
|
||||
let (name, rank, max_rank) = match &model.craft {
|
||||
Some(c) if enchanting && c.display_line.is_some() => {
|
||||
(c.display_line.clone(), c.rank, c.max_rank)
|
||||
}
|
||||
_ => (None, 0, 0),
|
||||
let enchanting = {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
model.open_professions().craft == Some(CRAFT_TYPE_ENCHANTING)
|
||||
};
|
||||
let line = enchanting
|
||||
.then(|| {
|
||||
super::live::ask(lua, &CraftDisplayLineQuery).unwrap_or_else(|| {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
model
|
||||
.craft
|
||||
.as_ref()
|
||||
.and_then(|c| c.display_line.clone().map(|n| (n, c.rank, c.max_rank)))
|
||||
})
|
||||
})
|
||||
.flatten();
|
||||
let (name, rank, max_rank) = match line {
|
||||
Some((n, r, m)) => (Some(n), r, m),
|
||||
None => (None, 0, 0),
|
||||
};
|
||||
Ok(MultiValue::from_vec(vec![
|
||||
opt_str(lua, name.as_ref())?,
|
||||
@@ -622,7 +754,8 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
// A header row answers its line's name, nil, `header`, 0, 1 while its mask bit by its place
|
||||
// in the sorted header array is set or nil while clear (`0x4f6f4f` → `0x4f6b80`, `0x4f6bc1`),
|
||||
// not the collapse word the recount stored before the sort, then 0, 0; a recipe's
|
||||
// `isExpanded` is nil. The cost and the level are the app's, read off the pet bar's unit
|
||||
// `isExpanded` is nil. The name, rank text, bucket and count are the row's (`0x4f6f9b`-
|
||||
// `0x4f6fcf`); the cost and the level are read at the call off the pet bar's unit
|
||||
// (`0xb714a0`) for the spell a pet-learn effect teaches (`0x4f6fe6`-`0x4f7093`).
|
||||
g.set(
|
||||
"GetCraftInfo",
|
||||
@@ -651,7 +784,7 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
Value::Integer(0),
|
||||
]));
|
||||
}
|
||||
let Some(r) = recipe(&model, index) else {
|
||||
let Some(r) = recipe(&model, index).cloned() else {
|
||||
// `0x4f70a4`: nil, nil, nil, 0, nil, 0, 0, a header with no `SkillLine.dbc` row
|
||||
// included (`0x4f6f1a`).
|
||||
return Ok(binding_abi::tuple(&[
|
||||
@@ -664,14 +797,19 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
Some(0),
|
||||
]));
|
||||
};
|
||||
drop(model);
|
||||
let (cost, level) = super::live::ask(lua, &CraftRecipeQuery(r.spell_id))
|
||||
.map_or((r.training_point_cost, r.required_level), |now| {
|
||||
(now.training_point_cost, now.required_level)
|
||||
});
|
||||
Ok(MultiValue::from_vec(vec![
|
||||
Value::String(lua.create_string(&r.name)?),
|
||||
Value::String(lua.create_string(&r.sub_name)?),
|
||||
Value::String(lua.create_string(r.difficulty.as_str())?),
|
||||
Value::Integer(i64::from(r.num_available)),
|
||||
Value::Nil,
|
||||
Value::Integer(i64::from(r.training_point_cost)),
|
||||
Value::Integer(i64::from(r.required_level)),
|
||||
Value::Integer(i64::from(cost)),
|
||||
Value::Integer(i64::from(level)),
|
||||
]))
|
||||
})?,
|
||||
)?;
|
||||
@@ -689,17 +827,18 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
)?;
|
||||
|
||||
// GetCraftDescription(index) → the description or nil, which the stock window tests before
|
||||
// painting (`Blizzard_CraftUI.lua:312`).
|
||||
// painting (`Blizzard_CraftUI.lua:312`). The host expands the tokens as they stand at the call
|
||||
// ([`CraftRecipeQuery`]); each template they name is read from the VM's strings here, as the
|
||||
// expander reads them (`0x5075f0`).
|
||||
g.set(
|
||||
"GetCraftDescription",
|
||||
lua.create_function(|lua, index: Value| {
|
||||
// `is-number` else `Usage: GetCraftDescription(index)` (`0x84d500`, `0x4f7aac`).
|
||||
let index = binding_abi::index_arg(lua, index, "Usage: GetCraftDescription(index)")?;
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
opt_str(
|
||||
lua,
|
||||
recipe(&model, index).and_then(|r| r.description.as_ref()),
|
||||
)
|
||||
let text = recipe_now(lua, index)
|
||||
.and_then(|r| r.description)
|
||||
.map(|t| t.text(crate::strings::Strings::Vm(lua)));
|
||||
opt_str(lua, text.as_ref())
|
||||
})?,
|
||||
)?;
|
||||
|
||||
@@ -731,13 +870,12 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
reagent_index,
|
||||
"Usage: GetCraftReagentInfo(index, reagentIndex)",
|
||||
)?;
|
||||
let reagent = {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
recipe(&model, index).and_then(|r| {
|
||||
let n = reagent_index.checked_sub(1)?;
|
||||
Some((r.reagents.get(n)?.clone(), r.spell_id))
|
||||
})
|
||||
};
|
||||
// The name and icon off the item cache and the carried count, read at the call
|
||||
// (`0x4f75f2`, `0x4f76b2`).
|
||||
let reagent = recipe_now(lua, index).and_then(|r| {
|
||||
let n = reagent_index.checked_sub(1)?;
|
||||
Some((r.reagents.get(n)?.clone(), r.spell_id))
|
||||
});
|
||||
let Some((reagent, spell_id)) = reagent else {
|
||||
return Ok(binding_abi::tuple(&[None; 4]));
|
||||
};
|
||||
@@ -761,12 +899,12 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
lua.create_function(|lua, index: Value| {
|
||||
// `is-number` else `Usage: GetCraftSpellFocus(index)` (`0x84d4dc`, `0x4f78db`).
|
||||
let index = binding_abi::index_arg(lua, index, "Usage: GetCraftSpellFocus(index)")?;
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
let Some(r) = recipe(&model, index) else {
|
||||
// The totems' names off the item cache and whether the bags hold each, read at the
|
||||
// call (`0x4f7a0a`, `0x4f7a3c`).
|
||||
let Some(r) = recipe_now(lua, index) else {
|
||||
return Ok(MultiValue::new());
|
||||
};
|
||||
let (tools, pending, spell_id) = (r.tools.clone(), r.tools_pending.clone(), r.spell_id);
|
||||
drop(model);
|
||||
let (tools, pending, spell_id) = (r.tools, r.tools_pending, r.spell_id);
|
||||
// Each totem in flight is asked with the callback `0x4f7710` inside the call
|
||||
// (`0x4f79f2`).
|
||||
for entry in pending {
|
||||
@@ -932,7 +1070,7 @@ mod tests {
|
||||
difficulty,
|
||||
num_available,
|
||||
icon: Some(format!("Interface\\Icons\\Spell_{spell_id}")),
|
||||
description: Some(format!("{name} description.")),
|
||||
description: Some(format!("{name} description.").into()),
|
||||
needs_item_target: true,
|
||||
reagents: vec![CraftReagent {
|
||||
item: 10940,
|
||||
@@ -1358,7 +1496,8 @@ mod tests {
|
||||
assert_eq!(heard::take(&s), ["CRAFT_UPDATE 6"]);
|
||||
s.run("CollapseCraftSkillLine(0)").unwrap();
|
||||
assert_eq!(heard::take(&s), ["CRAFT_UPDATE 2"]);
|
||||
s.craft_opened();
|
||||
let held = s.model_ref().craft.clone();
|
||||
assert!(s.open_craft(CRAFT_TYPE_BEAST_TRAINING, held));
|
||||
assert_eq!(s.eval::<i64>("return GetNumCrafts()").unwrap(), 6);
|
||||
s.run("CollapseCraftSkillLine(-1) ExpandCraftSkillLine(0)")
|
||||
.unwrap();
|
||||
|
||||
@@ -290,7 +290,10 @@ pub use container::{
|
||||
PendingWrap, PetitionSlotView, RandomPropertyView, UiCursorMode, UseArm, UseFork,
|
||||
};
|
||||
pub use cooldown_read::{CooldownQuery, CooldownTriple};
|
||||
pub use craft::{CraftCall, CraftDifficulty, CraftReagent, CraftRecipe, CraftState, CraftTooltip};
|
||||
pub use craft::{
|
||||
CraftBookQuery, CraftCall, CraftDifficulty, CraftDisplayLineQuery, CraftNameQuery,
|
||||
CraftReagent, CraftRecipe, CraftRecipeQuery, CraftState, CraftTooltip,
|
||||
};
|
||||
pub use cursor::equip::{AutoEquip, BIND_WHEN_EQUIPPED};
|
||||
pub use cursor::money::coin_icon;
|
||||
pub use cursor::swap::Swap;
|
||||
|
||||
+4
-4
@@ -754,8 +754,8 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
|
||||
- The reference's `set` registers an unknown name as a new category-5 record (`0x63d569`-`0x63d582`); benilla refuses it, because nothing would read the row and `config.toml` keeps an unknown key anyway. ([`src/script/console_exec.rs:120`](../crates/benilla-ui/src/script/console_exec.rs#L120))
|
||||
- A row the session owns (an env lever) is passed, because the env chose its value for this run and the file never holds it, so a reset would undo the lever and save nothing. ([`src/script/console_exec.rs:204`](../crates/benilla-ui/src/script/console_exec.rs#L204))
|
||||
- A row index the list no longer holds buys nothing and drops, where this path reads through a null row (`0x4f9f35`). ([`src/script/container.rs:753`](../crates/benilla-ui/src/script/container.rs#L753))
|
||||
- A last `spell_id` key breaks the remaining ties (Charge's six ranks all have `spellLevel` 0), because the reference leaves them to its qsort over an array benilla does not reproduce; ascending id is ascending rank in every 1.12 pet-ability family. ([`src/script/craft.rs:202`](../crates/benilla-ui/src/script/craft.rs#L202))
|
||||
- The reference reads past the table unbounded (`0x4f6c90`), so type 5 would answer "CloseCraft"; no shipped opener carries a type past 3, and benilla answers nil rather than read past it. ([`src/script/craft.rs:788`](../crates/benilla-ui/src/script/craft.rs#L788))
|
||||
- A last `spell_id` key breaks the remaining ties (Charge's six ranks all have `spellLevel` 0), because the reference leaves them to its qsort over an array benilla does not reproduce; ascending id is ascending rank in every 1.12 pet-ability family. ([`src/script/craft.rs:255`](../crates/benilla-ui/src/script/craft.rs#L255))
|
||||
- The reference reads past the table unbounded (`0x4f6c90`), so type 5 would answer "CloseCraft"; no shipped opener carries a type past 3, and benilla answers nil rather than read past it. ([`src/script/craft.rs:926`](../crates/benilla-ui/src/script/craft.rs#L926))
|
||||
- On `Terrain` the reference keeps a spell, action, macro or pet action on the left button; we clear them, because otherwise a spell has no left-click way off the cursor. ([`src/script/cursor.rs:744`](../crates/benilla-ui/src/script/cursor.rs#L744))
|
||||
- Every lock lifts here, bag contents included. The reference's walk of a bag's contents indexes the bag by its own player-array index (`0x495528`, `0x495535`), at least 19, past a bag's slots in every case but the biggest bags, so it normally unlocks none of them; a lock it strands lasts until the item's seat or stack moves, which this does not copy. ([`src/script/cursor.rs:953`](../crates/benilla-ui/src/script/cursor.rs#L953))
|
||||
- Returns nothing. The handler ends `mov eax,1` with nothing pushed (`0x4895bc`), so Lua 5.0 hands back the stack top, the last argument or the function itself: an accident of the handler, not an API, and copying a stack-top leak would copy a bug. ([`src/script/cursor.rs:1242`](../crates/benilla-ui/src/script/cursor.rs#L1242))
|
||||
@@ -791,8 +791,8 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
|
||||
- A listing that finds no icon stays empty, to be listed again on the next ask, where the reference's dedup then reads below its null list (`0x4f0134`-`0x4f0145`) and faults. ([`src/script/macros.rs:551`](../crates/benilla-ui/src/script/macros.rs#L551))
|
||||
- Each line is trimmed, because the reference sends an indented `" /say hi"` as plain chat, never as the command meant. ([`src/script/macros/bind.rs:30`](../crates/benilla-ui/src/script/macros/bind.rs#L30))
|
||||
- The `/cast` argument is trimmed, because the reference binds `/cast Fireball` (two spaces) to a name that never resolves. ([`src/script/macros/bind.rs:50`](../crates/benilla-ui/src/script/macros/bind.rs#L50))
|
||||
- The client's Lua has no such bound, as nothing sets a hook (`lua_sethook`, `0x6fba40`, has no caller and no pointer to it), so a load that never ends hangs it. ([`src/script/mod.rs:934`](../crates/benilla-ui/src/script/mod.rs#L934))
|
||||
- The reference sets the cells only when glue or the interface is built, `0x41ad10` from `0x46a828` (`0x46a7b0`) and `0x48fe2b` (`0x48fbf0`), and a resize reaches them only through the rebuild it asks for. ([`src/script/mod.rs:1022`](../crates/benilla-ui/src/script/mod.rs#L1022))
|
||||
- The client's Lua has no such bound, as nothing sets a hook (`lua_sethook`, `0x6fba40`, has no caller and no pointer to it), so a load that never ends hangs it. ([`src/script/mod.rs:937`](../crates/benilla-ui/src/script/mod.rs#L937))
|
||||
- The reference sets the cells only when glue or the interface is built, `0x41ad10` from `0x46a828` (`0x46a7b0`) and `0x48fe2b` (`0x48fbf0`), and a resize reaches them only through the rebuild it asks for. ([`src/script/mod.rs:1025`](../crates/benilla-ui/src/script/mod.rs#L1025))
|
||||
- A path that does not resolve is stored, where the reference raises `Invalid model file: %s` (`0x878b44`), because the file loads asynchronously here and the call cannot know yet. ([`src/script/modelframe.rs:333`](../crates/benilla-ui/src/script/modelframe.rs#L333))
|
||||
- The reference's free list is FIFO; either keeps every index stable, all an addon can observe. ([`src/script/nameplate.rs:526`](../crates/benilla-ui/src/script/nameplate.rs#L526))
|
||||
- The reference adds this rim over the bar; we brighten the bar (`LIT_BOOST`), because the rim reads as hard edge lines in our linear-blending pipeline. ([`src/script/nameplate.rs:991`](../crates/benilla-ui/src/script/nameplate.rs#L991))
|
||||
|
||||
Reference in New Issue
Block a user