A:GetCurrentMapID() contains misordered statements #66


Closed
  • tw_vincent created this issue Jul 21, 2018

    In the code block below, C_Map.GetMapInfo() is called before the mapID is checked for validity. This allows C_Map.GetMapInfo() to throw an error if mapID=nil instead of allowing "if ( not mapID ) then return" to exit the routine. Suggest moving the C_Map.GetMapInfo() after the conditional return if-block.

     

    function A:GetCurrentMapID()
        local mapID = C_Map.GetBestMapForUnit("player");
        local mapInfo = C_Map.GetMapInfo(mapID);
    
        A:DebugMessage(("GetCurrentMapID() - mapID: %s"):format(tostring(mapID)));
    
        if ( not mapID ) then
            A.currentMapID = 0;
            return;
        end

     

     

     

  • Forge_User_34400336 posted a comment Jul 22, 2018

    Thank you for pointing that to me.

  • Forge_User_34400336 self-assigned this issue Jul 22, 2018
  • Forge_User_34400336 closed issue Aug 11, 2018

To post a comment, please login or register a new account.