Send Housing Items depending on last refresh. (bug)

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

Send Housing Items depending on last refresh. (bug)

Postby elcotek » Tue Jan 09, 2018 8:50 am

Your code have a bug and i tell you why:
Code: Select all
var houses = housesDict.Values.Where(h => h != null && player.IsWithinRadius(h, HousingConstants.HouseViewingDistance)).ToArray();


var can't hold null values and this will cause a Exception


Your Code in WorldUpdateThread:
Code: Select all
public static void UpdatePlayerHousing(GamePlayer player, long nowTicks)
        {
            // If no house update needed exit.
            if (player.CurrentRegion == null || !player.CurrentRegion.HousingEnabled)
                return;

            // Get All House in Region
            IDictionary<int, House> housesDict = HouseMgr.GetHouses(player.CurrentRegionID);
            // Build Vincinity List
            var houses = housesDict.Values.Where(h => h != null && player.IsWithinRadius(h, HousingConstants.HouseViewingDistance)).ToArray();


            try
            {






Here is the fixed verion:

Code: Select all
/// <summary>
        /// Send Housing Items depending on last refresh.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="nowTicks"></param>
        public static void UpdatePlayerHousing(GamePlayer player, long nowTicks)
        {
           
            ArrayList houses = null;
           
            // If no house update needed exit.
            if (player == null || player.CurrentRegion == null || !player.CurrentRegion.HousingEnabled)
                return;
         
            //Get all Houses of a Region and Close to a Spot
            ArrayList housess = (ArrayList)HouseMgr.GetHousesCloseToSpot((ushort)player.CurrentRegionID, player.X, player.Y, 10120);
           
            // Get All House in Region
            IDictionary<int, House> housesDict = HouseMgr.GetHouses(player.CurrentRegionID);
           
            //Make sure there is a House and player
            if (housess != null && housesDict.Values.Where(h => h != null && player.IsWithinRadius(h, HousingConstants.HouseViewingDistance)).ToArray() != null)
            {
                houses = housess;
            }

            if (houses != null)//we do sure values are not null
{
  try




Sorry i can't create patches for your source but i try to help find and fix bugs. :wink:
Brotherland Final RvR/PvE/ToA http://brotherland.phpbb8.de/
User avatar
elcotek
Server Representative
 
Posts: 172
Joined: Mon May 12, 2008 9:28 pm
Location: Germany

Return to DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest