RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RunUO 2.0 RC1] Resources (Ore/Granite/Leather/Wood/Boards/Crystals/Powders) Mining Error

FingersMcSteal

Sorceror
Server Crash Report
===================

RunUO Version 2.1, Build 4031.28390
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 3
.NET Framework: 2.0.50727.3615
Time: 2/1/2011 4:11:10 PM
Mobiles: 37253
Items: 187136
Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Server.Engines.Harvest.Mining.GetResourceType(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource)
at Server.Engines.Harvest.HarvestSystem.FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, Object toHarvest, Object locked)
at Server.Engines.Harvest.HarvestSoundTimer.OnTick()
at Server.Timer.Slice() in c:\testshard\Stygian\Stygian Abyss ML\Server\Timer.cs:line 386
at Server.Core.Main(String[] args) in c:\testshard\Stygian\Stygian Abyss ML\Server\Main.cs:line 517

Clients:
- Count: 1
+ 192.168.1.46: (account = player1) (mobile = 0x32BA 'Nyx Vashuu')

I've had a quick look at this error and the mining file you had attached...

Looks to me like the following lines might be the cause of the crash...

Code:
        public override Type GetResourceType( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource )
        {
            if ( def == m_OreAndStone )
            {
                PlayerMobile pm = from as PlayerMobile;
                [B]if ( pm != null && pm.GemMining && pm.ToggleMiningGem && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() )[/B]
[B]                    return resource.Types[2];[/B]
                if ( pm != null && pm.StoneMining && pm.ToggleMiningStone && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() )
                    return resource.Types[1];

                return resource.Types[0];
            }

            return base.GetResourceType( from, tool, def, map, loc, resource );
        }

It looks to me like this line...

if ( pm != null && pm.GemMining && pm.ToggleMiningGem && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() )
return resource.Types[2];

Is newer code. Probably added as the SVN has been updated over time etc etc etc.
If you could run your server in DEBUG mode for a bit until you get the crash again it might help pin point the problem tho since that debug mode would give line numbers as to where the problems coming from, just a bit more detail to go on is all.
 

Pure Insanity

Sorceror
Few questions, what map was that player located on when it crashed? Are you positive you put this resource system in correctly? I suggest double checking all distro edits you needed to make, check them with a merging program such as Notepad++ or WinMerge, but DO NOT merge over all of the changes as it will simply screw things up more than anything.

Other questions...what you using a mining tool when this happened? If so, what kind, how many uses were left, was it a distro tool or custom one? Was the tool made out of one of the new resources? Was you actually trying to mine or gem or not?
 

FingersMcSteal

Sorceror
I get the feeling it's a problem with the Gem Mining part myself, the original error is telling me it's an array pointer thats going out of bounds.

The original system (which i did on SVN 300) only had 2 array elements to go through (0 or 1) as a result (the return call). The line that looks like the cause is...

if ( pm != null && pm.GemMining && pm.ToggleMiningGem && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() )
return resource.Types[2];
specifically resource.Types[2]; Which would return a Type[2], which in the original system would never happen. I added the ML drop code to my mining system before it was added into the SVN's when i was at SVN300 so i think this maybe the cause. In the harvest resource section theres this...

new HarvestResource( 00.0, 00.0, 100.0, 1007072, typeof( IronOre ), typeof
( Granite ) ),

Which has only 2 Types (0 or 1) not taking into account anything for Type[2] which is a 3rd array element (or a NULL element).

I'm not sure where the Gem Mining check came into it or why (maybe another part to a different custom system) but normally it was just Stone Mining that was checked in the original, I can't check whats new right now as i can't download a newer SVN version (UserName & Password errors).

Anyways, taking a quick look that seems to me anyway where the problems cropping up, like i said tho... run the server with DEBUG and it might give line numbers etc and something else to work with.

*** EDIT ***
Please remember this release is almost 5 years old ;)
 

sec_goat

Squire
Good morning,

I will try running the server in debug mode and see if I can get it to crash again.
The map that this all started on was Malas, just south of Umbra (if that matters?).
I did merge the mining file and the new mining file, and I am by no means any sort of expert so I could have easily messed something up.
I will try to reproduce and look into the mining files today and come back with some more info.

Thank you for all your help and suggestions!
 

sec_goat

Squire
Here is some more info:

Tool used: Sturdy Shovel 30 uses remaining not made of special material


Code:
Server Crash Report
===================

