Dan

Moderator
I made this donation vendor, it compiles fines, and works fine, but on restart it asks to delete. I do not see anything wrong in the serialize or deserialize. Any help would be appreciated!

Code:
#region Header
//   Voxpire    _,-'/-'/  DonationVendor.cs
//   .      __,-; ,'( '/
//    \.    `-.__`-._`:_,-._       _ , . ``
//     `:-._,------' ` _,`--` -: `_ , ` ,' :
//        `---..__,,--'  (C) 2016  ` -'. -'
//        #  Vita-Nex [http://core.vita-nex.com]  #
//  {o)xxx|===============-   #   -===============|xxx(o}
//        #        The MIT License (MIT)          #
#endregion

#region References
using Server;
using Server.Mobiles;
using Server.Engines.VeteranRewards;
using Server.Engines.Auction;
using Server.Engines.Plants;

using VitaNex.Items;
using VitaNex.Mobiles;
#endregion

namespace Server.Items
{
    public class DonationVendor : AdvancedVendor
    {
       
        public override bool HasHonestyDiscount { get { return false; } }
       
        [Constructable]
        public DonationVendor()
            : base("the sovereign merchant", typeof(DonationScroll), "Sovereign Notes", "SN")
        { }

        public DonationVendor(Serial serial)
            : base(serial)
        { }

        protected override void InitBuyInfo()
        {
           
            // 125K - 5K           
            AddStock<ResurrectToken>(10);
            AddStock<HeritageToken>(25);
            AddStock<HoodedShroudOfShadows>(50);
            AddStock<BannerDeed>(50);
            AddStock<SpecialDyeTub>(50);
            AddStock<FlamingHeadDeed>(50);   
           
           
            // 1MIL - 4.9MIL   
            AddStock<EtherealHorse>(100);
            AddStock<PottedCactusDeed>(100);
            AddStock<SoulstoneToken>(200);
            AddStock<EtherealLlama>(200);
            AddStock<EtherealOstard>(200);
            AddStock<StatuetteDyeTub>(300);
            AddStock<PottedPlantDeed>(300);
            AddStock<HoodedShroudOfShadows1>(400);
           
           
            // 5MIL    - 9.9MIL                   
            AddStock<ForgedMetalOfArtifacts1>(500);
            AddStock<WallBannerDeed>(500);
            AddStock<EtherealBeetle>(500);
            AddStock<DecorativeShieldDeed>(500);
            AddStock<CommodityDeedBox>(500);
            AddStock<LuckyNecklace1>(500);
            AddStock<HangingSkeletonDeed>(600);
            AddStock<RunebookDyeTub>(600);
            AddStock<CannonDeed>(800);
            AddStock<EtherealSwampDragon>(800);
            AddStock<FurnitureDyeTub>(900);
           
           
            // 10MIL - 19.9MIL               
            AddStock<EtherealRetouchingTool>(1000);
            AddStock<BloodyPentagramDeed>(1000);
            AddStock<EtherealCuSidhe>(1000);
            AddStock<ShadowCloakOfRejuvenation>(1000);
            AddStock<EarringsOfProtection>(1000);
            AddStock<AuctionSafeDeed>(1000);
            AddStock<LeatherDyeTub>(1000);
            AddStock<RewardBrazierDeed>(1500);
            AddStock<HeritageSpellbook>(1500);
           
           
            // 20MIL - 50MIL   
            AddStock<WhiteLeatherDyeTub>(2000);
            AddStock<HeritageTrinket>(2000);
            AddStock<RangersCloakOfAugmentation>(2000);
            AddStock<SeedBox>(2000);
            AddStock<DaviesLockerAddonDeed>(2500);
            AddStock<EtherealReptalon>(2500);
            AddStock<RoseRugEastAddonDeed>(3000);
            AddStock<RoseRugSouthAddonDeed>(3000);
            AddStock<DolphinRugEastAddonDeed>(3000);
            AddStock<DolphinRugSouthAddonDeed>(3000);
            AddStock<SkullRugEastAddonDeed>(3000);
            AddStock<SkullRugSouthAddonDeed>(3000);
            AddStock<EtherealHiryu>(3500);
            AddStock<AnkhOfSacrificeDeed>(4000);
            AddStock<LighthouseAddonDeed>(5000);
            AddStock<RewardBlackDyeTub>(5000);
            AddStock<EtherealBoura>(5000);
            AddStock<RaisedGardenSmallAddonDeed>(5000);
           
           
            // HIGHEST TIER
            AddStock<RaisedGardenEastAddonDeed>(6500);
            AddStock<RaisedGardenSouthAddonDeed>(6500);
            AddStock<RaisedGardenLargeAddonDeed>(7500);
            AddStock<BronzeStatueMaker>(10000);
            AddStock<JadeStatueMaker>(10000);
            AddStock<MarbleStatueMaker>(10000);
            AddStock<WeaponEngravingTool>(10000);
            AddStock<ChargerOfTheFallen>(12500);
            AddStock<AnniversaryRobe1>(15000);       
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            var version = writer.SetVersion(0);

            switch (version)
            {
                case 0:
                    break;
            }
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            var version = reader.GetVersion();

            switch (version)
            {
                case 0:
                    break;
            }
        }
    }
}
 

