System Knive's Town Houses 2.1 - Majorly Cleaned Up 2014-11-29

Optimized for .NET 4.0

  1. Ravenwolfe

    Ravenwolfe Administrator Staff Member JustUO Developer

    That's VNC being over cautious, you can safely ignore that. There is no reason to have a serial/deserial method. If it bothers you to see the warning, you can add an empty deserial/serial method to those scripts and it will go away.
     
  2. Dian

    Dian Administrator

    *oops, didnt notice Ravenwolfe's post :p *

    Yea, that script has no Serialization method, as it states. You can add one to it..
    It will remove that warning, though its not needed according to Tresdni.. He says its redundant. I added it too though.

    In RUOVersions.cs file,
    Code:
    public override void Serialize(GenericWriter writer)
      {
      base.Serialize(writer);
      }
    
      public override void Deserialize(GenericReader reader)
      {
      base.Deserialize(reader);
      }
    Or if you need entire script to be certain where..
    Code:
    #region References
    
    using System.Collections;
    using System.Collections.Generic;
    using Server;
    using Server.Commands;
    using Server.Multis;
    
    #endregion
    
    #if (RunUO_2_RC1)
      using Server.Commands;
    #endif
    
    namespace Knives.TownHouses
    {
      public class RUOVersion
      {
      private static readonly Hashtable s_Commands = new Hashtable();
    
      public static void AddCommand(string com, AccessLevel acc, TownHouseCommandHandler cch)
      {
      s_Commands[com.ToLower()] = cch;
      CommandSystem.Register(com, acc, OnCommand);
      }
    
      private static void OnCommand(CommandEventArgs e)
      {
      if (s_Commands[e.Command.ToLower()] == null)
      {
      return;
      }
    
      ((TownHouseCommandHandler) s_Commands[e.Command.ToLower()])(new CommandInfo(e.Mobile, e.Command, e.ArgString,
      e.Arguments));
      }
    
      public static void UpdateRegion(TownHouseSign sign)
      {
      if (sign.House == null)
      {
      return;
      }
    
      sign.House.UpdateRegion();
    
      Rectangle3D rect = new Rectangle3D(Point3D.Zero, Point3D.Zero);
    
      for (int i = 0; i < sign.House.Region.Area.Length; ++i)
      {
      rect = sign.House.Region.Area[i];
      rect = new Rectangle3D(
      new Point3D(rect.Start.X - sign.House.X, rect.Start.Y - sign.House.Y, sign.MinZ),
      new Point3D(rect.End.X - sign.House.X, rect.End.Y - sign.House.Y, sign.MaxZ));
      sign.House.Region.Area[i] = rect;
      }
    
      sign.House.Region.Unregister();
      sign.House.Region.Register();
      sign.House.Region.GoLocation = sign.BanLoc;
      }
    
      public static bool RegionContains(Region region, Mobile m)
      {
      return region.GetMobiles().Contains(m);
      }
    
      public static IEnumerable<Rectangle3D> RegionArea(Region region)
      {
      return region.Area;
      }
      }
    
      public class VersionHouse : BaseHouse
      {
      protected VersionHouse(int id, Mobile m, int locks, int secures)
      : base(id, m, locks, secures)
      {
      }
    
      public override Rectangle2D[] Area
      {
      get { return new Rectangle2D[5]; }
      }
    
      public override Point3D BaseBanLocation
      {
      get { return Point3D.Zero; }
      }
    
      public VersionHouse(Serial serial)
      : base(serial)
      {
      }
    
      public override void Serialize(GenericWriter writer)
      {
      base.Serialize(writer);
      }
    
      public override void Deserialize(GenericReader reader)
      {
      base.Deserialize(reader);
      }
      }
    }
     
    • Like Like x 1
  3. Fireball

    Fireball Distinguished Member

    Hi guys,
    I've just dropped this in my shard and I have a problem which only affects buildings in GreenAcres.

    At first I thought it just didn't work as I tested it on a custom (brick-by-brick) building in GreenAcres. I set it up and then clicked the claim button and everything except the doors, a staircase and the sign vanished!

    I then went to Britain and did the same with one of the normal static town buildings there and it worked perfectly, so next I built my custom house on a flat spot in the normal world and ran TownHouses on that and it worked perfectly there. Went back to GreenAcres and tried it again (incase I had messed something up) there with exactly the same failure I originally had. Is there something about GreenAcres which prevents this working?

    The other thing that is a bit annoying is that the secures and lockdowns seem to be messed up. It appears to give the house the number of lockdowns and secures it fancies, but the secures are double the lockdowns, and the secures are a ludicrously large number. Once the house is claimed I can go back in and edit them to, say, make the secures 50 and then go back in again to make the lockdowns 3000 but whatever I do it will not let me do both on the fly.

    Has anyone else seen this?

    Thanks

    FB

    PS. Running RunUO 2.4
     
  4. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    getting around to trying this system out for an idea.
    i wanted to create nonmovable tiles as a floor without freezing them. when i claim the property it deletes the nonmovable floor, if i demolish the house it puts them back.

    seems to be something in the code that deletes non-static/non-frozen items even if you say you want the player to have them when they buy the house
     
  5. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    tried it in both greenacres and brit
     
  6. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    was able to confirm the line of code that's making it happen is line 831 in TownHouseSign.
    I blocked it out for easy test. going to figure out what's actually wrong though.

    update:

    line 267 comment out c_LeaveItems = false;
    line 565 change: ConvertItems(false); to ConvertItems(c_KeepItems);

    then in the method protected virtual void ConvertItems(bool keep) change
    else if (!c_LeaveItems) to else if (c_LeaveItems == false)
    and

    if (!c_KeepItems || !keep) to if ( c_KeepItems == false )


    tested and working for both true and false now
     
    Last edited: Jul 5, 2015
  7. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    also, don't know if anyone's interested but i changed GetProps to be a little more "reader friendly"

    add: using VitaNex.Network;
    to the top of townhouse sign

    end result:
    ths.jpg

    - price/lockdown/secures now have commas
    - will indicate if forced public or private
    - will indicate if banning is disabled (should be obvious for public buildings but it's there just in case)
    - will indicate if a building can be traded or not

    Code:
    public override void GetProperties(ObjectPropertyList list)
            {
                base.GetProperties(list);
    
                if (c_Free)
                {
                    list.Add(1060658, "Price\tFree");
                }
                else if (c_RentByTime == TimeSpan.Zero)
                {
                    list.Add(1060658, "Price\t{0}{1}", c_Price.ToString("#,0"), c_KeepItems ? " (+" + c_ItemsPrice.ToString("#,0") + " for the items)" : "");
                }
                else if (c_RecurRent)
                {
                    list.Add(1060658, "{0}\t{1}\r{2}", PriceType + (c_RentToOwn ? " Rent-to-Own" : " Recurring"), c_Price.ToString("#,0"),
                        c_KeepItems ? " (+" + c_ItemsPrice.ToString("#,0") + " for the items)" : "");
                }
                else
                {
                    list.Add(1060658, "One {0}\t{1}{2}", PriceTypeShort, c_Price.ToString("#,0"),
                        c_KeepItems ? " (+" + c_ItemsPrice.ToString("#,0") + " for the items)" : "");
                }
    
                list.Add(1060659, "Lockdowns\t{0}", c_Locks.ToString("#,0"));
                list.Add(1060660, "Secures\t{0}", c_Secures.ToString("#,0"));
    
                if (c_SkillReq != 0.0)
                {
                    list.Add(1060661, "Requires\t{0}", c_SkillReq + " in " + c_Skill);
                }
                if (c_MinTotalSkill != 0)
                {
                    list.Add(1060662, "Requires more than\t{0} total skills", c_MinTotalSkill);
                }
                if (c_MaxTotalSkill != 0)
                {
                    list.Add(1060663, "Requires less than\t{0} total skills", c_MaxTotalSkill);
                }
    
                if (c_YoungOnly)
                {
                    list.Add(1063483, "Must be\tYoung");
                }
                else switch (c_Murderers)
                {
                    case Intu.Yes:
                        list.Add(1063483, "Must be\ta murderer");
                        break;
                    case Intu.No:
                        list.Add(1063483, "Must be\tinnocent");
                        break;
                }
               
                var opl = new ExtendedOPL( list );
               
                if( c_ForcePrivate == true ) {
                    opl.Add("Area required to be Private");
                }
                if( c_ForcePublic == true ) {
                    opl.Add("Area required to be Public");
                }
                if( c_NoBanning == true){
                    opl.Add("Banning Disabled");
                }
                if( c_NoBanning == false){
                    opl.Add("Banning Disabled");
                }
                if( c_NoTrade == true ) {
                    opl.Add("This area cannot be Traded");
                }
                if( c_NoTrade == false ) {
                    opl.Add("This area can be Traded");
                }
               
                opl.Apply( );
            }
     
    • Like Like x 2
  8. Greed

    Greed Grandmaster Member Gold Star Member

    .
     
    Last edited: Sep 28, 2016
  9. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    thanks man, i do what i can
     
  10. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    it should also be noted that if you make an item Movable = false and then add a townhouse the item will be considered locked down and can be released by the owner, once they or if they demolish the house everything that was originally there will be readded.
    but it will not duplicate a copy of an item on top of the original.
     
  11. Fireball

    Fireball Distinguished Member

    Thanks zero. I almost had a clutcher when I resold a house that was full of stuff and it all got deleted. I thought I maybe didn't select the option correctly so I reverted and tried again with the same effect! This is a great help thank you.

    Also actually while I am on this post, there is another problem with Knive's Town Houses and that is the patch for checking what's in the house (IsInside I think). It completely messes up castle courtyards so you can't mark or recall there without mapping out the courtyard in houses.cs which is a pain and that brings another problem in that people can then mark runes on the castle bridges! I became quite concerned with these problems and if it wasn't so totally awesome to be able to declare anything you care to place is a "house" or turn a town building into a shop I would probably have got rid of it long ago. So great to see another bug bite the dust!

    Thanks!

    FB
     
  12. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    did you make the change to BaseHouse?

    i'd have to test it but seems to me that it might fix that problem

    actually i just checked with the distro BaseHouse and i can mark in recall in Castle Courtyards just fine
     
    Last edited: Jul 6, 2015
  13. Forest Condon

    Forest Condon Illustrious Member

    I too have been finally testing this out as players have requested it. There seems to be an issue when a player tries to "demolish" a rented location. It crashes the server. Not like reboots and gives a crash log but like it completely errors out and terminates with no log. This is in the console before I hit ok on the crash termination report.

    Code:
    22:00:44 World: Saving...Warning: Attempted to add 0x40016BBF "Bag" during world
    save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
    22:00:45 Warning: Attempted to delete 0x40016BBF "Bag" during world save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
    22:00:45 Warning: Attempted to add 0x40016C12 "BankCheck" during world save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
    22:00:45 Warning: Attempted to delete 0x40018712 "TownHouse" during world save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
    Process is terminated due to StackOverflowException.
    
    This error happens if you try demolishing a rental contract, if a gm just tries deleting it, or even if the main owner of the home destroys there home and on world save the rental contract is supposed to be terminatd. So basically when ever rentals are terminated. Makes that feature useless. :(


    If it helps, here is the COMPLETE world save error log.

    Code:
    7/6/2015 10:00:45 PM    Warning: Attempted to add 0x40016BBF "Bag" during world save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
       at Server.Item..ctor()
       at Server.Items.Container..ctor(Int32 itemID)
       at Server.Items.Bag..ctor()
       at Knives.TownHouses.TownHouseSign.PackUpItems()
       at Knives.TownHouses.TownHouseSign.PackUpHouse()
       at Knives.TownHouses.RentalContract.Delete()
       at Knives.TownHouses.General.OnSave(WorldSaveEventArgs e)
       at Server.WorldSaveEventHandler.Invoke(WorldSaveEventArgs e)
       at Server.World.Save(Boolean message, Boolean permitBackgroundWrite)
       at Server.Commands.CommandHandlers.Save_OnCommand(CommandEventArgs e)
       at Server.Commands.CommandSystem.Handle(Mobile from, String text, MessageType type)
       at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
       at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
       at Server.Network.MessagePump.HandleReceive(NetState ns)
       at Server.Network.MessagePump.Slice()
       at Server.Core.Main(String[] args)
    
    
    7/6/2015 10:00:45 PM    Warning: Attempted to delete 0x40016BBF "Bag" during world save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
       at Knives.TownHouses.TownHouseSign.PackUpItems()
       at Knives.TownHouses.TownHouseSign.PackUpHouse()
       at Knives.TownHouses.RentalContract.Delete()
       at Knives.TownHouses.General.OnSave(WorldSaveEventArgs e)
       at Server.WorldSaveEventHandler.Invoke(WorldSaveEventArgs e)
       at Server.World.Save(Boolean message, Boolean permitBackgroundWrite)
       at Server.Commands.CommandHandlers.Save_OnCommand(CommandEventArgs e)
       at Server.Commands.CommandSystem.Handle(Mobile from, String text, MessageType type)
       at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
       at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
       at Server.Network.MessagePump.HandleReceive(NetState ns)
       at Server.Network.MessagePump.Slice()
       at Server.Core.Main(String[] args)
    
    
    7/6/2015 10:00:45 PM    Warning: Attempted to add 0x40016C12 "BankCheck" during world save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
       at Server.Item..ctor()
       at Knives.TownHouses.TownHouseSign.PackUpHouse()
       at Knives.TownHouses.RentalContract.Delete()
       at Knives.TownHouses.General.OnSave(WorldSaveEventArgs e)
       at Server.WorldSaveEventHandler.Invoke(WorldSaveEventArgs e)
       at Server.World.Save(Boolean message, Boolean permitBackgroundWrite)
       at Server.Commands.CommandHandlers.Save_OnCommand(CommandEventArgs e)
       at Server.Commands.CommandSystem.Handle(Mobile from, String text, MessageType type)
       at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
       at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
       at Server.Network.MessagePump.HandleReceive(NetState ns)
       at Server.Network.MessagePump.Slice()
       at Server.Core.Main(String[] args)
    
    
    7/6/2015 10:00:45 PM    Warning: Attempted to delete 0x40018712 "TownHouse" during world save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
       at Knives.TownHouses.RentalContract.Delete()
       at Knives.TownHouses.General.OnSave(WorldSaveEventArgs e)
       at Server.WorldSaveEventHandler.Invoke(WorldSaveEventArgs e)
       at Server.World.Save(Boolean message, Boolean permitBackgroundWrite)
       at Server.Commands.CommandHandlers.Save_OnCommand(CommandEventArgs e)
       at Server.Commands.CommandSystem.Handle(Mobile from, String text, MessageType type)
       at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
       at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
       at Server.Network.MessagePump.HandleReceive(NetState ns)
       at Server.Network.MessagePump.Slice()
       at Server.Core.Main(String[] args)
    
    
    7/6/2015 10:08:54 PM    Warning: Attempted to delete 0x400186B9 "RentalContract" during world save.
    This action could cause inconsistent state.
    It is strongly advised that the offending scripts be corrected.
       at Knives.TownHouses.TownHouseSign.Delete()
       at Knives.TownHouses.RentalContract.Delete()
       at Knives.TownHouses.General.OnSave(WorldSaveEventArgs e)
       at Server.WorldSaveEventHandler.Invoke(WorldSaveEventArgs e)
       at Server.World.Save(Boolean message, Boolean permitBackgroundWrite)
       at Server.Commands.CommandHandlers.Save_OnCommand(CommandEventArgs e)
       at Server.Commands.CommandSystem.Handle(Mobile from, String text, MessageType type)
       at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
       at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
       at Server.Network.MessagePump.HandleReceive(NetState ns)
       at Server.Network.MessagePump.Slice()
       at Server.Core.Main(String[] args)
    
     
    Last edited: Jul 6, 2015
  14. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    I know that was an issue with an older version released on RunUO but I haven't had any issues with this version.
    I've demolished and rented multiple properties several times without any issues.
    I even tried deleting the townhousesign while owned by someone and it won't let me.

    Seems very solid to me.

    so the question is, are you using this version?
     
  15. Forest Condon

    Forest Condon Illustrious Member

    I compared the files and it's the same zip, size and everything. Just in case I somehow got mixed up I'll test this new one as soon as I have time when kids go to bed but I i'm 99.9% positive it's the correct one..

    Though if it makes a difference the house we were having issues with was a static building near the britain bank. I'll retest tonight when I have a chance.
     
  16. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    interesting, I've tried it with a static build too and found no issues. that was after I made the changes. might check on the RunUO boards if you still have the problem to see how others fixed it before
     
  17. Forest Condon

    Forest Condon Illustrious Member

    Makes me wonder if its some wierd one time issue. using the same system I tried to replicate it and cant. So weird. If I find anything out about it I will reply here. BTW nice get props mod. :)
     
    • Like Like x 1
  18. Fireball

    Fireball Distinguished Member

    Yeah it works fine with the distro (I'm actually using RunUO 2.4) but if you add the recommended TownHouses patch it changes (from memory) checking you are PartOf(HouseRegion) to checking IsInside, and I think it was that which stopped recalling into coutyards from working. It returns as blocked.
    If you take out that patch then courtyards work fine again.

    Code:
    // Town Houses Patch:
    // public virtual bool IsInside( Point3D p, int height )
    // {
    // if ( Deleted )
    // return false;
    //
    // MultiComponentList mcl = Components;
    //
    // int x = p.X - (X + mcl.Min.X);
    // int y = p.Y - (Y + mcl.Min.Y);
    //
    // if ( x < 0 || x >= mcl.Width || y < 0 || y >= mcl.Height )
    // return false;
    //
    // if ( this is HouseFoundation && y < (mcl.Height-1) && p.Z >= this.Z )
    // return true;
    //
    // StaticTile[] tiles = mcl.Tiles[x][y];
    //
    // for ( int j = 0; j < tiles.Length; ++j )
    // {
    // StaticTile tile = tiles[j];
    // int id = tile.ID & TileData.MaxItemValue;
    // ItemData data = TileData.ItemTable[id];
    //
    //  Slanted roofs do not count; they overhang blocking south and east sides of the multi
    // if ( (data.Flags & TileFlag.Roof) != 0 )
    // continue;
    //
    //  Signs and signposts are not considered part of the multi
    // if ( (id >= 0xB95 && id <= 0xC0E) || (id >= 0xC43 && id <= 0xC44) )
    // continue;
    //
    // int tileZ = tile.Z + this.Z;
    //
    // if ( p.Z == tileZ || (p.Z + height) > tileZ )
    // return true;
    // }
    //
    // return false;
    // }
    public virtual bool IsInside( Point3D p, int height )
    {
    Sector sector = Map.GetSector( p );
    foreach( BaseMulti m in sector.Multis )
    {
    if ( m != this
    && m is Knives.TownHouses.TownHouse
    && ((Knives.TownHouses.TownHouse)m).ForSaleSign is Knives.TownHouses.RentalContract
    && ((Knives.TownHouses.TownHouse)m).IsInside( p, height ) )
    return false;
    }
    return Region.Contains( p );
    }
    // End of Town houses patch
    
     
    • Like Like x 1
  19. Visam

    Visam Distinguished Member

    I really like the extra sign info that zerodowned posted, but a small fix:

    There is a typo in the code for adding more info to the sign as it shows banning disabled regardless if it is enabled or not to fix simply change the following.

    if( c_NoBanning == true){
    opl.Add("Banning Disabled");
    }
    if( c_NoBanning == false){
    opl.Add("Banning Disabled"); //the line to fix is here change Disabled to Enabled
    }
     
    • Like Like x 1
    • Agree Agree x 1
  20. Forest Condon

    Forest Condon Illustrious Member

    I made the Interior Decorator mod (cause players couldnt raise decoration) and this error I get.

    Code:
    ----------------------------------------------------------------------------
    JustUO - [http://www.playuo.org] Version 2.0
    Publish 4
    Core: .NET Framework Version 4.0.30319
    Core: Optimizing for 4 64-bit processors
    RandomImpl: CSPRandom (Software)
    Scripts: Compiling C# scripts...Failed with: 1 errors
    Errors:
     + Items/- Misc/InteriorDecorator.cs:
        CS0246: Line 324: The type or namespace name 'Tile' could not be found (are
    you missing a using directive or an assembly reference?)
        CS0029: Line 324: Cannot implicitly convert type 'Server.StaticTile[]' to 'T
    ile[]'
    
     
  21. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    ah, yeah i found the fix for that on RunUO i think

    StaticTile[] tiles = map.Tiles.GetStaticTiles(item.X, item.Y, true);
     
    • Like Like x 2
  22. Forest Condon

    Forest Condon Illustrious Member

    Thanks man
     
    • Like Like x 1
  23. zerodowned

    zerodowned Administrator Moderator JustUO Developer Gold Star Member Et Cetera, Et Cetera

    after not opening my bank box for a few months i realized a problem with this edit.
    you need to be careful what you set it up with.

    for example, i tiled stonepavers and added the townhouse area over it. when i go to demolish the house, all those tiles get added to my bankbox in the moving container.

    yikes
     
    • Informative Informative x 1
  24. Archaaz

    Archaaz Renowned Member

    I am running RunUO 2.2, and using the original Town Houses script (V2.01). I am using this script for all housing on the shard, and have created quite a few extra static houses with CentrED. I will look into other options depending on shard population, but I expect it should be sufficient.

    I posted on RunUO.net about the issue of the Interior Decorator patch not working (fix posted by zeroedown. Thanks!). The owner of UOEvolution replied, revealing that he eventually had to remove it. He said it works fine up to about 300 players, but causes issues above that, and suggested I would probably need to rescript it (or in my case hire someone to rescript it for me). Thus far, it is working fine, though the shard is not released, and I am the only one testing it. I am able to set up, purchase and demolish houses with no issues.


    Has anyone else used this version on RunUo and experienced the same issues? If so can I replace it with this script with no problems, and will that affect houses already set up (I already set them all up)? Or has anyone perhaps found a way to mitigate such problems in the original script? Thanks in advance for any advice.
     

Share This Page