#117 Inventory Armor filter broken


Trying to filter for armor fails because the IsFilter
filter has a string indexing bug. If the filter is just
a single [ character, it crashes trying to do a
substring to an invalid index.

The fix is quite simple. You don't need to use the two
argument substring(), just the one argument. Simply
replace line 11 with "name = query.substring(1);" and
it works.

I believe that there are other places that use the two
argument version unnecessariily, as well.

ThingMaker.createDesignerThing(String s)
PlugInUtility.getValue(Object o)
Game.displayMessage(String s)

... and about a dozen more. Anything doing
"string.substring(1,string.length() - 1)" is probably
wrong, unless it really is trying to strip off the last
character. Most of them seem to be trying to strip off
starting characters only. If that is what you want,
then you should use the one argument
String.substring(int beginIndex) method.


  • Mike Anderson

    Mike Anderson - 2005-06-12

    Logged In: YES

    Fixed - though the intention is to ignore the last letter in
    all of these cases.

    E.g. if the filter is "[IsFood]" we want to extract the
    "IsFood" part

  • Mike Anderson

    Mike Anderson - 2005-06-12
    • status: open --> closed-fixed

Log in to post a comment.