Trigger matching regardless of line colors

Posted by Larkin on Fri 17 Jul 2009 03:53 PM — 7 posts, 33,879 views.

#0
I just upgraded to 4.42, and I don't know if this is a bug or what, but my trigger which is set to match only yellow (non-bold) on black is now firing on anything that matches the pattern regardless of color...

<triggers>
  <trigger
   back_colour="8"
   enabled="y"
   keep_evaluating="y"
   match="^(?:In the trees above |Flying above |On the rooftops over |In a pit at |In the mountains above |In a nest above )?(.+?\.)$"
   match_back_colour="y"
   match_bold="y"
   match_text_colour="y"
   omit_from_log="y"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="10000"
   text_colour="11"
  >
  <send>Note("%0")</send>
  </trigger>
</triggers>
Australia Forum Administrator #1
I can't reproduce that. Can you please paste here the packet debug of a line which you say is firing, which shouldn't?
#2
Just to be sure, I made a brand new world with just this one trigger and connected to Lusternia. Here's the debug I recorded:

Sent  packet: 12 (7 bytes) at Friday, July 17, 2009, 7:38:51 PM

nstat..            6e 73 74 61 74 0d 0a

Incoming packet: 14 (818 bytes) at Friday, July 17, 2009, 7:38:52 PM

News summary for   4e 65 77 73 20 73 75 6d 6d 61 72 79 20 66 6f 72
 Iasmos:....Publ   20 49 61 73 6d 6f 73 3a 0d 0a 0d 0a 50 75 62 6c
ic:           Re   69 63 3a 20 20 20 20 20 20 20 20 20 20 20 52 65
ad 1200/1200 art   61 64 20 31 32 30 30 2f 31 32 30 30 20 61 72 74
icles...Comments   69 63 6c 65 73 2e 0d 0a 43 6f 6d 6d 65 6e 74 73
:         Read 0   3a 20 20 20 20 20 20 20 20 20 52 65 61 64 20 30
/44 articles...A   2f 34 34 20 61 72 74 69 63 6c 65 73 2e 0d 0a 41
nnounce:           6e 6e 6f 75 6e 63 65 3a 20 20 20 20 20 20 20 20
 Read 1279/1279    20 52 65 61 64 20 31 32 37 39 2f 31 32 37 39 20
