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)
@ -108,9 +107,12 @@ namespace FFXIVClassic_Map_Server.Actors
#region Actor Management #region Actor Management
public void AddActorToZone(Actor actor) public void AddActorToZone(Actor actor)
{
lock (mActorList)
{ {
if (!mActorList.ContainsKey(actor.actorId)) if (!mActorList.ContainsKey(actor.actorId))
mActorList.Add(actor.actorId, actor); 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,6 +136,7 @@ namespace FFXIVClassic_Map_Server.Actors
public void RemoveActorFromZone(Actor actor) public void RemoveActorFromZone(Actor actor)
{ {
lock (mActorList)
mActorList.Remove(actor.actorId); mActorList.Remove(actor.actorId);
int gridX = (int)actor.positionX / boundingGridSize; int gridX = (int)actor.positionX / boundingGridSize;
@ -223,6 +226,8 @@ namespace FFXIVClassic_Map_Server.Actors
List<Actor> result = new List<Actor>(); List<Actor> result = new List<Actor>();
lock (mActorBlock)
{
for (int gx = gridX - checkDistance; gx <= gridX + checkDistance; gx++) for (int gx = gridX - checkDistance; gx <= gridX + checkDistance; gx++)
{ {
for (int gy = gridY - checkDistance; gy <= gridY + checkDistance; gy++) for (int gy = gridY - checkDistance; gy <= gridY + checkDistance; gy++)
@ -230,6 +235,7 @@ namespace FFXIVClassic_Map_Server.Actors
result.AddRange(mActorBlock[gx, gy]); result.AddRange(mActorBlock[gx, gy]);
} }
} }
}
//Remove players if isolation zone //Remove players if isolation zone
if (isIsolated) if (isIsolated)
@ -266,6 +272,8 @@ namespace FFXIVClassic_Map_Server.Actors
List<Actor> result = new List<Actor>(); 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 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++) 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]); result.AddRange(mActorBlock[gx, gy]);
} }
} }
}
//Remove players if isolation zone //Remove players if isolation zone
if (isIsolated) if (isIsolated)
{ {
@ -290,13 +298,18 @@ namespace FFXIVClassic_Map_Server.Actors
#endregion #endregion
public Actor FindActorInArea(uint id) public Actor FindActorInArea(uint id)
{
lock (mActorList)
{ {
if (!mActorList.ContainsKey(id)) if (!mActorList.ContainsKey(id))
return null; return null;
return mActorList[id]; return mActorList[id];
} }
}
public Actor FindActorInZoneByUniqueID(string uniqueId) public Actor FindActorInZoneByUniqueID(string uniqueId)
{
lock (mActorList)
{ {
foreach (Actor a in mActorList.Values) foreach (Actor a in mActorList.Values)
{ {
@ -306,10 +319,13 @@ namespace FFXIVClassic_Map_Server.Actors
return a; return a;
} }
} }
}
return null; return null;
} }
public Player FindPCInZone(string name) public Player FindPCInZone(string name)
{
lock (mActorList)
{ {
foreach (Actor a in mActorList.Values) foreach (Actor a in mActorList.Values)
{ {
@ -321,18 +337,26 @@ namespace FFXIVClassic_Map_Server.Actors
} }
return null; return null;
} }
}
public Player FindPCInZone(uint id) public Player FindPCInZone(uint id)
{
lock (mActorList)
{ {
if (!mActorList.ContainsKey(id)) if (!mActorList.ContainsKey(id))
return null; return null;
return (Player)mActorList[id]; return (Player)mActorList[id];
} }
}
public void Clear() public void Clear()
{
lock (mActorList)
{ {
//Clear All //Clear All
mActorList.Clear(); mActorList.Clear();
lock (mActorBlock)
{
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++)
@ -341,6 +365,8 @@ namespace FFXIVClassic_Map_Server.Actors
} }
} }
} }
}
}
public void BroadcastPacketAroundActor(Actor actor, SubPacket packet) 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)); player.QueuePacket(BasePacket.CreatePacket(SetWeatherPacket.BuildPacket(player.actorId, weather, transitionTime), true, false));
} }
if (zoneWide) if (zoneWide)
{
lock (mActorList)
{ {
foreach (var actor in mActorList) foreach (var actor in mActorList)
{ {
@ -460,6 +488,7 @@ namespace FFXIVClassic_Map_Server.Actors
} }
} }
} }
}
public Director CreateDirector(string path) public Director CreateDirector(string path)
{ {

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;