GetTradeSkillNumMade answers 1, 1 on a header or past the rows (#1459)

`GetTradeSkillNumMade` answered 0, 0 for a header row or an index past the rows.

1.12.1's `GetTradeSkillNumMade` (`0x4fdc50`) sends a bad index, a header (spell -1, `0x4fdcaa`) and a missing spell record to the fallback at `0x4fdd13`, which pushes 1 twice. A recipe with no spell record never becomes a row in benilla, so the past-the-rows case covers it.

The miss now answers 1, 1. Tests: the header, no-window and past-the-rows cases pin 1, 1.

Fixes #1262

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 129b3bb852b2f328de529f3c698595c14baf5fa5)
This commit is contained in:
badmagick329
2026-10-25 23:02:28 -06:00
committed by grom
parent 8e0a0155d6
commit 4c98a8d981
2 changed files with 10 additions and 3 deletions
@@ -252,12 +252,13 @@ pub(in crate::script) fn install(lua: &Lua) -> mlua::Result<()> {
})?,
)?;
// GetTradeSkillNumMade(index) (`0x4fdc50`): 1, 1 on a header or past the rows (`0x4fdd13`).
g.set(
"GetTradeSkillNumMade",
lua.create_function(|lua, index: usize| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
let (min_made, max_made) =
recipe_at(&model, index).map_or((0, 0), |r| (r.min_made, r.max_made));
recipe_at(&model, index).map_or((1, 1), |r| (r.min_made, r.max_made));
Ok(MultiValue::from_vec(vec![
Value::Integer(i64::from(min_made)),
Value::Integer(i64::from(max_made)),
@@ -235,10 +235,16 @@ fn do_trade_skill_and_getters_no_op_on_a_header_index() {
assert!(s
.eval::<bool>("return GetTradeSkillIcon(1) == nil")
.unwrap());
// But the made counts, which answer 1, 1 on a header and past the last row (`0x4fdd13`).
assert_eq!(
s.eval::<(i64, i64)>("return GetTradeSkillNumMade(1)")
.unwrap(),
(0, 0)
(1, 1)
);
assert_eq!(
s.eval::<(i64, i64)>("return GetTradeSkillNumMade(99)")
.unwrap(),
(1, 1)
);
assert!(s
.eval::<bool>("return GetTradeSkillCooldown(1) == nil")
@@ -488,7 +494,7 @@ fn no_snapshot_shapes_unknown_line_and_nil_info() {
assert_eq!(
s.eval::<(i64, i64)>("return GetTradeSkillNumMade(1)")
.unwrap(),
(0, 0)
(1, 1)
);
assert!(s
.eval::<bool>("return GetTradeSkillCooldown(1) == nil")