1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Demon Hunter's Standard

Discussion in 'Archived Bug Reports' started by Kalamus, Jun 2, 2014.

  1. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    282
    Likes Received:
    32
    Can't create Demon Hunter's Standard due to bug in code.
    Code (C#):
    1. public class DemonHuntersStandard : Spear
    2. {
    3.     [Constructable]
    4.     public DemonHuntersStandard()
    5.         : base(0xF62)
    6.     {
    As you can see the class inherits from Spear and it's constructor tries to call base(0xF62) from the Spear class.
    Code (C#):
    1. public class Spear : BaseSpear
    2. {
    3.     [Constructable]
    4.     public Spear()
    5.         : base(0xF62)
    6.     {
    7.         this.Weight = 7.0;
    8.     }
    9.  
    10.     public Spear(Serial serial)
    11.         : base(serial)
    12.     {
    13.     }
    Spear class doesn't contain a constructor for an Int so it instead calls
    Spear(Serial serial) (since Serail can convert to an int) which leads it back to the wrong base constructors and Attributes property among others not getting initialized and causing Demon Hunter's Standard to fail to create.


    Add this to Spear.cs as a simple fix:
    Code (C#):
    1. public Spear(int itemID)
    2.     : base(itemID)
    3. {
    4. }


    Edit: Just realized they both use the same ItemID so the correct fix and just as simple would be to remove : base(0xF62) from DemonHuntersStandard.cs constructor making it like so:
    Code (C#):
    1. public class DemonHuntersStandard : Spear
    2. {
    3.     [Constructable]
    4.     public DemonHuntersStandard()
    5.     {
     
    #1 Kalamus, Jun 2, 2014
    Last edited: Jun 2, 2014
  2. Crome969
    Offline

    Crome969 Member

    Joined:
    Jan 9, 2014
    Messages:
    195
    Likes Received:
    20
    Wouldnt it be easyier just make a blank constructor to spear? and call this?
    I mean your constructor solution doesnt inherit the constructor of a Spear. This would be not a good way ...

    Code (C#):
    1.  
    2. public class DemonHuntersStandard : Spear
    3. {
    4.     [Constructable]
    5.     public DemonHuntersStandard()
    6.         : base()
    7.     {
    8.  

    still would inherit the Weight 7
     
  3. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    282
    Likes Received:
    32
    This code:
    Code (C#):
    1. [Constructable]
    2. public DemonHuntersStandard()
    3. {
    4. }
    Is the exact same as this code:
    Code (C#):
    1. [Constructable]
    2. public DemonHuntersStandard()
    3.     : base()
    4. {
    5. }
    The : base() call is redundant since it calls it's base class constructor automatically.

    So to answer your question it already calls the parameterless constructor of Spear.
     
  4. Crome969
    Offline

    Crome969 Member

    Joined:
    Jan 9, 2014
    Messages:
    195
    Likes Received:
    20
    Okay i accept this, i have less runuo experience against some people here around :)
    I just remembered some java lessons where our teacher told us always to call the inherited constructor.
     
  5. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    282
    Likes Received:
    32
    Not sure about Java but in C# the constructor of the base class is called automatically. Only time you have to include the base call is if you want to pass in more parameters. Not sure if it's good practice to include it or not but I don't like having redundant code so I try to keep it clean :).
     
  6. Ravenwolfe
    Offline

    Moderator ServUO Developer

    Joined:
    Sep 7, 2013
    Messages:
    1,102
    Likes Received:
    117
    Fixed in Repo, thanks Kalamus.
     
Similar Threads: Demon Hunter's
Forum Title Date
Archived Bug Reports DemonHuntersStandard without slayer Aug 4, 2016
Archived Bug Reports demon bones Mar 28, 2016
Archived Bug Reports Bone Demon should not be on spawner in doom. Mar 27, 2016
Archived Bug Reports Demon Slayer Properties Problem Dec 30, 2014