Input string was not in correct format.

05/13/2010 05:30 scottdavey#1
I have fully converted LOTF to ini, as you can see it works pretty much ok from the screenshot:

[Only registered and activated users can see links. Click Here To Register...]

But I get this error/warning that is to do with my LoadMobSpawns function:
[Only registered and activated users can see links. Click Here To Register...]

Code:
public static void LoadMobSpawns()
        {
            if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\Objects\MobSpawns.txt"))
            {
                TextReader TR = new StreamReader(System.Windows.Forms.Application.StartupPath + @"\Objects\MobSpawns.txt");
                string Items = TR.ReadToEnd();
                TR.Close();
                Items = Items.Replace("\r", "");
                string[] AllItems = Items.Split('\n');
                MobSpawns = new uint[AllItems.Length][];
                int i = 0;
                foreach (string _item in AllItems)
                {
                    string _item_ = _item.Trim();
                    if (_item_.Length >= 2)
                    {
                        if (_item_.IndexOf("//", 0, 2) != 0)
                        {
                            string[] SpawnInfo = _item_.Split(' ');
                            uint SpawnID = uint.Parse(SpawnInfo[0]);
                            uint SpawnWhatID = uint.Parse(SpawnInfo[1]);
                            uint SpawnNr = uint.Parse(SpawnInfo[2]);
                            uint XStart = uint.Parse(SpawnInfo[3]);
                            uint YStart = uint.Parse(SpawnInfo[4]);
                            uint XEnd = uint.Parse(SpawnInfo[5]);
                            uint YEnd = uint.Parse(SpawnInfo[6]);
                            uint Map = uint.Parse(SpawnInfo[7]);
                            MobSpawns[i] = new uint[8] { SpawnID, SpawnWhatID, SpawnNr, XStart, YStart, XEnd, YEnd, Map };
                            i++;
                        }
                    }
                }
                Console.WriteLine(i + " Mob Spawns successfully loaded.");
            }
            else
            {
                Console.WriteLine("MobSpawns file is missing, no MobSpawns where loaded!");
            }
        }
The error line:

Code:
SingleMob Mob = new SingleMob(spawn_x, spawn_y, Convert.ToInt16(ThisSpawn[7]), uint.Parse(ThisMob[3]), uint.Parse(ThisMob[3]), short.Parse(ThisMob[6]), short.Parse(ThisMob[7]), UID, ThisMob[2], int.Parse(ThisMob[1]), short.Parse(ThisMob[4]), (byte)General.Rand.Next(8), byte.Parse(ThisMob[5]));
I have used the same method for 4 other types of loading, portals, etc the funny thing is the monsters still load ingame, I have to use this method as I coded a php script to dump the lotf db to ini.

Any ideas? I have attached the file for you to review.
05/13/2010 08:39 -impulse-#2
Code:
public static void LoadMobSpawns()
        {
            if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\Objects\MobSpawns.txt"))
            {
                TextReader TR = new StreamReader(System.Windows.Forms.Application.StartupPath + @"\Objects\MobSpawns.txt");
                string Items = TR.ReadToEnd();
                TR.Close();
                Items = Items.Replace("\r", "");
                string[] AllItems = Items.Split('\n');
                MobSpawns = new uint[AllItems.Length][];
                int i = 0;
                foreach (string _item in AllItems)
                {
                    string _item_ = _item.Trim();
                    if (_item_.Length >= 2)
                    {
                        if (_item_.IndexOf("//", 0, 2) != 0)
                        {try{
                            string[] SpawnInfo = _item_.Split(' ');
                            uint SpawnID = uint.Parse(SpawnInfo[0]);
                            uint SpawnWhatID = uint.Parse(SpawnInfo[1]);
                            uint SpawnNr = uint.Parse(SpawnInfo[2]);
                            uint XStart = uint.Parse(SpawnInfo[3]);
                            uint YStart = uint.Parse(SpawnInfo[4]);
                            uint XEnd = uint.Parse(SpawnInfo[5]);
                            uint YEnd = uint.Parse(SpawnInfo[6]);
                            uint Map = uint.Parse(SpawnInfo[7]);
                            MobSpawns[i] = new uint[8] { SpawnID, SpawnWhatID, SpawnNr, XStart, YStart, XEnd, YEnd, Map };
                            i++;
}
catch
{
Console.WriteLine(_item);
}
                        }
                    }
                }
                Console.WriteLine(i + " Mob Spawns successfully loaded.");
            }
            else
            {
                Console.WriteLine("MobSpawns file is missing, no MobSpawns where loaded!");
            }
        }
See what lines gives you error with this code.
05/13/2010 08:59 scottdavey#3
Same error, doesn't write any line.

Strange..
05/13/2010 11:20 Korvacs#4
There error is being caused by one of your short.Parse() attempts, go back and check that everything your parsing can be parsed, and check that your .ini file is layed out correctly.
05/13/2010 11:40 scottdavey#5
Quote:
Originally Posted by Korvacs View Post
There error is being caused by one of your short.Parse() attempts, go back and check that everything your parsing can be parsed, and check that your .ini file is layed out correctly.
The text file attached was generated by a php script I created, I cannot see anything wrong with it with the naked eye, could you check it and see what you think?

Cheers
05/13/2010 11:47 Korvacs#6
Your looking for anything which isnt a number, or something that should be a number and for some reason isnt.

If you cant find anything that way, surround the line in question with a try catch exception, once you have done that throw a breakpoint into the catch side of the exception, once this breakpoint is triggered, you can see exactly which line of your .ini file is causing the problem, and specifically which point in the line is failing to be parsed.
05/13/2010 18:56 scottdavey#7
Quote:
Originally Posted by Korvacs View Post
Your looking for anything which isnt a number, or something that should be a number and for some reason isnt.

If you cant find anything that way, surround the line in question with a try catch exception, once you have done that throw a breakpoint into the catch side of the exception, once this breakpoint is triggered, you can see exactly which line of your .ini file is causing the problem, and specifically which point in the line is failing to be parsed.
I have no idea what you just said, I know how to try and catch but everything else you just said has just puzzled me lol, I'm still amateur at C#.

Playing with the source to improve my knowledge.
05/13/2010 19:17 .Summer#8
line 213 entities.cs :)
05/13/2010 20:10 scottdavey#9
[Only registered and activated users can see links. Click Here To Register...]

These are the only three that appear bugged, can anyone check the ini file and see if they see a problem as I can't see one..

On a side note:
2000 mobs spawn now instead of like 200.
05/13/2010 23:53 scottdavey#10
Fixed, impulse found the problem!

The problem was that there where two spaces in three monsters, PHP dump must have added them by accident.
05/14/2010 00:02 .Summer#11
Good to hear is fixed now :)