GM tickets, cursor casts, hover, gossip and plate flashes follow 1.12.1 (#2685)
What differed from 1.12.1: - **Ticket results** show their lines: create and update codes 1, 3 and 5, a fetch status of 0 and a failed delete (`0x5e4432`, `0x5e44ff`). Update text is cut at 1999 bytes (`0x5efacd`). - **UPDATE_TICKET** clamps a negative age to 0 and passes the client's NaN and denormal bits for the no-ticket answer. Arguments the client fills from stack residue are a `Deviation:`. - **Ticket status** 2 sends the no-ticket answer; status 3 fires GMSURVEY_DISPLAY (`0x5e78f0`). - **Casting** reads the cursor first: a held spell goes through pickup, and anything else is cleared (`0x4b3310`). - **Hover:** Disable fires OnLeave first, Enable fires OnEnter after (`0x779160`). - **Gossip:** leaving the world resets the gossip lists (`0x4e1f60`). - **Nameplates:** a name flashes red for 5 seconds on damage (`0x7cba77`). Each fix has a test. Fixes #2462 Fixes #2472 Fixes #2476 Fixes #2478 Fixes #2481 Fixes #2484 Fixes #2536 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -870,17 +870,26 @@ fn spell_cast_line(
|
||||
/// takes absorb and resist trailers, and on you raises [`combat::damage_word`] (`0x62ac74`). Then,
|
||||
/// for the active player (`0x624f83`), `UNIT_COMBAT` `WOUND` in the type's school, marked `0x20`
|
||||
/// for an absorb and `0x40` for a resist (`0x624f8c`-`0x624fc4`).
|
||||
///
|
||||
/// A victim the client holds as a unit, within its class's range (the one-sided test, strictly
|
||||
/// inside), of a type below 6 (`0x62aae7`) flashes its nameplate (`0x62abac`) ahead of the line;
|
||||
/// the answer is that victim.
|
||||
pub(super) fn environmental_damage_log(
|
||||
e: EnvironmentalDamageLog,
|
||||
ctx: &ChatCtx,
|
||||
stores: &impl Stores,
|
||||
poses: &impl Poses,
|
||||
log: &ChatLog,
|
||||
) {
|
||||
) -> Option<u64> {
|
||||
if e.damage == 0 && e.absorb == 0 && e.resist == 0 {
|
||||
return;
|
||||
return None;
|
||||
}
|
||||
let victim = ctx.classify(e.victim, stores);
|
||||
let flash = (e.victim != 0
|
||||
&& usize::from(e.damage_type) < ENV_DAMAGE_SCHOOLS.len()
|
||||
&& ctx.holds_unit(e.victim, stores)
|
||||
&& ctx.in_range(e.victim, victim, poses))
|
||||
.then_some(e.victim);
|
||||
let kind = combat::combat_kind(victim, victim, false);
|
||||
if let (Some(family), Some(kind)) = (combat::env_family(e.damage_type), kind) {
|
||||
queue_worded(
|
||||
@@ -910,6 +919,7 @@ pub(super) fn environmental_damage_log(
|
||||
let marks = super::feedback::hit_flags(false, e.absorb, e.resist, 0);
|
||||
super::feedback::wound(log, e.victim, e.damage, marks, school);
|
||||
}
|
||||
flash
|
||||
}
|
||||
|
||||
/// The school of each environmental damage type 0 to 5, the table `0x809274` that `0x624fb3`
|
||||
|
||||
@@ -14,14 +14,16 @@ use crate::ui_chat::ChatLog;
|
||||
/// `SMSG_SPELLNONMELEEDAMAGELOG` (`0x5e85e0`): the line (`0x5e87de`), then, for a spell with a
|
||||
/// record and no `Attributes & 0x100` (`0x5e87e3`-`0x5e87f4`), `UNIT_COMBAT` `WOUND` on the target
|
||||
/// (`0x5e883f`) with the crit and partial flags, or none for split damage (`0x5e872d`-`0x5e876a`).
|
||||
///
|
||||
/// Returns the victim whose nameplate the direct hit flashes (`0x62cd80` at `0x62ce43`).
|
||||
pub(in crate::combat_log) fn spell_damage_log(
|
||||
s: SpellDamageLog,
|
||||
ctx: &ChatCtx,
|
||||
stores: &impl Stores,
|
||||
poses: &impl Poses,
|
||||
log: &ChatLog,
|
||||
) {
|
||||
spell_damage_line(&s, ctx, stores, poses, log);
|
||||
) -> Option<u64> {
|
||||
let flash = spell_damage_line(&s, ctx, stores, poses, log);
|
||||
if combat::feedback_spell(ctx.spells, s.spell_id).is_some() {
|
||||
let flags = if s.hit_info & SPELL_HIT_TYPE_SPLIT != 0 {
|
||||
0
|
||||
@@ -30,25 +32,24 @@ pub(in crate::combat_log) fn spell_damage_log(
|
||||
};
|
||||
feedback::wound(log, s.target, s.damage, flags, u32::from(s.school));
|
||||
}
|
||||
flash
|
||||
}
|
||||
|
||||
/// vmangos `SPELL_HIT_TYPE_SPLIT`, the split-damage bit of the packet's hit info.
|
||||
const SPELL_HIT_TYPE_SPLIT: u32 = 0x8;
|
||||
|
||||
/// The spell-damage line: split damage, then a periodic hit, then a direct one, each its own
|
||||
/// formatter.
|
||||
/// formatter. Answers the victim a direct hit flashes.
|
||||
fn spell_damage_line(
|
||||
s: &SpellDamageLog,
|
||||
ctx: &ChatCtx,
|
||||
stores: &impl Stores,
|
||||
poses: &impl Poses,
|
||||
log: &ChatLog,
|
||||
) {
|
||||
) -> Option<u64> {
|
||||
let attacker = ctx.classify(s.attacker, stores);
|
||||
let victim = ctx.classify(s.target, stores);
|
||||
let Some(spell) = ctx.spell_name(s.spell_id) else {
|
||||
return;
|
||||
};
|
||||
let spell = ctx.spell_name(s.spell_id)?;
|
||||
|
||||
// Split damage (`hit_info & 8`, to `0x62de60`) is tested first, before the periodic split: it
|
||||
// reads "%s's %s causes %s %d damage.", has no `…SELFSELF` key and no trailers, and words the
|
||||
@@ -57,10 +58,8 @@ fn spell_damage_line(
|
||||
// table (`0x626be0`, from `0x62df69` and `0x62dfc4`).
|
||||
if s.hit_info & SPELL_HIT_TYPE_SPLIT != 0 {
|
||||
let buff = attacker == UnitClass::Me && victim != UnitClass::Me;
|
||||
let Some(kind) = combat::spell_kind(attacker, victim, buff) else {
|
||||
return;
|
||||
};
|
||||
return queue_worded(
|
||||
let kind = combat::spell_kind(attacker, victim, buff)?;
|
||||
queue_worded(
|
||||
log,
|
||||
ctx,
|
||||
poses,
|
||||
@@ -75,54 +74,61 @@ fn spell_damage_line(
|
||||
},
|
||||
to_me(victim, LineWord::with("SPLIT_DAMAGE", s.damage)),
|
||||
);
|
||||
return None;
|
||||
}
|
||||
if s.periodic {
|
||||
// A chat-only `CombatLogPeriodicSpells` read (`0x62d9ae` in `0x62d9a0`): it skips the line
|
||||
// emit `0x628100` and nothing else, so the floats still fire.
|
||||
if !ctx.periodic {
|
||||
return;
|
||||
if ctx.periodic {
|
||||
periodic_damage(
|
||||
log,
|
||||
ctx,
|
||||
poses,
|
||||
&spell,
|
||||
(s.attacker, attacker),
|
||||
(s.target, victim),
|
||||
PeriodicHit {
|
||||
damage: s.damage,
|
||||
school: s.school,
|
||||
absorbed: s.absorb,
|
||||
resisted: s.resist,
|
||||
},
|
||||
);
|
||||
}
|
||||
return periodic_damage(
|
||||
log,
|
||||
ctx,
|
||||
poses,
|
||||
&spell,
|
||||
(s.attacker, attacker),
|
||||
(s.target, victim),
|
||||
PeriodicHit {
|
||||
damage: s.damage,
|
||||
school: s.school,
|
||||
absorbed: s.absorb,
|
||||
resisted: s.resist,
|
||||
},
|
||||
);
|
||||
return None;
|
||||
}
|
||||
direct_damage(
|
||||
log,
|
||||
ctx,
|
||||
stores,
|
||||
poses,
|
||||
&spell,
|
||||
s.spell_id,
|
||||
(s.attacker, attacker),
|
||||
(s.target, victim),
|
||||
s,
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
/// `0x62cd80`, a direct spell hit. Nothing through is worded as the reason, tested absorbed
|
||||
/// (`0x6285b0`), blocked (the miss formatter with code 5, `0x62cec7`), then resisted
|
||||
/// (`0x628720`); nothing at all writes no line. Damage through takes `SPELLLOG` and its crit and
|
||||
/// school forms, with trailers, and [`combat::spell_hit_word`].
|
||||
///
|
||||
/// Past the range gate (`0x626630`, either endpoint) a nonzero damage flashes the target's
|
||||
/// nameplate (`0x62ce3c`-`0x62ce43`) before any word is chosen; the answer is that target, a unit
|
||||
/// the client holds.
|
||||
fn direct_damage(
|
||||
log: &ChatLog,
|
||||
ctx: &ChatCtx,
|
||||
stores: &impl Stores,
|
||||
poses: &impl Poses,
|
||||
spell: &str,
|
||||
spell_id: u32,
|
||||
caster: (u64, UnitClass),
|
||||
target: (u64, UnitClass),
|
||||
s: &SpellDamageLog,
|
||||
) {
|
||||
) -> Option<u64> {
|
||||
let school = Some(s.school);
|
||||
if s.damage == 0 {
|
||||
if s.absorb != 0 {
|
||||
@@ -134,10 +140,14 @@ fn direct_damage(
|
||||
} else if s.resist != 0 {
|
||||
resisted_line(log, ctx, poses, spell, caster, target, school, false);
|
||||
}
|
||||
return;
|
||||
return None;
|
||||
}
|
||||
let flash = (ctx.in_range(caster.0, caster.1, poses)
|
||||
|| ctx.in_range(target.0, target.1, poses))
|
||||
.then_some(target.0)
|
||||
.filter(|&guid| ctx.holds_unit(guid, stores));
|
||||
let Some(kind) = combat::spell_kind(caster.1, target.1, false) else {
|
||||
return;
|
||||
return flash;
|
||||
};
|
||||
// `SPELL_HIT_TYPE_CRIT` (vmangos `SpellDefines.h:179`).
|
||||
let crit = s.hit_info & 0x2 != 0;
|
||||
@@ -172,6 +182,7 @@ fn direct_damage(
|
||||
fills,
|
||||
to_me(target.1, word),
|
||||
);
|
||||
flash
|
||||
}
|
||||
|
||||
/// One periodic damage tick's figures, as `0x628100` takes them.
|
||||
|
||||
@@ -271,17 +271,17 @@ mod emitters {
|
||||
|
||||
/// The lines and `UNIT_COMBAT`s `emit` parks, in queue order
|
||||
/// ([`ChatLog::pending_combat_order`]).
|
||||
fn order(
|
||||
fn order<R>(
|
||||
&self,
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &NoPoses, &ChatLog),
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &NoPoses, &ChatLog) -> R,
|
||||
) -> Vec<String> {
|
||||
self.run(emit).pending_combat_order()
|
||||
}
|
||||
|
||||
/// The `UNIT_COMBAT`s `emit` parks, as `(guid, action, descriptor, amount)`.
|
||||
fn flashes(
|
||||
fn flashes<R>(
|
||||
&self,
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &NoPoses, &ChatLog),
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &NoPoses, &ChatLog) -> R,
|
||||
) -> Vec<(u64, &'static str, &'static str, u32)> {
|
||||
self.run(emit)
|
||||
.pending_unit_combat()
|
||||
@@ -291,26 +291,26 @@ mod emitters {
|
||||
}
|
||||
|
||||
/// The lines `emit` parks, with their words.
|
||||
fn lines(
|
||||
fn lines<R>(
|
||||
&self,
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &NoPoses, &ChatLog),
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &NoPoses, &ChatLog) -> R,
|
||||
) -> Vec<PendingCombat> {
|
||||
self.run(emit).pending_combat()
|
||||
}
|
||||
|
||||
/// The log `emit` leaves.
|
||||
fn run(
|
||||
fn run<R>(
|
||||
&self,
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &NoPoses, &ChatLog),
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &NoPoses, &ChatLog) -> R,
|
||||
) -> ChatLog {
|
||||
self.run_posed(&NoPoses, emit)
|
||||
}
|
||||
|
||||
/// [`Self::run`] with the units at `poses`.
|
||||
fn run_posed<P: Poses>(
|
||||
fn run_posed<P: Poses, R>(
|
||||
&self,
|
||||
poses: &P,
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &P, &ChatLog),
|
||||
emit: impl FnOnce(&ChatCtx, &HashMap<Entity, ObjectStore>, &P, &ChatLog) -> R,
|
||||
) -> ChatLog {
|
||||
let (self_guid, reputations, ranges) = (
|
||||
SelfGuid(Some(ME)),
|
||||
@@ -333,7 +333,7 @@ mod emitters {
|
||||
periodic: true,
|
||||
};
|
||||
let mut log = ChatLog::default();
|
||||
emit(&ctx, &self.stores, poses, &mut log);
|
||||
let _ = emit(&ctx, &self.stores, poses, &mut log);
|
||||
log
|
||||
}
|
||||
}
|
||||
@@ -491,6 +491,49 @@ mod emitters {
|
||||
assert_eq!(words(&lines), [Some(LineWord::pair("ABSORB", 300, 50))]);
|
||||
}
|
||||
|
||||
/// `0x62cd80` flashes the target's nameplate (`0x62ce43`) for a direct hit with damage through
|
||||
/// and no other: not a zero-damage one, not split damage (`0x62de60`), not a periodic tick
|
||||
/// (`0x628100`), not a target the client does not hold as a unit.
|
||||
#[test]
|
||||
fn only_a_direct_hit_with_damage_flashes_the_targets_plate() {
|
||||
let flash = |s: SpellDamageLog| {
|
||||
let mut flash = None;
|
||||
Bench::new().run(|ctx, st, po, log| {
|
||||
flash = super::super::spell_damage_log(s, ctx, st, po, log);
|
||||
});
|
||||
flash
|
||||
};
|
||||
assert_eq!(flash(spell_hit(300, 0, 0, 0)), Some(ME));
|
||||
assert_eq!(
|
||||
flash(SpellDamageLog {
|
||||
target: MOB,
|
||||
attacker: ME,
|
||||
..spell_hit(300, 50, 20, 10)
|
||||
}),
|
||||
Some(MOB),
|
||||
"the damage through is what counts, not the trailers"
|
||||
);
|
||||
assert_eq!(flash(spell_hit(0, 50, 0, 0)), None, "absorbed whole");
|
||||
assert_eq!(flash(spell_hit(0, 0, 0, 0)), None);
|
||||
for (periodic, hit_info) in [(true, 0), (false, 0x8), (true, 0x8)] {
|
||||
let s = SpellDamageLog {
|
||||
periodic,
|
||||
hit_info,
|
||||
..spell_hit(300, 0, 0, 0)
|
||||
};
|
||||
assert_eq!(
|
||||
flash(s),
|
||||
None,
|
||||
"periodic {periodic}, hit info {hit_info:#x}"
|
||||
);
|
||||
}
|
||||
let stranger = SpellDamageLog {
|
||||
target: 0x99,
|
||||
..spell_hit(300, 0, 0, 0)
|
||||
};
|
||||
assert_eq!(flash(stranger), None, "a target not held as a unit");
|
||||
}
|
||||
|
||||
fn periodic(ticks: Vec<PeriodicTick>) -> Vec<PendingCombat> {
|
||||
periodic_of(FIREBALL, ticks)
|
||||
}
|
||||
|
||||
@@ -155,6 +155,51 @@ fn env_lines(e: EnvironmentalDamageLog) -> Vec<PendingCombat> {
|
||||
})
|
||||
}
|
||||
|
||||
/// `0x62aac0` flashes the victim's nameplate (`0x62abac`) for a type below 6, a victim held as a
|
||||
/// unit and strictly inside its class's range of you (`0x62ab97`-`0x62aba4`, a creature's 30
|
||||
/// yards), ahead of the line; the zero hit `0x624f4c` stops first.
|
||||
#[test]
|
||||
fn environmental_damage_flashes_the_victims_plate_inside_its_range() {
|
||||
let flash = |e: EnvironmentalDamageLog, mob_yards: f32| {
|
||||
let bench = Bench::new();
|
||||
let at = super::At(std::collections::HashMap::from([
|
||||
(bench.index.0[&ME], bevy::prelude::Vec3::ZERO),
|
||||
(
|
||||
bench.index.0[&MOB],
|
||||
bevy::prelude::Vec3::new(mob_yards, 0.0, 0.0),
|
||||
),
|
||||
]));
|
||||
let mut flash = None;
|
||||
bench.run_posed(&at, |ctx, st, po, log| {
|
||||
flash = super::super::super::environmental_damage_log(e, ctx, st, po, log);
|
||||
});
|
||||
flash
|
||||
};
|
||||
assert_eq!(flash(environment(MOB, 2, 245, 0, 0), 20.0), Some(MOB));
|
||||
assert_eq!(
|
||||
flash(environment(MOB, 2, 245, 0, 0), 40.0),
|
||||
None,
|
||||
"past a creature's 30 yards"
|
||||
);
|
||||
assert_eq!(flash(environment(ME, 2, 245, 0, 0), 20.0), Some(ME));
|
||||
assert_eq!(
|
||||
flash(environment(MOB, 0, 0, 12, 0), 20.0),
|
||||
Some(MOB),
|
||||
"an absorbed fall still flashes"
|
||||
);
|
||||
assert_eq!(flash(environment(MOB, 6, 245, 0, 0), 20.0), None, "type 6");
|
||||
assert_eq!(
|
||||
flash(environment(MOB, 2, 0, 0, 0), 20.0),
|
||||
None,
|
||||
"a zero hit"
|
||||
);
|
||||
assert_eq!(
|
||||
flash(environment(0x99, 2, 245, 0, 0), 20.0),
|
||||
None,
|
||||
"a victim not held as a unit"
|
||||
);
|
||||
}
|
||||
|
||||
/// `0x62aac0` raises its word when the victim is you (`0x62ac74`): `RESIST` with the damage and a
|
||||
/// resisted amount above 0 (`0x62ac7e`), else `ABSORB` with an absorbed one (`0x62ac99`), else
|
||||
/// `DAMAGE` (`0x62acad`).
|
||||
|
||||
@@ -24,6 +24,7 @@ use crate::net::{
|
||||
};
|
||||
use crate::ui_chat::combat::{CombatLogRanges, LogPeriodicSpells};
|
||||
use crate::ui_chat::ChatLog;
|
||||
use crate::vplates::PlateFlashes;
|
||||
|
||||
pub(crate) mod chat;
|
||||
#[cfg(test)]
|
||||
@@ -132,6 +133,8 @@ impl Plugin for CombatLogPlugin {
|
||||
.net_handler(K::PvpCredit, on_pvp_credit)
|
||||
// Written by the missile flight; declared here too, as registering is idempotent.
|
||||
.add_message::<MissileMiss>()
|
||||
// Taken by the plate driver; declared here too, as registering is idempotent.
|
||||
.init_resource::<PlateFlashes>()
|
||||
// After the flight that writes the arrivals (`entities::move_missiles`), so the
|
||||
// flash and the line queue together, in `0x61dd50`'s order, the frame the missile
|
||||
// lands. The flight runs after the frame's feeds (the sheath request it follows is
|
||||
@@ -155,10 +158,17 @@ fn on_attacker_state(In(ev): In<SessionEvent>, c: Ctx, l: Sinks) {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_spell_damage_log(In(ev): In<SessionEvent>, c: Ctx, mut l: Sinks) {
|
||||
fn on_spell_damage_log(
|
||||
In(ev): In<SessionEvent>,
|
||||
c: Ctx,
|
||||
mut l: Sinks,
|
||||
mut flashes: ResMut<PlateFlashes>,
|
||||
) {
|
||||
if let SessionEvent::SpellDamageLog(s) = ev {
|
||||
let ctx = c.ctx();
|
||||
chat::spell_damage_log(s, &ctx, &l.stores, &l.poses, &l.log);
|
||||
if let Some(victim) = chat::spell_damage_log(s, &ctx, &l.stores, &l.poses, &l.log) {
|
||||
flashes.0.push(victim);
|
||||
}
|
||||
text::spell_damage_log(
|
||||
s,
|
||||
&c.index,
|
||||
@@ -402,10 +412,17 @@ fn on_spell_log_execute(In(ev): In<SessionEvent>, c: Ctx, caches: LockCaches, l:
|
||||
}
|
||||
}
|
||||
|
||||
fn on_environmental_damage_log(In(ev): In<SessionEvent>, c: Ctx, l: Sinks) {
|
||||
fn on_environmental_damage_log(
|
||||
In(ev): In<SessionEvent>,
|
||||
c: Ctx,
|
||||
l: Sinks,
|
||||
mut flashes: ResMut<PlateFlashes>,
|
||||
) {
|
||||
if let SessionEvent::EnvironmentalDamageLog(e) = ev {
|
||||
let ctx = c.ctx();
|
||||
chat::environmental_damage_log(e, &ctx, &l.stores, &l.poses, &l.log);
|
||||
if let Some(victim) = chat::environmental_damage_log(e, &ctx, &l.stores, &l.poses, &l.log) {
|
||||
flashes.0.push(victim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2052,6 +2052,8 @@ pub(crate) mod schedule_tests {
|
||||
"`pending` holds only the VM's own `Screenshot()` asks, and the take spawns a capture, publishing nothing"),
|
||||
("screenshot.rs", "report_captures", Because::FilledByVm,
|
||||
"the outcome chain starts with the VM's own `Screenshot()` call"),
|
||||
("vplates.rs", "drive_vplates", Because::Deliberate,
|
||||
"its take is the hits queued for plates: a hit before the interface is up has no plate to flash, since a plate exists only once this driver has bound it under a loaded interface, so a dropped one loses nothing"),
|
||||
("target/click.rs", "select_on_plate_click", Because::FilledByVm,
|
||||
"filled only by a nameplate frame's click, which a frameless VM has no plate to make"),
|
||||
("ui_action/cooldown_lane.rs", "fire_cooldowns", Because::Deliberate,
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
//! (`GMTicketHandler.cpp:91,106-113`), and a third `CMSG_GMTICKET_UPDATETEXT` in one world tick
|
||||
//! trips its anti-flood kick (`WorldSession.cpp:1316-1342`).
|
||||
//!
|
||||
//! `GMSURVEY_DISPLAY` is not fired: vmangos never sends its trigger, `SMSG_GM_TICKET_STATUS_UPDATE`
|
||||
//! status 3, and the survey window (`Blizzard_GMSurveyUI`) is not built.
|
||||
//! `SMSG_GM_TICKET_STATUS_UPDATE` is cmangos's; vmangos never sends it. Its status 2 fires the
|
||||
//! no-ticket `UPDATE_TICKET` and status 3 `GMSURVEY_DISPLAY`, which `HelpFrame` hears
|
||||
//! (`HelpFrame.xml:744`, `HelpFrame.lua:391`).
|
||||
|
||||
use benilla_ui::script::{GmTicketIntent, GmTicketWrite, ScriptValue, UnservedSend};
|
||||
use bevy::prelude::*;
|
||||
@@ -18,6 +19,7 @@ use benilla_assets::coords::bevy_to_wow;
|
||||
|
||||
use crate::net::{ClientCommand, NetCommands};
|
||||
use crate::player::Player;
|
||||
use crate::ui_action::{UiError, UiErrorKeys};
|
||||
use crate::ui_dialog_verbs::DialogLane;
|
||||
use crate::ui_script::{UiFeed, VmMemo};
|
||||
|
||||
@@ -90,19 +92,31 @@ fn feed_gm_ticket(
|
||||
}
|
||||
|
||||
/// `SMSG_GMTICKET_GETTICKET`'s `UPDATE_TICKET` (`0x5e4527`), fired for every answer, an unchanged
|
||||
/// one too, as the window re-polls `GetGMTicket()` every 10 minutes.
|
||||
fn ticket_answer(lane: &mut DialogLane, ticket: Option<&benilla_protocol::messages::GmTicket>) {
|
||||
/// one too, as the window re-polls `GetGMTicket()` every 10 minutes. Status 0 shows
|
||||
/// `ERR_TICKET_DB_ERROR` first (`0x5e44fb`-`0x5e4509`), then the no-ticket answer like any other
|
||||
/// status but 6.
|
||||
fn ticket_answer(
|
||||
lane: &mut DialogLane,
|
||||
errors: &UiErrorKeys,
|
||||
status: u32,
|
||||
ticket: Option<&benilla_protocol::messages::GmTicket>,
|
||||
) {
|
||||
if status == 0 {
|
||||
errors.push(UiError::key("ERR_TICKET_DB_ERROR"));
|
||||
}
|
||||
lane.event("UPDATE_TICKET", update_ticket_args(ticket));
|
||||
}
|
||||
|
||||
/// `SMSG_GMTICKET_DELETETICKET`'s result 9 (`0x5e4606`): `UPDATE_TICKET` with `%d%s`, 0 and `""`
|
||||
/// (`0x5e461d`).
|
||||
fn deleted(lane: &mut DialogLane, code: u32) {
|
||||
/// `SMSG_GMTICKET_DELETETICKET` (`0x5e4606`): result 9 fires `UPDATE_TICKET` with `%d%s`, 0 and
|
||||
/// `""` (`0x5e461d`); any other result shows `ERR_TICKET_DB_ERROR` (`0x5e4635`).
|
||||
fn deleted(lane: &mut DialogLane, errors: &UiErrorKeys, code: u32) {
|
||||
if code == 9 {
|
||||
lane.event(
|
||||
"UPDATE_TICKET",
|
||||
vec![ScriptValue::Int(0), ScriptValue::Str(String::new())],
|
||||
);
|
||||
} else {
|
||||
errors.push(UiError::key("ERR_TICKET_DB_ERROR"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,18 +132,24 @@ fn status_answer(lane: &mut DialogLane, status: i32) {
|
||||
|
||||
/// `UPDATE_TICKET`'s arguments: category, text, the three day figures, assigned, opened. The wire
|
||||
/// has the text first and the reference's handler reorders as it fires, so the decoder keeps wire
|
||||
/// order. No ticket is a single `0`: `HelpFrameOpenTicket_OnEvent` tests `arg1 and arg1 ~= 0`
|
||||
/// (`HelpFrame.lua:403`), and its else branch resets the form (`:468-475`).
|
||||
/// order. `HelpFrameOpenTicket_OnEvent` tests `arg1 and arg1 ~= 0` (`HelpFrame.lua:403`), and its
|
||||
/// else branch resets the form (`:468-475`).
|
||||
fn update_ticket_args(ticket: Option<&benilla_protocol::messages::GmTicket>) -> Vec<ScriptValue> {
|
||||
let Some(t) = ticket else {
|
||||
return vec![ScriptValue::Int(0)];
|
||||
return no_ticket_args();
|
||||
};
|
||||
vec![
|
||||
ScriptValue::Int(i64::from(t.category)),
|
||||
ScriptValue::Str(t.text.clone()),
|
||||
// Days, unclamped: a negative figure is the server's "unknown", which the window shows as
|
||||
// `GM_TICKET_UNAVAILABLE` (`HelpFrame.lua:442`).
|
||||
ScriptValue::Number(f64::from(t.ticket_age)),
|
||||
// The first figure, below 0 stored as 0, NaN and -0 passing (`0x5e4568`-`0x5e4578`: a
|
||||
// `fcomp` against 0.0, then `jp` over the store); it is `ticket_age`, which the window
|
||||
// subtracts from the wait estimate. The other two stay signed: a negative is the server's
|
||||
// "unknown", shown as `GM_TICKET_UNAVAILABLE` (`HelpFrame.lua:442`).
|
||||
ScriptValue::Number(f64::from(if t.ticket_age < 0.0 {
|
||||
0.0
|
||||
} else {
|
||||
t.ticket_age
|
||||
})),
|
||||
ScriptValue::Number(f64::from(t.oldest_ticket_age)),
|
||||
ScriptValue::Number(f64::from(t.update_time)),
|
||||
ScriptValue::Int(i64::from(t.assigned_to_gm)),
|
||||
@@ -137,6 +157,28 @@ fn update_ticket_args(ticket: Option<&benilla_protocol::messages::GmTicket>) ->
|
||||
]
|
||||
}
|
||||
|
||||
/// The no-ticket `UPDATE_TICKET` (`0x5e450c`, `0x5e7945`): seven dwords 0, `""`, -1, -1, -1, 0, 0
|
||||
/// under the format `%d%s%f%f%f%d%d` (`0x8603e4`), which reads ten. A `%f` takes eight bytes
|
||||
/// (`fld qword` at `0x704fe3`), so arg3 is `0xFFFFFFFFFFFFFFFF`, a NaN, and arg4
|
||||
/// `0x00000000FFFFFFFF`, a denormal; the bits are kept, so `tostring` reads `-1.#QNAN`. Arg5's
|
||||
/// high half and both `%d` are read from past the pushed arguments: on the fetch path (esp at
|
||||
/// `0x5e450c`) the handler's saved edi, saved esi and its local `[ebp-0x9b8]`, on status 2
|
||||
/// (`0x5e7945`) the saved ebp, the return address into the dispatcher and the handler's first
|
||||
/// argument.
|
||||
///
|
||||
/// Deviation: those three are stack residue, so benilla sends 0 for each.
|
||||
fn no_ticket_args() -> Vec<ScriptValue> {
|
||||
vec![
|
||||
ScriptValue::Int(0),
|
||||
ScriptValue::Str(String::new()),
|
||||
ScriptValue::Number(f64::from_bits(u64::MAX)),
|
||||
ScriptValue::Number(f64::from_bits(0xFFFF_FFFF)),
|
||||
ScriptValue::Number(0.0),
|
||||
ScriptValue::Int(0),
|
||||
ScriptValue::Int(0),
|
||||
]
|
||||
}
|
||||
|
||||
/// The engine's re-asks ([`GmTicketState::note_write_landed`]): they answer a push that arrived
|
||||
/// before this frame's input.
|
||||
fn send_gm_reasks(mut reask: ResMut<GmTicketState>, commands: Res<NetCommands>) {
|
||||
@@ -312,7 +354,7 @@ pub(crate) mod net {
|
||||
|
||||
use crate::net::NetHandlerApp;
|
||||
|
||||
use super::{DialogLane, GmTicketState};
|
||||
use super::{DialogLane, GmTicketState, UiError, UiErrorKeys};
|
||||
|
||||
/// Register the ticket's handlers, called from [`super::UiGmTicketPlugin`].
|
||||
pub(super) fn register(app: &mut App) {
|
||||
@@ -328,9 +370,9 @@ pub(crate) mod net {
|
||||
|
||||
/// Every GETTICKET answer, asked for or pushed after a GM's `.ticket` command
|
||||
/// (`GMTicketMgr.cpp:153-159`): the wire does not tell them apart.
|
||||
fn on_ticket(In(ev): In<SessionEvent>, mut lane: ResMut<DialogLane>) {
|
||||
if let SessionEvent::GmTicket { ticket } = ev {
|
||||
super::ticket_answer(&mut lane, ticket.as_deref());
|
||||
fn on_ticket(In(ev): In<SessionEvent>, mut lane: ResMut<DialogLane>, errors: Res<UiErrorKeys>) {
|
||||
if let SessionEvent::GmTicket { status, ticket } = ev {
|
||||
super::ticket_answer(&mut lane, &errors, status, ticket.as_deref());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,31 +383,42 @@ pub(crate) mod net {
|
||||
}
|
||||
|
||||
/// `SMSG_GM_TICKET_STATUS_UPDATE`, which vmangos never sends; cmangos does, so it is parsed.
|
||||
fn on_status_update(In(ev): In<SessionEvent>, mut ticket: ResMut<GmTicketState>) {
|
||||
fn on_status_update(
|
||||
In(ev): In<SessionEvent>,
|
||||
mut ticket: ResMut<GmTicketState>,
|
||||
mut lane: ResMut<DialogLane>,
|
||||
) {
|
||||
if let SessionEvent::GmTicketStatusUpdate { status } = ev {
|
||||
status_update(status, &mut ticket);
|
||||
status_update(status, &mut ticket, &mut lane);
|
||||
}
|
||||
}
|
||||
|
||||
/// The create and update responses, which no 1.12 FrameXML handler reads.
|
||||
fn on_written(In(ev): In<SessionEvent>, mut ticket: ResMut<GmTicketState>) {
|
||||
fn on_written(
|
||||
In(ev): In<SessionEvent>,
|
||||
mut ticket: ResMut<GmTicketState>,
|
||||
errors: Res<UiErrorKeys>,
|
||||
) {
|
||||
match ev {
|
||||
SessionEvent::GmTicketCreated { response } => {
|
||||
write_response("create", response, 2, &mut ticket)
|
||||
}
|
||||
SessionEvent::GmTicketUpdated { response } => {
|
||||
write_response("update", response, 4, &mut ticket)
|
||||
SessionEvent::GmTicketCreated { response }
|
||||
| SessionEvent::GmTicketUpdated { response } => {
|
||||
write_response(response, &mut ticket, &errors)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// `SMSG_GMTICKET_DELETETICKET` (`0x5e4606`): result 9, deleted, signals `UPDATE_TICKET`
|
||||
/// with `%d%s` over 0 and `""` (`0x5e461d`), the window's no-ticket answer.
|
||||
fn on_deleted(In(ev): In<SessionEvent>, mut lane: ResMut<DialogLane>) {
|
||||
/// with `%d%s` over 0 and `""` (`0x5e461d`), the window's no-ticket answer; any other result
|
||||
/// shows `ERR_TICKET_DB_ERROR`.
|
||||
fn on_deleted(
|
||||
In(ev): In<SessionEvent>,
|
||||
mut lane: ResMut<DialogLane>,
|
||||
errors: Res<UiErrorKeys>,
|
||||
) {
|
||||
if let SessionEvent::GmTicketDeleted { response: code } = ev {
|
||||
response("delete", code);
|
||||
super::deleted(&mut lane, code);
|
||||
debug!("gm ticket: delete answered {code}");
|
||||
super::deleted(&mut lane, &errors, code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,44 +427,45 @@ pub(crate) mod net {
|
||||
ticket.clear_session();
|
||||
}
|
||||
|
||||
/// `SMSG_GMTICKET_CREATE` 2 (created) and `SMSG_GMTICKET_UPDATETEXT` 4 (saved) re-ask for the
|
||||
/// ticket, as the reference engine does at `0x5e4479`. Other codes are logged only: which
|
||||
/// `ERR_TICKET_*` string the reference shows for each is untraced.
|
||||
/// `SMSG_GMTICKET_CREATE` and `SMSG_GMTICKET_UPDATETEXT` share one arm of `0x5e38c0`
|
||||
/// (`0x5e4432`, table `0x5e4d30`): 2 and 4 re-ask for the ticket (`0x5e4479`), 1 shows
|
||||
/// `ERR_TICKET_ALREADY_EXISTS` (`0x5e448e`), 3 `ERR_TICKET_CREATE_ERROR` (`0x5e44ab`), 5
|
||||
/// `ERR_TICKET_UPDATE_ERROR` (`0x5e44c8`), whichever opcode carried the code; others do nothing.
|
||||
pub(crate) fn write_response(
|
||||
what: &str,
|
||||
response: u32,
|
||||
success: u32,
|
||||
ticket: &mut super::GmTicketState,
|
||||
errors: &UiErrorKeys,
|
||||
) {
|
||||
if response == success {
|
||||
debug!("gm ticket: {what} landed ({response}) — re-asking for the ticket");
|
||||
ticket.note_write_landed();
|
||||
} else {
|
||||
debug!("gm ticket: {what} answered {response}");
|
||||
match response {
|
||||
2 | 4 => {
|
||||
debug!("gm ticket: write landed ({response}) — re-asking for the ticket");
|
||||
ticket.note_write_landed();
|
||||
}
|
||||
1 => errors.push(UiError::key("ERR_TICKET_ALREADY_EXISTS")),
|
||||
3 => errors.push(UiError::key("ERR_TICKET_CREATE_ERROR")),
|
||||
5 => errors.push(UiError::key("ERR_TICKET_UPDATE_ERROR")),
|
||||
other => debug!("gm ticket: write answered {other}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// `SMSG_GM_TICKET_STATUS_UPDATE`: 1 (updated) re-asks, the reference's `0x5e7932`; 2 (closed)
|
||||
/// shows on the next poll; 3 (survey offered) is logged, as the survey window is not built.
|
||||
pub(crate) fn status_update(status: u32, ticket: &mut super::GmTicketState) {
|
||||
/// `SMSG_GM_TICKET_STATUS_UPDATE` (`0x5e78f0`): 1 (updated) re-asks, `0x5e7932`; 2 (closed)
|
||||
/// fires the no-ticket `UPDATE_TICKET` at once, `0x5e7945`-`0x5e7960`; 3 (survey offered)
|
||||
/// fires `GMSURVEY_DISPLAY`, event 0x21a with no arguments (`0x5e7976`); others do nothing.
|
||||
pub(crate) fn status_update(
|
||||
status: u32,
|
||||
ticket: &mut super::GmTicketState,
|
||||
lane: &mut DialogLane,
|
||||
) {
|
||||
match status {
|
||||
1 => {
|
||||
debug!("gm ticket: a GM updated the ticket — re-asking");
|
||||
ticket.note_write_landed();
|
||||
}
|
||||
2 => debug!("gm ticket: a GM closed the ticket"),
|
||||
3 => {
|
||||
debug!("gm ticket: a GM survey was offered — the survey window is deferred")
|
||||
}
|
||||
2 => lane.event("UPDATE_TICKET", super::update_ticket_args(None)),
|
||||
3 => lane.event("GMSURVEY_DISPLAY", Vec::new()),
|
||||
other => debug!("gm ticket: unknown status update {other}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// `SMSG_GMTICKET_DELETETICKET`: logged only, as the reference's `0x5e4479` re-asks on create
|
||||
/// and update alone.
|
||||
pub(crate) fn response(what: &str, response: u32) {
|
||||
debug!("gm ticket: {what} answered {response}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The GM trouble-ticket flow: the answer feed and the window's sends.
|
||||
@@ -579,10 +633,42 @@ mod tests {
|
||||
assert_eq!(args[6], ScriptValue::Int(1), "arg7 openedByGM");
|
||||
}
|
||||
|
||||
/// The window's form reset hangs on `arg1 and arg1 ~= 0`.
|
||||
/// The window's form reset hangs on `arg1 and arg1 ~= 0`; an addon reads the reference's
|
||||
/// seven arguments, the floats as the format `%d%s%f%f%f%d%d` reads the pushed dwords.
|
||||
#[test]
|
||||
fn the_no_ticket_answer_is_a_single_zero() {
|
||||
assert_eq!(update_ticket_args(None), vec![ScriptValue::Int(0)]);
|
||||
fn the_no_ticket_answer_carries_the_references_seven_arguments() {
|
||||
let args = update_ticket_args(None);
|
||||
assert_eq!(args.len(), 7);
|
||||
assert_eq!(args[0], ScriptValue::Int(0));
|
||||
assert_eq!(args[1], ScriptValue::Str(String::new()));
|
||||
let float = |i: usize| match args[i] {
|
||||
ScriptValue::Number(n) => n,
|
||||
ref other => panic!("arg{} is {other:?}", i + 1),
|
||||
};
|
||||
assert_eq!(float(2).to_bits(), u64::MAX, "(-1, -1) read as one double");
|
||||
assert_eq!(
|
||||
float(3).to_bits(),
|
||||
0xFFFF_FFFF,
|
||||
"(-1, 0) read as one double"
|
||||
);
|
||||
}
|
||||
|
||||
/// `0x5e4568`: a negative first figure is stored as 0; NaN and -0 pass, the others untouched.
|
||||
#[test]
|
||||
fn a_negative_ticket_age_reaches_lua_as_zero() {
|
||||
let age = |v: f32| {
|
||||
let mut t = ticket();
|
||||
t.ticket_age = v;
|
||||
match update_ticket_args(Some(&t))[2] {
|
||||
ScriptValue::Number(n) => n,
|
||||
ref other => panic!("{other:?}"),
|
||||
}
|
||||
};
|
||||
assert_eq!(age(-3.5), 0.0);
|
||||
assert_eq!(age(-3.5).to_bits(), 0.0f64.to_bits(), "+0, not -0");
|
||||
assert!(age(f32::NAN).is_nan());
|
||||
assert_eq!(age(-0.0).to_bits(), (-0.0f64).to_bits());
|
||||
assert_eq!(age(2.0), 2.0);
|
||||
}
|
||||
|
||||
/// The window's `arg4 < 0 or arg5 < 0` test shows "unavailable".
|
||||
@@ -601,35 +687,84 @@ mod tests {
|
||||
fn each_answer_signals_its_update_ticket() {
|
||||
let t = ticket();
|
||||
let mut lane = DialogLane::default();
|
||||
let errors = UiErrorKeys::default();
|
||||
for _ in 0..2 {
|
||||
ticket_answer(&mut lane, Some(&t));
|
||||
ticket_answer(&mut lane, &errors, 6, Some(&t));
|
||||
}
|
||||
ticket_answer(&mut lane, None);
|
||||
let ticket = |args| DialogSignal::Event("UPDATE_TICKET".into(), args);
|
||||
assert_eq!(
|
||||
lane.take(),
|
||||
[
|
||||
ticket(update_ticket_args(Some(&t))),
|
||||
ticket(update_ticket_args(Some(&t))),
|
||||
ticket(vec![ScriptValue::Int(0)]),
|
||||
]
|
||||
);
|
||||
ticket_answer(&mut lane, &errors, 10, None);
|
||||
// The no-ticket answer carries a NaN, which never equals itself: compare its shape.
|
||||
let signals = lane.take();
|
||||
let [first, second, none] = signals.as_slice() else {
|
||||
panic!("{signals:?}");
|
||||
};
|
||||
let ticket = DialogSignal::Event("UPDATE_TICKET".into(), update_ticket_args(Some(&t)));
|
||||
assert_eq!((first, second), (&ticket, &ticket));
|
||||
let DialogSignal::Event(name, args) = none else {
|
||||
panic!("{none:?}");
|
||||
};
|
||||
assert_eq!((name.as_str(), args.len()), ("UPDATE_TICKET", 7));
|
||||
}
|
||||
|
||||
/// The reference's `0x5e4479` re-ask; a refusal has nothing new to fetch.
|
||||
#[test]
|
||||
fn a_landed_write_makes_the_engine_reask_and_a_refused_one_does_not() {
|
||||
let mut state = GmTicketState::default();
|
||||
net::write_response("create", 2, 2, &mut state);
|
||||
net::write_response("update", 4, 4, &mut state);
|
||||
let errors = UiErrorKeys::default();
|
||||
// One arm serves both opcodes: 2 and 4 re-ask whichever carried them.
|
||||
net::write_response(2, &mut state, &errors);
|
||||
net::write_response(4, &mut state, &errors);
|
||||
assert_eq!(state.take_reasks(), 2, "one re-ask per landed write");
|
||||
assert_eq!(state.take_reasks(), 0, "drained means drained");
|
||||
assert!(errors.is_empty(), "a landed write shows no error");
|
||||
|
||||
net::write_response("create", 3, 2, &mut state); // CREATE_ERROR
|
||||
net::write_response("update", 5, 4, &mut state); // UPDATE_ERROR
|
||||
for refused in [1, 3, 5] {
|
||||
net::write_response(refused, &mut state, &errors);
|
||||
}
|
||||
assert_eq!(state.take_reasks(), 0, "a refusal has nothing to fetch");
|
||||
}
|
||||
|
||||
fn keys(errors: &UiErrorKeys) -> Vec<&'static str> {
|
||||
errors.take().into_iter().map(|e| e.key).collect()
|
||||
}
|
||||
|
||||
/// The shared arm `0x5e4432` shows 1, 3 and 5 as `ERR_TICKET_ALREADY_EXISTS`,
|
||||
/// `ERR_TICKET_CREATE_ERROR` and `ERR_TICKET_UPDATE_ERROR` (table `0x5e4d30`); every other
|
||||
/// code is silent.
|
||||
#[test]
|
||||
fn a_refused_ticket_write_shows_its_error() {
|
||||
let mut state = GmTicketState::default();
|
||||
let errors = UiErrorKeys::default();
|
||||
for code in [0, 1, 2, 3, 4, 5, 6, 9, 10] {
|
||||
net::write_response(code, &mut state, &errors);
|
||||
}
|
||||
assert_eq!(
|
||||
keys(&errors),
|
||||
[
|
||||
"ERR_TICKET_ALREADY_EXISTS",
|
||||
"ERR_TICKET_CREATE_ERROR",
|
||||
"ERR_TICKET_UPDATE_ERROR"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/// `0x5e44fb`: status 0 shows `ERR_TICKET_DB_ERROR` before the no-ticket event; the other
|
||||
/// non-6 statuses fire the event alone.
|
||||
#[test]
|
||||
fn a_ticket_fetch_status_zero_shows_the_db_error() {
|
||||
let mut lane = DialogLane::default();
|
||||
let errors = UiErrorKeys::default();
|
||||
ticket_answer(&mut lane, &errors, 0, None);
|
||||
assert_eq!(keys(&errors), ["ERR_TICKET_DB_ERROR"]);
|
||||
assert_eq!(lane.take().len(), 1, "the no-ticket event follows");
|
||||
for status in [10, 1, 7] {
|
||||
ticket_answer(&mut lane, &errors, status, None);
|
||||
}
|
||||
assert!(errors.is_empty());
|
||||
let t = ticket();
|
||||
ticket_answer(&mut lane, &errors, 6, Some(&t));
|
||||
assert!(errors.is_empty());
|
||||
}
|
||||
|
||||
/// vmangos sends only 0 or 1, so no live run reaches the window's -1 arm.
|
||||
#[test]
|
||||
fn a_minus_one_queue_status_survives_to_lua_as_minus_one() {
|
||||
@@ -649,8 +784,13 @@ mod tests {
|
||||
#[test]
|
||||
fn a_deleted_ticket_signals_the_no_ticket_answer() {
|
||||
let mut lane = DialogLane::default();
|
||||
deleted(&mut lane, 8);
|
||||
deleted(&mut lane, 9);
|
||||
let errors = UiErrorKeys::default();
|
||||
deleted(&mut lane, &errors, 8);
|
||||
// Any other result is the DB error and fires nothing (`0x5e4635`).
|
||||
assert_eq!(keys(&errors), ["ERR_TICKET_DB_ERROR"]);
|
||||
assert!(lane.take().is_empty());
|
||||
deleted(&mut lane, &errors, 9);
|
||||
assert!(errors.is_empty());
|
||||
assert_eq!(
|
||||
lane.take(),
|
||||
[DialogSignal::Event(
|
||||
@@ -660,6 +800,35 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// `0x5e78f0`: status 2 fires the no-ticket `UPDATE_TICKET` and 3 `GMSURVEY_DISPLAY`; 1
|
||||
/// re-asks and fires nothing; anything outside 1 to 3 is ignored.
|
||||
#[test]
|
||||
fn a_closed_ticket_and_an_offered_survey_fire_their_events() {
|
||||
let mut state = GmTicketState::default();
|
||||
let mut lane = DialogLane::default();
|
||||
for status in [0, 4, 1] {
|
||||
net::status_update(status, &mut state, &mut lane);
|
||||
}
|
||||
assert!(lane.take().is_empty(), "1 re-asks and the rest do nothing");
|
||||
assert_eq!(state.take_reasks(), 1);
|
||||
|
||||
net::status_update(2, &mut state, &mut lane);
|
||||
net::status_update(3, &mut state, &mut lane);
|
||||
let signals = lane.take();
|
||||
let [closed, survey] = signals.as_slice() else {
|
||||
panic!("{signals:?}");
|
||||
};
|
||||
assert!(matches!(
|
||||
closed,
|
||||
DialogSignal::Event(name, args) if name == "UPDATE_TICKET" && args.len() == 7
|
||||
));
|
||||
assert_eq!(
|
||||
survey,
|
||||
&DialogSignal::Event("GMSURVEY_DISPLAY".into(), Vec::new())
|
||||
);
|
||||
assert_eq!(state.take_reasks(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dead_session_forgets_the_owed_reasks() {
|
||||
let mut state = GmTicketState::default();
|
||||
|
||||
@@ -164,6 +164,13 @@ impl GossipState {
|
||||
self.text.clear();
|
||||
}
|
||||
|
||||
/// `ResetGossipOptions` (`0x4e26a0`): every option slot's index to -1 and every quest id to 0,
|
||||
/// so no getter or select finds a row; the text, the NPC cell and the latches stay.
|
||||
pub(crate) fn reset_slots(&mut self) {
|
||||
self.options.clear();
|
||||
self.quests.clear();
|
||||
}
|
||||
|
||||
/// The disconnect clear; NPC text is static per id, so the records stay.
|
||||
pub(crate) fn clear_session(&mut self) {
|
||||
self.clear();
|
||||
@@ -192,8 +199,8 @@ impl Plugin for UiGossipPlugin {
|
||||
lane::add_gossip_lane(app);
|
||||
app.init_resource::<GossipState>()
|
||||
.add_latched_window::<GossipState>()
|
||||
// `0x490ac1` → `0x4e1f60` → `0x4e1fa0(0)`, the core.
|
||||
.add_sweep_leg(SweepLeg::Gossip, close_core);
|
||||
// `0x490ac1` → `0x4e1f60`: the core `0x4e1fa0(0)`, then the slots' reset (`0x4e1f89`).
|
||||
.add_sweep_leg(SweepLeg::Gossip, leave_world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,12 +218,20 @@ impl LatchedWindow for GossipState {
|
||||
}
|
||||
}
|
||||
|
||||
/// The leave-world leg `0x4e1f60`: the close core (`0x4e1f84`), then `ResetGossipOptions`
|
||||
/// (`0x4e1f89` → `0x4e26a0`) whether or not a menu was open, so the getters answer empty lists
|
||||
/// until the next gossip.
|
||||
fn leave_world(world: &mut World) {
|
||||
close_core(world);
|
||||
world.resource_mut::<GossipState>().reset_slots();
|
||||
}
|
||||
|
||||
/// The close core, `0x4e1fa0` with a zero guid: nothing with no menu (`0x4e1fb8`, a zero guid
|
||||
/// against a zero cell), else the latch release (`0x4e1fc5`), the cell zeroed (`0x4e1fcc`), and
|
||||
/// `GOSSIP_CLOSED` (`0x4e1fdc`); the slots, the text and its latch stay, and their getters read
|
||||
/// them still. A menu still waiting on its text was latched at its open, so its close fires too.
|
||||
/// `SMSG_GOSSIP_COMPLETE` (`0x4e2824`), the missing-text path (`0x4e2197`), `0x493310` and the
|
||||
/// leave-world sweep's leg (`0x490ac1` → `0x4e1f60`) call it as it is.
|
||||
/// leave-world sweep's leg ([`leave_world`]) call it as it is.
|
||||
/// It runs behind the gossip lane, so it never fires ahead of a show still queued there.
|
||||
pub(crate) fn close_core(world: &mut World) {
|
||||
let Some(npc) = world.resource::<GossipState>().npc else {
|
||||
|
||||
@@ -82,8 +82,7 @@ impl GossipVerbs<'_, '_> {
|
||||
// no getter or select reads, and every quest id to 0, which ends the row scans.
|
||||
// No event: the menu the feed pushed is the VM's as reset.
|
||||
let state = state.bypass_change_detection();
|
||||
state.options.clear();
|
||||
state.quests.clear();
|
||||
state.reset_slots();
|
||||
script.reset_gossip_slots();
|
||||
}
|
||||
GossipCall::Quest { active, index } => {
|
||||
|
||||
@@ -1940,13 +1940,6 @@ mod tests {
|
||||
a divergence, not a fix",
|
||||
),
|
||||
("DISPLAY_SIZE_CHANGED", "the four paperdoll files"),
|
||||
(
|
||||
"GMSURVEY_DISPLAY",
|
||||
"HelpFrame.lua — the post-ticket survey. A real 1.12 event (fired at \
|
||||
`0x5e797b`, id 538) whose whole UI is the LoadOnDemand `Blizzard_GMSurveyUI`; \
|
||||
we have neither the producer nor the addon on the chain, and the ticket \
|
||||
flow works without it",
|
||||
),
|
||||
("ITEM_TEXT_TRANSLATION", "ItemTextFrame.lua"),
|
||||
(
|
||||
"SHOW_COMPARE_TOOLTIP",
|
||||
|
||||
@@ -72,7 +72,7 @@ pub(crate) enum SweepLeg {
|
||||
Loot,
|
||||
/// `0x490abc` → `0x4e3240` → `0x4e32e0(0, 0)`.
|
||||
ItemText,
|
||||
/// `0x490ac1` → `0x4e1f60` → `0x4e1fa0(0)`.
|
||||
/// `0x490ac1` → `0x4e1f60`: `0x4e1fa0(0)`, then the slots' reset `0x4e26a0`.
|
||||
Gossip,
|
||||
/// `0x490ac6` → `0x500bc0` → `0x501130(0, 1)`.
|
||||
Quest,
|
||||
|
||||
@@ -181,6 +181,34 @@ fn the_sweep_closes_every_window_in_the_references_order() {
|
||||
assert!(!world.resource::<crate::ui_bank::BankOpen>().is_open());
|
||||
}
|
||||
|
||||
/// The gossip leg `0x4e1f60` ends with `ResetGossipOptions` (`0x4e1f89`): after a world change
|
||||
/// the getters' rows are gone, the greeting text stays, and it runs with no menu open too.
|
||||
#[test]
|
||||
fn the_gossip_leg_resets_the_option_and_quest_slots() {
|
||||
use benilla_protocol::messages::GossipOption;
|
||||
let (mut app, _rx) = legs_app();
|
||||
app.insert_non_send_resource(spied_vm(&EVENTS));
|
||||
{
|
||||
let mut gossip = app
|
||||
.world_mut()
|
||||
.resource_mut::<crate::ui_gossip::GossipState>();
|
||||
gossip.npc = Some(GOSSIPER);
|
||||
gossip.text = "Hello".into();
|
||||
gossip.options = vec![GossipOption {
|
||||
index: 0,
|
||||
icon: 1,
|
||||
coded: false,
|
||||
message: "Browse".into(),
|
||||
}];
|
||||
gossip.quests = vec![(7, 4, 1, "A quest".into())];
|
||||
}
|
||||
sweep_in_place(&mut app);
|
||||
let gossip = app.world().resource::<crate::ui_gossip::GossipState>();
|
||||
assert_eq!(gossip.npc, None);
|
||||
assert!(gossip.options.is_empty() && gossip.quests.is_empty());
|
||||
assert_eq!(gossip.text, "Hello", "the text buffer is not a slot");
|
||||
}
|
||||
|
||||
/// The latch spent, a second departure in the same world sweeps nothing (`0x490a87`).
|
||||
#[test]
|
||||
fn a_second_departure_in_one_world_closes_nothing() {
|
||||
|
||||
@@ -354,6 +354,7 @@ fn drive_vplates(
|
||||
mut vm: crate::script_calls::VmWith<PlateWorld<'static, 'static>>,
|
||||
mut plates: ResMut<VPlates>,
|
||||
mut plate_clicks: ResMut<PlateClicks>,
|
||||
mut flashes: ResMut<PlateFlashes>,
|
||||
rig: Res<crate::player::CameraControl>,
|
||||
names: Res<NameCache>,
|
||||
spells: Option<Res<crate::ui_action::Spells>>,
|
||||
@@ -710,6 +711,7 @@ fn drive_vplates(
|
||||
states,
|
||||
)
|
||||
});
|
||||
let flashes = std::mem::take(&mut flashes.0);
|
||||
vm.run(|script| {
|
||||
let Some(script) = script else {
|
||||
return;
|
||||
@@ -718,6 +720,10 @@ fn drive_vplates(
|
||||
PlateStep::Retire => script.retire_nameplates(),
|
||||
PlateStep::Sync(geometry, states) => script.sync_nameplates(geometry, &states),
|
||||
}
|
||||
// After the sync, so a plate bound this frame is a hit's to flash.
|
||||
for guid in flashes {
|
||||
script.flash_nameplate(guid);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -738,6 +744,28 @@ enum PlateStep {
|
||||
Sync(PlateGeometry, Vec<PlateState>),
|
||||
}
|
||||
|
||||
/// The units hit since the plate driver last ran, whose plates flash their names red for 5 s
|
||||
/// (`FlashNamePlate`, `0x6122e0`): the combat log's direct spell hit (`0x62cd80` at `0x62ce43`)
|
||||
/// and environmental damage (`0x62aac0` at `0x62abac`) push here, and [`flash_on_health_loss`]
|
||||
/// the health drops (`0x6046f0` at `0x604764`). The driver hands them to the widgets.
|
||||
#[derive(Resource, Default)]
|
||||
pub(crate) struct PlateFlashes(pub(crate) Vec<u64>);
|
||||
|
||||
/// Queue every unit-block `UNIT_FIELD_HEALTH` edge whose old value is above the new, compared
|
||||
/// signed (`0x6046f0`: `cmp edi,[health]` at `0x60475d`, `jle` at `0x604760` skips).
|
||||
fn flash_on_health_loss(
|
||||
mut edges: MessageReader<crate::net::FieldChanged>,
|
||||
mut flashes: ResMut<PlateFlashes>,
|
||||
) {
|
||||
flashes.0.extend(
|
||||
edges
|
||||
.read()
|
||||
.filter(|e| e.unit_field(benilla_protocol::field::FIELD_UNIT_HEALTH))
|
||||
.filter(|e| e.old as i32 > e.new as i32)
|
||||
.map(|e| e.guid),
|
||||
);
|
||||
}
|
||||
|
||||
/// The plate driver's set; the overhead-name driver runs after it.
|
||||
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct VPlateSet;
|
||||
@@ -751,12 +779,16 @@ impl Plugin for VPlatesPlugin {
|
||||
.init_resource::<VPlates>()
|
||||
.init_resource::<PlateHover>()
|
||||
.init_resource::<PlateClicks>()
|
||||
.init_resource::<PlateFlashes>()
|
||||
.add_systems(
|
||||
Update,
|
||||
// After the targeting chain, itself after `WorldStage::Input`, so this projects
|
||||
// through this frame's camera; `ui_script::extract::paint_script` runs after it,
|
||||
// so the plates paint the same frame.
|
||||
drive_vplates.after(TargetUpdate).in_set(VPlateSet),
|
||||
(
|
||||
// After the targeting chain, itself after `WorldStage::Input`, so this projects
|
||||
// through this frame's camera; `ui_script::extract::paint_script` runs after
|
||||
// it, so the plates paint the same frame.
|
||||
drive_vplates.after(TargetUpdate).in_set(VPlateSet),
|
||||
flash_on_health_loss.before(VPlateSet),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1021,6 +1053,116 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// The driver's hand-over of the queued hits: what [`drive_vplates`] does with them.
|
||||
fn hand_over(app: &mut App) {
|
||||
let guids = std::mem::take(&mut app.world_mut().resource_mut::<PlateFlashes>().0);
|
||||
let mut script = app
|
||||
.world_mut()
|
||||
.non_send_resource_mut::<benilla_ui::script::UiScript>();
|
||||
for guid in guids {
|
||||
script.flash_nameplate(guid);
|
||||
}
|
||||
}
|
||||
|
||||
/// A plate's name goes red for a unit whose health fell (`0x6046f0` at `0x604764`, old above
|
||||
/// new, signed) or that a combat-log hit named ([`PlateFlashes`]); a rise, a unit-less field and
|
||||
/// a unit with no plate flash nothing.
|
||||
#[test]
|
||||
fn a_health_drop_or_a_logged_hit_flashes_the_units_plate() {
|
||||
use benilla_protocol::field::FIELD_UNIT_HEALTH;
|
||||
use benilla_protocol::messages::ObjectType;
|
||||
const WOLF: u64 = 0x1001;
|
||||
const BEAR: u64 = 0x1002;
|
||||
let mut script = benilla_ui::script::UiScript::new().unwrap();
|
||||
script
|
||||
.run(
|
||||
r#"NAMEPLATE_FONT = "Fonts\FRIZQT__.TTF"
|
||||
WorldFrame = CreateFrame("WorldFrame", "WorldFrame") WorldFrame:SetAllPoints()"#,
|
||||
)
|
||||
.unwrap();
|
||||
let state = |key| PlateState {
|
||||
key,
|
||||
top_centre: (500.0, 400.0),
|
||||
health: 30.0,
|
||||
max_health: 40.0,
|
||||
bar_colour: [1.0, 0.0, 0.0],
|
||||
name: "Wolf".into(),
|
||||
level: Some(12),
|
||||
skull: false,
|
||||
level_colour: [1.0, 1.0, 0.0],
|
||||
raid_icon: None,
|
||||
alpha: 255,
|
||||
lit: false,
|
||||
hovered: false,
|
||||
};
|
||||
let geometry = PlateGeometry {
|
||||
width: 128.0,
|
||||
height: 32.0,
|
||||
bar_off_x: 4.0,
|
||||
bar_off_y: 4.0,
|
||||
bar_width: 103.0,
|
||||
bar_height: 9.0,
|
||||
level_off_x: 11.8,
|
||||
level_off_y: 9.1,
|
||||
skull_size: 12.8,
|
||||
raid_size: 25.6,
|
||||
name_height: 12.8,
|
||||
level_height: 11.0,
|
||||
shadow_offset: 1.0,
|
||||
};
|
||||
script.sync_nameplates(geometry, &[state(WOLF), state(BEAR)]);
|
||||
let mut app = App::new();
|
||||
app.add_message::<crate::net::FieldChanged>()
|
||||
.init_resource::<PlateFlashes>()
|
||||
.insert_non_send_resource(script)
|
||||
.add_systems(Update, flash_on_health_loss);
|
||||
let colour = |app: &App, plate: u32| {
|
||||
app.world()
|
||||
.non_send_resource::<benilla_ui::script::UiScript>()
|
||||
.eval::<f64>(&format!(
|
||||
"local children = {{ WorldFrame:GetChildren() }} \
|
||||
local _, _, name = children[{plate}]:GetRegions() \
|
||||
local r, g, b = name:GetTextColor() return g"
|
||||
))
|
||||
.map(|g| g.round())
|
||||
.unwrap()
|
||||
};
|
||||
let edge = |guid, index, old, new| crate::net::FieldChanged {
|
||||
at: crate::lanes::stamp(),
|
||||
entity: Entity::PLACEHOLDER,
|
||||
guid,
|
||||
kind: ObjectType::Unit,
|
||||
index,
|
||||
old,
|
||||
new,
|
||||
};
|
||||
// Both plates read white: green is 1.
|
||||
assert_eq!((colour(&app, 1), colour(&app, 2)), (1.0, 1.0));
|
||||
|
||||
// A rise (signed: -16 to 5 is one), and a drop on a field that is not the health: nothing.
|
||||
app.world_mut()
|
||||
.write_message(edge(WOLF, FIELD_UNIT_HEALTH, 10, 20));
|
||||
app.world_mut()
|
||||
.write_message(edge(WOLF, FIELD_UNIT_HEALTH, 0xFFFF_FFF0, 5));
|
||||
app.world_mut()
|
||||
.write_message(edge(WOLF, FIELD_UNIT_HEALTH + 1, 20, 10));
|
||||
app.update();
|
||||
hand_over(&mut app);
|
||||
assert_eq!(colour(&app, 1), 1.0);
|
||||
|
||||
// A drop flashes the wolf's plate alone, red having no green.
|
||||
app.world_mut()
|
||||
.write_message(edge(WOLF, FIELD_UNIT_HEALTH, 20, 10));
|
||||
app.update();
|
||||
hand_over(&mut app);
|
||||
assert_eq!((colour(&app, 1), colour(&app, 2)), (0.0, 1.0));
|
||||
|
||||
// A logged hit names the bear; a unit with no plate is ignored.
|
||||
app.world_mut().resource_mut::<PlateFlashes>().0 = vec![0x9999, BEAR];
|
||||
hand_over(&mut app);
|
||||
assert_eq!((colour(&app, 1), colour(&app, 2)), (0.0, 0.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plate_tint_matches_the_byte_order() {
|
||||
assert_eq!(plate_tint(1, false), PLATE_HOSTILE);
|
||||
|
||||
@@ -409,9 +409,13 @@ pub enum SessionEvent {
|
||||
ServerUnixTime { unix_time: u32 },
|
||||
/// The hearthstone bind (`SMSG_BINDPOINTUPDATE`): the AreaTable id the `$z` token names.
|
||||
BindPoint { area: u32 },
|
||||
/// `SMSG_GMTICKET_GETTICKET`, `None` for no ticket. The Help window re-polls every 10 minutes
|
||||
/// and fires `UPDATE_TICKET` on each answer, changed or not: count these, never diff them.
|
||||
GmTicket { ticket: Option<Box<GmTicket>> },
|
||||
/// `SMSG_GMTICKET_GETTICKET`: the wire status, and the ticket (`None` for no ticket). The Help
|
||||
/// window re-polls every 10 minutes and fires `UPDATE_TICKET` on each answer, changed or not:
|
||||
/// count these, never diff them.
|
||||
GmTicket {
|
||||
status: u32,
|
||||
ticket: Option<Box<GmTicket>>,
|
||||
},
|
||||
/// `SMSG_GMTICKET_CREATE`: 2 created, 3 refused, 1 already exists (vmangos never sends 1, and
|
||||
/// sometimes sends nothing at all).
|
||||
GmTicketCreated { response: u32 },
|
||||
|
||||
@@ -759,7 +759,9 @@ pub fn decode(packet: ServerPacket) -> Vec<SessionEvent> {
|
||||
vec![SessionEvent::ServerUnixTime { unix_time }]
|
||||
}
|
||||
ServerPacket::BindPoint { area, .. } => vec![SessionEvent::BindPoint { area }],
|
||||
ServerPacket::GmTicketAnswer { ticket } => vec![SessionEvent::GmTicket { ticket }],
|
||||
ServerPacket::GmTicketAnswer { status, ticket } => {
|
||||
vec![SessionEvent::GmTicket { status, ticket }]
|
||||
}
|
||||
ServerPacket::GmTicketCreated { response } => {
|
||||
vec![SessionEvent::GmTicketCreated { response }]
|
||||
}
|
||||
|
||||
@@ -63,12 +63,18 @@ pub fn gm_ticket_create(category: u8, map: u32, pos: [f32; 3], text: &str) -> Ve
|
||||
out
|
||||
}
|
||||
|
||||
/// `CMSG_GMTICKET_UPDATETEXT` body: the category byte (`0x5efb2d`), then the text. vmangos stores
|
||||
/// the byte, so an edit re-files the ticket under it (`GMTicketHandler.cpp:59-61`).
|
||||
/// The most text bytes either client sender keeps: `SStrCopy` into a 0x7d0-byte buffer
|
||||
/// (`0x5ef7f0`, `0x5efacd`) leaves 1999 and the terminator.
|
||||
const TICKET_TEXT_MAX: usize = 0x7d0 - 1;
|
||||
|
||||
/// `CMSG_GMTICKET_UPDATETEXT` body: the category byte (`0x5efb2d`), then the text cut at
|
||||
/// [`TICKET_TEXT_MAX`] bytes (`0x5efacd`). vmangos stores the byte, so an edit re-files the ticket
|
||||
/// under it (`GMTicketHandler.cpp:59-61`).
|
||||
pub fn gm_ticket_updatetext(category: u8, text: &str) -> Vec<u8> {
|
||||
let text = &text.as_bytes()[..text.len().min(TICKET_TEXT_MAX)];
|
||||
let mut out = Vec::with_capacity(1 + text.len() + 1);
|
||||
out.push(category);
|
||||
out.extend_from_slice(text.as_bytes());
|
||||
out.extend_from_slice(text);
|
||||
out.push(0);
|
||||
out
|
||||
}
|
||||
@@ -85,21 +91,26 @@ pub(super) fn read_gm_ticket_system_status(r: &mut &[u8]) -> io::Result<i32> {
|
||||
Ok(read_u32_le(r)? as i32)
|
||||
}
|
||||
|
||||
/// Read `SMSG_GMTICKET_GETTICKET`: a status, then the ticket only for
|
||||
/// [`GMTICKET_STATUS_HASTEXT`]; any other status is no ticket, not an error.
|
||||
pub(super) fn read_gm_ticket(r: &mut &[u8]) -> io::Result<Option<GmTicket>> {
|
||||
if read_u32_le(r)? != GMTICKET_STATUS_HASTEXT {
|
||||
return Ok(None);
|
||||
/// Read `SMSG_GMTICKET_GETTICKET`: the status, then the ticket only for
|
||||
/// [`GMTICKET_STATUS_HASTEXT`]; any other status is no ticket, and the status stays because 0
|
||||
/// shows `ERR_TICKET_DB_ERROR` (`0x5e44fb`) where the rest do not.
|
||||
pub(super) fn read_gm_ticket(r: &mut &[u8]) -> io::Result<(u32, Option<GmTicket>)> {
|
||||
let status = read_u32_le(r)?;
|
||||
if status != GMTICKET_STATUS_HASTEXT {
|
||||
return Ok((status, None));
|
||||
}
|
||||
Ok(Some(GmTicket {
|
||||
text: read_cstring(r)?,
|
||||
category: read_u8(r)?,
|
||||
ticket_age: read_f32_le(r)?,
|
||||
oldest_ticket_age: read_f32_le(r)?,
|
||||
update_time: read_f32_le(r)?,
|
||||
assigned_to_gm: read_u8(r)?,
|
||||
opened_by_gm: read_u8(r)?,
|
||||
}))
|
||||
Ok((
|
||||
status,
|
||||
Some(GmTicket {
|
||||
text: read_cstring(r)?,
|
||||
category: read_u8(r)?,
|
||||
ticket_age: read_f32_le(r)?,
|
||||
oldest_ticket_age: read_f32_le(r)?,
|
||||
update_time: read_f32_le(r)?,
|
||||
assigned_to_gm: read_u8(r)?,
|
||||
opened_by_gm: read_u8(r)?,
|
||||
}),
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -134,6 +145,17 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// `0x5efacd` copies at most 0x7d0 bytes, terminator included.
|
||||
#[test]
|
||||
fn the_updatetext_is_cut_at_1999_bytes() {
|
||||
let body = gm_ticket_updatetext(1, &"a".repeat(3000));
|
||||
assert_eq!(body.len(), 1 + 1999 + 1);
|
||||
assert_eq!(body[1..2000], *"a".repeat(1999).as_bytes());
|
||||
assert_eq!(body.last(), Some(&0));
|
||||
let exact = gm_ticket_updatetext(1, &"b".repeat(1999));
|
||||
assert_eq!(exact.len(), 2001, "1999 bytes fit whole");
|
||||
}
|
||||
|
||||
/// The Lua `UPDATE_TICKET` event reverses this order; the wire does not.
|
||||
#[test]
|
||||
fn a_held_ticket_decodes_in_wire_order_text_before_category() {
|
||||
@@ -148,15 +170,18 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
read_gm_ticket(&mut &bytes[..]).unwrap(),
|
||||
Some(GmTicket {
|
||||
text: "Stuck in a rock.".to_string(),
|
||||
category: 1,
|
||||
ticket_age: 0.25,
|
||||
oldest_ticket_age: 2.5,
|
||||
update_time: 0.01,
|
||||
assigned_to_gm: 2,
|
||||
opened_by_gm: 1,
|
||||
})
|
||||
(
|
||||
GMTICKET_STATUS_HASTEXT,
|
||||
Some(GmTicket {
|
||||
text: "Stuck in a rock.".to_string(),
|
||||
category: 1,
|
||||
ticket_age: 0.25,
|
||||
oldest_ticket_age: 2.5,
|
||||
update_time: 0.01,
|
||||
assigned_to_gm: 2,
|
||||
opened_by_gm: 1,
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -177,9 +202,12 @@ mod tests {
|
||||
#[test]
|
||||
fn the_no_ticket_answer_is_four_bytes_and_is_not_an_error() {
|
||||
let bytes = GMTICKET_STATUS_DEFAULT.to_le_bytes();
|
||||
assert_eq!(read_gm_ticket(&mut &bytes[..]).unwrap(), None);
|
||||
// Any other status is also no ticket.
|
||||
assert_eq!(
|
||||
read_gm_ticket(&mut &bytes[..]).unwrap(),
|
||||
(GMTICKET_STATUS_DEFAULT, None)
|
||||
);
|
||||
// Any other status is also no ticket, and keeps its number: 0 is the DB error.
|
||||
let bytes = 0u32.to_le_bytes();
|
||||
assert_eq!(read_gm_ticket(&mut &bytes[..]).unwrap(), None);
|
||||
assert_eq!(read_gm_ticket(&mut &bytes[..]).unwrap(), (0, None));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,9 +209,10 @@ pub enum ServerPacket {
|
||||
map: u32,
|
||||
area: u32,
|
||||
},
|
||||
/// `SMSG_GMTICKET_GETTICKET`: our open ticket, `None` for "no ticket". Also pushed unasked
|
||||
/// when a GM views, escalates or completes it (`GMTicketMgr.cpp:153-159`).
|
||||
/// `SMSG_GMTICKET_GETTICKET`: the status and our open ticket, `None` for "no ticket". Also
|
||||
/// pushed unasked when a GM views, escalates or completes it (`GMTicketMgr.cpp:153-159`).
|
||||
GmTicketAnswer {
|
||||
status: u32,
|
||||
ticket: Option<Box<GmTicket>>,
|
||||
},
|
||||
/// `SMSG_GMTICKET_CREATE`: 2 created, 3 refused, 1 already have one; vmangos never sends 1
|
||||
|
||||
@@ -459,9 +459,13 @@ fn parse_server_body(
|
||||
}
|
||||
}
|
||||
// The ticket response opcodes share one 4-byte body; only the opcode names the verb.
|
||||
opcode::SMSG_GMTICKET_GETTICKET => ServerPacket::GmTicketAnswer {
|
||||
ticket: gm_ticket::read_gm_ticket(&mut r)?.map(Box::new),
|
||||
},
|
||||
opcode::SMSG_GMTICKET_GETTICKET => {
|
||||
let (status, ticket) = gm_ticket::read_gm_ticket(&mut r)?;
|
||||
ServerPacket::GmTicketAnswer {
|
||||
status,
|
||||
ticket: ticket.map(Box::new),
|
||||
}
|
||||
}
|
||||
opcode::SMSG_GMTICKET_CREATE => ServerPacket::GmTicketCreated {
|
||||
response: gm_ticket::read_gm_ticket_response(&mut r)?,
|
||||
},
|
||||
|
||||
@@ -330,8 +330,44 @@ fn with_button_shown(
|
||||
/// region in that layer goes dark, not only the HighlightTexture. `Enable()` here turns it back
|
||||
/// on; the reference restores it only on a hovered button, by re-running its `<OnEnter>`
|
||||
/// (`0x779183`), and never while `LockHighlight` holds (`[frame+0xf8]`).
|
||||
///
|
||||
/// On the hovered frame (`[[this+0xa0]+0x7c]`, `0x7791a3`, `0x779189`) a change runs the leave
|
||||
/// notify with 1 (`0x7791b4`) first, while the state still enables it, and the enter notify
|
||||
/// (`0x779192`) after the state is set, so the button's `OnLeave` and `OnEnter` fire for it; the
|
||||
/// hover itself does not move. A call that changes nothing returns at once (`0x779175`,
|
||||
/// `0x77919c`).
|
||||
fn set_enabled(lua: &Lua, this: &Table, on: bool) -> mlua::Result<()> {
|
||||
let h = frame_handle_of(lua, this)?;
|
||||
let hovered_change = {
|
||||
let model = lua.app_data_ref::<Model>().expect("model app_data");
|
||||
let frame = model
|
||||
.arena
|
||||
.frame(h)
|
||||
.ok_or_else(|| mlua::Error::runtime("stale frame handle"))?;
|
||||
match &frame.kind_state {
|
||||
KindState::Button(bs) => (bs.enabled() != on && model.mouseover == Some(h))
|
||||
.then(|| model.frame_to_id.get(&h).copied())
|
||||
.flatten(),
|
||||
_ => return Err(mlua::Error::runtime("not a Button")),
|
||||
}
|
||||
};
|
||||
if let (Some(id), false) = (hovered_change, on) {
|
||||
super::mouseover::leave(lua, h, Some(id));
|
||||
// The notify's argument 1 clears the drag arm (`0x76b725`).
|
||||
let mut model = lua.app_data_mut::<Model>().expect("model app_data");
|
||||
if model.drag.as_ref().is_some_and(|d| d.source == h) {
|
||||
model.drag = None;
|
||||
}
|
||||
}
|
||||
apply_enabled(lua, h, on)?;
|
||||
if let (Some(id), true) = (hovered_change, on) {
|
||||
super::mouseover::enter(lua, h, id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// [`set_enabled`]'s state and layer write, under one borrow.
|
||||
fn apply_enabled(lua: &Lua, h: FrameHandle, on: bool) -> mlua::Result<()> {
|
||||
let mut model = lua.app_data_mut::<Model>().expect("model app_data");
|
||||
let frame = model
|
||||
.arena
|
||||
@@ -370,7 +406,9 @@ pub(super) fn edge(
|
||||
|
||||
/// Whether a hover edge on `h` reaches the base notify, the HIGHLIGHT layer and the Lua
|
||||
/// `<OnEnter>`/`<OnLeave>`: `OnEnter`/`OnLeave` (`0x779490`/`0x7794e0`) skip it on a DISABLED
|
||||
/// Button, leaving only the hover sound (`0x7794b0`). Every hover path goes through that pair
|
||||
/// Button. The tail they still run (`0x7794b0`) calls a C++ listener at `+0x31c`, which the constructor
|
||||
/// zeroes (`0x7786be`) and whose only setter `0x779760` nothing references, so no hover sound plays.
|
||||
/// Every hover path goes through that pair
|
||||
/// (the hover walk `0x766218`, `SetMouseFocus` `0x764dc0`, the hide tail `0x764cce`), and the
|
||||
/// Hyperlink and NamePlate overrides chain back (`0x7cb8a5`). The hover target still moves, so
|
||||
/// `GetMouseFocus()` answers a disabled button.
|
||||
|
||||
@@ -77,6 +77,20 @@ pub(super) fn leave(lua: &Lua, h: FrameHandle, script: Option<u32>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A frame's enter notify (`vtbl+0x4c`) with `script` the id whose `OnEnter` fires: the walk's
|
||||
/// motion enter and an enabled Button's `Enable()` while hovered (`0x77918e`) both come here. A
|
||||
/// hyperlink button's enter is its text frame's `OnHyperlinkEnter` (`0x7a34b0`); the base
|
||||
/// enter's plain runner (`0x76b6e5` → `0x702690`) sets no arg global. An enabled Button
|
||||
/// refreshes its label after the base enter and its `OnEnter` (`0x76b6a0`, then `0x7794ab`).
|
||||
pub(super) fn enter(lua: &Lua, h: FrameHandle, script: u32) {
|
||||
if !super::hyperlink::hover(lua, h, true) {
|
||||
if let Err(e) = event::fire_widget_handler(lua, script, "OnEnter", Vec::new()) {
|
||||
model(lua).record_lua_error(&e);
|
||||
}
|
||||
}
|
||||
super::button::refresh_label(&mut model(lua), h);
|
||||
}
|
||||
|
||||
/// The publisher behind the change check: an unchanged mouseover does nothing (`0x4820b5`). A
|
||||
/// change away from a published one requests the fade on `GameTooltip` (`0x4928d5`, `0x492909` →
|
||||
/// `0x530ae0`), whoever holds it, after `"mouseover"` stops naming the old unit (the pair is zeroed
|
||||
|
||||
@@ -105,6 +105,10 @@ struct Plate {
|
||||
bar: FrameHandle,
|
||||
/// `None` when the fill's file failed to load (`0x7831b4`).
|
||||
fill: Option<RegionHandle>,
|
||||
/// The name's flash timer `+0x514`, in milliseconds: [`FLASH_MS`] when a hit arms it
|
||||
/// (`0x7cba77`), 0 at every bind (`0x7cb80e`), counted down by the plate's update; a negative
|
||||
/// timer is idle, and while it is above 0 the hover leaves the name red.
|
||||
flash_ms: i32,
|
||||
/// Last frame's state, so [`Plate::drive`] writes only what moved; `None` while retired.
|
||||
last: Option<PlateState>,
|
||||
/// The geometry its anchors were written under, `None` before the first lay-out. Kept per
|
||||
@@ -153,12 +157,56 @@ impl NamePlates {
|
||||
self.by_frame.contains_key(&frame)
|
||||
}
|
||||
|
||||
/// The plate frames, for the update walk to visit: each runs [`update`] ahead of its
|
||||
/// `OnUpdate` (`0x7cb950` → `0x76b2c0`).
|
||||
pub(super) fn frames(&self) -> impl Iterator<Item = FrameHandle> + '_ {
|
||||
self.by_frame.keys().copied()
|
||||
}
|
||||
|
||||
/// Whether the `0x7cba30` veto refuses `frame`: only a plate, only while the veto stands.
|
||||
pub(crate) fn vetoes(&self, frame: FrameHandle) -> bool {
|
||||
self.hit_test_vetoed && self.by_frame.contains_key(&frame)
|
||||
}
|
||||
}
|
||||
|
||||
/// The flash a hit starts, in milliseconds (`0x7cba77`, `0x1388`).
|
||||
const FLASH_MS: i32 = 5000;
|
||||
|
||||
/// The name colour while it flashes (`0x7cba88`, `0xffff0000`), and at rest: yellow while the glow
|
||||
/// shows, white otherwise (`0x7cb89e`, `0x7cb991`, `0x7cb8ed`).
|
||||
const FLASH_RED: crate::color::Rgba8 = crate::color::Rgba8::rgba(255, 0, 0, 255);
|
||||
const NAME_YELLOW: crate::color::Rgba8 = crate::color::Rgba8::rgba(255, 255, 0, 255);
|
||||
|
||||
/// The plate's `OnUpdate` override (`0x7cb950`), the flash half: a timer at or above 0 loses
|
||||
/// `ftol(elapsed * 1000)` (`0x7cb962`-`0x7cb976`), and once it is 0 or less the name takes its
|
||||
/// resting colour, by whether the glow shows (`0x7cb97e`-`0x7cb9ac`). A negative timer does
|
||||
/// nothing, so the bind's 0 resets the name on the first update and then idles. It runs ahead of
|
||||
/// the plate's own `OnUpdate` script, which the override tail-calls (`0x76b2c0`).
|
||||
pub(super) fn update(model: &mut Model, frame: FrameHandle, elapsed: f32) {
|
||||
let Some(&slot) = model.nameplates.by_frame.get(&frame) else {
|
||||
return;
|
||||
};
|
||||
let plate = &mut model.nameplates.plates[slot];
|
||||
if plate.flash_ms < 0 {
|
||||
return;
|
||||
}
|
||||
plate.flash_ms -= super::binding_abi::ftol(f64::from(elapsed) * 1000.0);
|
||||
if plate.flash_ms > 0 {
|
||||
return;
|
||||
}
|
||||
let colour = if plate.last.as_ref().is_some_and(|l| l.hovered) {
|
||||
NAME_YELLOW
|
||||
} else {
|
||||
crate::color::Rgba8::WHITE
|
||||
};
|
||||
let name = plate.name;
|
||||
model
|
||||
.region_data
|
||||
.entry(name)
|
||||
.or_default()
|
||||
.set_vertex_color(Some(colour));
|
||||
}
|
||||
|
||||
/// A completed click on a plate. The reference's click slot (`0x7cb910`) selects the unit on the
|
||||
/// left button (`0x4925d0`) and selects and interacts on the right (`0x492820`).
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@@ -311,6 +359,29 @@ impl UiScript {
|
||||
}
|
||||
}
|
||||
|
||||
/// A hit on the unit `key`: `FlashNamePlate` (`0x6122e0` → `0x7cba70`) starts the flash on the
|
||||
/// unit's plate, if it has one (`[unit+0xe60]`, `0x6122e6`): the timer to 5000 ms and the
|
||||
/// name red, whatever the hover. Called for a health drop (`0x6046f0`), a direct spell hit
|
||||
/// (`0x62cd80`) and environmental damage (`0x62aac0`).
|
||||
pub fn flash_nameplate(&mut self, key: u64) {
|
||||
let lua = self.lua();
|
||||
let mut model = lua.app_data_mut::<Model>().expect("model app_data");
|
||||
let Some(&slot) = model.nameplates.assigned.get(&key) else {
|
||||
return;
|
||||
};
|
||||
let plate = &mut model.nameplates.plates[slot];
|
||||
if plate.last.is_none() {
|
||||
return;
|
||||
}
|
||||
plate.flash_ms = FLASH_MS;
|
||||
let name = plate.name;
|
||||
model
|
||||
.region_data
|
||||
.entry(name)
|
||||
.or_default()
|
||||
.set_vertex_color(Some(FLASH_RED));
|
||||
}
|
||||
|
||||
/// The unit whose plate is the hovered frame, the mouseover its OnEnter publishes (`0x7cb850`
|
||||
/// → `0x492890`, `[0xb4e2c8]`); an addon frame on a plate takes the hover from it.
|
||||
pub fn hovered_nameplate(&self) -> Option<u64> {
|
||||
@@ -586,6 +657,7 @@ impl Plate {
|
||||
raid,
|
||||
bar,
|
||||
fill,
|
||||
flash_ms: 0,
|
||||
last: None,
|
||||
laid_out: None,
|
||||
}
|
||||
@@ -766,17 +838,25 @@ impl Plate {
|
||||
// A new string clears the valid bit and invalidates (`0x771ea4`).
|
||||
model.clear_region_valid(name);
|
||||
}
|
||||
// The bind starts the plate's flash timer at 0 (`0x7cb80e`).
|
||||
if last.is_none() {
|
||||
model.nameplates.plates[i].flash_ms = 0;
|
||||
}
|
||||
if last.as_ref().is_none_or(|l| l.hovered != state.hovered) {
|
||||
let c = if state.hovered {
|
||||
crate::color::Rgba8::rgba(255, 255, 0, 255)
|
||||
} else {
|
||||
crate::color::Rgba8::WHITE
|
||||
};
|
||||
model
|
||||
.region_data
|
||||
.entry(name)
|
||||
.or_default()
|
||||
.set_vertex_color(Some(c));
|
||||
// The enter and leave notifies (`0x7cb883`, `0x7cb8d9`) set the name's colour only
|
||||
// with the timer at 0 or less; a flash outlasts the hover.
|
||||
if model.nameplates.plates[i].flash_ms <= 0 {
|
||||
let c = if state.hovered {
|
||||
NAME_YELLOW
|
||||
} else {
|
||||
crate::color::Rgba8::WHITE
|
||||
};
|
||||
model
|
||||
.region_data
|
||||
.entry(name)
|
||||
.or_default()
|
||||
.set_vertex_color(Some(c));
|
||||
}
|
||||
// The glow really shows, as addons read mouseover from it; it only paints nothing.
|
||||
model.set_region_hidden(glow, !state.hovered);
|
||||
}
|
||||
|
||||
@@ -261,20 +261,8 @@ impl UiScript {
|
||||
if let Some((h, script)) = leave {
|
||||
super::mouseover::leave(&self.lua, h, script);
|
||||
}
|
||||
if let Some(nid) = enter_id {
|
||||
// A hyperlink button's enter is its text frame's `OnHyperlinkEnter` (`0x7a34b0`); the
|
||||
// base enter's plain runner (`0x76b6e5` → `0x702690`) sets no arg global.
|
||||
let routed = new_handle.is_some_and(|h| super::hyperlink::hover(&self.lua, h, true));
|
||||
if !routed {
|
||||
if let Err(e) = event::fire_widget_handler(&self.lua, nid, "OnEnter", Vec::new()) {
|
||||
self.push_error(e);
|
||||
}
|
||||
}
|
||||
// An enabled Button's enter refreshes its label after the base enter and its
|
||||
// `OnEnter` (`0x76b6a0`, then `0x7794ab`).
|
||||
if let Some(h) = new_handle {
|
||||
button::refresh_label(&mut self.model_mut(), h);
|
||||
}
|
||||
if let (Some(nid), Some(h)) = (enter_id, new_handle) {
|
||||
super::mouseover::enter(&self.lua, h, nid);
|
||||
}
|
||||
new_id
|
||||
}
|
||||
|
||||
@@ -383,6 +383,25 @@ fn pickup_spell(lua: &Lua, id: u32, book_type: &str) -> bool {
|
||||
payload.is_some_and(|payload| set_cursor(lua, true, Setter::of(&payload), |_| Some(payload)))
|
||||
}
|
||||
|
||||
/// The head of the cast dispatcher `0x4b3300`, which `CastSpell` and `CastSpellByName` both run
|
||||
/// (`0x4b4356`, `0x4b4b24`), before anything else is read: with a spell on the cursor (`0x4b3310`
|
||||
/// → `0x494e10` above 0) the slot goes through the pickup (`0x4b331f` → `0x4b3260`) and nothing
|
||||
/// is cast; otherwise `ClearCursor(1,1)` (`0x4b3354`) sends any held payload home, whatever the
|
||||
/// slot then does. A pet action on the cursor is not a spell there (`0x494e20` writes `0xb4e2f8`,
|
||||
/// not `0xb4e2f4`). Returns whether the verb is over.
|
||||
fn cast_head(lua: &Lua, id: u32, book_type: &str) -> bool {
|
||||
let spell_held = matches!(
|
||||
lua.app_data_ref::<Model>().expect("model app_data").cursor,
|
||||
Some(CursorPayload::Spell(_))
|
||||
);
|
||||
if spell_held {
|
||||
pickup_spell(lua, id, book_type);
|
||||
} else {
|
||||
verb(lua, clear_cursor);
|
||||
}
|
||||
spell_held
|
||||
}
|
||||
|
||||
/// Register the spellbook globals.
|
||||
pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
let g = lua.globals();
|
||||
@@ -576,6 +595,9 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
|lua, (id, book_type, on_self): (Value, Value, Option<Value>)| {
|
||||
let (id, book_type) = spell_slot_args(lua, id, book_type, "CastSpell")?;
|
||||
let on_self = bool_or_default(on_self.as_ref(), false);
|
||||
if cast_head(lua, id, &book_type) {
|
||||
return Ok(());
|
||||
}
|
||||
// The player book's cast is `TryCastSpell`, behind the gate's tag 2 (`0x6e4bc1`),
|
||||
// after the cancels of an active aura or form (`0x4b3466`, `0x4b35da`), so the call
|
||||
// is queued whatever the gate said and carries the answer to the cast alone; the
|
||||
@@ -724,6 +746,16 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
&name.as_bytes(),
|
||||
)
|
||||
};
|
||||
if let Some(found) = found {
|
||||
let book = if found.pet {
|
||||
BOOKTYPE_PET
|
||||
} else {
|
||||
BOOKTYPE_SPELL
|
||||
};
|
||||
if cast_head(lua, found.slot, book) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
let call = match found {
|
||||
Some(found) if found.pet => ScriptCall::CastPetSpell {
|
||||
spell_id: found.spell_id,
|
||||
@@ -1211,6 +1243,59 @@ mod tests {
|
||||
assert!(s.cursor_payload().is_none());
|
||||
}
|
||||
|
||||
/// `0x4b3300`: a held spell sends the slot through the pickup and casts nothing, for the
|
||||
/// plain click and the named cast alike; any other payload is cleared first, then the cast
|
||||
/// goes on (`0x4b3310`, `0x4b331f`, `0x4b3354`).
|
||||
#[test]
|
||||
fn a_cast_clears_the_cursor_and_with_a_spell_held_casts_nothing() {
|
||||
let held_action = || {
|
||||
CursorPayload::Action(CursorAction {
|
||||
src_slot: 1,
|
||||
kind: 0,
|
||||
action: 111,
|
||||
texture: None,
|
||||
count: 0,
|
||||
consumable: false,
|
||||
state: None,
|
||||
})
|
||||
};
|
||||
let mut s = UiScript::new().unwrap();
|
||||
s.keep_calls();
|
||||
s.set_spellbook(book());
|
||||
|
||||
for cast in [
|
||||
"CastSpell(3, BOOKTYPE_SPELL)",
|
||||
"CastSpellByName('Frost Armor')",
|
||||
// The held spell's own slot: put down, not cast.
|
||||
"CastSpell(1, BOOKTYPE_SPELL)",
|
||||
"CastSpellByName('Fireball')",
|
||||
] {
|
||||
assert!(pickup_spell(&s.lua, 1, "spell"), "{cast}");
|
||||
s.run(cast).unwrap();
|
||||
assert!(
|
||||
s.take_spell_casts().is_empty(),
|
||||
"{cast} cast with a spell held"
|
||||
);
|
||||
assert!(s.cursor_payload().is_none(), "{cast} left the spell held");
|
||||
}
|
||||
|
||||
for cast in [
|
||||
"CastSpell(1, BOOKTYPE_SPELL)",
|
||||
"CastSpellByName('Fireball')",
|
||||
] {
|
||||
s.set_cursor_for_test(held_action());
|
||||
s.run(cast).unwrap();
|
||||
assert_eq!(s.take_spell_casts(), vec![(133, false)], "{cast}");
|
||||
assert!(s.cursor_payload().is_none(), "{cast} left the payload held");
|
||||
}
|
||||
|
||||
// The clear is ahead of the slot test: a slot with no spell still drops the payload.
|
||||
s.set_cursor_for_test(held_action());
|
||||
s.run("CastSpell(3, BOOKTYPE_PET)").unwrap();
|
||||
assert!(s.take_spell_casts().is_empty());
|
||||
assert!(s.cursor_payload().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn passive_refuses_the_cast_but_active_queues_it() {
|
||||
let mut s = UiScript::new().unwrap();
|
||||
|
||||
@@ -13,6 +13,9 @@ const RANK_BUFFER: usize = 0x200;
|
||||
/// the player's cast refuses (`0x6e4bb2`) and the pet's order does not test.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct NamedSpell {
|
||||
/// The 1-based slot in its book, as `CastSpell` takes it: `0x4b3950` answers the index
|
||||
/// `0x4b4ab0` hands `0x4b3300`.
|
||||
pub slot: u32,
|
||||
pub spell_id: u32,
|
||||
/// The pet's book, not the player's (`0x4b3b51` writes 1, `0x4b3b3d` writes 0).
|
||||
pub pet: bool,
|
||||
@@ -36,8 +39,9 @@ pub(super) fn resolve_named(
|
||||
text: &[u8],
|
||||
) -> Option<NamedSpell> {
|
||||
let (name, rank) = split_name_rank(text);
|
||||
let (slot, pet) = find_in_books(&player.slots, &pet.slots, name, rank)?;
|
||||
let (index, slot, pet) = find_in_books(&player.slots, &pet.slots, name, rank)?;
|
||||
Some(NamedSpell {
|
||||
slot: index as u32 + 1,
|
||||
spell_id: slot.spell_id,
|
||||
pet,
|
||||
passive: slot.passive,
|
||||
@@ -109,7 +113,7 @@ fn find_in_books<'a>(
|
||||
pet: &'a [SpellSlotView],
|
||||
name: &[u8],
|
||||
rank: &[u8],
|
||||
) -> Option<(&'a SpellSlotView, bool)> {
|
||||
) -> Option<(usize, &'a SpellSlotView, bool)> {
|
||||
if name.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@@ -122,12 +126,10 @@ fn find_in_books<'a>(
|
||||
.as_bytes()
|
||||
.eq_ignore_ascii_case(rank))
|
||||
};
|
||||
player
|
||||
.iter()
|
||||
.rev()
|
||||
.find(named)
|
||||
.map(|s| (s, false))
|
||||
.or_else(|| pet.iter().rev().find(named).map(|s| (s, true)))
|
||||
let last = |slots: &'a [SpellSlotView]| slots.iter().enumerate().rev().find(|(_, s)| named(s));
|
||||
last(player)
|
||||
.map(|(i, s)| (i, s, false))
|
||||
.or_else(|| last(pet).map(|(i, s)| (i, s, true)))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -906,17 +906,83 @@ fn a_disabled_button_takes_the_hover_but_fires_no_enter_or_leave() {
|
||||
"no leave from the disabled button; the enabled one notifies normally"
|
||||
);
|
||||
|
||||
// Disabled while hovered: the leave is gated on the state at leave time.
|
||||
// Disabled while hovered: `SetEnabled` runs the leave itself (`0x7791b4`), so the walk's
|
||||
// later leave finds the state gone and fires nothing.
|
||||
s.run("On:Disable()").unwrap();
|
||||
assert_eq!(
|
||||
s.eval::<String>("return table.concat(log, ',')").unwrap(),
|
||||
"On:enter,On:leave",
|
||||
"Disable() under the cursor fires the leave"
|
||||
);
|
||||
s.mouse_move(400.0, 50.0);
|
||||
assert_eq!(
|
||||
s.eval::<String>("return table.concat(log, ',')").unwrap(),
|
||||
"On:enter",
|
||||
"a button disabled under the cursor swallows its own leave"
|
||||
"On:enter,On:leave",
|
||||
"the walk's leave is gated on the state at leave time"
|
||||
);
|
||||
assert!(s.errors().is_empty(), "{:?}", s.errors());
|
||||
}
|
||||
|
||||
/// `SetEnabled` (`0x779160`) on the hovered frame: `Disable()` runs the leave notify while the
|
||||
/// state still enables it (`0x7791b4`), and `Enable()` runs the enter notify once the state is set
|
||||
/// (`0x779192`). Off the hovered frame, or with no change, no script runs.
|
||||
#[test]
|
||||
fn enabling_or_disabling_a_hovered_button_fires_its_leave_and_enter() {
|
||||
let mut s = script();
|
||||
s.set_screen_size(800.0, 600.0);
|
||||
s.run(
|
||||
r#"
|
||||
log = {}
|
||||
local function mk(name, x)
|
||||
local b = CreateFrame("Button", name)
|
||||
b:SetPoint("BOTTOMLEFT", x, 0); b:SetWidth(100); b:SetHeight(100); b:EnableMouse(true)
|
||||
b:SetScript("OnEnter", function() table.insert(log, name..":enter:"..b:IsEnabled()) end)
|
||||
b:SetScript("OnLeave", function() table.insert(log, name..":leave:"..b:IsEnabled()) end)
|
||||
return b
|
||||
end
|
||||
Hot = mk("Hot", 0)
|
||||
Cold = mk("Cold", 200)
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
s.resolve();
|
||||
let log = |s: &mut crate::script::UiScript| {
|
||||
s.eval::<String>("local t = table.concat(log, ',') log = {} return t")
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
s.mouse_move(50.0, 50.0);
|
||||
assert_eq!(log(&mut s), "Hot:enter:1");
|
||||
|
||||
// The leave runs with the state still enabled, then the button is disabled; the hover stays.
|
||||
s.run("Hot:Disable()").unwrap();
|
||||
assert_eq!(log(&mut s), "Hot:leave:1");
|
||||
assert_eq!(s.eval::<i64>("return Hot:IsEnabled()").unwrap(), 0);
|
||||
assert_eq!(
|
||||
s.eval::<String>("return GetMouseFocus():GetName()")
|
||||
.unwrap(),
|
||||
"Hot"
|
||||
);
|
||||
// No change, nothing fires.
|
||||
s.run("Hot:Disable()").unwrap();
|
||||
assert_eq!(log(&mut s), "");
|
||||
|
||||
// The enter runs after the state is set.
|
||||
s.run("Hot:Enable()").unwrap();
|
||||
assert_eq!(log(&mut s), "Hot:enter:1");
|
||||
s.run("Hot:Enable()").unwrap();
|
||||
assert_eq!(log(&mut s), "");
|
||||
|
||||
// A button off the cursor fires neither way.
|
||||
s.run("Cold:Disable() Cold:Enable()").unwrap();
|
||||
assert_eq!(log(&mut s), "");
|
||||
|
||||
// The walk still leaves an enabled button normally.
|
||||
s.mouse_move(250.0, 50.0);
|
||||
assert_eq!(log(&mut s), "Hot:leave:1,Cold:enter:1");
|
||||
assert!(s.errors().is_empty(), "{:?}", s.errors());
|
||||
}
|
||||
|
||||
// ── The hover re-pick on a show (`0x764b8d`) ──
|
||||
|
||||
/// A mouse-enabled `Mover` hidden-cursor setup: the cursor rests at (150, 150) over nothing, then
|
||||
|
||||
@@ -1193,3 +1193,72 @@ fn the_plates_fill_shrinks_with_health() {
|
||||
crate::assert_near!(fill_width(&mut s), whole * part);
|
||||
}
|
||||
}
|
||||
|
||||
/// The name's `GetTextColor()` as a plate addon reads it: `r,g,b` rounded to bytes.
|
||||
fn name_colour(s: &mut UiScript) -> (u8, u8, u8) {
|
||||
let [r, g, b] = ["r", "g", "b"].map(|c| {
|
||||
s.eval::<f64>(&format!(
|
||||
"local _, _, name = WorldFrame:GetChildren():GetRegions() \
|
||||
local r, g, b = name:GetTextColor() return {c}"
|
||||
))
|
||||
.unwrap()
|
||||
});
|
||||
let byte = |c: f64| (c * 255.0).round() as u8;
|
||||
(byte(r), byte(g), byte(b))
|
||||
}
|
||||
|
||||
/// `FlashNamePlate` (`0x6122e0` → `0x7cba70`) sets the timer `+0x514` to 5000 ms and the name to
|
||||
/// `0xffff0000`; the plate's update (`0x7cb950`) takes `ftol(elapsed * 1000)` off it and, at 0 or
|
||||
/// less, restores white, or yellow while the glow shows. Hover moves (`0x7cb850`, `0x7cb8b0`)
|
||||
/// change the colour only with the timer at 0 or less, and a bind starts it at 0 (`0x7cb80e`).
|
||||
#[test]
|
||||
fn a_flashed_plate_reads_red_for_five_seconds_then_its_resting_colour() {
|
||||
const WHITE: (u8, u8, u8) = (255, 255, 255);
|
||||
const RED: (u8, u8, u8) = (255, 0, 0);
|
||||
const YELLOW: (u8, u8, u8) = (255, 255, 0);
|
||||
let mut s = vm();
|
||||
let wolf = plate("Wolf", 30.0, 40.0);
|
||||
drive(&mut s, std::slice::from_ref(&wolf));
|
||||
s.tick(0.0);
|
||||
assert_eq!(name_colour(&mut s), WHITE);
|
||||
|
||||
// A unit with no plate flashes nothing.
|
||||
s.flash_nameplate(wolf.key + 1);
|
||||
assert_eq!(name_colour(&mut s), WHITE);
|
||||
|
||||
s.flash_nameplate(wolf.key);
|
||||
assert_eq!(name_colour(&mut s), RED);
|
||||
s.tick(2.0);
|
||||
assert_eq!(name_colour(&mut s), RED, "3000 ms left");
|
||||
|
||||
// The hover does not touch the name while the timer is above 0.
|
||||
let mut hovered = wolf.clone();
|
||||
hovered.hovered = true;
|
||||
drive(&mut s, &[hovered.clone()]);
|
||||
assert_eq!(name_colour(&mut s), RED, "enter keeps the flash");
|
||||
drive(&mut s, std::slice::from_ref(&wolf));
|
||||
assert_eq!(name_colour(&mut s), RED, "leave keeps the flash");
|
||||
|
||||
// A second hit rearms the whole 5 s.
|
||||
s.flash_nameplate(wolf.key);
|
||||
s.tick(4.9);
|
||||
assert_eq!(name_colour(&mut s), RED, "100 ms left");
|
||||
s.tick(0.1);
|
||||
assert_eq!(name_colour(&mut s), WHITE, "the timer ran out unhovered");
|
||||
|
||||
// Expiring under the pointer restores yellow, the glow being shown.
|
||||
drive(&mut s, &[hovered.clone()]);
|
||||
assert_eq!(name_colour(&mut s), YELLOW, "the hover works again at rest");
|
||||
s.flash_nameplate(wolf.key);
|
||||
s.tick(5.0);
|
||||
assert_eq!(name_colour(&mut s), YELLOW);
|
||||
|
||||
// A bind clears a running flash: the plate returns for another unit.
|
||||
s.flash_nameplate(wolf.key);
|
||||
drive(&mut s, &[]);
|
||||
drive(&mut s, &[plate("Bear", 10.0, 90.0)]);
|
||||
s.tick(0.0);
|
||||
assert_eq!(name_colour(&mut s), WHITE);
|
||||
s.tick(1.0);
|
||||
assert_eq!(name_colour(&mut s), WHITE);
|
||||
}
|
||||
|
||||
@@ -49,10 +49,13 @@ impl UiScript {
|
||||
}
|
||||
// Only frames with an `OnUpdate` or a kind's own update do anything when walked.
|
||||
let mut seen = HashSet::new();
|
||||
// The plates' own update (`0x7cb950`) runs whether or not an addon set an `OnUpdate`.
|
||||
let plates: Vec<FrameHandle> = model.nameplates.frames().collect();
|
||||
for &h in model
|
||||
.on_update_frames
|
||||
.iter()
|
||||
.chain(model.arena.walked_kinds())
|
||||
.chain(&plates)
|
||||
{
|
||||
if let Some(f) = model.arena.frame(h).filter(|f| f.effective_visible) {
|
||||
let place = (f.strata as u8, f.level, 0, u64::from(f.insertion_seq));
|
||||
@@ -86,6 +89,10 @@ impl UiScript {
|
||||
.scripts
|
||||
.get(&h)
|
||||
.is_some_and(|s| s.contains("OnUpdate"));
|
||||
// The plate's override runs first and tail-calls the script (`0x7cb950`).
|
||||
if here {
|
||||
super::nameplate::update(&mut model, h, elapsed);
|
||||
}
|
||||
(on_update.then(|| model.frame_id(h)), kind_update)
|
||||
};
|
||||
if let Some(id) = on_update {
|
||||
|
||||
+15
-11
@@ -29,7 +29,7 @@ A setting boots at the reference's default unless it is listed here (`docs/METHO
|
||||
|
||||
Each entry is the first sentence of a `Deviation:` comment, linking to where it lives.
|
||||
|
||||
- [benilla-app](#benilla-app): 245
|
||||
- [benilla-app](#benilla-app): 246
|
||||
- [benilla-assets](#benilla-assets): 6
|
||||
- [benilla-blp](#benilla-blp): 1
|
||||
- [benilla-formats](#benilla-formats): 22
|
||||
@@ -345,9 +345,13 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
|
||||
- The reference skips that upload when windowed (`byte[dev+0x20b]` is `gxWindow`), and every benilla mode is windowed, so the same curve applies in the compositor, where the slider can move pixels: `UiGammaNode` raises the gamma byte the RAMDAC would have read to `gamma` before its decode, the continuous form of the 256-entry ramp. ([`src/ui_gamma.rs:56`](../crates/benilla-app/src/ui_gamma.rs#L56))
|
||||
- The reference never clamps (`SetGamma` `0x4891f0` writes `-4.000000` for 5), but its ramp is a fullscreen OS call and ours is the image, where an extreme exponent blacks out the panel that would undo it. ([`src/ui_gamma.rs:66`](../crates/benilla-app/src/ui_gamma.rs#L66))
|
||||
|
||||
#### ui_gm_ticket
|
||||
|
||||
- Those three are stack residue, so benilla sends 0 for each. ([`src/ui_gm_ticket.rs:169`](../crates/benilla-app/src/ui_gm_ticket.rs#L169))
|
||||
|
||||
#### ui_gossip
|
||||
|
||||
- 14 (a NULL, pushed as `nil`) and 15 up (a read past the table's end) give `"gossip"`, because the reference's behaviour there is a missing bounds check. ([`src/ui_gossip/mod.rs:238`](../crates/benilla-app/src/ui_gossip/mod.rs#L238))
|
||||
- 14 (a NULL, pushed as `nil`) and 15 up (a read past the table's end) give `"gossip"`, because the reference's behaviour there is a missing bounds check. ([`src/ui_gossip/mod.rs:253`](../crates/benilla-app/src/ui_gossip/mod.rs#L253))
|
||||
|
||||
#### ui_guild
|
||||
|
||||
@@ -500,7 +504,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
|
||||
- The reference dims non-target plates to `0x7F`; raised because that fades them too far to read. ([`src/vplates.rs:128`](../crates/benilla-app/src/vplates.rs#L128))
|
||||
- The reference draws at fractional device coordinates; the snap keeps the magnified border crisp. ([`src/vplates.rs:187`](../crates/benilla-app/src/vplates.rs#L187))
|
||||
- The reference's plates grow with the diagonal without limit (`0x7705b0`), which reads too big and soft; past this diagonal, where the frame is the border art's native 128x32 px, the basis grows at `PLATE_GROWTH_DAMP` of that rate. ([`src/vplates.rs:193`](../crates/benilla-app/src/vplates.rs#L193))
|
||||
- A constant one-logical-pixel shadow, not the reference's 0.001 gx, which draws 2 px thick and too heavy at larger windows. ([`src/vplates.rs:705`](../crates/benilla-app/src/vplates.rs#L705))
|
||||
- A constant one-logical-pixel shadow, not the reference's 0.001 gx, which draws 2 px thick and too heavy at larger windows. ([`src/vplates.rs:706`](../crates/benilla-app/src/vplates.rs#L706))
|
||||
- The reference magnifies the 128 × 32 `Interface\Tooltips\Nameplate-Border` art with `GL_LINEAR` (`0x770200`, filter `[0x878cf0]` = 1), smearing its 1 px bevel once the plate is larger than native; we resample the same pixels to the plate's physical size with sharp bilinear and draw it 1:1, because the chosen look is the same art with a crisp bevel. `super::drive_vplates` regenerates it when the physical size changes. ([`src/vplates/border.rs:3`](../crates/benilla-app/src/vplates/border.rs#L3))
|
||||
|
||||
#### wdb
|
||||
@@ -643,9 +647,9 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
|
||||
|
||||
#### events
|
||||
|
||||
- `benilla::spell_mods` refuses an out-of-range pair, because the reference would overrun it. ([`src/events.rs:759`](../crates/benilla-protocol/src/events.rs#L759))
|
||||
- An out-of-range list past the first block reads no body in the write passes (`0x466076`), which misread every block behind it, while the notify pass reads past it (`0x465fd0`) and stays in step; benilla reads the list and drops it, keeping the blocks behind it whole. ([`src/events/decode.rs:1136`](../crates/benilla-protocol/src/events/decode.rs#L1136))
|
||||
- The flagged pass reads a movement block's guid as 8 raw bytes (`0x467140`, `0x46714d`) where the wire packs it, so unless the packed guid happens to be 8 bytes the reference misreads the rest of that pass; benilla reads the block once, packed, as pass 0 does (`0x467080`). ([`src/events/decode.rs:1153`](../crates/benilla-protocol/src/events/decode.rs#L1153))
|
||||
- `benilla::spell_mods` refuses an out-of-range pair, because the reference would overrun it. ([`src/events.rs:763`](../crates/benilla-protocol/src/events.rs#L763))
|
||||
- An out-of-range list past the first block reads no body in the write passes (`0x466076`), which misread every block behind it, while the notify pass reads past it (`0x465fd0`) and stays in step; benilla reads the list and drops it, keeping the blocks behind it whole. ([`src/events/decode.rs:1138`](../crates/benilla-protocol/src/events/decode.rs#L1138))
|
||||
- The flagged pass reads a movement block's guid as 8 raw bytes (`0x467140`, `0x46714d`) where the wire packs it, so unless the packed guid happens to be 8 bytes the reference misreads the rest of that pass; benilla reads the block once, packed, as pass 0 does (`0x467080`). ([`src/events/decode.rs:1155`](../crates/benilla-protocol/src/events/decode.rs#L1155))
|
||||
|
||||
#### examples
|
||||
|
||||
@@ -664,7 +668,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
|
||||
- String reads are unbounded. The reference `0x4191b0` caps each field, counting the NUL (roster name `0x30`, notes `0x80`, MOTD `0x200`, info `0x7d0`, guild name `0x60`, rank name `0x40`), and on overflow empties it and no-ops every later read in the packet. ([`src/messages/guild.rs:4`](../crates/benilla-protocol/src/messages/guild.rs#L4))
|
||||
- A reason of 3 or more is silent, where the reference prints an uninitialized stack buffer, because 3 is the server's `INSTANCERESET_FAIL_SILENTLY`. ([`src/messages/instance.rs:70`](../crates/benilla-protocol/src/messages/instance.rs#L70))
|
||||
- 2 or more prints nothing, because the reference prints an uninitialized buffer. ([`src/messages/opcode.rs:1052`](../crates/benilla-protocol/src/messages/opcode.rs#L1052))
|
||||
- The consumer refuses 64 and up, because there the reference's store overruns its table. ([`src/messages/packet.rs:641`](../crates/benilla-protocol/src/messages/packet.rs#L641))
|
||||
- The consumer refuses 64 and up, because there the reference's store overruns its table. ([`src/messages/packet.rs:642`](../crates/benilla-protocol/src/messages/packet.rs#L642))
|
||||
- A body too short for the position gives `None` where the client redisplays a stale global, because showing a stale queue position as current is a client bug. ([`src/messages/parse.rs:285`](../crates/benilla-protocol/src/messages/parse.rs#L285))
|
||||
- A type outside 1-7 reads as nothing rather than the reference's default arm, which under-pushes its returns. ([`src/messages/pet.rs:71`](../crates/benilla-protocol/src/messages/pet.rs#L71))
|
||||
- Both are read, told apart exactly by the tail length (`12n` vs `1 + 14n`), since the 1.12 client mis-parses vmangos's. ([`src/messages/pet.rs:191`](../crates/benilla-protocol/src/messages/pet.rs#L191))
|
||||
@@ -719,8 +723,8 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
|
||||
- `None` answers `nil` where the reference's `-1` faction leg pushes nothing (Lua reads below the tuple), because no playable race reaches that leg. ([`src/script/battlefield_queue.rs:40`](../crates/benilla-ui/src/script/battlefield_queue.rs#L40))
|
||||
- The reference (`0x4abdc0`) admits 9 and reads one dword past its block; we answer 0 because that read is out of bounds. ([`src/script/battlefield_score.rs:289`](../crates/benilla-ui/src/script/battlefield_score.rs#L289))
|
||||
- `pow(10, n)` is the platform's, where the reference's (`0x73f940`, `fyl2x`) rounds its extended-precision steps at 53 bits, so a power or a fraction term can differ in the last place. ([`src/script/binding_abi.rs:281`](../crates/benilla-ui/src/script/binding_abi.rs#L281))
|
||||
- The disabled-checked leg (`0x785380`) tests and reloads the checked slot (`[+0x4e0]`, `0x785388`/`0x7853a5`), a copy of the checked leg's (`0x785270`), so in 1.12.1 a check box with a checked texture repaints that one and never gets its disabled-checked texture from a path. benilla tests and reloads the slot the method names. ([`src/script/button.rs:582`](../crates/benilla-ui/src/script/button.rs#L582))
|
||||
- The slot is read before the handler, where the reference reads it after (`[esi+0x4dc]`), because reading first keeps the borrow simple and no stock handler re-slots its row. ([`src/script/button.rs:1169`](../crates/benilla-ui/src/script/button.rs#L1169))
|
||||
- The disabled-checked leg (`0x785380`) tests and reloads the checked slot (`[+0x4e0]`, `0x785388`/`0x7853a5`), a copy of the checked leg's (`0x785270`), so in 1.12.1 a check box with a checked texture repaints that one and never gets its disabled-checked texture from a path. benilla tests and reloads the slot the method names. ([`src/script/button.rs:620`](../crates/benilla-ui/src/script/button.rs#L620))
|
||||
- The slot is read before the handler, where the reference reads it after (`[esi+0x4dc]`), because reading first keeps the borrow simple and no stock handler re-slots its row. ([`src/script/button.rs:1207`](../crates/benilla-ui/src/script/button.rs#L1207))
|
||||
- The reference's only bound is `luaD_call`'s count of 200 nested calls (`0x6f65ae`), past which it raises `C stack overflow` (`0x6f65bf`); eight here, as each level keeps an apply's frame on the Rust stack. ([`src/script/calls.rs:644`](../crates/benilla-ui/src/script/calls.rs#L644))
|
||||
- The reference composes the Shortcut with `GetRealZoneText` alone (`0x49efe8`), so in a capital `/leave Trade` sends `Trade - Stormwind City` and leaves nothing; ours uses the join's city-aware name, because the reference's form cannot leave the channel it joined. ([`src/script/channel.rs:497`](../crates/benilla-ui/src/script/channel.rs#L497))
|
||||
- The frame's bottom-left origin is snapped onto the device grid so the border art blits 1:1; the reference ceils the anchor point itself onto it (`0x7666a0`, `0x766750`). ([`src/script/chat_bubble.rs:482`](../crates/benilla-ui/src/script/chat_bubble.rs#L482))
|
||||
@@ -773,8 +777,8 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
|
||||
- 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:903`](../crates/benilla-ui/src/script/mod.rs#L903))
|
||||
- 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:991`](../crates/benilla-ui/src/script/mod.rs#L991))
|
||||
- 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:455`](../crates/benilla-ui/src/script/nameplate.rs#L455))
|
||||
- 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:911`](../crates/benilla-ui/src/script/nameplate.rs#L911))
|
||||
- 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))
|
||||
- A wrapper that decodes to no live widget takes `default_parent`, because the reference, with no `IsA` check, reads a wild pointer. ([`src/script/object/anchor_args.rs:218`](../crates/benilla-ui/src/script/object/anchor_args.rs#L218))
|
||||
- An `OnSizeChanged` that resolve produces fires at the next `UiScript::resolve`, because a Lua handler must not run in the middle of a level compaction. ([`src/script/object/toplevel.rs:77`](../crates/benilla-ui/src/script/object/toplevel.rs#L77))
|
||||
- A third `%s` gets an empty string, because the reference pushes two varargs (`0x6093f2 add esp,0x14`) and would read uninitialised stack. ([`src/script/pvp/mod.rs:318`](../crates/benilla-ui/src/script/pvp/mod.rs#L318))
|
||||
|
||||
Reference in New Issue
Block a user