RunUO Version 2.1, Build 4031.28390
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 3
.NET Framework: 2.0.50727.3607
Time: 2/4/2011 9:16:06 AM
Mobiles: 37257
Items: 187122
Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Server.Engines.Harvest.Mining.GetResourceType(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource) in c:\testshard\Stygian\Stygian Abyss ML\Scripts\Custom\YaksResources\Harvesting\Mining.cs:line 239
   at Server.Engines.Harvest.HarvestSystem.FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, Object toHarvest, Object locked) in c:\testshard\Stygian\Stygian Abyss ML\Scripts\Engines\Harvest\Core\HarvestSystem.cs:line 152
   at Server.Engines.Harvest.HarvestSoundTimer.OnTick() in c:\testshard\Stygian\Stygian Abyss ML\Scripts\Engines\Harvest\Core\HarvestSoundTimer.cs:line 30
   at Server.Timer.Slice() in c:\testshard\Stygian\Stygian Abyss ML\Server\Timer.cs:line 386
   at Server.Core.Main(String[] args) in c:\testshard\Stygian\Stygian Abyss ML\Server\Main.cs:line 517

Clients:
- Count: 1
+ 127.0.0.1: (account = player1) (mobile = 0x32BA 'Nyx Vashuu')


Here is the line from the mining file:

Code:
            new HarvestVein( 04.4, 0.4, res[8], res[0] ),   // Verite
 

FingersMcSteal

Sorceror
Ok, the debug helpped with giving the line numbers for a start.

Maps shouldn't make a great deal of difference for this problem so thats nothing to worry about.

I've had a quick look (just got in from work) and the original line i was thinking is in fact (according to debug info) the problem line...


if ( pm != null
&& pm.GemMining && pm.ToggleMiningGem && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() ) return
resource.Types[2];

And also from the harvest system error in line 152...

type = GetResourceType( from, tool, def, map, loc, resource );

Couple of things thats got me stuck are... Player Mobile, have you changed this in any way. The reason i'm asking this is the Gem Mining flag thats attached to the pm.GemMining part in the first part of that line. I've had a look at a player Mobile file i have (the newest i have) and theres no such flag for the player mobile...


namespace
Server.Mobiles
{
#region
Enums
[Flags
] public enum PlayerFlag
// First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
{
None = 0x00000000,
Glassblowing = 0x00000001,
Masonry = 0x00000002,
SandMining = 0x00000004,
StoneMining = 0x00000008,
ToggleMiningStone = 0x00000010,
KarmaLocked = 0x00000020,
AutoRenewInsurance = 0x00000040,
UseOwnFilter = 0x00000080,
PublicMyRunUO = 0x00000100,
PagingSquelched = 0x00000200,
Young = 0x00000400,
AcceptGuildInvites = 0x00000800,
DisplayChampionTitle = 0x00001000,
HasStatReward = 0x00002000
}

Which leads me to think you've got some 'other' system or change to your server thats maybe got GemMining defined ???

The other thing i'm curious about is when you click the shovel prior to digging is there any additional settings that show up, as in where you set the shovel to mine for Stone or metals etc etc, does yours have anything in for gem mining there ???

Best way forward for this tho would be to post the Mining.cs and HarvestSystem.cs files here, probably the player flag part of your PlayerMobile.cs too so i can take a quick look.

The error's being created at that line which has GemMining in there tho for sure, i have a feeling this also might be when Elemental creatures should be spawning too since there actually referenced as Resource Type [2] in the arrays where the resources are defined...


new HarvestResource( 65.0, 25.0, 105.0, 1007073, typeof( DullCopperOre ), typeof( DullCopperGranite ), typeof
( DullCopperElemental ) ),

Here the Dull Copper Elemental would be the type[2] in an array....

The line above that...


typeof( IronOre ), typeof
( Granite ) ),

only has 2 types in this array of resources (0 & 1) with no elemental creature (type[2]).

Like i said tho, better to just post those 2 files so i can take a look and also the part of PlayerMobile.cs too please.
 

sec_goat

Squire
Yes the Playermobile does have a enum for gem Mining. I believe this is a new add for compatability with the SA expansion. I am using the RunUO server from here http://code.google.com/p/sa-project/downloads/list

There are some extra options on the shovel before I strat mining. They Say MegaCiloc id not found, but when I choose it says I am set to start mining gems and ore.

I really appreciate your time in looking at these errors for us, it is definitely helping me learn more about how to script and how the code all works together.

