mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-06 05:05:40 +12:00
Update Server
This commit is contained in:
parent
48d1b9e100
commit
43035bbf05
7 changed files with 8939 additions and 8867 deletions
File diff suppressed because it is too large
Load diff
|
@ -137,6 +137,7 @@ namespace Horse_Isle_Server
|
|||
}
|
||||
public static string GetWorldWeather()
|
||||
{
|
||||
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "SELECT Weather FROM World";
|
||||
string Weather = sqlCommand.ExecuteScalar().ToString();
|
||||
|
|
|
@ -81,8 +81,10 @@ namespace Horse_Isle_Server
|
|||
specialTile.Title = gameData.places.special_tiles[i].title;
|
||||
specialTile.Description = gameData.places.special_tiles[i].description;
|
||||
specialTile.Code = gameData.places.special_tiles[i].code;
|
||||
specialTile.ExitX = gameData.places.special_tiles[i].exit_x;
|
||||
specialTile.ExitY = gameData.places.special_tiles[i].exit_y;
|
||||
if(gameData.places.special_tiles[i].exit_x != null)
|
||||
specialTile.ExitX = gameData.places.special_tiles[i].exit_x;
|
||||
if(gameData.places.special_tiles[i].exit_x != null)
|
||||
specialTile.ExitY = gameData.places.special_tiles[i].exit_y;
|
||||
specialTile.AutoplaySwf = gameData.places.special_tiles[i].autoplay_swf;
|
||||
specialTile.TypeFlag = gameData.places.special_tiles[i].type_flag;
|
||||
|
||||
|
@ -181,6 +183,8 @@ namespace Horse_Isle_Server
|
|||
Messages.Seperator = gameData.messages.meta.seperator;
|
||||
Messages.TileFormat = gameData.messages.meta.tile_format;
|
||||
Messages.NothingMessage = gameData.messages.meta.nothing_message;
|
||||
Messages.ExitThisPlace = gameData.messages.meta.exit_this_place;
|
||||
Messages.MetaTerminator = gameData.messages.meta.end_of_meta;
|
||||
|
||||
Messages.NearbyPlayers = gameData.messages.meta.nearby.players_nearby;
|
||||
Messages.North = gameData.messages.meta.nearby.north;
|
||||
|
|
|
@ -39,27 +39,36 @@ namespace Horse_Isle_Server
|
|||
}
|
||||
public static bool CheckPassable(int x, int y)
|
||||
{
|
||||
int tileId = GetTileId(x, y, false);
|
||||
int otileId = GetTileId(x, y, true);
|
||||
int tileId = GetTileId(x, y, false) - 1;
|
||||
int otileId = GetTileId(x, y, true) - 1;
|
||||
|
||||
bool terrainPassable = TerrainTiles[tileId - 1].Passable;
|
||||
bool terrainPassable = TerrainTiles[tileId].Passable;
|
||||
int tileset = 0;
|
||||
|
||||
if (otileId > 190)
|
||||
|
||||
if (otileId > 192)
|
||||
{
|
||||
otileId -= 192;
|
||||
if (World.InIsle(x, y))
|
||||
tileset = World.GetIsle(x, y).Tileset+1;
|
||||
tileset = World.GetIsle(x, y).Tileset;
|
||||
otileId = otileId + 64 * tileset;
|
||||
}
|
||||
|
||||
otileId = (otileId - 1) * (tileset+1);
|
||||
|
||||
bool overlayPassable = OverlayTilesetPassibility[otileId];
|
||||
int tileDepth = OverlayTileDepth[otileId];
|
||||
bool overlayPassable = false;
|
||||
if (tileDepth == 0)
|
||||
overlayPassable = false;
|
||||
if (tileDepth == 1)
|
||||
overlayPassable = false;
|
||||
if (tileDepth == 2)
|
||||
overlayPassable = true;
|
||||
if (tileDepth == 3)
|
||||
overlayPassable = true;
|
||||
|
||||
bool tilePassable = false;
|
||||
if (terrainPassable || overlayPassable)
|
||||
tilePassable = true;
|
||||
if (!overlayPassable && otileId != 1)
|
||||
if (!overlayPassable && otileId != 0)
|
||||
tilePassable = false;
|
||||
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace Horse_Isle_Server
|
|||
public static string TileFormat;
|
||||
public static string NothingMessage;
|
||||
public static string Seperator;
|
||||
public static string ExitThisPlace;
|
||||
public static string MetaTerminator;
|
||||
|
||||
// Disconnect Messages
|
||||
public static string BanMessage;
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Horse_Isle_Server
|
|||
public const byte MOVE_RIGHT = 0x16;
|
||||
public const byte MOVE_LEFT = 0x17;
|
||||
public const byte MOVE_ESCAPE = 0x18;
|
||||
public const byte MOVE_EXIT = 0x10;
|
||||
public const byte MOVE_UPDATE = 0x0A;
|
||||
|
||||
public const byte CHAT_BOTTOM_LEFT = 0x14;
|
||||
public const byte CHAT_BOTTOM_RIGHT = 0x15;
|
||||
|
|
|
@ -174,9 +174,60 @@ namespace Horse_Isle_Server
|
|||
}
|
||||
|
||||
User loggedInUser = sender.LoggedinUser;
|
||||
byte movementDirection = packet[1];
|
||||
byte movementDirection = packet[1];
|
||||
|
||||
if (movementDirection == PacketBuilder.MOVE_UP)
|
||||
if (movementDirection == PacketBuilder.MOVE_ESCAPE)
|
||||
{
|
||||
|
||||
byte Direction;
|
||||
if (World.InSpecialTile(loggedInUser.X, loggedInUser.Y))
|
||||
{
|
||||
|
||||
int newX = loggedInUser.X;
|
||||
int newY = loggedInUser.Y;
|
||||
|
||||
World.SpecialTile tile = World.GetSpecialTile(loggedInUser.X, loggedInUser.Y);
|
||||
if (tile.ExitX != 0)
|
||||
newX = tile.ExitX;
|
||||
if (tile.ExitY != 0)
|
||||
newY = tile.ExitY;
|
||||
else
|
||||
if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y + 1))
|
||||
newY += 1;
|
||||
|
||||
|
||||
|
||||
if (loggedInUser.X + 1 == newX && loggedInUser.Y == newY)
|
||||
Direction = PacketBuilder.DIRECTION_RIGHT;
|
||||
else if (loggedInUser.X - 1 == newX && loggedInUser.Y == newY)
|
||||
Direction = PacketBuilder.DIRECTION_LEFT;
|
||||
else if (loggedInUser.Y + 1 == newY && loggedInUser.X == newX)
|
||||
Direction = PacketBuilder.DIRECTION_DOWN;
|
||||
else if (loggedInUser.Y - 1 == newY && loggedInUser.X == newX)
|
||||
Direction = PacketBuilder.DIRECTION_UP;
|
||||
else
|
||||
Direction = PacketBuilder.DIRECTION_TELEPORT;
|
||||
|
||||
loggedInUser.X = newX;
|
||||
loggedInUser.Y = newY;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y + 1))
|
||||
loggedInUser.Y += 1;
|
||||
|
||||
Direction = PacketBuilder.DIRECTION_DOWN;
|
||||
}
|
||||
if (loggedInUser.X == 0 && loggedInUser.Y == 0)
|
||||
Logger.ErrorPrint("Impossible bug occured.");
|
||||
Logger.DebugPrint("Exiting player: " + loggedInUser.Username + " to: " + loggedInUser.X + "," + loggedInUser.Y);
|
||||
byte[] moveResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, Direction, Direction, true);
|
||||
sender.SendPacket(moveResponse);
|
||||
}
|
||||
|
||||
if (movementDirection == PacketBuilder.MOVE_UP)
|
||||
{
|
||||
loggedInUser.Facing = PacketBuilder.DIRECTION_UP;
|
||||
if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y - 1))
|
||||
|
@ -222,7 +273,7 @@ namespace Horse_Isle_Server
|
|||
sender.SendPacket(moveLeftResponse);
|
||||
}
|
||||
}
|
||||
else if (movementDirection == PacketBuilder.MOVE_DOWN || movementDirection == PacketBuilder.MOVE_ESCAPE)
|
||||
else if (movementDirection == PacketBuilder.MOVE_DOWN)
|
||||
{
|
||||
loggedInUser.Facing = PacketBuilder.DIRECTION_DOWN;
|
||||
if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y + 1))
|
||||
|
@ -238,6 +289,11 @@ namespace Horse_Isle_Server
|
|||
}
|
||||
|
||||
}
|
||||
else if(movementDirection == PacketBuilder.MOVE_UPDATE)
|
||||
{
|
||||
Update(sender, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Update(sender);
|
||||
|
@ -401,7 +457,7 @@ namespace Horse_Isle_Server
|
|||
connectedClients.Remove(sender);
|
||||
}
|
||||
|
||||
public static void UpdateArea(Client forClient)
|
||||
public static void UpdateArea(Client forClient, bool justArea=false)
|
||||
{
|
||||
if (!forClient.LoggedIn)
|
||||
{
|
||||
|
@ -417,12 +473,12 @@ namespace Horse_Isle_Server
|
|||
else
|
||||
{
|
||||
World.SpecialTile specialTile = World.GetSpecialTile(forClient.LoggedinUser.X, forClient.LoggedinUser.Y);
|
||||
if(specialTile.AutoplaySwf != null && specialTile.AutoplaySwf != "")
|
||||
if(specialTile.AutoplaySwf != null && specialTile.AutoplaySwf != "" && !justArea)
|
||||
{
|
||||
byte[] swfModulePacket = PacketBuilder.CreateSwfModulePacket(specialTile.AutoplaySwf);
|
||||
forClient.SendPacket(swfModulePacket);
|
||||
}
|
||||
if(specialTile.Code != null)
|
||||
if(specialTile.Code != null && !justArea)
|
||||
if (!ProcessMapCode(forClient, specialTile.Code))
|
||||
return;
|
||||
LocationStr = Meta.BuildSpecialTileInfo(specialTile);
|
||||
|
@ -572,13 +628,14 @@ namespace Horse_Isle_Server
|
|||
Update(client);
|
||||
|
||||
}
|
||||
public static void Update(Client client)
|
||||
public static void Update(Client client, bool justArea = false)
|
||||
{
|
||||
UpdateUserInfo(client.LoggedinUser);
|
||||
UpdateArea(client);
|
||||
UpdateArea(client, justArea);
|
||||
foreach (User nearbyUser in Server.GetNearbyUsers(client.LoggedinUser.X, client.LoggedinUser.Y, false, false))
|
||||
if (nearbyUser.Id != client.LoggedinUser.Id)
|
||||
UpdateArea(nearbyUser.LoggedinClient);
|
||||
UpdateArea(nearbyUser.LoggedinClient, justArea);
|
||||
|
||||
UpdateUserInfo(client.LoggedinUser);
|
||||
}
|
||||
|
||||
public static bool ProcessMapCode(Client forClient, string mapCode)
|
||||
|
|
Loading…
Add table
Reference in a new issue