mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 21:55:42 +12:00
Implement click packet
This commit is contained in:
parent
b8934c1faa
commit
862375cc75
10 changed files with 140 additions and 71 deletions
|
@ -8,6 +8,7 @@
|
||||||
"profile_save":"Your profile changes were saved.",
|
"profile_save":"Your profile changes were saved.",
|
||||||
"buddy_request":"Attempting to Add Buddy. The other player must click ADD BUDDY as well. (Many players reserve this for just a couple players so don't feel insulted if they do not).",
|
"buddy_request":"Attempting to Add Buddy. The other player must click ADD BUDDY as well. (Many players reserve this for just a couple players so don't feel insulted if they do not).",
|
||||||
"drawing_notice":"Drawing not sent to other players when you are not a subscriber.",
|
"drawing_notice":"Drawing not sent to other players when you are not a subscriber.",
|
||||||
|
"click_nothing_message":"Nothing interesting here...",
|
||||||
"sec_code":{
|
"sec_code":{
|
||||||
"invalid_sec_code":"Data Code Error. You did not get the bonus. You should reconnect if you get this message again.",
|
"invalid_sec_code":"Data Code Error. You did not get the bonus. You should reconnect if you get this message again.",
|
||||||
"item_earned":"You Earned a %ITEM%!"
|
"item_earned":"You Earned a %ITEM%!"
|
||||||
|
|
|
@ -152,6 +152,9 @@ namespace HISP.Game
|
||||||
public static string WagonCutscene;
|
public static string WagonCutscene;
|
||||||
public static string BallonCutscene;
|
public static string BallonCutscene;
|
||||||
|
|
||||||
|
// Click
|
||||||
|
public static string NothingInterestingHere;
|
||||||
|
|
||||||
public static string FormatYouEarnedAnItemMessage(string itemName)
|
public static string FormatYouEarnedAnItemMessage(string itemName)
|
||||||
{
|
{
|
||||||
return YouEarnedAnItemFormat.Replace("%ITEM%", itemName);
|
return YouEarnedAnItemFormat.Replace("%ITEM%", itemName);
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace HISP.Game
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quest.WarpX != 0 && quest.WarpY != 0)
|
if (quest.WarpX != 0 && quest.WarpY != 0)
|
||||||
GameServer.Teleport(user.LoggedinClient, quest.WarpX, quest.WarpY);
|
user.Teleport(quest.WarpX, quest.WarpY);
|
||||||
|
|
||||||
// Give quest points
|
// Give quest points
|
||||||
user.QuestPoints += quest.QuestPointsEarned;
|
user.QuestPoints += quest.QuestPointsEarned;
|
||||||
|
|
|
@ -152,6 +152,17 @@ namespace HISP.Player
|
||||||
public int SecCodeInc = 0;
|
public int SecCodeInc = 0;
|
||||||
public int SecCodeCount = 0;
|
public int SecCodeCount = 0;
|
||||||
|
|
||||||
|
public void Teleport(int newX, int newY)
|
||||||
|
{
|
||||||
|
Logger.DebugPrint("Teleporting: " + Username + " to: " + newX.ToString() + "," + newY.ToString());
|
||||||
|
|
||||||
|
X = newX;
|
||||||
|
Y = newY;
|
||||||
|
|
||||||
|
byte[] MovementPacket = PacketBuilder.CreateMovementPacket(X, Y, CharacterId, Facing, PacketBuilder.DIRECTION_TELEPORT, true);
|
||||||
|
LoggedinClient.SendPacket(MovementPacket);
|
||||||
|
GameServer.Update(LoggedinClient);
|
||||||
|
}
|
||||||
public byte[] GenerateSecCode()
|
public byte[] GenerateSecCode()
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
|
@ -17,8 +17,8 @@ namespace HISP
|
||||||
ConfigReader.OpenConfig();
|
ConfigReader.OpenConfig();
|
||||||
CrossDomainPolicy.GetPolicy();
|
CrossDomainPolicy.GetPolicy();
|
||||||
Database.OpenDatabase();
|
Database.OpenDatabase();
|
||||||
Map.OpenMap();
|
|
||||||
GameDataJson.ReadGamedata();
|
GameDataJson.ReadGamedata();
|
||||||
|
Map.OpenMap();
|
||||||
World.ReadWorldData();
|
World.ReadWorldData();
|
||||||
DroppedItems.Init();
|
DroppedItems.Init();
|
||||||
GameServer.StartServer();
|
GameServer.StartServer();
|
||||||
|
|
|
@ -31,8 +31,9 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
if (!File.Exists(ConfigurationFileName))
|
if (!File.Exists(ConfigurationFileName))
|
||||||
{
|
{
|
||||||
Logger.ErrorPrint(ConfigurationFileName+" not found! writing default.");
|
Logger.WarnPrint(ConfigurationFileName+" not found! writing default.");
|
||||||
File.WriteAllText(ConfigurationFileName,Resources.DefaultServerProperties);
|
File.WriteAllText(ConfigurationFileName,Resources.DefaultServerProperties);
|
||||||
|
Logger.InfoPrint("! Its very likely database connection will fail...");
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] configFile = File.ReadAllLines(ConfigurationFileName);
|
string[] configFile = File.ReadAllLines(ConfigurationFileName);
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace HISP.Server
|
||||||
if(!File.Exists(ConfigReader.GameDataFile))
|
if(!File.Exists(ConfigReader.GameDataFile))
|
||||||
{
|
{
|
||||||
Logger.ErrorPrint("Game Data JSON File: " + ConfigReader.GameDataFile + " Does not exist!");
|
Logger.ErrorPrint("Game Data JSON File: " + ConfigReader.GameDataFile + " Does not exist!");
|
||||||
return;
|
throw new FileNotFoundException(ConfigReader.GameDataFile + " Not found :(");
|
||||||
}
|
}
|
||||||
string jsonData = File.ReadAllText(ConfigReader.GameDataFile);
|
string jsonData = File.ReadAllText(ConfigReader.GameDataFile);
|
||||||
dynamic gameData = JsonConvert.DeserializeObject(jsonData);
|
dynamic gameData = JsonConvert.DeserializeObject(jsonData);
|
||||||
|
@ -554,7 +554,9 @@ namespace HISP.Server
|
||||||
// Inventory
|
// Inventory
|
||||||
|
|
||||||
Messages.DefaultInventoryMax = gameData.item.max_carryable;
|
Messages.DefaultInventoryMax = gameData.item.max_carryable;
|
||||||
|
|
||||||
|
// Click
|
||||||
|
Messages.NothingInterestingHere = gameData.messages.click_nothing_message;
|
||||||
|
|
||||||
// Swf
|
// Swf
|
||||||
Messages.WagonCutscene = gameData.transport.wagon_cutscene;
|
Messages.WagonCutscene = gameData.transport.wagon_cutscene;
|
||||||
|
|
|
@ -33,6 +33,12 @@ namespace HISP.Server
|
||||||
private static int gameTickSpeed = 4320; // Changing this to ANYTHING else will cause desync with the client.
|
private static int gameTickSpeed = 4320; // Changing this to ANYTHING else will cause desync with the client.
|
||||||
|
|
||||||
private static List<GameClient> connectedClients = new List<GameClient>();
|
private static List<GameClient> connectedClients = new List<GameClient>();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This section is where all the event handlers live,
|
||||||
|
* eg: OnMovementPacket is whenever the server receies a movement request from the client.
|
||||||
|
*/
|
||||||
|
|
||||||
public static void OnCrossdomainPolicyRequest(GameClient sender) // When a cross-domain-policy request is received.
|
public static void OnCrossdomainPolicyRequest(GameClient sender) // When a cross-domain-policy request is received.
|
||||||
{
|
{
|
||||||
Logger.DebugPrint("Cross-Domain-Policy request received from: " + sender.RemoteIp);
|
Logger.DebugPrint("Cross-Domain-Policy request received from: " + sender.RemoteIp);
|
||||||
|
@ -41,7 +47,6 @@ namespace HISP.Server
|
||||||
|
|
||||||
sender.SendPacket(crossDomainPolicyResponse); // Send to client.
|
sender.SendPacket(crossDomainPolicyResponse); // Send to client.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnUserInfoRequest(GameClient sender, byte[] packet)
|
public static void OnUserInfoRequest(GameClient sender, byte[] packet)
|
||||||
{
|
{
|
||||||
if (!sender.LoggedIn)
|
if (!sender.LoggedIn)
|
||||||
|
@ -97,7 +102,6 @@ namespace HISP.Server
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnKeepAlive(GameClient sender, byte[] packet)
|
public static void OnKeepAlive(GameClient sender, byte[] packet)
|
||||||
{
|
{
|
||||||
if (!sender.LoggedIn)
|
if (!sender.LoggedIn)
|
||||||
|
@ -254,7 +258,6 @@ namespace HISP.Server
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnMovementPacket(GameClient sender, byte[] packet)
|
public static void OnMovementPacket(GameClient sender, byte[] packet)
|
||||||
{
|
{
|
||||||
if (!sender.LoggedIn)
|
if (!sender.LoggedIn)
|
||||||
|
@ -380,7 +383,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
else if(movementDirection == PacketBuilder.MOVE_UPDATE)
|
else if(movementDirection == PacketBuilder.MOVE_UPDATE)
|
||||||
{
|
{
|
||||||
Update(sender, true);
|
Update(sender);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +455,7 @@ namespace HISP.Server
|
||||||
|
|
||||||
if (reply.GotoChatpoint == -1)
|
if (reply.GotoChatpoint == -1)
|
||||||
{
|
{
|
||||||
UpdateArea(sender,true);
|
UpdateArea(sender);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.LoggedinUser.MetaPriority = true;
|
sender.LoggedinUser.MetaPriority = true;
|
||||||
|
@ -515,7 +518,7 @@ namespace HISP.Server
|
||||||
sender.SendPacket(swfModulePacket);
|
sender.SendPacket(swfModulePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
Teleport(sender, transportLocation.GotoX, transportLocation.GotoY);
|
sender.LoggedinUser.Teleport(transportLocation.GotoX, transportLocation.GotoY);
|
||||||
|
|
||||||
byte[] welcomeToIslePacket = PacketBuilder.CreateChat(Messages.FormatWelcomeToAreaMessage(transportLocation.LocationTitle), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] welcomeToIslePacket = PacketBuilder.CreateChat(Messages.FormatWelcomeToAreaMessage(transportLocation.LocationTitle), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(welcomeToIslePacket);
|
sender.SendPacket(welcomeToIslePacket);
|
||||||
|
@ -610,7 +613,52 @@ namespace HISP.Server
|
||||||
// Send to sender
|
// Send to sender
|
||||||
sender.SendPacket(chatPacketSender);
|
sender.SendPacket(chatPacketSender);
|
||||||
}
|
}
|
||||||
|
public static void OnClickPacket(GameClient sender, byte[] packet)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!sender.LoggedIn)
|
||||||
|
{
|
||||||
|
Logger.ErrorPrint(sender.RemoteIp + " Send click packet when not logged in.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet.Length < 4)
|
||||||
|
{
|
||||||
|
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid Click Packet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string packetStr = Encoding.UTF8.GetString(packet);
|
||||||
|
if(packetStr.Contains("|"))
|
||||||
|
{
|
||||||
|
string packetContents = packetStr.Substring(0, packetStr.Length - 3);
|
||||||
|
string[] xy = packetContents.Split('|');
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
x = int.Parse(xy[0]);
|
||||||
|
y = int.Parse(xy[1]);
|
||||||
|
}
|
||||||
|
catch(FormatException)
|
||||||
|
{
|
||||||
|
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent a click packet with non-string xy value.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get description of tile
|
||||||
|
string returnedMsg = Messages.NothingInterestingHere;
|
||||||
|
if(World.InSpecialTile(x, y))
|
||||||
|
{
|
||||||
|
World.SpecialTile tile = World.GetSpecialTile(x, y);
|
||||||
|
if (tile.Title != null)
|
||||||
|
returnedMsg = tile.Title;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] tileInfoPacket = PacketBuilder.CreateClickTileInfoPacket(returnedMsg);
|
||||||
|
sender.SendPacket(tileInfoPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void OnItemInteraction(GameClient sender, byte[] packet)
|
public static void OnItemInteraction(GameClient sender, byte[] packet)
|
||||||
{
|
{
|
||||||
if (!sender.LoggedIn)
|
if (!sender.LoggedIn)
|
||||||
|
@ -1031,7 +1079,6 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnInventoryRequested(GameClient sender, byte[] packet)
|
public static void OnInventoryRequested(GameClient sender, byte[] packet)
|
||||||
{
|
{
|
||||||
if (!sender.LoggedIn)
|
if (!sender.LoggedIn)
|
||||||
|
@ -1107,9 +1154,6 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void OnDisconnect(GameClient sender)
|
public static void OnDisconnect(GameClient sender)
|
||||||
{
|
{
|
||||||
connectedClients.Remove(sender);
|
connectedClients.Remove(sender);
|
||||||
|
@ -1133,6 +1177,9 @@ namespace HISP.Server
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get(Some Information)
|
||||||
|
*/
|
||||||
|
|
||||||
public static User[] GetUsersUsersInIsle(World.Isle isle, bool includeStealth = false, bool includeMuted = false)
|
public static User[] GetUsersUsersInIsle(World.Isle isle, bool includeStealth = false, bool includeMuted = false)
|
||||||
{
|
{
|
||||||
|
@ -1151,7 +1198,6 @@ namespace HISP.Server
|
||||||
|
|
||||||
return usersInIsle.ToArray();
|
return usersInIsle.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static User[] GetUsersAt(int x, int y, bool includeStealth = false, bool includeMuted = false)
|
public static User[] GetUsersAt(int x, int y, bool includeStealth = false, bool includeMuted = false)
|
||||||
{
|
{
|
||||||
List<User> usersHere = new List<User>();
|
List<User> usersHere = new List<User>();
|
||||||
|
@ -1169,7 +1215,6 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
return usersHere.ToArray();
|
return usersHere.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static User[] GetNearbyUsers(int x, int y, bool includeStealth=false, bool includeMuted=false)
|
public static User[] GetNearbyUsers(int x, int y, bool includeStealth=false, bool includeMuted=false)
|
||||||
{
|
{
|
||||||
int startX = x - 15;
|
int startX = x - 15;
|
||||||
|
@ -1191,7 +1236,6 @@ namespace HISP.Server
|
||||||
|
|
||||||
return usersNearby.ToArray();
|
return usersNearby.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetNumberOfPlayers(bool includeStealth=false)
|
public static int GetNumberOfPlayers(bool includeStealth=false)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -1206,7 +1250,6 @@ namespace HISP.Server
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetNumberOfModsOnline()
|
public static int GetNumberOfModsOnline()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -1218,33 +1261,33 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
public static int GetNumberOfAdminsOnline()
|
||||||
public static void Teleport(GameClient client, int newX, int newY)
|
|
||||||
{
|
{
|
||||||
if (!client.LoggedIn)
|
int count = 0;
|
||||||
return;
|
foreach (GameClient client in ConnectedClients)
|
||||||
Logger.DebugPrint("Teleporting: " + client.LoggedinUser.Username + " to: " + newX.ToString() + "," + newY.ToString());
|
{
|
||||||
|
if (client.LoggedIn)
|
||||||
client.LoggedinUser.X = newX;
|
if (client.LoggedinUser.Administrator)
|
||||||
client.LoggedinUser.Y = newY;
|
count++;
|
||||||
|
}
|
||||||
byte[] MovementPacket = PacketBuilder.CreateMovementPacket(client.LoggedinUser.X, client.LoggedinUser.Y, client.LoggedinUser.CharacterId, client.LoggedinUser.Facing, PacketBuilder.DIRECTION_TELEPORT, true);
|
return count;
|
||||||
client.SendPacket(MovementPacket);
|
|
||||||
Update(client);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void Update(GameClient client, bool justArea = false)
|
|
||||||
|
/*
|
||||||
|
* Update game state functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static void Update(GameClient client)
|
||||||
{
|
{
|
||||||
UpdateArea(client, justArea);
|
UpdateArea(client);
|
||||||
foreach (User nearbyUser in GameServer.GetNearbyUsers(client.LoggedinUser.X, client.LoggedinUser.Y, false, false))
|
foreach (User nearbyUser in GameServer.GetNearbyUsers(client.LoggedinUser.X, client.LoggedinUser.Y, false, false))
|
||||||
if (nearbyUser.Id != client.LoggedinUser.Id)
|
if (nearbyUser.Id != client.LoggedinUser.Id)
|
||||||
if(!nearbyUser.MetaPriority)
|
if(!nearbyUser.MetaPriority)
|
||||||
UpdateArea(nearbyUser.LoggedinClient, justArea);
|
UpdateArea(nearbyUser.LoggedinClient);
|
||||||
|
|
||||||
|
|
||||||
UpdateUserInfo(client.LoggedinUser);
|
UpdateUserInfo(client.LoggedinUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateInventory(GameClient forClient)
|
public static void UpdateInventory(GameClient forClient)
|
||||||
{
|
{
|
||||||
if (!forClient.LoggedIn)
|
if (!forClient.LoggedIn)
|
||||||
|
@ -1264,7 +1307,6 @@ namespace HISP.Server
|
||||||
byte[] WorldData = PacketBuilder.CreateWorldData(World.ServerTime.Minutes, World.ServerTime.Days, World.ServerTime.Years, World.GetWeather());
|
byte[] WorldData = PacketBuilder.CreateWorldData(World.ServerTime.Minutes, World.ServerTime.Days, World.ServerTime.Years, World.GetWeather());
|
||||||
forClient.SendPacket(WorldData);
|
forClient.SendPacket(WorldData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdatePlayer(GameClient forClient)
|
public static void UpdatePlayer(GameClient forClient)
|
||||||
{
|
{
|
||||||
if (!forClient.LoggedIn)
|
if (!forClient.LoggedIn)
|
||||||
|
@ -1275,7 +1317,6 @@ namespace HISP.Server
|
||||||
byte[] PlayerData = PacketBuilder.CreatePlayerData(forClient.LoggedinUser.Money, GameServer.GetNumberOfPlayers(), forClient.LoggedinUser.MailBox.MailCount);
|
byte[] PlayerData = PacketBuilder.CreatePlayerData(forClient.LoggedinUser.Money, GameServer.GetNumberOfPlayers(), forClient.LoggedinUser.MailBox.MailCount);
|
||||||
forClient.SendPacket(PlayerData);
|
forClient.SendPacket(PlayerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateUserInfo(User user)
|
public static void UpdateUserInfo(User user)
|
||||||
{
|
{
|
||||||
byte[] playerInfoBytes = PacketBuilder.CreatePlayerInfoUpdateOrCreate(user.X, user.Y, user.Facing, user.CharacterId, user.Username);
|
byte[] playerInfoBytes = PacketBuilder.CreatePlayerInfoUpdateOrCreate(user.X, user.Y, user.Facing, user.CharacterId, user.Username);
|
||||||
|
@ -1292,17 +1333,16 @@ namespace HISP.Server
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateAreaForAll(int x, int y)
|
public static void UpdateAreaForAll(int x, int y)
|
||||||
{
|
{
|
||||||
foreach(GameClient client in ConnectedClients)
|
foreach(GameClient client in ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (client.LoggedinUser.X == x && client.LoggedinUser.Y == y)
|
if (client.LoggedinUser.X == x && client.LoggedinUser.Y == y)
|
||||||
UpdateArea(client, true);
|
UpdateArea(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void UpdateArea(GameClient forClient, bool justArea = false)
|
public static void UpdateArea(GameClient forClient)
|
||||||
{
|
{
|
||||||
if (!forClient.LoggedIn)
|
if (!forClient.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -1318,12 +1358,12 @@ namespace HISP.Server
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
World.SpecialTile specialTile = World.GetSpecialTile(forClient.LoggedinUser.X, forClient.LoggedinUser.Y);
|
World.SpecialTile specialTile = World.GetSpecialTile(forClient.LoggedinUser.X, forClient.LoggedinUser.Y);
|
||||||
if (specialTile.AutoplaySwf != null && specialTile.AutoplaySwf != "" && !justArea)
|
if (specialTile.AutoplaySwf != null && specialTile.AutoplaySwf != "")
|
||||||
{
|
{
|
||||||
byte[] swfModulePacket = PacketBuilder.CreateSwfModulePacket(specialTile.AutoplaySwf,PacketBuilder.PACKET_SWF_MODULE_GENTLE);
|
byte[] swfModulePacket = PacketBuilder.CreateSwfModulePacket(specialTile.AutoplaySwf,PacketBuilder.PACKET_SWF_MODULE_GENTLE);
|
||||||
forClient.SendPacket(swfModulePacket);
|
forClient.SendPacket(swfModulePacket);
|
||||||
}
|
}
|
||||||
if (specialTile.Code != null && !justArea)
|
if (specialTile.Code != null)
|
||||||
if (!ProcessMapCodeWithArg(forClient, specialTile.Code))
|
if (!ProcessMapCodeWithArg(forClient, specialTile.Code))
|
||||||
return;
|
return;
|
||||||
LocationStr = Meta.BuildSpecialTileInfo(forClient.LoggedinUser, specialTile);
|
LocationStr = Meta.BuildSpecialTileInfo(forClient.LoggedinUser, specialTile);
|
||||||
|
@ -1334,6 +1374,9 @@ namespace HISP.Server
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Other...
|
||||||
|
*/
|
||||||
public static bool ProcessMapCodeWithArg(GameClient forClient, string mapCode)
|
public static bool ProcessMapCodeWithArg(GameClient forClient, string mapCode)
|
||||||
{
|
{
|
||||||
if(mapCode.Contains('-'))
|
if(mapCode.Contains('-'))
|
||||||
|
@ -1351,7 +1394,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
int newX = int.Parse(args[0]);
|
int newX = int.Parse(args[0]);
|
||||||
int newY = int.Parse(args[1]);
|
int newY = int.Parse(args[1]);
|
||||||
Teleport(forClient, newX, newY);
|
forClient.LoggedinUser.Teleport(newX, newY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch(Exception)
|
catch(Exception)
|
||||||
|
@ -1363,31 +1406,6 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int GetNumberOfAdminsOnline()
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
foreach (GameClient client in ConnectedClients)
|
|
||||||
{
|
|
||||||
if (client.LoggedIn)
|
|
||||||
if (client.LoggedinUser.Administrator)
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void onTick(object state)
|
|
||||||
{
|
|
||||||
World.TickWorldClock();
|
|
||||||
|
|
||||||
if(World.ServerTime.Minutes % 20 == 0)
|
|
||||||
{
|
|
||||||
DroppedItems.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void StartServer()
|
public static void StartServer()
|
||||||
{
|
{
|
||||||
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
@ -1408,5 +1426,21 @@ namespace HISP.Server
|
||||||
connectedClients.Add(client);
|
connectedClients.Add(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Private methods..
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static void onTick(object state)
|
||||||
|
{
|
||||||
|
World.TickWorldClock();
|
||||||
|
|
||||||
|
if(World.ServerTime.Minutes % 20 == 0)
|
||||||
|
{
|
||||||
|
DroppedItems.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,10 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
public static void HackerPrint(string text) // When someone is obviously cheating.
|
public static void HackerPrint(string text) // When someone is obviously cheating.
|
||||||
{
|
{
|
||||||
|
ConsoleColor prevColor = Console.ForegroundColor;
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.WriteLine("[HACK] " + text);
|
Console.WriteLine("[HACK] " + text);
|
||||||
|
Console.ForegroundColor = prevColor;
|
||||||
}
|
}
|
||||||
public static void DebugPrint(string text)
|
public static void DebugPrint(string text)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace HISP.Server
|
||||||
public const byte PACKET_LOGIN = 0x7F;
|
public const byte PACKET_LOGIN = 0x7F;
|
||||||
public const byte PACKET_CHAT = 0x14;
|
public const byte PACKET_CHAT = 0x14;
|
||||||
public const byte PACKET_MOVE = 0x15;
|
public const byte PACKET_MOVE = 0x15;
|
||||||
|
public const byte PACKET_CLICK = 0x77;
|
||||||
public const byte PACKET_USERINFO = 0x81;
|
public const byte PACKET_USERINFO = 0x81;
|
||||||
public const byte PACKET_WORLD = 0x7A;
|
public const byte PACKET_WORLD = 0x7A;
|
||||||
public const byte PACKET_BASE_STATS = 0x7B;
|
public const byte PACKET_BASE_STATS = 0x7B;
|
||||||
|
@ -354,6 +355,21 @@ namespace HISP.Server
|
||||||
return Packet;
|
return Packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] CreateClickTileInfoPacket(string text)
|
||||||
|
{
|
||||||
|
byte[] strBytes = Encoding.UTF8.GetBytes(text);
|
||||||
|
MemoryStream ms = new MemoryStream();
|
||||||
|
ms.WriteByte(PACKET_CLICK);
|
||||||
|
ms.Write(strBytes, 0x00, strBytes.Length);
|
||||||
|
ms.WriteByte(PACKET_TERMINATOR);
|
||||||
|
|
||||||
|
ms.Seek(0x00, SeekOrigin.Begin);
|
||||||
|
byte[] Packet = ms.ToArray();
|
||||||
|
ms.Dispose();
|
||||||
|
|
||||||
|
return Packet;
|
||||||
|
}
|
||||||
|
|
||||||
public static byte[] CreateMetaPacket(string formattedText)
|
public static byte[] CreateMetaPacket(string formattedText)
|
||||||
{
|
{
|
||||||
byte[] strBytes = Encoding.UTF8.GetBytes(formattedText);
|
byte[] strBytes = Encoding.UTF8.GetBytes(formattedText);
|
||||||
|
@ -361,9 +377,7 @@ namespace HISP.Server
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
|
|
||||||
ms.WriteByte(PACKET_PLACE_INFO);
|
ms.WriteByte(PACKET_PLACE_INFO);
|
||||||
|
|
||||||
ms.Write(strBytes, 0x00, strBytes.Length);
|
ms.Write(strBytes, 0x00, strBytes.Length);
|
||||||
|
|
||||||
ms.WriteByte(PACKET_TERMINATOR);
|
ms.WriteByte(PACKET_TERMINATOR);
|
||||||
|
|
||||||
ms.Seek(0x00, SeekOrigin.Begin);
|
ms.Seek(0x00, SeekOrigin.Begin);
|
||||||
|
|
Loading…
Add table
Reference in a new issue