Attachments

  • DonationVendor.cs
    3.9 KB · Views: 15
When it asks you to delete and you hit N, it should display an error. 9/10 times it's a general exception thrown by some code in Deserialize, not necessarily data corruption (but it looks that way when it happens).

I'm willing to bet it's caused by one of the items in the stock, that probably doesn't have a default constructor or something.

The error would then be a TypeInitializationException if i recall correctly.

Anyway, that error after pressing N is the key to solving this issue.
 
I need you to tell me what the error is, so we can diagnose what's causing it, or it will happen every time.
 
As far as the items it sells, It has an exact clone using normal vendors that sells the same items for gold, that one I have been using for about a year now, no issues.
[doublepost=1485980745][/doublepost]Of course, give me a second to throw it on my test shard and fire it up
 
The main difference between those standard vendors and this vendor is that you don't have to specify the name, itemid, etc, when adding stock.
All the items are created in the background and their info extracted for you.

I should probably add "new()" to the AddStock<T> constraints, perhaps in the next VNc update.
 
SHOW.png


Tried N , restarted and same thing.

Again all the items sold here are sold on another vendor for gold, no issues. I have all the correct using Server.Items; ect that are used on that one.
 
I think Voxpire needed the error message after you pressed N.

Also I cant really see anything wrong (since it compiles too).
Only 2 things I see is that (assuming this is a normal npc vendor not a stone) you put the vendor in the items namespace.
And that you use SetVersion and GetVersion. Never saw these in the scripts befor so I can not say that they are not causing it.
 
could be because you're using namespace Server.Items for a mobile?
AdvancedVendor uses namespace VitaNex.Mobiles; trying changing it to that and see if that solves your problem.

Probably won't but it's the only issue I can see comparing your advanced vendor with the stock advanced vendors in vitanex
 
Oh fair enough let me get you a copy of that error.
[doublepost=1485992667][/doublepost]Look at the vote vendor. I copied it exactly from that.
[doublepost=1485993065][/doublepost]
Code:
World: Loading...
An error was encountered while loading a saved object
- Type: Server.Items.DonationVendor
- Serial: 0x00006BC6
Delete the object? (y/n)
After pressing return an exception will be thrown and the server will terminate.


Error:
System.Exception: Load failed (items=False, mobiles=True, guilds=False, data=Fal
se, type=Server.Items.DonationVendor, serial=0x00006BC6) ---> System.NullReferen
ceException: Object reference not set to an instance of an object.
   at Server.Items.EtherealRetouchingTool.AddProperty(EtherealMount mount, Objec
tPropertyList list)
   at Server.Item.get_PropertyList() in c:\Users\Administrator\Desktop\ServUO.gi
t\trunk\Server\Item.cs:line 2135
   at Server.ItemExtUtility.ResolveName(Item item, ClilocLNG lng, Boolean setIfN
ull)
   at VitaNex.Mobiles.AdvancedBuyInfo..ctor(AdvancedSBInfo parent, Type type, In
t32 price, String name, Int32 amount, Object[] args)
   at VitaNex.Mobiles.AdvancedSBInfo.AddStock(Type type, Int32 price, String nam
e, Int32 amount, Object[] args)
   at Server.Items.DonationVendor.InitBuyInfo()
   at VitaNex.Mobiles.AdvancedVendor.InitSBInfo()
   at Server.Mobiles.BaseVendor.LoadSBInfo()
   at Server.Mobiles.BaseVendor.Deserialize(GenericReader reader)
   at VitaNex.Mobiles.AdvancedVendor.Deserialize(GenericReader reader)
   at Server.Items.DonationVendor.Deserialize(GenericReader reader)
   at Server.World.Load() in c:\Users\Administrator\Desktop\ServUO.git\trunk\Ser
