diff --git a/doc/lua.adoc b/doc/lua.adoc index 8ca4fd9c1..3d03342b8 100644 --- a/doc/lua.adoc +++ b/doc/lua.adoc @@ -61,6 +61,7 @@ Set debugging flags. | mongen | boolean | Do monsters generate | hunger | boolean | Does hero's hunger-state increase | overwrite_stairs | boolean | Allow special-file commands overwrite the stairs +| prevent_pline | boolean | Prevent messages going out to the UI |=== Example: diff --git a/include/flag.h b/include/flag.h index 59ef02c04..dbcccd312 100644 --- a/include/flag.h +++ b/include/flag.h @@ -293,6 +293,7 @@ struct instance_flags { boolean debug_overwrite_stairs; /* debug: allow overwriting stairs */ boolean debug_mongen; /* debug: prevent monster generation */ boolean debug_hunger; /* debug: prevent hunger */ + boolean debug_prevent_pline; /* debug: prevent pline going to UI */ boolean mon_polycontrol; /* debug: control monster polymorphs */ boolean mon_telecontrol; /* debug: control monster teleports */ boolean in_dumplog; /* doing the dumplog right now? */ diff --git a/src/nhlua.c b/src/nhlua.c index 092c42e60..96970f73c 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -1494,6 +1494,12 @@ nhl_debug_flags(lua_State *L) iflags.debug_overwrite_stairs = (boolean) val; } + /* prevent pline going out to the UI */ + val = get_table_boolean_opt(L, "prevent_pline", -1); + if (val != -1) { + iflags.debug_prevent_pline = (boolean) val; + } + return 0; } diff --git a/src/pline.c b/src/pline.c index 48f8fc89f..f79cc6631 100644 --- a/src/pline.c +++ b/src/pline.c @@ -66,6 +66,9 @@ putmesg(const char *line) { int attr = ATR_NONE; + if (iflags.debug_prevent_pline) + return; + if ((gp.pline_flags & URGENT_MESSAGE) != 0 && (windowprocs.wincap2 & WC2_URGENT_MESG) != 0) attr |= ATR_URGENT; diff --git a/test/test_obj.lua b/test/test_obj.lua index 68ef9147b..1baad9832 100644 --- a/test/test_obj.lua +++ b/test/test_obj.lua @@ -101,3 +101,46 @@ for i = nhc.FIRST_OBJECT, nhc.LAST_OBJECT do end end + + +function test_use_item(action, itemname, otherkeys) + nh.debug_flags({ prevent_pline = true }); + u.clear_inventory(); + u.giveobj(obj.new(itemname)); + local o = u.inventory; + local ot = o:totable(); + + nh.pushkey(action); + nh.pushkey(ot.invlet); + + if (otherkeys ~= nil and type(otherkeys) == "string") then + nh.pushkey(otherkeys); + end + + nh.doturn(); + nh.debug_flags({ prevent_pline = false }); +end + +nh.parse_config("OPTIONS=number_pad:0"); +nh.parse_config("OPTIONS=!timed_delay"); + +-- apply +test_use_item("a", "uncursed tin whistle"); +test_use_item("a", "cursed tin whistle"); +test_use_item("a", "blessed magic whistle"); + +test_use_item("a", "uncursed camera", "h"); +test_use_item("a", "uncursed camera", "j"); +test_use_item("a", "uncursed camera", "k"); +test_use_item("a", "blessed camera", ">"); +test_use_item("a", "+0 blessed camera", ">"); + +test_use_item("a", "blessed stethoscope", "h"); +test_use_item("a", "blessed stethoscope", "j"); +test_use_item("a", "blessed stethoscope", "."); +test_use_item("a", "blessed stethoscope", ">"); +test_use_item("a", "blessed stethoscope", "<"); +obj.new("corpse"):placeobj(u.ux, u.uy); +test_use_item("a", "blessed stethoscope", ">"); +obj.new("statue"):placeobj(u.ux, u.uy); +test_use_item("a", "blessed stethoscope", ">");