Code:
namespace Server.Mobiles
{
    #region Enums
    [Flags]
    public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
    {
        None                     = 0x00000000,
        Glassblowing             = 0x00000001,
        Masonry                 = 0x00000002,
        SandMining                 = 0x00000004,
        StoneMining             = 0x00000008,
        ToggleMiningStone         = 0x00000010,
        KarmaLocked             = 0x00000020,
        AutoRenewInsurance         = 0x00000040,
        UseOwnFilter             = 0x00000080,
        PublicMyRunUO             = 0x00000100,
        PagingSquelched         = 0x00000200,
        Young                     = 0x00000400,
        AcceptGuildInvites         = 0x00000800,
        DisplayChampionTitle     = 0x00001000,
        HasStatReward             = 0x00002000,

        #region Mondain's Legacy
        Bedlam                     = 0x00010000,
        LibraryFriend             = 0x00020000,
        Spellweaving             = 0x00040000,
        #endregion

        #region SA Gemmining
        GemMining                 = 0x00080000,
        ToggleMiningGem         = 0x00100000,
        #endregion
    }
 

Attachments

  • Mining.cs
    19.5 KB · Views: 7
  • HarvestSystem.cs
    13.8 KB · Views: 4

Pure Insanity

Sorceror
Seems like the sa gem mining is clashing with the gem mining in this system...there is gem mining in this system, right? :/
 

FingersMcSteal

Sorceror
The way i added the Yaks Diamond drop in there shouldn't cause a problem.
I've downloaded the SA version from the link you've posted and can see where it's going paer shaped already. With the current Mining.cs file your using i'm guessing your NOT getting gem's popping up when mining.

From the Original SA files i've got here...

res =[/SIZE]

new
HarvestResource[]

{

new HarvestResource( 00.0, 00.0, 100.0, 1007072, typeof( IronOre ), typeof( Granite ), typeof
( Amber ) ),

new HarvestResource( 65.0, 25.0, 105.0, 1007073, typeof( DullCopperOre ), typeof( DullCopperGranite ), typeof( Citrine ), typeof
( DullCopperElemental ) ),

new HarvestResource( 70.0, 30.0, 110.0, 1007074, typeof( ShadowIronOre ), typeof( ShadowIronGranite ), typeof( Tourmaline ), typeof
( ShadowIronElemental ) ),

new HarvestResource( 75.0, 35.0, 115.0, 1007075, typeof( CopperOre ), typeof( CopperGranite ), typeof( Ruby ), typeof
( CopperElemental ) ),

new HarvestResource( 80.0, 40.0, 120.0, 1007076, typeof( BronzeOre ), typeof( BronzeGranite ), typeof( Amethyst ), typeof
( BronzeElemental ) ),

new HarvestResource( 85.0, 45.0, 125.0, 1007077, typeof( GoldOre ), typeof( GoldGranite ), typeof( Sapphire ), typeof
( GoldenElemental ) ),

new HarvestResource( 90.0, 50.0, 130.0, 1007078, typeof( AgapiteOre ), typeof( AgapiteGranite ), typeof( Emerald ), typeof
( AgapiteElemental ) ),

new HarvestResource( 95.0, 55.0, 135.0, 1007079, typeof( VeriteOre ), typeof( VeriteGranite ), typeof( StarSapphire ), typeof
( VeriteElemental ) ),

new HarvestResource( 99.0, 59.0, 139.0, 1007080, typeof( ValoriteOre ), typeof( ValoriteGranite ), typeof( Diamond ), typeof
( ValoriteElemental ) )

[/CODE]

Excuse the messy code tags (Not liking the new forum setup here), but where this line in your current Mining.cs file is causing the error...

if ( pm != null
&& pm.GemMining && pm.ToggleMiningGem && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() ) return
resource.Types[2];

Is when it's surposed to be digging up AMBER gems, this is the 3rd array element in the Harvest Definitions. In the file your using right after IronOre then Granite theres nothing to cover Type[2] (Thats position 3 in the array elements...

typeof( IronOre ), typeof( Granite ) ), <NOTHING ELSE AFTER GRANITE>

So based on your skills and if your looking for gems etc etc etc, whenever your checks come back and you should get AMBER it's causing your NULL error...
System.IndexOutOfRangeException: Index was outside the bounds of the array.

Which means your trying to look for something extra by pushing the array pointer out of bounds, as in... the first line has only 2 items (0 & 1) and Type[2] (or the 3rd array item) just isn't there... hence the error. If the gem mining triggers and it's not AMBER i'd guess your seeing alot of elemental monsters instead since Type[2] anywhere after the 1st line is a monster.[/CODE][/SIZE]

*** EDIT ***
My messy post for the year ;)
 

sec_goat

Squire
Aha! yes I see it now that it is pointed out to me. If it were a snake it would have bitten me.

Let me make these changes and see what happens!

Thank you so much for your help, I am still learning the whole programming thing and I sometimes have a hard time following where i need to go to follow what is happening in the code.
 

FingersMcSteal

