1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-20 19:57:46 +00:00
This commit is contained in:
Filip Maj 2017-06-14 22:24:26 -04:00
commit 866e2d3559
5 changed files with 76 additions and 42 deletions

View file

@ -87,7 +87,7 @@ namespace FFXIVClassic_Map_Server.Actors
public SubPacket CreateSpeedPacket(uint playerActorId) public SubPacket CreateSpeedPacket(uint playerActorId)
{ {
return SetActorSpeedPacket.BuildPacket(actorId, playerActorId); return SetActorSpeedPacket.BuildPacket(actorId, playerActorId, moveSpeeds[0], moveSpeeds[1], moveSpeeds[2], moveSpeeds[3]);
} }
public SubPacket CreateSpawnPositonPacket(uint playerActorId, ushort spawnType) public SubPacket CreateSpawnPositonPacket(uint playerActorId, ushort spawnType)

View file

@ -64,7 +64,7 @@ namespace FFXIVClassic_Map_Server.Actors
this.displayNameId = 0; this.displayNameId = 0;
this.customDisplayName = "_areaMaster"; this.customDisplayName = "_areaMaster";
this.actorName = String.Format("_areaMaster@{0:X5}",id<<8); this.actorName = String.Format("_areaMaster@{0:X5}", id << 8);
this.classPath = classPath; this.classPath = classPath;
this.className = classPath.Substring(classPath.LastIndexOf("/") + 1); this.className = classPath.Substring(classPath.LastIndexOf("/") + 1);
@ -77,12 +77,11 @@ namespace FFXIVClassic_Map_Server.Actors
for (int y = 0; y < numYBlocks; y++) for (int y = 0; y < numYBlocks; y++)
{ {
for (int x = 0; x < numXBlocks; x++ ) for (int x = 0; x < numXBlocks; x++)
{ {
mActorBlock[x, y] = new List<Actor>(); mActorBlock[x, y] = new List<Actor>();
} }
} }
} }
public override SubPacket CreateScriptBindPacket(uint playerActorId) public override SubPacket CreateScriptBindPacket(uint playerActorId)
@ -109,8 +108,11 @@ namespace FFXIVClassic_Map_Server.Actors
public void AddActorToZone(Actor actor) public void AddActorToZone(Actor actor)
{ {
if (!mActorList.ContainsKey(actor.actorId)) lock (mActorList)
mActorList.Add(actor.actorId, actor); {
if (!mActorList.ContainsKey(actor.actorId))
mActorList.Add(actor.actorId, actor);
}
int gridX = (int)actor.positionX / boundingGridSize; int gridX = (int)actor.positionX / boundingGridSize;
int gridY = (int)actor.positionZ / boundingGridSize; int gridY = (int)actor.positionZ / boundingGridSize;
@ -134,7 +136,8 @@ namespace FFXIVClassic_Map_Server.Actors
public void RemoveActorFromZone(Actor actor) public void RemoveActorFromZone(Actor actor)
{ {
mActorList.Remove(actor.actorId); lock (mActorList)
mActorList.Remove(actor.actorId);
int gridX = (int)actor.positionX / boundingGridSize; int gridX = (int)actor.positionX / boundingGridSize;
int gridY = (int)actor.positionZ / boundingGridSize; int gridY = (int)actor.positionZ / boundingGridSize;
@ -223,11 +226,14 @@ namespace FFXIVClassic_Map_Server.Actors
List<Actor> result = new List<Actor>(); List<Actor> result = new List<Actor>();
for (int gx = gridX - checkDistance; gx <= gridX + checkDistance; gx++) lock (mActorBlock)
{ {
for (int gy = gridY - checkDistance; gy <= gridY + checkDistance; gy++) for (int gx = gridX - checkDistance; gx <= gridX + checkDistance; gx++)
{ {
result.AddRange(mActorBlock[gx, gy]); for (int gy = gridY - checkDistance; gy <= gridY + checkDistance; gy++)
{
result.AddRange(mActorBlock[gx, gy]);
}
} }
} }
@ -266,14 +272,16 @@ namespace FFXIVClassic_Map_Server.Actors
List<Actor> result = new List<Actor>(); List<Actor> result = new List<Actor>();
for (int gy = ((gridY - checkDistance) < 0 ? 0 : (gridY - checkDistance)); gy <= ((gridY + checkDistance) >= numYBlocks ? numYBlocks - 1 : (gridY + checkDistance)); gy++) lock (mActorBlock)
{ {
for (int gx = ((gridX - checkDistance) < 0 ? 0 : (gridX - checkDistance)); gx <= ((gridX + checkDistance) >= numXBlocks ? numXBlocks - 1 : (gridX + checkDistance)); gx++) for (int gy = ((gridY - checkDistance) < 0 ? 0 : (gridY - checkDistance)); gy <= ((gridY + checkDistance) >= numYBlocks ? numYBlocks - 1 : (gridY + checkDistance)); gy++)
{ {
result.AddRange(mActorBlock[gx, gy]); for (int gx = ((gridX - checkDistance) < 0 ? 0 : (gridX - checkDistance)); gx <= ((gridX + checkDistance) >= numXBlocks ? numXBlocks - 1 : (gridX + checkDistance)); gx++)
{
result.AddRange(mActorBlock[gx, gy]);
}
} }
} }
//Remove players if isolation zone //Remove players if isolation zone
if (isIsolated) if (isIsolated)
{ {
@ -291,19 +299,25 @@ namespace FFXIVClassic_Map_Server.Actors
public Actor FindActorInArea(uint id) public Actor FindActorInArea(uint id)
{ {
if (!mActorList.ContainsKey(id)) lock (mActorList)
return null; {
return mActorList[id]; if (!mActorList.ContainsKey(id))
return null;
return mActorList[id];
}
} }
public Actor FindActorInZoneByUniqueID(string uniqueId) public Actor FindActorInZoneByUniqueID(string uniqueId)
{ {
foreach (Actor a in mActorList.Values) lock (mActorList)
{ {
if (a is Npc) foreach (Actor a in mActorList.Values)
{ {
if (((Npc)a).GetUniqueId().ToLower().Equals(uniqueId)) if (a is Npc)
return a; {
if (((Npc)a).GetUniqueId().ToLower().Equals(uniqueId))
return a;
}
} }
} }
return null; return null;
@ -311,33 +325,45 @@ namespace FFXIVClassic_Map_Server.Actors
public Player FindPCInZone(string name) public Player FindPCInZone(string name)
{ {
foreach (Actor a in mActorList.Values) lock (mActorList)
{ {
if (a is Player) foreach (Actor a in mActorList.Values)
{ {
if (((Player)a).customDisplayName.ToLower().Equals(name.ToLower())) if (a is Player)
return (Player)a; {
if (((Player)a).customDisplayName.ToLower().Equals(name.ToLower()))
return (Player)a;
}
} }
return null;
} }
return null;
} }
public Player FindPCInZone(uint id) public Player FindPCInZone(uint id)
{ {
if (!mActorList.ContainsKey(id)) lock (mActorList)
return null; {
return (Player)mActorList[id]; if (!mActorList.ContainsKey(id))
return null;
return (Player)mActorList[id];
}
} }
public void Clear() public void Clear()
{ {
//Clear All lock (mActorList)
mActorList.Clear();
for (int y = 0; y < numYBlocks; y++)
{ {
for (int x = 0; x < numXBlocks; x++) //Clear All
mActorList.Clear();
lock (mActorBlock)
{ {
mActorBlock[x, y].Clear(); for (int y = 0; y < numYBlocks; y++)
{
for (int x = 0; x < numXBlocks; x++)
{
mActorBlock[x, y].Clear();
}
}
} }
} }
} }
@ -450,12 +476,15 @@ namespace FFXIVClassic_Map_Server.Actors
} }
if (zoneWide) if (zoneWide)
{ {
foreach (var actor in mActorList) lock (mActorList)
{ {
if (actor.Value is Player) foreach (var actor in mActorList)
{ {
player = ((Player)actor.Value); if (actor.Value is Player)
player.QueuePacket(BasePacket.CreatePacket(SetWeatherPacket.BuildPacket(player.actorId, weather, transitionTime), true, false)); {
player = ((Player)actor.Value);
player.QueuePacket(BasePacket.CreatePacket(SetWeatherPacket.BuildPacket(player.actorId, weather, transitionTime), true, false));
}
} }
} }
} }

View file

@ -146,6 +146,11 @@ namespace FFXIVClassic_Map_Server.Actors
className = "Player"; className = "Player";
currentSubState = SetActorStatePacket.SUB_STATE_PLAYER; currentSubState = SetActorStatePacket.SUB_STATE_PLAYER;
moveSpeeds[0] = SetActorSpeedPacket.DEFAULT_STOP;
moveSpeeds[1] = SetActorSpeedPacket.DEFAULT_WALK;
moveSpeeds[2] = SetActorSpeedPacket.DEFAULT_RUN;
moveSpeeds[3] = SetActorSpeedPacket.DEFAULT_ACTIVE;
inventories[Inventory.NORMAL] = new Inventory(this, MAXSIZE_INVENTORY_NORMAL, Inventory.NORMAL); inventories[Inventory.NORMAL] = new Inventory(this, MAXSIZE_INVENTORY_NORMAL, Inventory.NORMAL);
inventories[Inventory.KEYITEMS] = new Inventory(this, MAXSIZE_INVENTORY_KEYITEMS, Inventory.KEYITEMS); inventories[Inventory.KEYITEMS] = new Inventory(this, MAXSIZE_INVENTORY_KEYITEMS, Inventory.KEYITEMS);
inventories[Inventory.CURRENCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRENCY); inventories[Inventory.CURRENCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRENCY);

View file

@ -48,7 +48,7 @@ function VerifyUser($dataConnection, $username, $password)
$statement->bind_result($id, $storedPasshash, $salt); $statement->bind_result($id, $storedPasshash, $salt);
if(!$statement->fetch()) if(!$statement->fetch())
{ {
throw new Exception(__FUNCTION__ . " failed."); throw new Exception("Incorrect username.");
} }
$saltedPassword = $password . $salt; $saltedPassword = $password . $salt;
@ -56,7 +56,7 @@ function VerifyUser($dataConnection, $username, $password)
if($hashedPassword !== $storedPasshash) if($hashedPassword !== $storedPasshash)
{ {
throw new Exception(__FUNCTION__ . " failed."); throw new Exception("Incorrect password.");
} }
return $id; return $id;

View file

@ -48,7 +48,7 @@ function VerifyUser($dataConnection, $username, $password)
$statement->bind_result($id, $storedPasshash, $salt); $statement->bind_result($id, $storedPasshash, $salt);
if(!$statement->fetch()) if(!$statement->fetch())
{ {
throw new Exception(__FUNCTION__ . " failed."); throw new Exception("Incorrect username.");
} }
$saltedPassword = $password . $salt; $saltedPassword = $password . $salt;
@ -56,7 +56,7 @@ function VerifyUser($dataConnection, $username, $password)
if($hashedPassword !== $storedPasshash) if($hashedPassword !== $storedPasshash)
{ {
throw new Exception(__FUNCTION__ . " failed."); throw new Exception("Incorrect password.");
} }
return $id; return $id;