mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	fixed some races
This commit is contained in:
		@@ -82,7 +82,6 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
                    mActorBlock[x, y] = new List<Actor>();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override SubPacket CreateScriptBindPacket(uint playerActorId)
 | 
			
		||||
@@ -108,9 +107,12 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
        #region Actor Management
 | 
			
		||||
 | 
			
		||||
        public void AddActorToZone(Actor actor)
 | 
			
		||||
        {
 | 
			
		||||
            lock (mActorList)
 | 
			
		||||
            {
 | 
			
		||||
                if (!mActorList.ContainsKey(actor.actorId))
 | 
			
		||||
                    mActorList.Add(actor.actorId, actor);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            int gridX = (int)actor.positionX / boundingGridSize;
 | 
			
		||||
            int gridY = (int)actor.positionZ / boundingGridSize;
 | 
			
		||||
@@ -134,6 +136,7 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
 | 
			
		||||
        public void RemoveActorFromZone(Actor actor)
 | 
			
		||||
        {
 | 
			
		||||
            lock (mActorList)
 | 
			
		||||
                mActorList.Remove(actor.actorId);
 | 
			
		||||
 | 
			
		||||
            int gridX = (int)actor.positionX / boundingGridSize;
 | 
			
		||||
@@ -223,6 +226,8 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
 | 
			
		||||
            List<Actor> result = new List<Actor>();
 | 
			
		||||
 | 
			
		||||
            lock (mActorBlock)
 | 
			
		||||
            {
 | 
			
		||||
                for (int gx = gridX - checkDistance; gx <= gridX + checkDistance; gx++)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int gy = gridY - checkDistance; gy <= gridY + checkDistance; gy++)
 | 
			
		||||
@@ -230,6 +235,7 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
                        result.AddRange(mActorBlock[gx, gy]);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //Remove players if isolation zone
 | 
			
		||||
            if (isIsolated)
 | 
			
		||||
@@ -266,6 +272,8 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
 | 
			
		||||
            List<Actor> result = new List<Actor>();
 | 
			
		||||
 | 
			
		||||
            lock (mActorBlock)
 | 
			
		||||
            {
 | 
			
		||||
                for (int gy = ((gridY - checkDistance) < 0 ? 0 : (gridY - checkDistance)); gy <= ((gridY + checkDistance) >= numYBlocks ? numYBlocks - 1 : (gridY + checkDistance)); gy++)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int gx = ((gridX - checkDistance) < 0 ? 0 : (gridX - checkDistance)); gx <= ((gridX + checkDistance) >= numXBlocks ? numXBlocks - 1 : (gridX + checkDistance)); gx++)
 | 
			
		||||
@@ -273,7 +281,7 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
                        result.AddRange(mActorBlock[gx, gy]);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            //Remove players if isolation zone
 | 
			
		||||
            if (isIsolated)
 | 
			
		||||
            {
 | 
			
		||||
@@ -290,13 +298,18 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        public Actor FindActorInArea(uint id)
 | 
			
		||||
        {
 | 
			
		||||
            lock (mActorList)
 | 
			
		||||
            {
 | 
			
		||||
                if (!mActorList.ContainsKey(id))
 | 
			
		||||
                    return null;
 | 
			
		||||
                return mActorList[id];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Actor FindActorInZoneByUniqueID(string uniqueId)
 | 
			
		||||
        {
 | 
			
		||||
            lock (mActorList)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (Actor a in mActorList.Values)
 | 
			
		||||
                {
 | 
			
		||||
@@ -306,10 +319,13 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
                            return a;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Player FindPCInZone(string name)
 | 
			
		||||
        {
 | 
			
		||||
            lock (mActorList)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (Actor a in mActorList.Values)
 | 
			
		||||
                {
 | 
			
		||||
@@ -321,18 +337,26 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
                }
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Player FindPCInZone(uint id)
 | 
			
		||||
        {
 | 
			
		||||
            lock (mActorList)
 | 
			
		||||
            {
 | 
			
		||||
                if (!mActorList.ContainsKey(id))
 | 
			
		||||
                    return null;
 | 
			
		||||
                return (Player)mActorList[id];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Clear()
 | 
			
		||||
        {
 | 
			
		||||
            lock (mActorList)
 | 
			
		||||
            {
 | 
			
		||||
                //Clear All
 | 
			
		||||
                mActorList.Clear();
 | 
			
		||||
                lock (mActorBlock)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int y = 0; y < numYBlocks; y++)
 | 
			
		||||
                    {
 | 
			
		||||
                        for (int x = 0; x < numXBlocks; x++)
 | 
			
		||||
@@ -341,6 +365,8 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void BroadcastPacketAroundActor(Actor actor, SubPacket packet)
 | 
			
		||||
        {
 | 
			
		||||
@@ -449,6 +475,8 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
                player.QueuePacket(BasePacket.CreatePacket(SetWeatherPacket.BuildPacket(player.actorId, weather, transitionTime), true, false));
 | 
			
		||||
            }
 | 
			
		||||
            if (zoneWide)
 | 
			
		||||
            {
 | 
			
		||||
                lock (mActorList)
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (var actor in mActorList)
 | 
			
		||||
                    {
 | 
			
		||||
@@ -460,6 +488,7 @@ namespace FFXIVClassic_Map_Server.Actors
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }                
 | 
			
		||||
 | 
			
		||||
        public Director CreateDirector(string path)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user