RPTools / maptool

Virtual Tabletop for playing roleplaying games with remote players or face to face.
http://rptools.net
GNU Affero General Public License v3.0
802 stars 262 forks source link

[Bug]: metamacro functions producing Java errors #4582

Closed bubblobill closed 11 months ago

bubblobill commented 11 months ago

Describe the Bug

image https://discord.com/channels/296230822262865920/905157521193455676/1188456999755714610

To Reproduce

use metamacro function without all optional parameters

Expected Behaviour

should function cleanly

Screenshots

No response

MapTool Info

No response

Desktop

No response

Additional Context

No response

kwvanderlinde commented 11 months ago

This change has broken all the functions it touches. E.g., getMacros() went from

      if (parameters.get(1).toString().equalsIgnoreCase("campaign")) {
        return getMacros(delim, MapTool.getCampaign().getMacroButtonPropertiesArray());
      } else if (parameters.get(1).toString().equalsIgnoreCase("gm")) {
        return getMacros(delim, MapTool.getCampaign().getGmMacroButtonPropertiesArray());
      } else {
        Token token = FunctionUtil.getTokenFromParam(resolver, functionName, parameters, 1, 2);
        return getMacros(delim, token);
      }

to

      if (parameters.size() > 1) {
        if (parameters.get(1).toString().equalsIgnoreCase("campaign")) {
          return getMacros(delim, MapTool.getCampaign().getMacroButtonPropertiesArray());
        } else if (parameters.get(1).toString().equalsIgnoreCase("gm")) {
          return getMacros(delim, MapTool.getCampaign().getGmMacroButtonPropertiesArray());
        }
      } else {
        Token token = FunctionUtil.getTokenFromParam(resolver, functionName, parameters, 1, 2);
        return getMacros(delim, token);
      }

So there is now no way to use this function with parameters, unless we happen to use the new "campaign" or "gm" options.

bubblobill commented 11 months ago

This change broken all the functions it touches. E.g., getMacros() went from

So there is now no way to use this function with parameters, unless we happen to use the new "campaign" or "gm" options.

Hmmm... that could be problematic. Just a little bit. That being said, it will only break every framework known to man,

bubblobill commented 11 months ago

Fixed the fix. Properly this time. Complete with lots of testing to prevent future embarrassment

kwvanderlinde commented 11 months ago

Awesome, looks good now!