articles...Polit   61 72 74 69 63 6c 65 73 2e 0d 0a 50 6f 6c 69 74
ics:.[32m          69 63 73 3a 1b 5b 33 32 6d 20 20 20 20 20 20 20
  Read 1268/1283   20 20 52 65 61 64 20 31 32 36 38 2f 31 32 38 33
 articles....[37   20 61 72 74 69 63 6c 65 73 2e 0d 0a 1b 5b 33 37
mEvents:           6d 45 76 65 6e 74 73 3a 20 20 20 20 20 20 20 20
   Read 145/145    20 20 20 52 65 61 64 20 31 34 35 2f 31 34 35 20
articles...Plots   61 72 74 69 63 6c 65 73 2e 0d 0a 50 6c 6f 74 73
:            Rea   3a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 61
d 0/117 articles   64 20 30 2f 31 31 37 20 61 72 74 69 63 6c 65 73
...Serenwilde:     2e 0d 0a 53 65 72 65 6e 77 69 6c 64 65 3a 20 20
     Read 3240/3   20 20 20 20 20 52 65 61 64 20 33 32 34 30 2f 33
240 articles...S   32 34 30 20 61 72 74 69 63 6c 65 73 2e 0d 0a 53
erenguard:         65 72 65 6e 67 75 61 72 64 3a 20 20 20 20 20 20
 Read 269/269 ar   20 52 65 61 64 20 32 36 39 2f 32 36 39 20 61 72
ticles...Charune   74 69 63 6c 65 73 2e 0d 0a 43 68 61 72 75 6e 65
:          Read    3a 20 20 20 20 20 20 20 20 20 20 52 65 61 64 20
107/107 articles   31 30 37 2f 31 30 37 20 61 72 74 69 63 6c 65 73
...Lodge:          2e 0d 0a 4c 6f 64 67 65 3a 20 20 20 20 20 20 20
     Read 708/70   20 20 20 20 20 52 65 61 64 20 37 30 38 2f 37 30
8 articles...Seg   38 20 61 72 74 69 63 6c 65 73 2e 0d 0a 53 65 67
:              R   3a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52
ead 170/170 arti   65 61 64 20 31 37 30 2f 31 37 30 20 61 72 74 69
cles...Rangers:    63 6c 65 73 2e 0d 0a 52 61 6e 67 65 72 73 3a 20
         Read 49   20 20 20 20 20 20 20 20 20 52 65 61 64 20 34 39
/49 articles...S   2f 34 39 20 61 72 74 69 63 6c 65 73 2e 0d 0a 53
ongSparrow:        6f 6e 67 53 70 61 72 72 6f 77 3a 20 20 20 20 20
 Read 162/162 ar   20 52 65 61 64 20 31 36 32 2f 31 36 32 20 61 72
ticles...AG:       74 69 63 6c 65 73 2e 0d 0a 41 47 3a 20 20 20 20
           Read    20 20 20 20 20 20 20 20 20 20 20 52 65 61 64 20
58/58 articles..   35 38 2f 35 38 20 61 72 74 69 63 6c 65 73 2e 0d
.MSKA:             0a 4d 53 4b 41 3a 20 20 20 20 20 20 20 20 20 20
   Read 42/42 ar   20 20 20 52 65 61 64 20 34 32 2f 34 32 20 61 72
ticles...Tcc:      74 69 63 6c 65 73 2e 0d 0a 54 63 63 3a 20 20 20
           Read    20 20 20 20 20 20 20 20 20 20 20 52 65 61 64 20
125/125 articles   31 32 35 2f 31 32 35 20 61 72 74 69 63 6c 65 73
......[32m6873h,   2e 0d 0a 0d 0a 1b 5b 33 32 6d 36 38 37 33 68 2c
.[37m.[32m 2946m   1b 5b 33 37 6d 1b 5b 33 32 6d 20 32 39 34 36 6d
,.[37m.[32m 4788   2c 1b 5b 33 37 6d 1b 5b 33 32 6d 20 34 37 38 38
e,.[37m.[32m 10p   65 2c 1b 5b 33 37 6d 1b 5b 33 32 6d 20 31 30 70
,.[37m.[32m 2708   2c 1b 5b 33 37 6d 1b 5b 33 32 6d 20 32 37 30 38
0en,.[37m.[32m 1   30 65 6e 2c 1b 5b 33 37 6d 1b 5b 33 32 6d 20 31
4660w.[37m elrx-   34 36 36 30 77 1b 5b 33 37 6d 20 65 6c 72 78 2d
ÿù                 ff f9
USA #3
Yes, it's happening to me too. Bold green on black trigger is matching on bold white on black text.
Australia Forum Administrator #4
Ah, well you can blame Willfa for that. ;)

In this thread

http://www.gammon.com.au/forum/bbshowpost.php?id=9537

... he suggested this change to the code:


       if (trigger_item->iMatch & TRIGGER_MATCH_TEXT)
          if (get_foreground (trigger_item->iMatch) !=
              (iFlags & INVERSE) ? iBackColour : iForeColour )
            continue;   // wrong text colour
        if (trigger_item->iMatch & TRIGGER_MATCH_BACK)
          if (get_background (trigger_item->iMatch) !=
              (iFlags & INVERSE) ? iForeColour : iBackColour)
            continue;   // wrong background colour


However the correct change is in fact:


       if (trigger_item->iMatch & TRIGGER_MATCH_TEXT)
          if (get_foreground (trigger_item->iMatch) !=
              ((iFlags & INVERSE) ? iBackColour : iForeColour))
            continue;   // wrong text colour
        if (trigger_item->iMatch & TRIGGER_MATCH_BACK)
          if (get_background (trigger_item->iMatch) !=
              ((iFlags & INVERSE) ? iForeColour : iBackColour))
            continue;   // wrong background colour


(It took me a few minutes to spot it).

Operator precedence strikes again.

Will be fixed in version 4.43.


This was introduced in version 4.42, so you can use version 4.41 if this problem troubles you until version 4.43 is released.
Amended on Sat 18 Jul 2009 02:44 AM by Nick Gammon
USA #5
Oops! </embarassed>

For what ever it's worth, I did say that I didn't have VC++ installed and the code was untested. ;)

Australia Forum Administrator #6
Don't worry, you only said you thought it would compile, which it did.

I think the C operator precedence is a bit counter-intuitive, which is why the missing brackets slipped past both of us.