ver\World.cs:line 595
   --- End of inner exception stack trace ---
   at Server.World.Load() in c:\Users\Administrator\Desktop\ServUO.git\trunk\Ser
ver\World.cs:line 328
   at Server.Core.Main(String[] args) in c:\Users\Administrator\Desktop\ServUO.g
it\trunk\Server\Main.cs:line 537
This exception is fatal, press return to exit
 
It's the EtherealRetouchingTool.AddProperty() method, there is a null reference in there.

The null reference is m_Table, because m_Table is only assigned when the static Initialize() method is called, which is called after World.Load (and subsequently Deserialized).

You can probably fix it by changing Initialize() to Configure(), which is called before a World.Load.

It's technically a ServUO bug, so I'll make changes to the repo.
 
Okay thanks sir.

It works fine on a stock servUO NPC, why would that be?

It's just due to the way the vendors restock.
The advanced vendor creates an item to store in the AdvancedSBInfo internal list so that it can extract the Type, Name and ItemID of the item.
These values are usually hard-coded in the SBInfo - the old way of doing it - so the stock SBInfo's don't generate items.
Stock vendors generate items when a player tries to buy from them.

So, in short, Initialize() would definitely have been called by the time the first client has logged in :)

This exercise exposed a small bug in the initialization pattern for that particular item, the update should be solid.
 
Applying your fix now.

Ill report back here tomorrow after my next shard restart.
[doublepost=1485996524][/doublepost]I applied these updates and tested on my test center. Every loads great now. Thanks @Voxpire for the fix and everyone else for the help.
 
Hmm after the newest SVN changes it once again asked me to delete the donation vendor.
[doublepost=1486149741][/doublepost]
Code:
- Type: Server.Items.DonationVendor
- Serial: 0x000003EB
Delete the object? (y/n)
After pressing return an exception will be thrown and the server will terminate.


Error:
System.Exception: Load failed (items=False, mobiles=True, guilds=False, data=Fal
se, type=Server.Items.DonationVendor, serial=0x000003EB) ---> System.NullReferen
ceException: Object reference not set to an instance of an object.
   at Server.Items.EtherealRetouchingTool.AddProperty(EtherealMount mount, Objec
tPropertyList list)
   at Server.Item.get_PropertyList() in c:\Users\Administrator\Desktop\Heritage\
trunk\Server\Item.cs:line 2135
   at Server.ItemExtUtility.ResolveName(Item item, ClilocLNG lng, Boolean setIfN
ull)
   at VitaNex.Mobiles.AdvancedBuyInfo..ctor(AdvancedSBInfo parent, Type type, In
t32 price, String name, Int32 amount, Object[] args)
   at VitaNex.Mobiles.AdvancedSBInfo.AddStock(Type type, Int32 price, String nam
e, Int32 amount, Object[] args)
   at Server.Items.DonationVendor.InitBuyInfo()
   at VitaNex.Mobiles.AdvancedVendor.InitSBInfo()
   at Server.Mobiles.BaseVendor.LoadSBInfo()
   at Server.Mobiles.BaseVendor.Deserialize(GenericReader reader)
   at VitaNex.Mobiles.AdvancedVendor.Deserialize(GenericReader reader)
   at Server.Items.DonationVendor.Deserialize(GenericReader reader)
   at Server.World.Load() in c:\Users\Administrator\Desktop\Heritage\trunk\Serve
r\World.cs:line 595
   --- End of inner exception stack trace ---
   at Server.World.Load() in c:\Users\Administrator\Desktop\Heritage\trunk\Serve
r\World.cs:line 328
   at Server.Core.Main(String[] args) in c:\Users\Administrator\Desktop\Heritage
\trunk\Server\Main.cs:line 537
This exception is fatal, press return to exit


Was the code to the retouching tool reverted in the last updates?
 
Oh? So there are resources already part of the core? I thought everything had to be added as a module. :)
 
A lot of VNc's features are included in the download :)

Modules and Services are basically optional plugins that can be added or removed without necessarily breaking other systems.

While VNc supports these plugins, it does have an extensive slew of content that isn't Module or Service based.
 
Now I'm gonna have to get it working for sure to check it out. :) I haven't tried to add it back in on he latest SVN. I'll try again when I do the next update on the shard. Thanks for the info.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back