From 1db0645c338dc00be1c2ada9a60ba0dd8c8dcf97 Mon Sep 17 00:00:00 2001 From: Jeff Claar Date: Thu, 1 Aug 2024 15:37:40 -0700 Subject: [PATCH 1/2] Fixed syntax so that "Strike Match" will work properly. --- mdlfun/dung.cpp | 4 ++-- mdlfun/makstr.cpp | 10 +++++++--- mdlfun/makstr.h | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mdlfun/dung.cpp b/mdlfun/dung.cpp index b852858..585b9ce 100644 --- a/mdlfun/dung.cpp +++ b/mdlfun/dung.cpp @@ -716,8 +716,8 @@ namespace sadd_action("STAY", stay()); add_action("STRIK", "Strike", ActionVec{ - AnyV{ AL{ Bits::vicbit, reach(), robjs() }, "WITH", AL{ Bits::weaponbit, aobjs(), robjs(), have() }, AVSyntax("ATTAC", attacker()) }, - AnyV{ AL{ Bits::vicbit, reach(), robjs() }, AVSyntax("ATTAC", attacker()), driver() }, + AnyV{ AL{ Bits::vicbit, eq(), reach(), robjs() }, "WITH", AL{ Bits::weaponbit, aobjs(), robjs(), have() }, AVSyntax("ATTAC", attacker()) }, + AnyV{ AL{ Bits::vicbit, eq(), reach(), robjs() }, AVSyntax("ATTAC", attacker()), driver() }, AnyV{ AL{ -1, reach(), robjs(), aobjs(), try_() }, AVSyntax("LIGHT", lamp_on()) } }); diff --git a/mdlfun/makstr.cpp b/mdlfun/makstr.cpp index dba5af1..fb5e61c 100644 --- a/mdlfun/makstr.cpp +++ b/mdlfun/makstr.cpp @@ -169,11 +169,15 @@ namespace // There are only two options that use this: KNOCK, and STRIKE. // It's basically used to distinguish between, for example, // attacking something (i.e. "strike troll") vs. lighting something. - // (i.e. "strike match") + // (i.e. "strike match") This is the "=" operator in the MDL code, + // which apparently (I can't find any docs on it) means "Copy of the + // previous element in the list." const Bits *b; - if (al.size() > 1 && (b = std::get_if(&idx(al,1)))) + if (al.size() > 1 && std::holds_alternative(idx(al,1))) { - vv->vfwim[*b] = 1; + _ASSERT(std::holds_alternative(idx(al, 0))); + auto b = std::get(idx(al, 0)); + vv->vfwim[b] = 1; } else { diff --git a/mdlfun/makstr.h b/mdlfun/makstr.h index 9538b93..ca5a58b 100644 --- a/mdlfun/makstr.h +++ b/mdlfun/makstr.h @@ -27,6 +27,7 @@ direction find_dir(const std::string &dir); // Actions // Object support flags. +class eq {}; class nrobj {}; class robjs {}; class reach {}; @@ -38,7 +39,7 @@ class try_ {}; // Added underscore to avoid using "try" keyword class take {}; class driver {}; class flip {}; -typedef std::variant> ALType; +typedef std::variant> ALType; typedef std::list AL; class AVSyntax : private std::tuple { -- 2.46.4