jpcsupplies / Economy_mod

Basic Economy System for Space Engineers
13 stars 12 forks source link

Bug - System.ArgumentOutOfRangeException #129

Closed jpcsupplies closed 8 years ago

jpcsupplies commented 8 years ago

From steam - zataralee 2 hours ago
Looks like the mod isn't working with the update.

2016-03-17 17:06:21.945 - System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at Sandbox.Game.Gui.MyHudObjectiveLine.get_CurrentObjective() at Economy.scripts.EconomyScript.ProcessMessage(String messageText) at Economy.scripts.EconomyScript.GotMessage(String messageText, Boolean& sendToOthers)

Not sure if his version is an issue or our name spaces, just testing now. Suspect DS out of date. But ill see in a moment.

midspace commented 8 years ago

It sounds like mission objectives list is empty. I'm guessing because we've turned the hud off on start, so no objectives have been created, so when you try /bal first (something I did not do), it throws an exception.

I'm guessing at the steps.

  1. Join server.
  2. Spawn.
  3. try /bal

We may have to check the count with MyAPIGateway.Utilities.GetObjectiveLine().Objectives.Count != 0

like this

//pull current mission text
if (MyAPIGateway.Utilities.GetObjectiveLine().Objectives.Count != 0 && MyAPIGateway.Utilities.GetObjectiveLine().CurrentObjective == "Type /bal to connect to network")
{
    if (!UpdateHud()) 
    { 
        MyAPIGateway.Utilities.ShowMessage("Error", "Hud Failed"); 
    }
}
match = Regex.Match(messageText, BalPattern, RegexOptions.IgnoreCase);
jpcsupplies commented 8 years ago

Just made a new map and did that, had no errors to speak of. Couldnt get any of the errors reported. Nor was it an issue on ramblers which potentially had existing data.

However the client mission number was not saving in a previous test.. but that shouldn't hurt unless someone manually changed it in the data file.. even then I had that extra invalid default mission fill in for if the number was out of range.

Aside from which- I thought that code was pretty much checking for conditions that can never happen since i disabled the increment in /debug before last weeks namespace commit.

Even if you dont .show the hud it still behaves like it is there (ie add/change missions etc)

midspace commented 8 years ago

I want to see the full log file.

midspace commented 8 years ago

I'm beginning to suspect there is another mod interfering. Can't tell without looking at a sample world having this problem.

jpcsupplies commented 8 years ago

So am i, not sure if you are watching skype, but i narrowed it down to one possible line that calls the crashing area - only thing that queries current objective is this: if (MyAPIGateway.Utilities.GetObjectiveLine().CurrentObjective == "Type /bal to connect to network") if (!UpdateHud()) { MyAPIGateway.Utilities.ShowMessage("Error", "Hud Failed"); };

midspace commented 8 years ago

The exception has been dealt with, and the cause has been fixed.