playMaker

Author Topic: Bug in "StringContains" and "StringCompare" [FIXED]  (Read 2553 times)

vonchor

  • Guest
Bug in "StringContains" and "StringCompare" [FIXED]
« on: September 13, 2011, 06:34:49 PM »
This drove me nuts for a few hours till I realized it wasn't me!  :o

This action (and StringCompare as well) fail in the case where you are only looking for the "False Event" condition. If you only have an event set up for the false condition then it always is sent regardless of the status of the comparison. That's because of the logic construct in DoStringContains which doesn't test for the false condition. So if you have String Contains without an "True Event" (i.e., it's null) but only a "False Event" then the logic that sends events doesn't work right.
I

Same problem in StringCompare but the variable names are different.

Here's a fix for String Contains.

Code: [Select]

if (contains && trueEvent != null) {
Fsm.Event(trueEvent);
return;
}

if (!contains && falseEvent != null)
Fsm.Event(falseEvent);

I suppose the "return" in the first test isn't absolutely needed but it's a tiny bit more efficient.
« Last Edit: November 05, 2011, 05:06:31 PM by alexchouls »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Bug in "StringContains" and "StringCompare"
« Reply #1 on: September 18, 2011, 10:38:21 AM »
Thanks vonchor! I've added this to the 1.2.1 update.