Sorceror
If your adding the gems your going to need 20 (number of resources my package had), adding just what the original had won't work. I'm guessing you'll know that tho.

Also if you do add them you'll need to alter the line...


BaseCreature spawned =
Activator.CreateInstance( res.Types[2], new object[]{ 250 } ) as BaseCreature;

To...

BaseCreature spawned = Activator.CreateInstance( res.Types[3], new object[]{ 250 } ) as BaseCreature;

After that it 'should' work.
 

sec_goat

Squire
I missed the Base Creature Spawned part, But I have just changed that. So far so good. I am getting ingots, and small gems with no crashes so far.

for the amount of gems I just used the same one for silver and gold, and diamond for all the customs above valorite.

if you don't mind will you help me decypher the Large gem code to see if I missed anything?

Code:
res = new HarvestResource[]
                {
                    // NUMBERS BELOW ARE...
                    // 1st Required Skill Needed
                    // 2nd Min Skill Needed
                    // 3rd Max Skill Needed
                    // 4th Success Message CLI No

                    new HarvestResource( 00.0, 00.0, 100.0, 1007072,                                    typeof( IronOre ),            typeof( Granite ),                typeof( Amber )),
                    new HarvestResource( 65.0, 25.0, 105.0, 1007073,                                    typeof( DullCopperOre ),    typeof( DullCopperGranite ),    typeof( Citrine ),            typeof( DullCopperElemental ) ),
                    new HarvestResource( 70.0, 30.0, 110.0, 1007074,                                    typeof( ShadowIronOre ),    typeof( ShadowIronGranite ),    typeof( Tourmaline ),        typeof( ShadowIronElemental ) ),
                    new HarvestResource( 75.0, 35.0, 115.0, 1007075,                                    typeof( CopperOre ),        typeof( CopperGranite ),        typeof( Ruby ),                typeof( CopperElemental ) ),
                    new HarvestResource( 80.0, 40.0, 120.0, 1007076,                                    typeof( BronzeOre ),        typeof( BronzeGranite ),        typeof( Amethyst ),            typeof( BronzeElemental ) ),
                    new HarvestResource( 85.0, 45.0, 125.0, 1007077,                                    typeof( GoldOre ),          typeof( GoldGranite ),            typeof( Sapphire ),            typeof( GoldenElemental ) ),
                    // MINE
                    new HarvestResource( 86.0, 46.0, 126.0, ( string.Format( "Silver Ore !!!" )) ,      typeof( SilverOre ),        typeof( SilverGranite ),        typeof( Sapphire ),            typeof( SilverElemental ) ),
                    // END
                    new HarvestResource( 90.0, 50.0, 130.0, 1007078,                                    typeof( AgapiteOre ),       typeof( AgapiteGranite ),        typeof( Emerald ),            typeof( AgapiteElemental ) ),
                    new HarvestResource( 95.0, 55.0, 135.0, 1007079,                                    typeof( VeriteOre ),        typeof( VeriteGranite ),        typeof( StarSapphire ),     typeof( VeriteElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, 1007080,                                    typeof( ValoriteOre ),      typeof( ValoriteGranite ),        typeof( Diamond ),            typeof( ValoriteElemental ) ),
                    // MINE
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Uridium Ore !!!" )) ,     typeof( UridiumOre ),       typeof( UridiumGranite ),        typeof( Diamond ),            typeof( UridiumElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Trillium Ore !!!" )) ,    typeof( TrilliumOre ),      typeof( TrilliumGranite ),        typeof( Diamond ),            typeof( TrilliumElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Titanium Ore !!!" )) ,    typeof( TitaniumOre ),      typeof( TitaniumGranite ),        typeof( Diamond ),            typeof( TitaniumElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Platinum Ore !!!" )) ,    typeof( PlatinumOre ),      typeof( PlatinumGranite ),        typeof( Diamond ),            typeof( PlatinumElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Zenite Ore !!!" )) ,      typeof( ZeniteOre ),        typeof( ZeniteGranite ),        typeof( Diamond ),            typeof( ZeniteElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Naquinite Ore !!!" )) ,   typeof( NaquiniteOre ),     typeof( NaquiniteGranite ),        typeof( Diamond ),            typeof( NaquiniteElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Galvinite Ore !!!" )) ,   typeof( GalviniteOre ),     typeof( GalviniteGranite ),        typeof( Diamond ),            typeof( GalviniteElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Trilamide Ore !!!" )) ,   typeof( TrilamideOre ),     typeof( TrilamideGranite ),        typeof( Diamond ),            typeof( TrilamideElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Veramide Ore !!!" )) ,    typeof( VeramideOre ),      typeof( VeramideGranite ),        typeof( Diamond ),            typeof( VeramideElemental ) ),
                    new HarvestResource( 99.0, 59.0, 139.0, ( string.Format( "Zenlamide Ore !!!" )),    typeof( ZenlamideOre ),     typeof( ZenlamideGranite ),        typeof( Diamond ),            typeof( ZenlamideElemental ) )

                    // END
                };

            veins = new HarvestVein[]
                {
                    // NUMBERS BELOW ARE...
                    // 1ST Vein Chance
                    // 2ND Chance To Fallback
                    // 3RD Primary Resource
                    // 4TH Fallback Resource

                    new HarvestVein( 25.0, 0.0, res[0], null   ),   // Iron
                    new HarvestVein( 11.8, 0.4, res[1], res[0] ),   // Dull Copper
                    new HarvestVein( 09.6, 0.4, res[2], res[0] ),   // Shadow Iron
                    new HarvestVein( 08.4, 0.4, res[3], res[0] ),   // Copper
                    new HarvestVein( 07.2, 0.4, res[4], res[0] ),   // Bronze
                    new HarvestVein( 06.0, 0.4, res[5], res[0] ),   // Gold
                    new HarvestVein( 05.8, 0.4, res[6], res[0] ),   // Silver
                    new HarvestVein( 04.6, 0.4, res[7], res[0] ),   // Agapite
                    new HarvestVein( 04.4, 0.4, res[8], res[0] ),   // Verite
                    new HarvestVein( 03.2, 0.4, res[9], res[0] ),   // Valorite
                    new HarvestVein( 03.0, 0.4, res[10], res[0] ),  // Urdium
                    new HarvestVein( 02.8, 0.4, res[11], res[0] ),  // Trillium
                    new HarvestVein( 02.6, 0.4, res[12], res[0] ),  // Titanium
                    new HarvestVein( 01.4, 0.4, res[13], res[0] ),  // Platinum
                    new HarvestVein( 01.2, 0.4, res[14], res[0] ),  // Zenite
                    new HarvestVein( 01.0, 0.4, res[15], res[0] ),  // Naquinite
                    new HarvestVein( 00.8, 0.4, res[16], res[0] ),  // Galvinite
                    new HarvestVein( 00.6, 0.4, res[17], res[0] ),  // Trilamide
                    new HarvestVein( 00.4, 0.4, res[18], res[0] ),  // Veramide
                    new HarvestVein( 00.2, 0.4, res[19], res[0] )   // Zenlamide
                };

            oreAndStone.Resources = res;
            oreAndStone.Veins = veins;

            if ( Core.ML )
            {
                oreAndStone.BonusResources = new BonusHarvestResource[]
                {
                    new BonusHarvestResource( 0, 99.8998, null, null ),    //Nothing    //Note: Rounded the below to .0167 instead of 1/6th of a %.  Close enough
                    new BonusHarvestResource( 100, .0167, 1072562, typeof( BlueDiamond ) ),
                    new BonusHarvestResource( 100, .0167, 1072567, typeof( DarkSapphire ) ),
                    new BonusHarvestResource( 100, .0167, 1072570, typeof( EcruCitrine ) ),
                    new BonusHarvestResource( 100, .0167, 1072564, typeof( FireRuby ) ),
                    new BonusHarvestResource( 100, .0167, 1072566, typeof( PerfectEmerald ) ),
                    new BonusHarvestResource( 100, .0167, 1072568, typeof( Turquoise ) )
                };
            }

EDIT: the large gem drop seems fine now too. apparently I just suck at testing, I mined for like an hour straight and didn't get any large gems. Dropped the fixed mod on my players and viola! we have it. Thanks so much for you help.

Would you like me to zip and upload the YaksResource package so you can re-release in the original thread?
 

FingersMcSteal

Sorceror
Thats up to you, i don't mind but when it comes to questions you'll understand that if it's about the new version obviously i didn't alter it so answering questions might be difficult.

Which part about the Large Gem code ???
 

sec_goat

Squire
Thats up to you, i don't mind but when it comes to questions you'll understand that if it's about the new version obviously i didn't alter it so answering questions might be difficult.

Which part about the Large Gem code ???

I was just concerened that I had some how broken the ability for them to drop. But it appears everything works just fine. Would you like a zip of the YaksResources so you can re-release?

Thank you for all your help!
 

FingersMcSteal

Sorceror
Problem with a re-release would be the Gem Mining part, you'd have to link to that too since this has that in it as well.

By all means release it if you want to tho, i have no problem with it and it's all public domain stuff anyways, just remember tho if people have issues with it you might have to help them out.
 
Top