mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-20 11:49:14 +12:00
Remove " " space from the names
This commit is contained in:
parent
bef3032886
commit
8e451633dc
59 changed files with 391 additions and 391 deletions
47
Horse Isle Server/HorseIsleServer/Game/AbuseReport.cs
Normal file
47
Horse Isle Server/HorseIsleServer/Game/AbuseReport.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System.Collections.Generic;
|
||||
namespace HISP.Game
|
||||
{
|
||||
class AbuseReport
|
||||
{
|
||||
public struct ReportReason
|
||||
{
|
||||
public string Id;
|
||||
public string Name;
|
||||
public string Meta;
|
||||
}
|
||||
private static List<ReportReason> reportReasons = new List<ReportReason>();
|
||||
|
||||
public static ReportReason[] ReportReasons
|
||||
{
|
||||
get
|
||||
{
|
||||
return reportReasons.ToArray();
|
||||
}
|
||||
}
|
||||
public static bool DoesReasonExist(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetReasonById(id);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static ReportReason GetReasonById(string id)
|
||||
{
|
||||
foreach(ReportReason reason in ReportReasons)
|
||||
{
|
||||
if (reason.Id == id)
|
||||
return reason;
|
||||
}
|
||||
throw new KeyNotFoundException("No reason of: " + id + " Found.");
|
||||
}
|
||||
public static void AddReason(ReportReason reason)
|
||||
{
|
||||
reportReasons.Add(reason);
|
||||
}
|
||||
}
|
||||
}
|
477
Horse Isle Server/HorseIsleServer/Game/Chat/Chat.cs
Normal file
477
Horse Isle Server/HorseIsleServer/Game/Chat/Chat.cs
Normal file
|
@ -0,0 +1,477 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Game.Chat
|
||||
{
|
||||
class Chat
|
||||
{
|
||||
public struct Correction
|
||||
{
|
||||
public string FilteredWord;
|
||||
public string ReplacedWord;
|
||||
}
|
||||
|
||||
public struct Reason
|
||||
{
|
||||
public string Name;
|
||||
public string Message;
|
||||
}
|
||||
public struct Filter
|
||||
{
|
||||
public string FilteredWord;
|
||||
public Reason Reason;
|
||||
public bool MatchAll;
|
||||
}
|
||||
|
||||
|
||||
public enum ChatChannel
|
||||
{
|
||||
All = 0x14,
|
||||
Ads = 0x1D,
|
||||
Near = 0x15,
|
||||
Buddies = 0x17,
|
||||
Here = 0x18,
|
||||
Isle = 0x1A,
|
||||
Dm = 0x16,
|
||||
Mod = 0x1c,
|
||||
Admin = 0x1b
|
||||
}
|
||||
public static string PrivateMessageSound;
|
||||
|
||||
public static List<Filter> FilteredWords = new List<Filter>();
|
||||
public static List<Correction> CorrectedWords = new List<Correction>();
|
||||
public static List<Reason> Reasons = new List<Reason>();
|
||||
public static bool ProcessCommand(User user, string message)
|
||||
{
|
||||
if (message.Length < 1)
|
||||
return false;
|
||||
|
||||
string[] args = message.Split(' ').Skip(1).ToArray();
|
||||
|
||||
if (user.Administrator || user.Moderator)
|
||||
if (message[0] == '%')
|
||||
{
|
||||
if(message.StartsWith("%STICKBUG"))
|
||||
return Command.Stickbug(message, args, user);
|
||||
if (message.StartsWith("%GIVE"))
|
||||
return Command.Give(message, args, user);
|
||||
if (message.StartsWith("%GOTO"))
|
||||
return Command.Goto(message, args, user);
|
||||
if (message.StartsWith("%KICK"))
|
||||
return Command.Kick(message, args, user);
|
||||
if (message.StartsWith("%NOCLIP"))
|
||||
return Command.NoClip(message, args, user);
|
||||
return false;
|
||||
}
|
||||
if (message[0] == '!')
|
||||
{
|
||||
// Alias for !MUTE
|
||||
if (message.StartsWith("!MUTEALL"))
|
||||
return Command.Mute(message, new string[] { "ALL" }, user);
|
||||
else if (message.StartsWith("!MUTEADS"))
|
||||
return Command.Mute(message, new string[] { "ADS" }, user);
|
||||
else if (message.StartsWith("!MUTEGLOBAL"))
|
||||
return Command.Mute(message, new string[] { "GLOBAL" }, user);
|
||||
else if (message.StartsWith("!MUTEISLAND"))
|
||||
return Command.Mute(message, new string[] { "ISLAND" }, user);
|
||||
else if (message.StartsWith("!MUTENEAR"))
|
||||
return Command.Mute(message, new string[] { "NEAR" }, user);
|
||||
else if (message.StartsWith("!MUTEHERE"))
|
||||
return Command.Mute(message, new string[] { "HERE" }, user);
|
||||
else if (message.StartsWith("!MUTEBUDDY"))
|
||||
return Command.Mute(message, new string[] { "BUDDY" }, user);
|
||||
else if (message.StartsWith("!MUTEPM"))
|
||||
return Command.Mute(message, new string[] { "PM" }, user);
|
||||
else if (message.StartsWith("!MUTEPM"))
|
||||
return Command.Mute(message, new string[] { "PM" }, user);
|
||||
else if (message.StartsWith("!MUTEBR"))
|
||||
return Command.Mute(message, new string[] { "BR" }, user);
|
||||
else if (message.StartsWith("!MUTESOCIALS"))
|
||||
return Command.Mute(message, new string[] { "SOCIALS" }, user);
|
||||
else if (message.StartsWith("!MUTELOGINS"))
|
||||
return Command.Mute(message, new string[] { "LOGINS" }, user);
|
||||
|
||||
else if (message.StartsWith("!MUTE"))
|
||||
return Command.Mute(message, args, user);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static Object FilterMessage(string message) // Handles chat filtering and violation stuffs returns
|
||||
{
|
||||
if (!ConfigReader.BadWords) // Freedom of Speech Mode
|
||||
return null;
|
||||
|
||||
|
||||
string[] wordsSaid;
|
||||
if (message.Contains(' '))
|
||||
wordsSaid = message.Split(' ');
|
||||
else
|
||||
wordsSaid = new string[] { message };
|
||||
|
||||
|
||||
foreach(Filter filter in FilteredWords)
|
||||
{
|
||||
if (!filter.MatchAll)
|
||||
{
|
||||
foreach (string word in wordsSaid)
|
||||
{
|
||||
if (word.ToLower() == filter.FilteredWord.ToLower())
|
||||
return filter.Reason;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (message.ToLower().Contains(filter.FilteredWord))
|
||||
return filter.Reason;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte GetSide(ChatChannel channel)
|
||||
{
|
||||
switch (channel)
|
||||
{
|
||||
case ChatChannel.All:
|
||||
case ChatChannel.Ads:
|
||||
case ChatChannel.Isle:
|
||||
return PacketBuilder.CHAT_BOTTOM_LEFT;
|
||||
case ChatChannel.Buddies:
|
||||
case ChatChannel.Here:
|
||||
case ChatChannel.Admin:
|
||||
case ChatChannel.Mod:
|
||||
return PacketBuilder.CHAT_BOTTOM_RIGHT;
|
||||
case ChatChannel.Dm:
|
||||
return PacketBuilder.CHAT_DM_RIGHT;
|
||||
default:
|
||||
Logger.ErrorPrint("unknown channel: " + (byte)channel);
|
||||
return PacketBuilder.CHAT_BOTTOM_LEFT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static string GetDmRecipiant(string message)
|
||||
{
|
||||
if(message.Contains('|'))
|
||||
{
|
||||
string recipiantName = message.Split('|')[0];
|
||||
return recipiantName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetDmMessage(string message)
|
||||
{
|
||||
if (message.Contains('|'))
|
||||
{
|
||||
string messageStr = message.Split('|')[1];
|
||||
return messageStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameClient[] GetRecipiants(User user, ChatChannel channel, string to=null)
|
||||
{
|
||||
if (channel == ChatChannel.All)
|
||||
{
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
foreach (GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
if (!client.LoggedinUser.MuteGlobal && !client.LoggedinUser.MuteAll)
|
||||
if (client.LoggedinUser.Id != user.Id)
|
||||
recipiants.Add(client);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
|
||||
if(channel == ChatChannel.Ads)
|
||||
{
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
foreach (GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
if (!client.LoggedinUser.MuteAds && !client.LoggedinUser.MuteAll)
|
||||
if (client.LoggedinUser.Id != user.Id)
|
||||
recipiants.Add(client);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
|
||||
if(channel == ChatChannel.Buddies)
|
||||
{
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
foreach (GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
if (!client.LoggedinUser.MuteBuddy && !client.LoggedinUser.MuteAll)
|
||||
if (client.LoggedinUser.Id != user.Id)
|
||||
if (client.LoggedinUser.Friends.List.Contains(user.Id))
|
||||
recipiants.Add(client);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
|
||||
if (channel == ChatChannel.Isle)
|
||||
{
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
if(World.InIsle(user.X,user.Y))
|
||||
{
|
||||
User[] usersInSile = GameServer.GetUsersUsersInIsle(World.GetIsle(user.X, user.Y), true, false);
|
||||
foreach (User userInIsle in usersInSile)
|
||||
{
|
||||
if (user.Id != userInIsle.Id)
|
||||
if(!user.MuteAll)
|
||||
recipiants.Add(userInIsle.LoggedinClient);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new GameClient[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (channel == ChatChannel.Here)
|
||||
{
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
User[] usersHere = GameServer.GetUsersAt(user.X, user.Y, true, false);
|
||||
foreach (User userHere in usersHere)
|
||||
{
|
||||
if (user.Id != userHere.Id)
|
||||
if (!user.MuteAll)
|
||||
recipiants.Add(userHere.LoggedinClient);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
|
||||
if (channel == ChatChannel.Near)
|
||||
{
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
User[] nearbyUsers = GameServer.GetNearbyUsers(user.X, user.Y, true, false);
|
||||
foreach (User nearbyUser in nearbyUsers)
|
||||
{
|
||||
if (user.Id != nearbyUser.Id)
|
||||
if (!user.MuteAll)
|
||||
recipiants.Add(nearbyUser.LoggedinClient);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
|
||||
if (channel == ChatChannel.Mod)
|
||||
{
|
||||
if (!user.Moderator || !user.Administrator) // No mod chat for non-mods!
|
||||
{
|
||||
Logger.WarnPrint(user.Username + " attempted to send in MOD chat, without being a MOD.");
|
||||
return new GameClient[0];
|
||||
}
|
||||
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
foreach (GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
if (client.LoggedinUser.Moderator)
|
||||
if (client.LoggedinUser.Id != user.Id)
|
||||
recipiants.Add(client);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
|
||||
if(channel == ChatChannel.Admin)
|
||||
{
|
||||
if (!user.Administrator) // No admin chat for non-admins!
|
||||
{
|
||||
Logger.WarnPrint(user.Username + " attempted to send in ADMIN chat, without being an ADMIN.");
|
||||
return new GameClient[0];
|
||||
}
|
||||
|
||||
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
foreach (GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
if (client.LoggedinUser.Administrator)
|
||||
if (client.LoggedinUser.Id != user.Id)
|
||||
recipiants.Add(client);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
|
||||
if(channel == ChatChannel.Dm)
|
||||
{
|
||||
if (to != null)
|
||||
{
|
||||
List<GameClient> recipiants = new List<GameClient>();
|
||||
foreach (GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
if (!client.LoggedinUser.MutePrivateMessage && !client.LoggedinUser.MuteAll)
|
||||
if (client.LoggedinUser.Username == to)
|
||||
recipiants.Add(client);
|
||||
}
|
||||
return recipiants.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.ErrorPrint("Channel is " + channel + " (DM) BUT no 'to' Paramater was specfied");
|
||||
return new GameClient[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Logger.ErrorPrint(user.Username + " Sent message in unknown channel: " + (byte)channel);
|
||||
return new GameClient[0]; // No recipiants
|
||||
}
|
||||
|
||||
public static string DoCorrections(string message)
|
||||
{
|
||||
if (!ConfigReader.DoCorrections)
|
||||
return message;
|
||||
|
||||
foreach(Correction correct in CorrectedWords)
|
||||
message = message.Replace(correct.FilteredWord, correct.ReplacedWord);
|
||||
|
||||
return message;
|
||||
}
|
||||
public static string EscapeMessage(string message)
|
||||
{
|
||||
return message.Replace("<", "<");
|
||||
}
|
||||
|
||||
public static string FormatChatForOthers(User user, ChatChannel channel, string message)
|
||||
{
|
||||
|
||||
switch (channel)
|
||||
{
|
||||
case ChatChannel.All:
|
||||
if (user.Moderator || user.Administrator)
|
||||
return Messages.FormatGlobalChatMessageForMod(user.Username, message);
|
||||
else
|
||||
return Messages.FormatGlobalChatMessage(user.Username, message);
|
||||
case ChatChannel.Ads:
|
||||
return Messages.FormatAdsChatMessage(user.Username, message);
|
||||
case ChatChannel.Buddies:
|
||||
return Messages.FormatBuddyChatMessage(user.Username, message);
|
||||
case ChatChannel.Dm:
|
||||
if (user.Moderator || user.Administrator)
|
||||
return Messages.FormatDirectMessageForMod(user.Username, message);
|
||||
else
|
||||
return Messages.FormatDirectMessage(user.Username, message);
|
||||
case ChatChannel.Near:
|
||||
return Messages.FormatNearbyChatMessage(user.Username, message);
|
||||
case ChatChannel.Isle:
|
||||
return Messages.FormatIsleChatMessage(user.Username, message);
|
||||
case ChatChannel.Here:
|
||||
return Messages.FormatHereChatMessage(user.Username, message);
|
||||
case ChatChannel.Mod:
|
||||
if (user.Moderator || user.Administrator)
|
||||
return Messages.FormatModChatMessage(user.Username, message);
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(user.Username + " Tried to send in mod chat without being a moderator. (Hack/Code Attempt)");
|
||||
return user.Username + " is a hacker! (Sent in mod channel without being a mod) Maybe ban?";
|
||||
}
|
||||
case ChatChannel.Admin:
|
||||
if (user.Administrator)
|
||||
return Messages.FormatAdminChatMessage(user.Username, message);
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(user.Username + " Tried to send in mod chat without being a moderator. (Hack/Code Attempt)");
|
||||
return user.Username + " is a hacker! (Sent in admin channel without being a admin) Maybe ban?";
|
||||
}
|
||||
default:
|
||||
Logger.ErrorPrint(user.Username + " is trying to end a message in unknown channel " + channel.ToString("X"));
|
||||
return "not implemented yet :(";
|
||||
}
|
||||
}
|
||||
public static string FormatChatForSender(User user, ChatChannel channel, string message, string dmRecipiant=null)
|
||||
{
|
||||
switch (channel)
|
||||
{
|
||||
case ChatChannel.All:
|
||||
if (user.Moderator || user.Administrator)
|
||||
return Messages.FormatGlobalChatMessageForMod(user.Username, message);
|
||||
else
|
||||
return Messages.FormatGlobalChatMessage(user.Username, message);
|
||||
case ChatChannel.Ads:
|
||||
int numbListening = GameServer.GetNumberOfPlayersListeningToAdsChat(); // vry specific function ik
|
||||
return Messages.FormatAdsChatForSender(numbListening-1, user.Username, message);
|
||||
case ChatChannel.Buddies:
|
||||
return Messages.FormatBuddyChatMessageForSender(user.Friends.Count, user.Username, message);
|
||||
case ChatChannel.Isle:
|
||||
int inIsle = 0;
|
||||
if (World.InIsle(user.X, user.Y))
|
||||
inIsle = GameServer.GetUsersUsersInIsle(World.GetIsle(user.X, user.Y), false, false).Length -1;
|
||||
return Messages.FormatIsleChatMessageForSender(inIsle, user.Username, message);
|
||||
case ChatChannel.Here:
|
||||
int usersHere = GameServer.GetUsersAt(user.X, user.Y, false, false).Length -1;
|
||||
return Messages.FormatHereChatMessageForSender(usersHere, user.Username, message);
|
||||
case ChatChannel.Near:
|
||||
int nearbyUsers = GameServer.GetNearbyUsers(user.X, user.Y, false, false).Length -1;
|
||||
return Messages.FormatNearChatMessageForSender(nearbyUsers, user.Username, message);
|
||||
case ChatChannel.Mod:
|
||||
int modsOnline = GameServer.GetNumberOfModsOnline() - 1;
|
||||
return Messages.FormatModChatForSender(modsOnline, user.Username, message);
|
||||
case ChatChannel.Admin:
|
||||
int adminsOnline = GameServer.GetNumberOfAdminsOnline() - 1;
|
||||
return Messages.FormatAdminChatForSender(adminsOnline, user.Username, message);
|
||||
case ChatChannel.Dm:
|
||||
return Messages.FormatDirectChatMessageForSender(user.Username, dmRecipiant, message);
|
||||
default:
|
||||
Logger.ErrorPrint(user.Username + " is trying to end a message in unknown channel " + channel.ToString("X"));
|
||||
return "not implemented yet :(";
|
||||
}
|
||||
}
|
||||
|
||||
public static string NonViolationChecks(User user, string message)
|
||||
{
|
||||
|
||||
// Check if contains password.
|
||||
if (message.ToLower().Contains(user.Password.ToLower()))
|
||||
return Messages.PasswordNotice;
|
||||
|
||||
// Check if ALL CAPS
|
||||
string[] wordsSaid;
|
||||
if (message.Contains(' '))
|
||||
wordsSaid = message.Split(' ');
|
||||
else
|
||||
wordsSaid = new string[] { message };
|
||||
|
||||
foreach (string word in wordsSaid)
|
||||
{
|
||||
string lettersOnly = "";
|
||||
foreach(char c in word)
|
||||
{
|
||||
if((byte)c >= (byte)'A' && (byte)c <= (byte)'z') // is letter
|
||||
{
|
||||
lettersOnly += c;
|
||||
}
|
||||
}
|
||||
if (lettersOnly.ToUpper() == lettersOnly && lettersOnly.Length >= 5)
|
||||
return Messages.CapsNotice;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public static Reason GetReason(string name)
|
||||
{
|
||||
foreach (Reason reason in Reasons)
|
||||
if (reason.Name == name)
|
||||
return reason;
|
||||
|
||||
throw new KeyNotFoundException("Reason " + name + " not found.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
246
Horse Isle Server/HorseIsleServer/Game/Chat/Command.cs
Normal file
246
Horse Isle Server/HorseIsleServer/Game/Chat/Command.cs
Normal file
|
@ -0,0 +1,246 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game.Chat
|
||||
{
|
||||
class Command
|
||||
{
|
||||
|
||||
public static bool Give(string message, string[] args, User user)
|
||||
{
|
||||
if (args.Length <= 0)
|
||||
return false;
|
||||
if (!user.Administrator)
|
||||
return false;
|
||||
if(args[0] == "OBJECT")
|
||||
{
|
||||
int itemId = 0;
|
||||
try
|
||||
{
|
||||
itemId = int.Parse(args[1]);
|
||||
Item.GetItemById(itemId);
|
||||
ItemInstance newItemInstance = new ItemInstance(itemId);
|
||||
user.Inventory.AddIgnoringFull(newItemInstance);
|
||||
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args[0] == "MONEY")
|
||||
{
|
||||
int money = 0;
|
||||
try
|
||||
{
|
||||
money = int.Parse(args[1]);
|
||||
user.Money += money;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args[0] == "QUEST")
|
||||
{
|
||||
int questId = 0;
|
||||
try
|
||||
{
|
||||
questId = int.Parse(args[1]);
|
||||
Quest.ActivateQuest(user, Quest.GetQuestById(questId));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
return true;
|
||||
}
|
||||
public static bool Stickbug(string message, string[] args, User user)
|
||||
{
|
||||
if (args.Length <= 0)
|
||||
return false;
|
||||
if (!user.Administrator)
|
||||
return false;
|
||||
|
||||
if(args[0] == "ALL")
|
||||
{
|
||||
foreach(GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if(client.LoggedIn)
|
||||
{
|
||||
byte[] swfModulePacket = PacketBuilder.CreateSwfModulePacket("fun/stickbug.swf", PacketBuilder.PACKET_SWF_MODULE_GENTLE);
|
||||
client.SendPacket(swfModulePacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
User victimUser = GameServer.GetUserByName(args[0]);
|
||||
byte[] swfModulePacket = PacketBuilder.CreateSwfModulePacket("fun/stickbug.swf", PacketBuilder.PACKET_SWF_MODULE_GENTLE);
|
||||
victimUser.LoggedinClient.SendPacket(swfModulePacket);
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool NoClip(string message, string[] args, User user)
|
||||
{
|
||||
if (!user.Administrator)
|
||||
return false;
|
||||
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Kick(string message, string[] args, User user)
|
||||
{
|
||||
if (!user.Administrator || !user.Moderator)
|
||||
return false;
|
||||
if (args.Length <= 0)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
User toKick = GameServer.GetUserByName(args[0]);
|
||||
|
||||
if (args.Length >= 2)
|
||||
{
|
||||
string reason = string.Join(" ", args, 1, args.Length - 1);
|
||||
toKick.LoggedinClient.Kick(reason);
|
||||
}
|
||||
else
|
||||
toKick.LoggedinClient.Kick(Messages.KickReasonKicked);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Goto(string message, string[] args, User user)
|
||||
{
|
||||
if (args.Length <= 0)
|
||||
return false;
|
||||
if (!user.Administrator)
|
||||
return false;
|
||||
if(args[0] == "PLAYER")
|
||||
{
|
||||
if(args.Length <= 2)
|
||||
return false;
|
||||
try
|
||||
{
|
||||
User teleportTo = GameServer.GetUserByName(args[1]);
|
||||
user.Teleport(teleportTo.X, teleportTo.Y);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(args[0].Contains(","))
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] xy = args[0].Split(',');
|
||||
int x = int.Parse(xy[0]);
|
||||
int y = int.Parse(xy[1]);
|
||||
user.Teleport(x, y);
|
||||
}
|
||||
catch(FormatException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
public static bool Mute(string message, string[] args, User user)
|
||||
{
|
||||
string formattedmessage = Messages.FormatPlayerCommandCompleteMessage(message.Substring(1));
|
||||
|
||||
if (args.Length <= 0)
|
||||
{
|
||||
formattedmessage += Messages.MuteHelp;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
string muteType = args[0];
|
||||
|
||||
if (muteType == "GLOBAL")
|
||||
{
|
||||
user.MuteGlobal = true;
|
||||
} else if (muteType == "ISLAND")
|
||||
{
|
||||
user.MuteIsland = true;
|
||||
} else if (muteType == "NEAR")
|
||||
{
|
||||
user.MuteNear = true;
|
||||
} else if (muteType == "HERE")
|
||||
{
|
||||
user.MuteHere = true;
|
||||
} else if (muteType == "BUDDY")
|
||||
{
|
||||
user.MuteBuddy = true;
|
||||
} else if (muteType == "SOCIALS")
|
||||
{
|
||||
user.MuteSocials = true;
|
||||
}
|
||||
else if (muteType == "PM")
|
||||
{
|
||||
user.MutePrivateMessage = true;
|
||||
}
|
||||
else if (muteType == "BR")
|
||||
{
|
||||
user.MuteBuddyRequests = true;
|
||||
}
|
||||
else if (muteType == "LOGINS")
|
||||
{
|
||||
user.MuteLogins = true;
|
||||
}
|
||||
else if (muteType == "ALL")
|
||||
{
|
||||
user.MuteAll = true;
|
||||
} else
|
||||
{
|
||||
formattedmessage += Messages.MuteHelp;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
leave:;
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(formattedmessage, PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
347
Horse Isle Server/HorseIsleServer/Game/DroppedItems.cs
Normal file
347
Horse Isle Server/HorseIsleServer/Game/DroppedItems.cs
Normal file
|
@ -0,0 +1,347 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
class DroppedItems
|
||||
{
|
||||
public struct DroppedItem
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
public int DespawnTimer;
|
||||
public ItemInstance instance;
|
||||
}
|
||||
private static int epoch = 0;
|
||||
private static List<DroppedItem> droppedItemsList = new List<DroppedItem>();
|
||||
public static int GetCountOfItem(Item.ItemInformation item)
|
||||
{
|
||||
|
||||
DroppedItem[] dropedItems = droppedItemsList.ToArray();
|
||||
int count = 0;
|
||||
foreach(DroppedItem droppedItem in dropedItems)
|
||||
{
|
||||
if (droppedItem.instance == null)
|
||||
{
|
||||
RemoveDroppedItem(droppedItem);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(droppedItem.instance.ItemId == item.Id)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static DroppedItem[] GetItemsAt(int x, int y)
|
||||
{
|
||||
|
||||
DroppedItem[] dropedItems = droppedItemsList.ToArray();
|
||||
List<DroppedItem> items = new List<DroppedItem>();
|
||||
foreach(DroppedItem droppedItem in dropedItems)
|
||||
{
|
||||
if(droppedItem.X == x && droppedItem.Y == y)
|
||||
{
|
||||
items.Add(droppedItem);
|
||||
}
|
||||
}
|
||||
return items.ToArray();
|
||||
}
|
||||
public static void ReadFromDatabase()
|
||||
{
|
||||
DroppedItem[] items = Database.GetDroppedItems();
|
||||
foreach (DroppedItem droppedItem in items)
|
||||
droppedItemsList.Add(droppedItem);
|
||||
}
|
||||
public static void Update()
|
||||
{
|
||||
int epoch_new = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
|
||||
DespawnItems(epoch, epoch_new);
|
||||
|
||||
GenerateItems();
|
||||
}
|
||||
public static void RemoveDroppedItem(DroppedItem item)
|
||||
{
|
||||
int randomId = item.instance.RandomId;
|
||||
Database.RemoveDroppedItem(randomId);
|
||||
droppedItemsList.Remove(item);
|
||||
|
||||
}
|
||||
|
||||
public static bool IsDroppedItemExist(int randomId)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetDroppedItemById(randomId);
|
||||
return true;
|
||||
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static DroppedItem GetDroppedItemById(int randomId)
|
||||
{
|
||||
|
||||
DroppedItem[] dropedItems = droppedItemsList.ToArray();
|
||||
|
||||
foreach (DroppedItem item in dropedItems)
|
||||
{
|
||||
if(item.instance.RandomId == randomId)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
throw new KeyNotFoundException("Random id: " + randomId.ToString() + " not found");
|
||||
|
||||
}
|
||||
public static void DespawnItems(int old_epoch, int new_epoch)
|
||||
{
|
||||
int removedCount = 0;
|
||||
DroppedItem[] items = droppedItemsList.ToArray();
|
||||
foreach (DroppedItem item in items)
|
||||
{
|
||||
if(new_epoch + item.DespawnTimer < old_epoch)
|
||||
{
|
||||
if(GameServer.GetUsersAt(item.X, item.Y,true,true).Length == 0)
|
||||
{
|
||||
RemoveDroppedItem(item);
|
||||
removedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(removedCount > 0)
|
||||
epoch = new_epoch;
|
||||
}
|
||||
|
||||
public static void AddItem(ItemInstance item, int x, int y)
|
||||
{
|
||||
DroppedItem droppedItem = new DroppedItem();
|
||||
droppedItem.X = x;
|
||||
droppedItem.Y = y;
|
||||
droppedItem.DespawnTimer = 1500;
|
||||
droppedItem.instance = item;
|
||||
droppedItemsList.Add(droppedItem);
|
||||
}
|
||||
public static void GenerateItems()
|
||||
{
|
||||
int newItems = 0;
|
||||
foreach (Item.ItemInformation item in Item.Items)
|
||||
{
|
||||
int count = GetCountOfItem(item);
|
||||
while (count < item.SpawnParamaters.SpawnCap)
|
||||
{
|
||||
|
||||
count++;
|
||||
|
||||
int despawnTimer = GameServer.RandomNumberGenerator.Next(900, 1500);
|
||||
|
||||
if (item.SpawnParamaters.SpawnInZone != null)
|
||||
{
|
||||
World.Zone spawnArea = World.GetZoneByName(item.SpawnParamaters.SpawnInZone);
|
||||
|
||||
while(true)
|
||||
{
|
||||
// Pick a random location inside the zone
|
||||
int tryX = GameServer.RandomNumberGenerator.Next(spawnArea.StartX, spawnArea.EndX);
|
||||
int tryY = GameServer.RandomNumberGenerator.Next(spawnArea.StartY, spawnArea.EndY);
|
||||
|
||||
|
||||
if (World.InSpecialTile(tryX, tryY))
|
||||
continue;
|
||||
|
||||
|
||||
if (Map.CheckPassable(tryX, tryY)) // Can the player walk here?
|
||||
{
|
||||
int TileID = Map.GetTileId(tryX, tryY, false);
|
||||
string TileType = Map.TerrainTiles[TileID - 1].Type; // Is it the right type?
|
||||
|
||||
if (item.SpawnParamaters.SpawnOnTileType == TileType)
|
||||
{
|
||||
ItemInstance instance = new ItemInstance(item.Id);
|
||||
DroppedItem droppedItem = new DroppedItem();
|
||||
droppedItem.X = tryX;
|
||||
droppedItem.Y = tryY;
|
||||
droppedItem.DespawnTimer = despawnTimer;
|
||||
droppedItem.instance = instance;
|
||||
droppedItemsList.Add(droppedItem);
|
||||
Database.AddDroppedItem(droppedItem);
|
||||
Logger.DebugPrint("Created Item ID: " + instance.ItemId + " in ZONE: " + spawnArea.Name + " at: X: " + droppedItem.X + " Y: " + droppedItem.Y);
|
||||
newItems++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (item.SpawnParamaters.SpawnOnSpecialTile != null)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
// Pick a random special tile
|
||||
World.SpecialTile[] possileTiles = World.GetSpecialTilesByName(item.SpawnParamaters.SpawnOnSpecialTile);
|
||||
World.SpecialTile spawnOn = possileTiles[GameServer.RandomNumberGenerator.Next(0, possileTiles.Length)];
|
||||
|
||||
if (Map.CheckPassable(spawnOn.X, spawnOn.Y))
|
||||
{
|
||||
ItemInstance instance = new ItemInstance(item.Id);
|
||||
DroppedItem droppedItem = new DroppedItem();
|
||||
droppedItem.X = spawnOn.X;
|
||||
droppedItem.Y = spawnOn.Y;
|
||||
droppedItem.DespawnTimer = despawnTimer;
|
||||
droppedItem.instance = instance;
|
||||
droppedItemsList.Add(droppedItem);
|
||||
Database.AddDroppedItem(droppedItem);
|
||||
Logger.DebugPrint("Created Item ID: " + instance.ItemId + " at: X: " + droppedItem.X + " Y: " + droppedItem.Y);
|
||||
newItems++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (item.SpawnParamaters.SpawnNearSpecialTile != null)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// Pick a random special tile
|
||||
World.SpecialTile[] possileTiles = World.GetSpecialTilesByName(item.SpawnParamaters.SpawnNearSpecialTile);
|
||||
World.SpecialTile spawnNearTile = possileTiles[GameServer.RandomNumberGenerator.Next(0, possileTiles.Length)];
|
||||
|
||||
// Pick a direction to try spawn in
|
||||
|
||||
int direction = GameServer.RandomNumberGenerator.Next(0, 4);
|
||||
int tryX = 0;
|
||||
int tryY = 0;
|
||||
if (direction == 0)
|
||||
{
|
||||
tryX = spawnNearTile.X + 1;
|
||||
tryY = spawnNearTile.Y;
|
||||
}
|
||||
else if(direction == 1)
|
||||
{
|
||||
tryX = spawnNearTile.X - 1;
|
||||
tryY = spawnNearTile.Y;
|
||||
}
|
||||
else if(direction == 3)
|
||||
{
|
||||
tryX = spawnNearTile.X;
|
||||
tryY = spawnNearTile.Y + 1;
|
||||
}
|
||||
else if (direction == 4)
|
||||
{
|
||||
tryX = spawnNearTile.X;
|
||||
tryY = spawnNearTile.Y - 1;
|
||||
}
|
||||
if (World.InSpecialTile(tryX, tryY))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(tryX, tryY);
|
||||
if (tile.Code != null)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Map.CheckPassable(tryX, tryY))
|
||||
{
|
||||
|
||||
ItemInstance instance = new ItemInstance(item.Id);
|
||||
DroppedItem droppedItem = new DroppedItem();
|
||||
droppedItem.X = tryX;
|
||||
droppedItem.Y = tryY;
|
||||
droppedItem.DespawnTimer = despawnTimer;
|
||||
droppedItem.instance = instance;
|
||||
droppedItemsList.Add(droppedItem);
|
||||
Database.AddDroppedItem(droppedItem);
|
||||
Logger.DebugPrint("Created Item ID: " + instance.ItemId + " at: X: " + droppedItem.X + " Y: " + droppedItem.Y);
|
||||
newItems++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (item.SpawnParamaters.SpawnOnTileType != null)
|
||||
{
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Pick a random isle:
|
||||
int isleId = GameServer.RandomNumberGenerator.Next(0, World.Isles.Count);
|
||||
World.Isle isle = World.Isles[isleId];
|
||||
|
||||
// Pick a random location inside the isle
|
||||
int tryX = GameServer.RandomNumberGenerator.Next(isle.StartX, isle.EndX);
|
||||
int tryY = GameServer.RandomNumberGenerator.Next(isle.StartY, isle.EndY);
|
||||
|
||||
|
||||
if (World.InSpecialTile(tryX, tryY))
|
||||
continue;
|
||||
|
||||
if (Map.CheckPassable(tryX, tryY)) // Can the player walk here?
|
||||
{
|
||||
int TileID = Map.GetTileId(tryX, tryY, false);
|
||||
string TileType = Map.TerrainTiles[TileID - 1].Type; // Is it the right type?
|
||||
|
||||
if (item.SpawnParamaters.SpawnOnTileType == TileType)
|
||||
{
|
||||
ItemInstance instance = new ItemInstance(item.Id);
|
||||
DroppedItem droppedItem = new DroppedItem();
|
||||
droppedItem.X = tryX;
|
||||
droppedItem.Y = tryY;
|
||||
droppedItem.DespawnTimer = despawnTimer;
|
||||
droppedItem.instance = instance;
|
||||
droppedItemsList.Add(droppedItem);
|
||||
Database.AddDroppedItem(droppedItem);
|
||||
Logger.DebugPrint("Created Item ID: " + instance.ItemId + " in " + isle.Name + " at: X: " + droppedItem.X + " Y: " + droppedItem.Y);
|
||||
newItems++;
|
||||
break;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
ReadFromDatabase();
|
||||
Logger.InfoPrint("Generating items, (this may take awhile on a fresh database!)");
|
||||
GenerateItems();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
10
Horse Isle Server/HorseIsleServer/Game/GameExceptions.cs
Normal file
10
Horse Isle Server/HorseIsleServer/Game/GameExceptions.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
// Inventory
|
||||
class InventoryException : Exception { };
|
||||
class InventoryFullException : InventoryException { };
|
||||
class InventoryMaxStackException : InventoryException { };
|
||||
}
|
547
Horse Isle Server/HorseIsleServer/Game/Horse/HorseInfo.cs
Normal file
547
Horse Isle Server/HorseIsleServer/Game/Horse/HorseInfo.cs
Normal file
|
@ -0,0 +1,547 @@
|
|||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game.Horse
|
||||
{
|
||||
class HorseInfo
|
||||
{
|
||||
public enum StatType
|
||||
{
|
||||
AGILITY,
|
||||
CONFORMATION,
|
||||
ENDURANCE,
|
||||
PERSONALITY,
|
||||
SPEED,
|
||||
STRENGTH,
|
||||
INTELIGENCE
|
||||
}
|
||||
public class StatCalculator
|
||||
{
|
||||
public StatCalculator(HorseInstance horse, StatType type)
|
||||
{
|
||||
baseHorse = horse;
|
||||
horseStat = type;
|
||||
}
|
||||
private StatType horseStat;
|
||||
private HorseInstance baseHorse;
|
||||
|
||||
public int BaseValue
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (horseStat)
|
||||
{
|
||||
case StatType.AGILITY:
|
||||
return baseHorse.Breed.BaseStats.Agility;
|
||||
case StatType.CONFORMATION:
|
||||
return baseHorse.Breed.BaseStats.Conformation;
|
||||
case StatType.ENDURANCE:
|
||||
return baseHorse.Breed.BaseStats.Endurance;
|
||||
case StatType.PERSONALITY:
|
||||
return baseHorse.Breed.BaseStats.Personality;
|
||||
case StatType.SPEED:
|
||||
return baseHorse.Breed.BaseStats.Speed;
|
||||
case StatType.STRENGTH:
|
||||
return baseHorse.Breed.BaseStats.Strength;
|
||||
case StatType.INTELIGENCE:
|
||||
return baseHorse.Breed.BaseStats.Inteligence;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int MaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return BaseValue * 2;
|
||||
}
|
||||
}
|
||||
public int BreedValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return BaseValue + BreedOffset;
|
||||
}
|
||||
}
|
||||
public int BreedOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (horseStat)
|
||||
{
|
||||
case StatType.AGILITY:
|
||||
return baseHorse.AdvancedStats.Agility;
|
||||
case StatType.CONFORMATION:
|
||||
return baseHorse.AdvancedStats.Conformation;
|
||||
case StatType.ENDURANCE:
|
||||
return baseHorse.AdvancedStats.Endurance;
|
||||
case StatType.PERSONALITY:
|
||||
return baseHorse.AdvancedStats.Personality;
|
||||
case StatType.SPEED:
|
||||
return baseHorse.AdvancedStats.Speed;
|
||||
case StatType.STRENGTH:
|
||||
return baseHorse.AdvancedStats.Strength;
|
||||
case StatType.INTELIGENCE:
|
||||
return baseHorse.AdvancedStats.Inteligence;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (horseStat)
|
||||
{
|
||||
case StatType.AGILITY:
|
||||
baseHorse.AdvancedStats.Agility = value;
|
||||
break;
|
||||
case StatType.CONFORMATION:
|
||||
baseHorse.AdvancedStats.Conformation = value;
|
||||
break;
|
||||
case StatType.ENDURANCE:
|
||||
baseHorse.AdvancedStats.Endurance = value;
|
||||
break;
|
||||
case StatType.PERSONALITY:
|
||||
baseHorse.AdvancedStats.Personality = value;
|
||||
break;
|
||||
case StatType.SPEED:
|
||||
baseHorse.AdvancedStats.Speed = value;
|
||||
break;
|
||||
case StatType.STRENGTH:
|
||||
baseHorse.AdvancedStats.Strength = value;
|
||||
break;
|
||||
case StatType.INTELIGENCE:
|
||||
baseHorse.AdvancedStats.Inteligence = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int CompanionOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
int offsetBy = 0;
|
||||
if (baseHorse.Equipment.Companion != null)
|
||||
offsetBy += getOffetFrom(baseHorse.Equipment.Companion);
|
||||
return offsetBy;
|
||||
}
|
||||
}
|
||||
public int TackOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
int offsetBy = 0;
|
||||
if (baseHorse.Equipment.Saddle != null)
|
||||
offsetBy += getOffetFrom(baseHorse.Equipment.Saddle);
|
||||
if (baseHorse.Equipment.SaddlePad != null)
|
||||
offsetBy += getOffetFrom(baseHorse.Equipment.SaddlePad);
|
||||
if (baseHorse.Equipment.Bridle != null)
|
||||
offsetBy += getOffetFrom(baseHorse.Equipment.Bridle);
|
||||
return offsetBy;
|
||||
}
|
||||
}
|
||||
public int Total
|
||||
{
|
||||
get
|
||||
{
|
||||
return BreedValue + CompanionOffset + TackOffset;
|
||||
}
|
||||
}
|
||||
|
||||
private int getOffetFrom(Item.ItemInformation tackPeice)
|
||||
{
|
||||
int offsetBy = 0;
|
||||
foreach (Item.Effects effect in baseHorse.Equipment.Bridle.Effects)
|
||||
{
|
||||
string effects = effect.EffectsWhat;
|
||||
switch (effects)
|
||||
{
|
||||
case "AGILITYOFFSET":
|
||||
if (horseStat == StatType.AGILITY)
|
||||
offsetBy += effect.EffectAmount;
|
||||
break;
|
||||
case "CONFORMATIONOFFSET":
|
||||
if (horseStat == StatType.CONFORMATION)
|
||||
offsetBy += effect.EffectAmount;
|
||||
break;
|
||||
case "ENDURANCEOFFSET":
|
||||
if (horseStat == StatType.ENDURANCE)
|
||||
offsetBy += effect.EffectAmount;
|
||||
break;
|
||||
case "PERSONALITYOFFSET":
|
||||
if (horseStat == StatType.PERSONALITY)
|
||||
offsetBy += effect.EffectAmount;
|
||||
break;
|
||||
case "SPEEDOFFSET":
|
||||
if (horseStat == StatType.SPEED)
|
||||
offsetBy += effect.EffectAmount;
|
||||
break;
|
||||
case "STRENGTHOFFSET":
|
||||
if (horseStat == StatType.STRENGTH)
|
||||
offsetBy += effect.EffectAmount;
|
||||
break;
|
||||
case "INTELLIGENCEOFFSET":
|
||||
if (horseStat == StatType.INTELIGENCE)
|
||||
offsetBy += effect.EffectAmount;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return offsetBy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class AdvancedStats
|
||||
{
|
||||
public AdvancedStats(HorseInstance horse, int newSpeed,int newStrength, int newConformation, int newAgility, int newInteligence, int newEndurance, int newPersonality, int newHeight)
|
||||
{
|
||||
if(horse != null)
|
||||
baseHorse = horse;
|
||||
speed = newSpeed;
|
||||
strength = newStrength;
|
||||
conformation = newConformation;
|
||||
agility = newAgility;
|
||||
endurance = newEndurance;
|
||||
inteligence = newInteligence;
|
||||
personality = newPersonality;
|
||||
Height = newHeight;
|
||||
}
|
||||
|
||||
|
||||
public int Speed
|
||||
{
|
||||
get
|
||||
{
|
||||
return speed;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > ((baseHorse.Breed.BaseStats.Speed * 2) - baseHorse.Breed.BaseStats.Speed))
|
||||
value = (baseHorse.Breed.BaseStats.Speed - baseHorse.Breed.BaseStats.Speed * 2);
|
||||
Database.SetHorseSpeed(baseHorse.RandomId, value);
|
||||
speed = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Strength
|
||||
{
|
||||
get
|
||||
{
|
||||
return strength;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > ((baseHorse.Breed.BaseStats.Strength * 2)- baseHorse.Breed.BaseStats.Strength))
|
||||
value = ((baseHorse.Breed.BaseStats.Strength * 2) - baseHorse.Breed.BaseStats.Strength);
|
||||
Database.SetHorseStrength(baseHorse.RandomId, value);
|
||||
strength = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Conformation
|
||||
{
|
||||
get
|
||||
{
|
||||
return conformation;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > ((baseHorse.Breed.BaseStats.Conformation * 2) - baseHorse.Breed.BaseStats.Conformation))
|
||||
value = ((baseHorse.Breed.BaseStats.Conformation * 2) - baseHorse.Breed.BaseStats.Conformation);
|
||||
Database.SetHorseConformation(baseHorse.RandomId, value);
|
||||
conformation = value;
|
||||
}
|
||||
}
|
||||
public int Agility
|
||||
{
|
||||
get
|
||||
{
|
||||
return agility;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > ((baseHorse.Breed.BaseStats.Agility * 2) - baseHorse.Breed.BaseStats.Agility))
|
||||
value = ((baseHorse.Breed.BaseStats.Agility * 2) - baseHorse.Breed.BaseStats.Agility);
|
||||
Database.SetHorseAgility(baseHorse.RandomId, value);
|
||||
agility = value;
|
||||
}
|
||||
}
|
||||
public int Endurance
|
||||
{
|
||||
get
|
||||
{
|
||||
return endurance;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > ((baseHorse.Breed.BaseStats.Endurance * 2) - baseHorse.Breed.BaseStats.Endurance))
|
||||
value = ((baseHorse.Breed.BaseStats.Endurance * 2) - baseHorse.Breed.BaseStats.Endurance);
|
||||
Database.SetHorseEndurance(baseHorse.RandomId, value);
|
||||
endurance = value;
|
||||
}
|
||||
}
|
||||
public int Inteligence
|
||||
{
|
||||
get
|
||||
{
|
||||
return inteligence;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > ((baseHorse.Breed.BaseStats.Inteligence* 2) - baseHorse.Breed.BaseStats.Inteligence))
|
||||
value = ((baseHorse.Breed.BaseStats.Inteligence * 2) - baseHorse.Breed.BaseStats.Inteligence);
|
||||
Database.SetHorseInteligence(baseHorse.RandomId, value);
|
||||
inteligence = value;
|
||||
}
|
||||
}
|
||||
public int Personality
|
||||
{
|
||||
get
|
||||
{
|
||||
return personality;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > ((baseHorse.Breed.BaseStats.Personality * 2) - baseHorse.Breed.BaseStats.Personality))
|
||||
value = ((baseHorse.Breed.BaseStats.Personality * 2) - baseHorse.Breed.BaseStats.Personality);
|
||||
Database.SetHorsePersonality(baseHorse.RandomId, value);
|
||||
personality = value;
|
||||
}
|
||||
}
|
||||
public int Height;
|
||||
public int MinHeight;
|
||||
public int MaxHeight;
|
||||
|
||||
private HorseInstance baseHorse;
|
||||
private int speed;
|
||||
private int strength;
|
||||
private int conformation;
|
||||
private int agility;
|
||||
private int endurance;
|
||||
private int inteligence;
|
||||
private int personality;
|
||||
}
|
||||
public class BasicStats
|
||||
{
|
||||
public BasicStats(HorseInstance horse, int newHealth, int newShoes, int newHunger, int newThirst, int newMood, int newGroom, int newTiredness, int newExperience)
|
||||
{
|
||||
baseHorse = horse;
|
||||
health = newHealth;
|
||||
shoes = newShoes;
|
||||
hunger = newHunger;
|
||||
thirst = newThirst;
|
||||
mood = newMood;
|
||||
groom = newGroom;
|
||||
tiredness = newTiredness;
|
||||
experience = newExperience;
|
||||
|
||||
}
|
||||
public int Health
|
||||
{
|
||||
get
|
||||
{
|
||||
return health;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 1000)
|
||||
value = 1000;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
health = value;
|
||||
Database.SetHorseHealth(baseHorse.RandomId, value);
|
||||
}
|
||||
}
|
||||
public int Shoes
|
||||
{
|
||||
get
|
||||
{
|
||||
return shoes;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 1000)
|
||||
value = 1000;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
shoes = value;
|
||||
Database.SetHorseShoes(baseHorse.RandomId, value);
|
||||
}
|
||||
}
|
||||
public int Hunger {
|
||||
get
|
||||
{
|
||||
return hunger;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 1000)
|
||||
value = 1000;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
hunger = value;
|
||||
Database.SetHorseHunger(baseHorse.RandomId, value);
|
||||
}
|
||||
}
|
||||
public int Thirst
|
||||
{
|
||||
get
|
||||
{
|
||||
return thirst;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 1000)
|
||||
value = 1000;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
thirst = value;
|
||||
Database.SetHorseThirst(baseHorse.RandomId, value);
|
||||
}
|
||||
}
|
||||
public int Mood
|
||||
{
|
||||
get
|
||||
{
|
||||
return mood;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 1000)
|
||||
value = 1000;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
mood = value;
|
||||
Database.SetHorseMood(baseHorse.RandomId, value);
|
||||
}
|
||||
}
|
||||
public int Groom
|
||||
{
|
||||
get
|
||||
{
|
||||
return groom;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 1000)
|
||||
value = 1000;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
groom = value;
|
||||
Database.SetHorseGroom(baseHorse.RandomId, value);
|
||||
}
|
||||
}
|
||||
public int Tiredness
|
||||
{
|
||||
get
|
||||
{
|
||||
return tiredness;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 1000)
|
||||
value = 1000;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
tiredness = value;
|
||||
Database.SetHorseTiredness(baseHorse.RandomId, value);
|
||||
}
|
||||
}
|
||||
public int Experience
|
||||
{
|
||||
get
|
||||
{
|
||||
return experience;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
experience = value;
|
||||
Database.SetHorseExperience(baseHorse.RandomId, value);
|
||||
}
|
||||
}
|
||||
|
||||
private HorseInstance baseHorse;
|
||||
private int health;
|
||||
private int shoes;
|
||||
private int hunger;
|
||||
private int thirst;
|
||||
private int mood;
|
||||
private int groom;
|
||||
private int tiredness;
|
||||
private int experience;
|
||||
}
|
||||
|
||||
public struct Breed
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
public string Description;
|
||||
public AdvancedStats BaseStats;
|
||||
public string[] Colors;
|
||||
public string SpawnOn;
|
||||
public string SpawnInArea;
|
||||
public string Swf;
|
||||
public string Type;
|
||||
}
|
||||
|
||||
public struct HorseEquips
|
||||
{
|
||||
public Item.ItemInformation Saddle;
|
||||
public Item.ItemInformation SaddlePad;
|
||||
public Item.ItemInformation Bridle;
|
||||
public Item.ItemInformation Companion;
|
||||
}
|
||||
|
||||
public struct Category
|
||||
{
|
||||
public string Name;
|
||||
public string Meta;
|
||||
}
|
||||
|
||||
public static string[] HorseNames;
|
||||
public static List<Category> HorseCategories = new List<Category>();
|
||||
public static List<Breed> Breeds = new List<Breed>();
|
||||
|
||||
public static string GenerateHorseName()
|
||||
{
|
||||
int indx = 0;
|
||||
int max = HorseNames.Length;
|
||||
int i = GameServer.RandomNumberGenerator.Next(indx, max);
|
||||
return HorseNames[i];
|
||||
}
|
||||
public static double CalculateHands(int height)
|
||||
{
|
||||
return ((double)height / 4.0);
|
||||
}
|
||||
public static string BreedViewerSwf(HorseInstance horse, string terrainTileType)
|
||||
{
|
||||
double hands = CalculateHands(horse.AdvancedStats.Height);
|
||||
|
||||
string swf = "breedviewer.swf?terrain=" + terrainTileType + "&breed=" + horse.Breed.Swf + "&color=" + horse.Color + "&hands=" + hands.ToString();
|
||||
if (horse.Equipment.Saddle != null)
|
||||
swf += "&saddle=" + horse.Equipment.Saddle.EmbedSwf;
|
||||
if (horse.Equipment.SaddlePad != null)
|
||||
swf += "&saddlepad=" + horse.Equipment.SaddlePad.EmbedSwf;
|
||||
if (horse.Equipment.Bridle != null)
|
||||
swf += "&bridle=" + horse.Equipment.Bridle.EmbedSwf;
|
||||
if (horse.Equipment.Companion != null)
|
||||
swf += "&companion=" + horse.Equipment.Companion.EmbedSwf;
|
||||
swf += "&junk=";
|
||||
|
||||
return swf;
|
||||
}
|
||||
public static Breed GetBreedById(int id)
|
||||
{
|
||||
foreach(Breed breed in Breeds)
|
||||
{
|
||||
if (breed.Id == id)
|
||||
return breed;
|
||||
}
|
||||
throw new KeyNotFoundException("No horse breed with id " + id);
|
||||
}
|
||||
}
|
||||
}
|
188
Horse Isle Server/HorseIsleServer/Game/Horse/HorseInstance.cs
Normal file
188
Horse Isle Server/HorseIsleServer/Game/Horse/HorseInstance.cs
Normal file
|
@ -0,0 +1,188 @@
|
|||
|
||||
using HISP.Security;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Game.Horse
|
||||
{
|
||||
class HorseInstance
|
||||
{
|
||||
public HorseInstance(HorseInfo.Breed breed, int randomId = -1, string loadName=null, string loadDescription = "", int loadSpoiled=0, string loadCategory="KEEPER", int loadMagicUsed=0, int loadAutoSell=0)
|
||||
{
|
||||
RandomId = RandomID.NextRandomId(randomId);
|
||||
Owner = 0;
|
||||
if(loadName == null)
|
||||
{
|
||||
|
||||
if (breed.Type == "camel")
|
||||
{
|
||||
name = "Wild Camel";
|
||||
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
|
||||
{
|
||||
Sex = "cow";
|
||||
}
|
||||
else
|
||||
{
|
||||
Sex = "bull";
|
||||
}
|
||||
|
||||
}
|
||||
else if (breed.Type == "llama")
|
||||
{
|
||||
name = "Jungle Llama";
|
||||
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
|
||||
{
|
||||
Sex = "male";
|
||||
}
|
||||
else
|
||||
{
|
||||
Sex = "female";
|
||||
}
|
||||
}
|
||||
else if (breed.Type == "zebra")
|
||||
{
|
||||
name = "Wild Zebra";
|
||||
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
|
||||
{
|
||||
Sex = "stallion";
|
||||
}
|
||||
else
|
||||
{
|
||||
Sex = "mare";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "Wild Horse";
|
||||
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
|
||||
{
|
||||
Sex = "stallion";
|
||||
}
|
||||
else
|
||||
{
|
||||
Sex = "mare";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = loadName;
|
||||
}
|
||||
|
||||
description = loadDescription;
|
||||
Breed = breed;
|
||||
Color = breed.Colors[GameServer.RandomNumberGenerator.Next(0, breed.Colors.Length)];
|
||||
|
||||
BasicStats = new HorseInfo.BasicStats(this, 1000, 0, 1000, 1000, 500, 1000, 1000, 0);
|
||||
int inteligence = (GameServer.RandomNumberGenerator.Next(breed.BaseStats.Inteligence, breed.BaseStats.Inteligence * 2)) - breed.BaseStats.Inteligence;
|
||||
int personality = (GameServer.RandomNumberGenerator.Next(breed.BaseStats.Personality, breed.BaseStats.Personality * 2)) - breed.BaseStats.Personality;
|
||||
int height = GameServer.RandomNumberGenerator.Next(breed.BaseStats.MinHeight, breed.BaseStats.MaxHeight);
|
||||
AdvancedStats = new HorseInfo.AdvancedStats(this, 0, 0, 0, 0, inteligence, 0, personality, height);
|
||||
|
||||
Equipment = new HorseInfo.HorseEquips();
|
||||
autosell = loadAutoSell;
|
||||
category = loadCategory;
|
||||
spoiled = loadSpoiled;
|
||||
magicUsed = loadMagicUsed;
|
||||
TrainTimer = 0;
|
||||
RanchId = 0;
|
||||
Leaser = 0;
|
||||
}
|
||||
public int RanchId;
|
||||
public int Leaser;
|
||||
public int RandomId;
|
||||
public int Owner;
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
Database.SetHorseName(this.RandomId, name);
|
||||
}
|
||||
}
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return description;
|
||||
}
|
||||
set
|
||||
{
|
||||
description = value;
|
||||
Database.SetHorseDescription(this.RandomId, value);
|
||||
}
|
||||
}
|
||||
public string Sex;
|
||||
public string Color;
|
||||
public int TrainTimer;
|
||||
public HorseInfo.Breed Breed;
|
||||
public HorseInfo.BasicStats BasicStats;
|
||||
public HorseInfo.AdvancedStats AdvancedStats;
|
||||
public HorseInfo.HorseEquips Equipment;
|
||||
public int AutoSell
|
||||
{
|
||||
get
|
||||
{
|
||||
return autosell;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetHorseAutoSell(RandomId, value);
|
||||
autosell = value;
|
||||
}
|
||||
}
|
||||
public int Spoiled
|
||||
{
|
||||
get
|
||||
{
|
||||
return spoiled;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetHorseSpoiled(RandomId, value);
|
||||
spoiled = value;
|
||||
}
|
||||
}
|
||||
public int MagicUsed
|
||||
{
|
||||
get
|
||||
{
|
||||
return magicUsed;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetHorseMagicUsed(RandomId, value);
|
||||
magicUsed = value;
|
||||
}
|
||||
}
|
||||
public string Category
|
||||
{
|
||||
get
|
||||
{
|
||||
return category;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetHorseCategory(RandomId, value);
|
||||
category = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string name;
|
||||
private string description;
|
||||
private int spoiled;
|
||||
private int magicUsed;
|
||||
private int autosell;
|
||||
private string category;
|
||||
|
||||
public void ChangeNameWithoutUpdatingDatabase(string newName)
|
||||
{
|
||||
name = newName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
295
Horse Isle Server/HorseIsleServer/Game/Horse/WildHorse.cs
Normal file
295
Horse Isle Server/HorseIsleServer/Game/Horse/WildHorse.cs
Normal file
|
@ -0,0 +1,295 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Horse
|
||||
{
|
||||
|
||||
class WildHorse
|
||||
{
|
||||
|
||||
public WildHorse(HorseInstance horse, int MapX = -1, int MapY = -1, int despawnTimeout=60, bool addToDatabase = true)
|
||||
{
|
||||
Instance = horse;
|
||||
timeout = despawnTimeout;
|
||||
|
||||
if(MapX == -1 && MapY == -1)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (horse.Breed.SpawnInArea == null)
|
||||
{
|
||||
|
||||
// Pick a random isle.
|
||||
int isleId = GameServer.RandomNumberGenerator.Next(0, World.Isles.Count);
|
||||
World.Isle isle = World.Isles[isleId];
|
||||
|
||||
// Pick x/y in isle.
|
||||
int tryX = GameServer.RandomNumberGenerator.Next(isle.StartX, isle.EndX);
|
||||
int tryY = GameServer.RandomNumberGenerator.Next(isle.StartY, isle.EndY);
|
||||
|
||||
// Horses cannot be in towns.
|
||||
if (World.InTown(tryX, tryY))
|
||||
continue;
|
||||
if (World.InSpecialTile(tryX, tryY))
|
||||
continue;
|
||||
|
||||
// Check Tile Type
|
||||
int TileID = Map.GetTileId(tryX, tryY, false);
|
||||
string TileType = Map.TerrainTiles[TileID - 1].Type;
|
||||
if (TileType == horse.Breed.SpawnOn)
|
||||
{
|
||||
if (Map.CheckPassable(tryX, tryY)) // Can the player stand over here?
|
||||
{
|
||||
x = tryX;
|
||||
y = tryY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
World.Zone zone = World.GetZoneByName(horse.Breed.SpawnInArea);
|
||||
// Pick x/y in zone.
|
||||
int tryX = GameServer.RandomNumberGenerator.Next(zone.StartX, zone.EndX);
|
||||
int tryY = GameServer.RandomNumberGenerator.Next(zone.StartY, zone.EndY);
|
||||
|
||||
// Horses cannot be in towns.
|
||||
if (World.InTown(tryX, tryY))
|
||||
continue;
|
||||
if (World.InSpecialTile(tryX, tryY))
|
||||
continue;
|
||||
|
||||
// Check Tile Type
|
||||
int TileID = Map.GetTileId(tryX, tryY, false);
|
||||
string TileType = Map.TerrainTiles[TileID - 1].Type;
|
||||
if (TileType == horse.Breed.SpawnOn)
|
||||
{
|
||||
if (Map.CheckPassable(tryX, tryY)) // Can the player stand over here?
|
||||
{
|
||||
x = tryX;
|
||||
y = tryY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x = MapX;
|
||||
y = MapY;
|
||||
}
|
||||
wildHorses.Add(this);
|
||||
if(addToDatabase)
|
||||
Database.AddWildHorse(this);
|
||||
}
|
||||
|
||||
|
||||
public void RandomWander()
|
||||
{
|
||||
int direction = GameServer.RandomNumberGenerator.Next(0, 3);
|
||||
int tryX = this.X;
|
||||
int tryY = this.Y;
|
||||
|
||||
switch(direction)
|
||||
{
|
||||
case 0:
|
||||
tryX += 1;
|
||||
break;
|
||||
case 1:
|
||||
tryX -= 1;
|
||||
break;
|
||||
case 2:
|
||||
tryY += 1;
|
||||
break;
|
||||
case 3:
|
||||
tryY -= 1;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
// Horses cannot be in towns.
|
||||
if (World.InTown(tryX, tryY))
|
||||
return;
|
||||
if (World.InSpecialTile(tryX, tryY))
|
||||
return;
|
||||
|
||||
if (Map.CheckPassable(tryX, tryY))
|
||||
{
|
||||
X = tryX;
|
||||
Y = tryY;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Escape()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
int tryX = X + GameServer.RandomNumberGenerator.Next(-15, 15);
|
||||
int tryY = Y + GameServer.RandomNumberGenerator.Next(-15, 15);
|
||||
|
||||
// Horses cannot be in towns.
|
||||
if (World.InTown(tryX, tryY))
|
||||
continue;
|
||||
if (World.InSpecialTile(tryX, tryY))
|
||||
continue;
|
||||
|
||||
if (Map.CheckPassable(tryX, tryY))
|
||||
{
|
||||
X = tryX;
|
||||
Y = tryY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Capture(User forUser)
|
||||
{
|
||||
forUser.HorseInventory.AddHorse(this.Instance);
|
||||
Despawn(this);
|
||||
}
|
||||
|
||||
private static List<WildHorse> wildHorses = new List<WildHorse>();
|
||||
public static WildHorse[] WildHorses
|
||||
{
|
||||
get
|
||||
{
|
||||
return wildHorses.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateHorses()
|
||||
{
|
||||
Logger.InfoPrint("Generating horses.");
|
||||
while(wildHorses.Count < 40)
|
||||
{
|
||||
HorseInfo.Breed horseBreed = HorseInfo.Breeds[GameServer.RandomNumberGenerator.Next(0, HorseInfo.Breeds.Count)];
|
||||
if (horseBreed.Swf == "")
|
||||
continue;
|
||||
if (horseBreed.SpawnInArea == "none") // no unipegs >_>
|
||||
continue;
|
||||
|
||||
HorseInstance horseInst = new HorseInstance(horseBreed);
|
||||
WildHorse wildHorse = new WildHorse(horseInst);
|
||||
|
||||
Logger.DebugPrint("Created " + horseBreed.Name + " at X:" + wildHorse.X + ", Y:" + wildHorse.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
Database.LoadWildHorses();
|
||||
GenerateHorses();
|
||||
}
|
||||
|
||||
public static WildHorse[] GetHorsesAt(int x, int y)
|
||||
{
|
||||
List<WildHorse> horses = new List<WildHorse>();
|
||||
foreach (WildHorse wildHorse in WildHorses)
|
||||
{
|
||||
if (wildHorse.X == x && wildHorse.Y == y)
|
||||
horses.Add(wildHorse);
|
||||
}
|
||||
return horses.ToArray();
|
||||
}
|
||||
|
||||
public static bool DoesHorseExist(int randomId)
|
||||
{
|
||||
foreach (WildHorse wildHorse in WildHorses)
|
||||
{
|
||||
if (wildHorse.Instance.RandomId == randomId)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static WildHorse GetHorseById(int randomId)
|
||||
{
|
||||
foreach(WildHorse wildHorse in WildHorses)
|
||||
{
|
||||
if (wildHorse.Instance.RandomId == randomId)
|
||||
return wildHorse;
|
||||
}
|
||||
throw new KeyNotFoundException("No horse with id: " + randomId + " was found.");
|
||||
}
|
||||
|
||||
public static void Despawn(WildHorse horse)
|
||||
{
|
||||
Database.RemoveWildHorse(horse.Instance.RandomId);
|
||||
wildHorses.Remove(horse);
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
foreach(WildHorse wildHorse in WildHorses)
|
||||
{
|
||||
wildHorse.Timeout -= 1;
|
||||
|
||||
if (GameServer.GetUsersAt(wildHorse.X, wildHorse.Y, true, true).Length > 0)
|
||||
continue;
|
||||
|
||||
if (wildHorse.Timeout <= 0)
|
||||
Despawn(wildHorse);
|
||||
|
||||
if(wildHorse.Timeout % 5 == 0)
|
||||
if (GameServer.RandomNumberGenerator.Next(0, 100) > 50)
|
||||
wildHorse.RandomWander();
|
||||
}
|
||||
if(WildHorses.Length < 40)
|
||||
{
|
||||
GenerateHorses();
|
||||
}
|
||||
}
|
||||
public HorseInstance Instance;
|
||||
public int X
|
||||
{
|
||||
get
|
||||
{
|
||||
return x;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetWildHorseX(this.Instance.RandomId, value);
|
||||
x = value;
|
||||
}
|
||||
}
|
||||
public int Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return y;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetWildHorseY(this.Instance.RandomId, value);
|
||||
y = value;
|
||||
}
|
||||
}
|
||||
public int Timeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return timeout;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetWildHorseTimeout(this.Instance.RandomId, value);
|
||||
timeout = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int timeout;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
using HISP.Game.Horse;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
class HorseInventory
|
||||
{
|
||||
private User baseUser;
|
||||
private List<HorseInstance> horsesList = new List<HorseInstance>();
|
||||
public HorseInstance[] HorseList
|
||||
{
|
||||
get
|
||||
{
|
||||
return horsesList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public int MaxHorses
|
||||
{
|
||||
get
|
||||
{
|
||||
return 7; // will change when ranches are implemented.
|
||||
}
|
||||
}
|
||||
public HorseInventory(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
Database.LoadHorseInventory(this, baseUser.Id);
|
||||
}
|
||||
|
||||
public void AddHorse(HorseInstance horse, bool addToDb=true)
|
||||
{
|
||||
if (HorseList.Length + 1 > MaxHorses)
|
||||
throw new InventoryFullException();
|
||||
|
||||
horse.Owner = baseUser.Id;
|
||||
if(addToDb)
|
||||
Database.AddHorse(horse);
|
||||
horsesList.Add(horse);
|
||||
}
|
||||
|
||||
public void DeleteHorse(HorseInstance horse)
|
||||
{
|
||||
Database.RemoveHorse(horse.RandomId);
|
||||
horsesList.Remove(horse);
|
||||
}
|
||||
|
||||
public bool HorseIdExist(int randomId)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetHorseById(randomId);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public HorseInstance GetHorseById(int randomId)
|
||||
{
|
||||
foreach(HorseInstance inst in HorseList)
|
||||
{
|
||||
if (inst.RandomId == randomId)
|
||||
return inst;
|
||||
}
|
||||
throw new KeyNotFoundException();
|
||||
}
|
||||
|
||||
public HorseInstance[] GetHorsesInCategory(HorseInfo.Category category)
|
||||
{
|
||||
List<HorseInstance> instances = new List<HorseInstance>();
|
||||
foreach(HorseInstance horse in HorseList)
|
||||
{
|
||||
if (horse.Category == category.Name)
|
||||
{
|
||||
instances.Add(horse);
|
||||
}
|
||||
}
|
||||
return instances.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
|
||||
interface IInventory
|
||||
{
|
||||
|
||||
void Add(ItemInstance item);
|
||||
void Remove(ItemInstance item);
|
||||
int Count
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
InventoryItem[] GetItemList();
|
||||
|
||||
bool HasItem(int randomId);
|
||||
bool HasItemId(int itemId);
|
||||
|
||||
InventoryItem GetItemByItemId(int itemId);
|
||||
|
||||
InventoryItem GetItemByRandomid(int randomId);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
class InventoryItem
|
||||
{
|
||||
public InventoryItem()
|
||||
{
|
||||
ItemInstances = new List<ItemInstance>();
|
||||
Infinite = false;
|
||||
ItemId = 0;
|
||||
}
|
||||
|
||||
public int ItemId;
|
||||
public bool Infinite;
|
||||
public List<ItemInstance> ItemInstances;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
|
||||
class PlayerInventory : IInventory
|
||||
{
|
||||
|
||||
|
||||
public User BaseUser;
|
||||
private List<InventoryItem> inventoryItems;
|
||||
public PlayerInventory(User forUser)
|
||||
{
|
||||
inventoryItems = new List<InventoryItem>();
|
||||
|
||||
BaseUser = forUser;
|
||||
ItemInstance[] instances = Database.GetPlayerInventory(BaseUser.Id).ToArray();
|
||||
foreach(ItemInstance instance in instances)
|
||||
{
|
||||
addItem(instance, false);
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return inventoryItems.Count;
|
||||
}
|
||||
}
|
||||
private void addItem(ItemInstance item, bool addToDatabase)
|
||||
{
|
||||
if (addToDatabase)
|
||||
Database.AddItemToInventory(BaseUser.Id, item);
|
||||
|
||||
foreach (InventoryItem invetoryItem in inventoryItems)
|
||||
{
|
||||
if (invetoryItem.ItemId == item.ItemId)
|
||||
{
|
||||
invetoryItem.ItemInstances.Add(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
InventoryItem inventoryItem = new InventoryItem();
|
||||
|
||||
inventoryItem.ItemId = item.ItemId;
|
||||
inventoryItem.ItemInstances.Add(item);
|
||||
inventoryItems.Add(inventoryItem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public InventoryItem[] GetItemList()
|
||||
{
|
||||
return inventoryItems.OrderBy(o => o.ItemInstances[0].GetItemInfo().SortBy).ToArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Remove(ItemInstance item)
|
||||
{
|
||||
|
||||
Database.RemoveItemFromInventory(BaseUser.Id, item);
|
||||
|
||||
foreach (InventoryItem inventoryItem in inventoryItems)
|
||||
{
|
||||
if(item.ItemId == inventoryItem.ItemId)
|
||||
{
|
||||
foreach(ItemInstance instance in inventoryItem.ItemInstances)
|
||||
{
|
||||
if(instance.RandomId == item.RandomId)
|
||||
{
|
||||
inventoryItem.ItemInstances.Remove(instance);
|
||||
|
||||
if (inventoryItem.ItemInstances.Count <= 0)
|
||||
inventoryItems.Remove(inventoryItem);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logger.ErrorPrint("Tried to remove item : " + item.RandomId + " from inventory when it was not in it");
|
||||
}
|
||||
|
||||
public bool HasItem(int randomId)
|
||||
{
|
||||
InventoryItem[] items = GetItemList();
|
||||
foreach(InventoryItem item in items)
|
||||
{
|
||||
ItemInstance[] instances = item.ItemInstances.ToArray();
|
||||
foreach(ItemInstance instance in instances)
|
||||
{
|
||||
if (instance.RandomId == randomId)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasItemId(int itemId)
|
||||
{
|
||||
InventoryItem[] items = GetItemList();
|
||||
foreach (InventoryItem item in items)
|
||||
{
|
||||
if (item.ItemId == itemId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public InventoryItem GetItemByItemId(int itemId)
|
||||
{
|
||||
InventoryItem[] items = GetItemList();
|
||||
foreach (InventoryItem item in items)
|
||||
{
|
||||
if (item.ItemId == itemId)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("id: " + itemId + " not found in inventory");
|
||||
}
|
||||
|
||||
public InventoryItem GetItemByRandomid(int randomId)
|
||||
{
|
||||
InventoryItem[] items = GetItemList();
|
||||
foreach (InventoryItem item in items)
|
||||
{
|
||||
ItemInstance[] instances = item.ItemInstances.ToArray();
|
||||
foreach (ItemInstance instance in instances)
|
||||
{
|
||||
if (instance.RandomId == randomId)
|
||||
return item;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("random id: " + randomId + " not found in inventory");
|
||||
}
|
||||
|
||||
public void AddIgnoringFull(ItemInstance item)
|
||||
{
|
||||
addItem(item, true);
|
||||
}
|
||||
public void Add(ItemInstance item)
|
||||
{
|
||||
// Check if has max allready
|
||||
if(HasItemId(item.ItemId))
|
||||
{
|
||||
InventoryItem items = GetItemByItemId(item.ItemId);
|
||||
if (items.ItemInstances.Count >= ConfigReader.MAX_STACK)
|
||||
{
|
||||
throw new InventoryMaxStackException();
|
||||
}
|
||||
else if (Count >= Messages.DefaultInventoryMax)
|
||||
{
|
||||
throw new InventoryFullException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addItem(item, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
using HISP.Game.Services;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
class ShopInventory : IInventory
|
||||
{
|
||||
private Shop baseShop;
|
||||
private List<InventoryItem> inventoryItems;
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return inventoryItems.Count;
|
||||
}
|
||||
}
|
||||
public ShopInventory(Shop shopkeeper)
|
||||
{
|
||||
baseShop = shopkeeper;
|
||||
|
||||
ItemInstance[] instances = Database.GetShopInventory(baseShop.Id).ToArray();
|
||||
inventoryItems = new List<InventoryItem>();
|
||||
|
||||
foreach (ItemInstance instance in instances)
|
||||
{
|
||||
addItem(instance, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void addItem(ItemInstance item, bool addToDatabase)
|
||||
{
|
||||
|
||||
|
||||
foreach (InventoryItem invetoryItem in inventoryItems)
|
||||
{
|
||||
if (invetoryItem.ItemId == item.ItemId)
|
||||
{
|
||||
if (invetoryItem.Infinite) // no need to add +1, theres allready infinite quanity.
|
||||
return;
|
||||
|
||||
invetoryItem.ItemInstances.Add(item);
|
||||
|
||||
goto retrn;
|
||||
}
|
||||
}
|
||||
|
||||
InventoryItem inventoryItem = new InventoryItem();
|
||||
|
||||
inventoryItem.ItemId = item.ItemId;
|
||||
inventoryItem.Infinite = false;
|
||||
inventoryItem.ItemInstances.Add(item);
|
||||
inventoryItems.Add(inventoryItem);
|
||||
|
||||
retrn:
|
||||
{
|
||||
if (addToDatabase)
|
||||
Database.AddItemToShopInventory(baseShop.Id, item);
|
||||
return;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public void AddInfinity(Item.ItemInformation itemInfo)
|
||||
{
|
||||
InventoryItem inventoryItem = new InventoryItem();
|
||||
inventoryItem.ItemId = itemInfo.Id;
|
||||
inventoryItem.Infinite = true;
|
||||
|
||||
for(int i = 0; i < 25; i++) // add 25
|
||||
inventoryItem.ItemInstances.Add(new ItemInstance(inventoryItem.ItemId));
|
||||
|
||||
inventoryItems.Add(inventoryItem);
|
||||
}
|
||||
public void Add(ItemInstance item)
|
||||
{
|
||||
addItem(item, true);
|
||||
}
|
||||
|
||||
public InventoryItem GetItemByItemId(int itemId)
|
||||
{
|
||||
InventoryItem[] items = GetItemList();
|
||||
foreach (InventoryItem item in items)
|
||||
{
|
||||
if (item.ItemId == itemId)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("id: " + itemId + " not found in shop inventory");
|
||||
}
|
||||
|
||||
public InventoryItem GetItemByRandomid(int randomId)
|
||||
{
|
||||
InventoryItem[] items = GetItemList();
|
||||
foreach (InventoryItem item in items)
|
||||
{
|
||||
ItemInstance[] instances = item.ItemInstances.ToArray();
|
||||
foreach (ItemInstance instance in instances)
|
||||
{
|
||||
if (instance.RandomId == randomId)
|
||||
return item;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("random id: " + randomId + " not found in shop inventory");
|
||||
}
|
||||
public InventoryItem[] GetItemList()
|
||||
{
|
||||
return inventoryItems.OrderBy(o => o.ItemInstances[0].GetItemInfo().SortBy).OrderBy(o => o.Infinite).ToArray();
|
||||
}
|
||||
|
||||
public bool HasItem(int randomId)
|
||||
{
|
||||
InventoryItem[] items = GetItemList();
|
||||
foreach (InventoryItem item in items)
|
||||
{
|
||||
ItemInstance[] instances = item.ItemInstances.ToArray();
|
||||
foreach (ItemInstance instance in instances)
|
||||
{
|
||||
if (instance.RandomId == randomId)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasItemId(int itemId)
|
||||
{
|
||||
InventoryItem[] items = GetItemList();
|
||||
foreach (InventoryItem item in items)
|
||||
{
|
||||
if (item.ItemId == itemId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void Remove(ItemInstance item)
|
||||
{
|
||||
|
||||
foreach (InventoryItem inventoryItem in inventoryItems)
|
||||
{
|
||||
if (item.ItemId == inventoryItem.ItemId)
|
||||
{
|
||||
foreach (ItemInstance instance in inventoryItem.ItemInstances)
|
||||
{
|
||||
if (instance.RandomId == item.RandomId)
|
||||
{
|
||||
inventoryItem.ItemInstances.Remove(instance);
|
||||
|
||||
if (inventoryItem.ItemInstances.Count <= 0)
|
||||
inventoryItems.Remove(inventoryItem);
|
||||
|
||||
|
||||
if (!inventoryItem.Infinite) // no need to bug the database.
|
||||
Database.RemoveItemFromShopInventory(baseShop.Id, item);
|
||||
else
|
||||
inventoryItem.ItemInstances.Add(new ItemInstance(inventoryItem.ItemId)); // Gen new item in inventory to replace it.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logger.ErrorPrint("Tried to remove item : " + item.RandomId + " from inventory when it was not in it");
|
||||
}
|
||||
}
|
||||
}
|
154
Horse Isle Server/HorseIsleServer/Game/Item.cs
Normal file
154
Horse Isle Server/HorseIsleServer/Game/Item.cs
Normal file
|
@ -0,0 +1,154 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
class Item
|
||||
{
|
||||
public struct Effects
|
||||
{
|
||||
public string EffectsWhat;
|
||||
public int EffectAmount;
|
||||
}
|
||||
|
||||
public struct SpawnRules
|
||||
{
|
||||
public int SpawnCap;
|
||||
public string SpawnInZone;
|
||||
public string SpawnOnTileType;
|
||||
public string SpawnOnSpecialTile;
|
||||
public string SpawnNearSpecialTile;
|
||||
}
|
||||
public class ItemInformation
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
public string PluralName;
|
||||
public string Description;
|
||||
|
||||
public int IconId;
|
||||
public int SortBy;
|
||||
public int SellPrice;
|
||||
|
||||
public string EmbedSwf;
|
||||
public bool WishingWell;
|
||||
public string Type;
|
||||
public int[] MiscFlags;
|
||||
public Effects[] Effects;
|
||||
|
||||
public SpawnRules SpawnParamaters;
|
||||
|
||||
}
|
||||
|
||||
public struct ThrowableItem
|
||||
{
|
||||
public int Id;
|
||||
public string Message;
|
||||
}
|
||||
|
||||
public static List<ItemInformation> Items = new List<ItemInformation>();
|
||||
public static List<ThrowableItem> ThrowableItems = new List<ThrowableItem>();
|
||||
|
||||
public static int Present;
|
||||
public static int MailMessage;
|
||||
public static int DorothyShoes;
|
||||
public static int PawneerOrder;
|
||||
public static int Telescope;
|
||||
public static int Pitchfork;
|
||||
public static int WishingCoin;
|
||||
public static int FishingPole;
|
||||
public static int Earthworm;
|
||||
|
||||
public static ItemInformation[] GetAllWishableItems()
|
||||
{
|
||||
List<ItemInformation> itemInfo = new List<ItemInformation>();
|
||||
foreach(ItemInformation item in Items)
|
||||
{
|
||||
if (item.WishingWell)
|
||||
itemInfo.Add(item);
|
||||
}
|
||||
return itemInfo.ToArray();
|
||||
}
|
||||
|
||||
public static bool ConsumeItem(User user, ItemInformation itmInfo)
|
||||
{
|
||||
|
||||
bool toMuch = false;
|
||||
foreach (Item.Effects effect in itmInfo.Effects)
|
||||
{
|
||||
switch (effect.EffectsWhat)
|
||||
{
|
||||
case "TIREDNESS":
|
||||
if (user.Tiredness + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Tiredness += effect.EffectAmount;
|
||||
break;
|
||||
case "THIRST":
|
||||
if (user.Thirst + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Thirst += effect.EffectAmount;
|
||||
break;
|
||||
case "HUNGER":
|
||||
if (user.Hunger + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Hunger += effect.EffectAmount;
|
||||
break;
|
||||
default:
|
||||
Logger.ErrorPrint("Unknown effect: " + effect.EffectsWhat);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return toMuch;
|
||||
}
|
||||
public static bool IsThrowable(int id)
|
||||
{
|
||||
foreach(ThrowableItem itm in ThrowableItems)
|
||||
{
|
||||
if(itm.Id == id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ThrowableItem GetThrowableItem(int id)
|
||||
{
|
||||
foreach (ThrowableItem itm in ThrowableItems)
|
||||
{
|
||||
if (itm.Id == id)
|
||||
{
|
||||
return itm;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("id: " + id + " is not a throwable item.");
|
||||
}
|
||||
|
||||
public static bool ItemIdExist(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetItemById(id);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemInformation GetItemById(int id)
|
||||
{
|
||||
foreach(ItemInformation item in Items)
|
||||
{
|
||||
if(item.Id == id)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Item id " + id + " Not found!");
|
||||
}
|
||||
}
|
||||
}
|
26
Horse Isle Server/HorseIsleServer/Game/ItemInstance.cs
Normal file
26
Horse Isle Server/HorseIsleServer/Game/ItemInstance.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using HISP.Security;
|
||||
namespace HISP.Game
|
||||
{
|
||||
class ItemInstance
|
||||
{
|
||||
public int RandomId;
|
||||
public int ItemId;
|
||||
|
||||
|
||||
|
||||
public Item.ItemInformation GetItemInfo()
|
||||
{
|
||||
return Item.GetItemById(ItemId);
|
||||
|
||||
}
|
||||
|
||||
public ItemInstance(int id,int randomId = -1)
|
||||
{
|
||||
RandomId = RandomID.NextRandomId(randomId);
|
||||
|
||||
ItemId = id;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
117
Horse Isle Server/HorseIsleServer/Game/Map.cs
Normal file
117
Horse Isle Server/HorseIsleServer/Game/Map.cs
Normal file
|
@ -0,0 +1,117 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
class Map
|
||||
{
|
||||
public struct TerrainTile
|
||||
{
|
||||
public bool Passable;
|
||||
public string Type;
|
||||
}
|
||||
|
||||
public static int[] OverlayTileDepth;
|
||||
|
||||
public static int Width;
|
||||
public static int Height;
|
||||
|
||||
public static byte[] MapData;
|
||||
public static byte[] oMapData;
|
||||
|
||||
public static TerrainTile[] TerrainTiles;
|
||||
|
||||
|
||||
public static int NewUserStartX;
|
||||
public static int NewUserStartY;
|
||||
public static int GetTileId(int x, int y, bool overlay)
|
||||
{
|
||||
if ((x > Width || x < 0) || (y > Height || y < 0)) // Outside map?
|
||||
return 0x1;
|
||||
|
||||
int pos = ((x * Height) + y);
|
||||
|
||||
if (overlay)
|
||||
return oMapData[pos];
|
||||
else
|
||||
return MapData[pos];
|
||||
}
|
||||
public static bool CheckPassable(int x, int y)
|
||||
{
|
||||
int tileId = GetTileId(x, y, false) - 1;
|
||||
int otileId = GetTileId(x, y, true) - 1;
|
||||
|
||||
bool terrainPassable = TerrainTiles[tileId].Passable;
|
||||
int tileset = 0;
|
||||
|
||||
|
||||
if (otileId > 192)
|
||||
{
|
||||
if (World.InIsle(x, y))
|
||||
tileset = World.GetIsle(x, y).Tileset;
|
||||
otileId = otileId + 64 * tileset;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
if ((!terrainPassable && overlayPassable) && otileId == 0)
|
||||
return false;
|
||||
|
||||
bool passable = false;
|
||||
if (!overlayPassable)
|
||||
passable = false;
|
||||
if (!terrainPassable)
|
||||
passable = false;
|
||||
|
||||
if (!passable && overlayPassable)
|
||||
passable = true;
|
||||
|
||||
|
||||
|
||||
|
||||
return passable;
|
||||
}
|
||||
|
||||
public static void OpenMap()
|
||||
{
|
||||
if(!File.Exists(ConfigReader.MapFile))
|
||||
{
|
||||
Logger.ErrorPrint("Map file not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
byte[] worldMap = File.ReadAllBytes(ConfigReader.MapFile);
|
||||
|
||||
Width = BitConverter.ToInt32(worldMap, 0);
|
||||
Height = BitConverter.ToInt32(worldMap, 4);
|
||||
|
||||
MapData = new byte[Width * Height];
|
||||
oMapData = new byte[Width * Height];
|
||||
int ii = 8;
|
||||
|
||||
for (int i = 0; i < MapData.Length; i++)
|
||||
{
|
||||
|
||||
oMapData[i] = worldMap[ii];
|
||||
MapData[i] = worldMap[ii+ 1];
|
||||
ii += 2;
|
||||
}
|
||||
|
||||
worldMap = null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1405
Horse Isle Server/HorseIsleServer/Game/Messages.cs
Normal file
1405
Horse Isle Server/HorseIsleServer/Game/Messages.cs
Normal file
File diff suppressed because it is too large
Load diff
1372
Horse Isle Server/HorseIsleServer/Game/Meta.cs
Normal file
1372
Horse Isle Server/HorseIsleServer/Game/Meta.cs
Normal file
File diff suppressed because it is too large
Load diff
139
Horse Isle Server/HorseIsleServer/Game/Npc.cs
Normal file
139
Horse Isle Server/HorseIsleServer/Game/Npc.cs
Normal file
|
@ -0,0 +1,139 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
class Npc
|
||||
{
|
||||
public struct NpcReply
|
||||
{
|
||||
public int Id;
|
||||
public string ReplyText;
|
||||
public int GotoChatpoint;
|
||||
public int RequiresQuestIdCompleted;
|
||||
public int RequiresQuestIdNotCompleted;
|
||||
}
|
||||
public struct NpcChat
|
||||
{
|
||||
public int Id;
|
||||
public string ChatText;
|
||||
public int ActivateQuestId;
|
||||
|
||||
public NpcReply[] Replies;
|
||||
}
|
||||
public struct NpcEntry
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
public string AdminDescription;
|
||||
public string ShortDescription;
|
||||
public string LongDescription;
|
||||
public bool Moves;
|
||||
public int X;
|
||||
public int Y;
|
||||
public string StayOn;
|
||||
public int RequiresQuestIdCompleted;
|
||||
public int RequiresQuestIdNotCompleted;
|
||||
public string UDLRScript;
|
||||
public int UDLRStartX;
|
||||
public int UDLRStartY;
|
||||
public bool AdminOnly;
|
||||
public bool LibarySearchable;
|
||||
public int IconId;
|
||||
|
||||
public NpcChat[] Chatpoints;
|
||||
}
|
||||
|
||||
public static List<NpcEntry> NpcList = new List<NpcEntry>();
|
||||
|
||||
public static NpcReply GetNpcReply(NpcEntry npc, int id)
|
||||
{
|
||||
|
||||
foreach (NpcChat chatpoint in npc.Chatpoints)
|
||||
{
|
||||
foreach (NpcReply reply in chatpoint.Replies)
|
||||
{
|
||||
if (reply.Id == id)
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Npc reply with " + id + " not found!");
|
||||
}
|
||||
|
||||
public static NpcReply GetNpcReply(NpcChat chatpoint, int id)
|
||||
{
|
||||
foreach(NpcReply reply in chatpoint.Replies)
|
||||
{
|
||||
if (reply.Id == id)
|
||||
return reply;
|
||||
}
|
||||
throw new KeyNotFoundException("Npc reply with " + id + " not found!");
|
||||
}
|
||||
public static NpcChat GetNpcChatpoint(NpcEntry npc, int chatpointId)
|
||||
{
|
||||
foreach(Npc.NpcChat chatpoint in npc.Chatpoints)
|
||||
{
|
||||
if(chatpoint.Id == chatpointId)
|
||||
{
|
||||
return chatpoint;
|
||||
}
|
||||
}
|
||||
|
||||
throw new KeyNotFoundException("Npc chatpoint id: " + chatpointId + " not found!");
|
||||
}
|
||||
|
||||
public static int GetDefaultChatpoint(User user, NpcEntry npc)
|
||||
{
|
||||
if (Database.HasNpcStartpointSet(user.Id, npc.Id))
|
||||
return Database.GetNpcStartPoint(user.Id, npc.Id);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void SetDefaultChatpoint(User user, NpcEntry npc, int chatpointId)
|
||||
{
|
||||
if (Database.HasNpcStartpointSet(user.Id, npc.Id))
|
||||
Database.SetNpcStartPoint(user.Id, npc.Id, chatpointId);
|
||||
else
|
||||
Database.AddNpcStartPoint(user.Id, npc.Id, chatpointId);
|
||||
}
|
||||
|
||||
|
||||
public static bool NpcExists(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNpcById(id);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static NpcEntry GetNpcById(int id)
|
||||
{
|
||||
foreach(NpcEntry npc in NpcList)
|
||||
{
|
||||
if (npc.Id == id)
|
||||
return npc;
|
||||
}
|
||||
throw new KeyNotFoundException("Npc id: " + id + " not found!");
|
||||
}
|
||||
|
||||
public static NpcEntry[] GetNpcByXAndY(int x, int y)
|
||||
{
|
||||
List<NpcEntry> npcs = new List<NpcEntry>();
|
||||
|
||||
foreach(NpcEntry npc in NpcList)
|
||||
{
|
||||
if (npc.X == x && npc.Y == y)
|
||||
npcs.Add(npc);
|
||||
}
|
||||
return npcs.ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
288
Horse Isle Server/HorseIsleServer/Game/Quest.cs
Normal file
288
Horse Isle Server/HorseIsleServer/Game/Quest.cs
Normal file
|
@ -0,0 +1,288 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
class Quest
|
||||
{
|
||||
public const string Shovel = "SHOVEL";
|
||||
public const string Binoculars = "BINOCS";
|
||||
public const string Rake = "RAKE";
|
||||
public const string MagnifyingGlass = "MAGNIFY";
|
||||
|
||||
public struct QuestItemInfo
|
||||
{
|
||||
public int ItemId;
|
||||
public int Quantity;
|
||||
}
|
||||
public struct QuestAltActivation
|
||||
{
|
||||
public string Type;
|
||||
public int ActivateX;
|
||||
public int ActivateY;
|
||||
}
|
||||
public struct QuestEntry
|
||||
{
|
||||
public int Id;
|
||||
public string Notes;
|
||||
public string Title;
|
||||
|
||||
public int[] RequiresQuestIdCompleteStatsMenu; // Not sure what this is for.
|
||||
public QuestAltActivation AltActivation;
|
||||
public bool Tracked; // Should we track how many times the player has completed this quest.
|
||||
// Fail Settings
|
||||
public int MaxRepeats;
|
||||
public int MoneyCost;
|
||||
public QuestItemInfo[] ItemsRequired;
|
||||
public string FailNpcChat;
|
||||
public int AwardRequired;
|
||||
public int[] RequiresQuestIdCompleted;
|
||||
public int[] RequiresQuestIdNotCompleted;
|
||||
|
||||
// Success Settings
|
||||
public int MoneyEarned;
|
||||
public QuestItemInfo[] ItemsEarned;
|
||||
public int QuestPointsEarned;
|
||||
public int SetNpcChatpoint;
|
||||
public int GotoNpcChatpoint;
|
||||
public int WarpX;
|
||||
public int WarpY;
|
||||
public string SuccessMessage;
|
||||
public string SuccessNpcChat;
|
||||
|
||||
public bool HideReplyOnFail;
|
||||
public string Difficulty;
|
||||
public string Author;
|
||||
public int ChainedQuestId;
|
||||
public bool Minigame;
|
||||
}
|
||||
|
||||
public static List<QuestEntry> QuestList = new List<QuestEntry>();
|
||||
|
||||
public static int GetTotalQuestPoints()
|
||||
{
|
||||
int totalQp = 0;
|
||||
QuestEntry[] quests = GetPublicQuestList();
|
||||
foreach (QuestEntry quest in quests)
|
||||
{
|
||||
totalQp += quest.QuestPointsEarned;
|
||||
}
|
||||
return totalQp;
|
||||
}
|
||||
|
||||
|
||||
public static int GetTotalQuestsComplete(User user)
|
||||
{
|
||||
QuestEntry[] questList = GetPublicQuestList();
|
||||
int totalComplete = 0;
|
||||
foreach (QuestEntry quest in questList)
|
||||
{
|
||||
if (user.Quests.GetTrackedQuestAmount(quest.Id) > 0)
|
||||
totalComplete++;
|
||||
}
|
||||
return totalComplete;
|
||||
}
|
||||
|
||||
|
||||
public static QuestEntry[] GetPublicQuestList()
|
||||
{
|
||||
QuestEntry[] quests = QuestList.OrderBy(o => o.Title).ToArray();
|
||||
List<QuestEntry> sortedQuests = new List<QuestEntry>();
|
||||
foreach (QuestEntry quest in quests)
|
||||
{
|
||||
if (quest.Title != null)
|
||||
sortedQuests.Add(quest);
|
||||
|
||||
}
|
||||
return sortedQuests.ToArray();
|
||||
}
|
||||
|
||||
public static bool CanComplete(User user, QuestEntry quest)
|
||||
{
|
||||
if (quest.Tracked)
|
||||
{
|
||||
|
||||
// Has completed other required quests?
|
||||
foreach (int questId in quest.RequiresQuestIdCompleted)
|
||||
if (user.Quests.GetTrackedQuestAmount(quest.Id) < 1)
|
||||
return false;
|
||||
|
||||
// Has NOT competed other MUST NOT BE required quests
|
||||
foreach (int questId in quest.RequiresQuestIdNotCompleted)
|
||||
if (user.Quests.GetTrackedQuestAmount(quest.Id) > 1)
|
||||
return false;
|
||||
|
||||
// Has allready tracked this quest?
|
||||
if (user.Quests.GetTrackedQuestAmount(quest.Id) >= quest.MaxRepeats)
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// Check if user has award unlocked
|
||||
if (quest.AwardRequired != 0)
|
||||
if (!user.Awards.HasAward(Award.GetAwardById(quest.AwardRequired)))
|
||||
return false;
|
||||
|
||||
// Check if i have required items
|
||||
foreach (QuestItemInfo itemInfo in quest.ItemsRequired)
|
||||
{
|
||||
bool hasThisItem = false;
|
||||
InventoryItem[] items = user.Inventory.GetItemList();
|
||||
foreach (InventoryItem item in items)
|
||||
{
|
||||
if (item.ItemId == itemInfo.ItemId && item.ItemInstances.Count >= itemInfo.Quantity)
|
||||
{
|
||||
hasThisItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasThisItem)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Have enough money?
|
||||
if (user.Money < quest.MoneyCost)
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CompleteQuest(User user, QuestEntry quest, bool npcActivation = false)
|
||||
{
|
||||
// Take Items
|
||||
foreach (QuestItemInfo itemInfo in quest.ItemsRequired)
|
||||
{
|
||||
InventoryItem itm = user.Inventory.GetItemByItemId(itemInfo.ItemId);
|
||||
for (int i = 0; i < itemInfo.Quantity; i++)
|
||||
user.Inventory.Remove(itm.ItemInstances[0]);
|
||||
|
||||
}
|
||||
user.Money -= quest.MoneyCost;
|
||||
// Give money
|
||||
user.Money += quest.MoneyEarned;
|
||||
// Give items
|
||||
foreach (QuestItemInfo itemInfo in quest.ItemsEarned)
|
||||
{
|
||||
for (int i = 0; i < itemInfo.Quantity; i++)
|
||||
{
|
||||
ItemInstance itm = new ItemInstance(itemInfo.ItemId);
|
||||
user.Inventory.AddIgnoringFull(itm);
|
||||
}
|
||||
}
|
||||
if (quest.WarpX != 0 && quest.WarpY != 0)
|
||||
user.Teleport(quest.WarpX, quest.WarpY);
|
||||
|
||||
// Give quest points
|
||||
user.QuestPoints += quest.QuestPointsEarned;
|
||||
|
||||
if (quest.ChainedQuestId != 0)
|
||||
ActivateQuest(user, GetQuestById(quest.ChainedQuestId));
|
||||
|
||||
if (quest.Tracked)
|
||||
user.Quests.TrackQuest(quest.Id);
|
||||
|
||||
|
||||
if (quest.SuccessMessage != null)
|
||||
{
|
||||
byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
user.LoggedinClient.SendPacket(ChatPacket);
|
||||
}
|
||||
|
||||
if (quest.SuccessNpcChat != null)
|
||||
{
|
||||
if (!npcActivation)
|
||||
{
|
||||
byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessNpcChat, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
user.LoggedinClient.SendPacket(ChatPacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check if award unlocked
|
||||
int questPointsPercent = Convert.ToInt32(Math.Floor(((decimal)user.QuestPoints / (decimal)GetTotalQuestPoints()) * (decimal)100.0));
|
||||
if (questPointsPercent >= 25)
|
||||
user.Awards.AddAward(Award.GetAwardById(1)); // 25% Quest Completion Award.
|
||||
if (questPointsPercent >= 50)
|
||||
user.Awards.AddAward(Award.GetAwardById(2)); // 50% Quest Completion Award.
|
||||
if (questPointsPercent >= 75)
|
||||
user.Awards.AddAward(Award.GetAwardById(3)); // 75% Quest Completion Award.
|
||||
if (questPointsPercent >= 100)
|
||||
user.Awards.AddAward(Award.GetAwardById(4)); // 100% Quest Completion Award.
|
||||
|
||||
// Is cloud isles quest?
|
||||
if (quest.Id == 1373)
|
||||
{
|
||||
byte[] swfLoadPacket = PacketBuilder.CreateSwfModulePacket("ballooncutscene", PacketBuilder.PACKET_SWF_CUTSCENE);
|
||||
user.LoggedinClient.SendPacket(swfLoadPacket);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public static bool FailQuest(User user, QuestEntry quest, bool npcActivation = false)
|
||||
{
|
||||
if (quest.FailNpcChat != null)
|
||||
{
|
||||
if (!npcActivation)
|
||||
{
|
||||
byte[] ChatPacket = PacketBuilder.CreateChat(quest.FailNpcChat, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
user.LoggedinClient.SendPacket(ChatPacket);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool ActivateQuest(User user, QuestEntry quest, bool npcActivation = false)
|
||||
{
|
||||
|
||||
if (CanComplete(user, quest))
|
||||
{
|
||||
return CompleteQuest(user, quest, npcActivation);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FailQuest(user, quest, npcActivation);
|
||||
}
|
||||
|
||||
}
|
||||
public static bool DoesQuestExist(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetQuestById(id);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static QuestEntry GetQuestById(int id)
|
||||
{
|
||||
foreach(QuestEntry quest in QuestList)
|
||||
{
|
||||
if(quest.Id == id)
|
||||
{
|
||||
return quest;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("QuestId: " + id + " Dont exist.");
|
||||
}
|
||||
public static bool UseTool(User user, string tool, int x, int y)
|
||||
{
|
||||
foreach(QuestEntry quest in QuestList)
|
||||
{
|
||||
if (quest.AltActivation.Type == tool && quest.AltActivation.ActivateX == x && quest.AltActivation.ActivateY == y)
|
||||
{
|
||||
ActivateQuest(user, quest);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
84
Horse Isle Server/HorseIsleServer/Game/Services/Inn.cs
Normal file
84
Horse Isle Server/HorseIsleServer/Game/Services/Inn.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using HISP.Player;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
class Inn
|
||||
{
|
||||
private static List<Inn> listInns = new List<Inn>();
|
||||
public static Inn[] Inns
|
||||
{
|
||||
get
|
||||
{
|
||||
return listInns.ToArray();
|
||||
}
|
||||
}
|
||||
public int Id;
|
||||
public Item.ItemInformation[] RestsOffered;
|
||||
public Item.ItemInformation[] MealsOffered;
|
||||
public int BuyPercentage;
|
||||
public int CalculateBuyCost(Item.ItemInformation item)
|
||||
{
|
||||
return (int)Math.Floor((float)item.SellPrice * (100.0 / (float)BuyPercentage));
|
||||
}
|
||||
|
||||
public Item.ItemInformation GetStockedItem(int itemId)
|
||||
{
|
||||
|
||||
// Check if inn stock..
|
||||
foreach(Item.ItemInformation offering in RestsOffered)
|
||||
{
|
||||
if (offering.Id == itemId)
|
||||
return offering;
|
||||
}
|
||||
|
||||
foreach (Item.ItemInformation offering in MealsOffered)
|
||||
{
|
||||
if (offering.Id == itemId)
|
||||
return offering;
|
||||
}
|
||||
|
||||
throw new KeyNotFoundException("Item is not stocked by this inn.");
|
||||
}
|
||||
|
||||
|
||||
public Inn(int id, int[] restsOffered, int[] mealsOffered, int buyPercentage)
|
||||
{
|
||||
Id = id;
|
||||
List<Item.ItemInformation> itemInfos = new List<Item.ItemInformation>();
|
||||
|
||||
foreach(int itemId in restsOffered)
|
||||
{
|
||||
itemInfos.Add(Item.GetItemById(itemId));
|
||||
}
|
||||
|
||||
RestsOffered = itemInfos.ToArray();
|
||||
itemInfos.Clear();
|
||||
|
||||
foreach (int itemId in mealsOffered)
|
||||
{
|
||||
itemInfos.Add(Item.GetItemById(itemId));
|
||||
}
|
||||
MealsOffered = itemInfos.ToArray();
|
||||
|
||||
itemInfos.Clear();
|
||||
itemInfos = null;
|
||||
|
||||
BuyPercentage = buyPercentage;
|
||||
listInns.Add(this);
|
||||
}
|
||||
|
||||
public static Inn GetInnById(int id)
|
||||
{
|
||||
foreach (Inn inn in Inns)
|
||||
if (inn.Id == id)
|
||||
return inn;
|
||||
throw new KeyNotFoundException("Inn " + id + " doesnt exist.");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
61
Horse Isle Server/HorseIsleServer/Game/Services/Shop.cs
Normal file
61
Horse Isle Server/HorseIsleServer/Game/Services/Shop.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using HISP.Game.Inventory;
|
||||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
class Shop
|
||||
{
|
||||
public int Id;
|
||||
|
||||
public string[] BuysItemTypes;
|
||||
public int BuyPricePercentage;
|
||||
public int SellPricePercentage;
|
||||
public ShopInventory Inventory;
|
||||
|
||||
public Shop(int[] infiniteStocks)
|
||||
{
|
||||
Id = ShopList.Count+1;
|
||||
this.Inventory = new ShopInventory(this);
|
||||
|
||||
|
||||
foreach(int stock in infiniteStocks)
|
||||
{
|
||||
if (Item.ItemIdExist(stock))
|
||||
this.Inventory.AddInfinity(Item.GetItemById(stock));
|
||||
else
|
||||
Logger.WarnPrint("Item ID: " + stock + " Does not exist.");
|
||||
}
|
||||
Shop.ShopList.Add(this);
|
||||
}
|
||||
|
||||
public int CalculateBuyCost(Item.ItemInformation item)
|
||||
{
|
||||
return (int)Math.Round((float)item.SellPrice * (100.0 / (float)BuyPricePercentage));
|
||||
}
|
||||
public int CalculateSellCost(Item.ItemInformation item)
|
||||
{
|
||||
return (int)Math.Round((float)item.SellPrice * (100.0 / (float)SellPricePercentage));
|
||||
}
|
||||
|
||||
public bool CanSell(Item.ItemInformation item)
|
||||
{
|
||||
foreach(string ItemType in BuysItemTypes)
|
||||
{
|
||||
if(ItemType == item.Type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Static Functions
|
||||
public static List<Shop> ShopList = new List<Shop>();
|
||||
public static Shop GetShopById(int id)
|
||||
{
|
||||
return ShopList[id-1];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
53
Horse Isle Server/HorseIsleServer/Game/Services/Transport.cs
Normal file
53
Horse Isle Server/HorseIsleServer/Game/Services/Transport.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
class Transport
|
||||
{
|
||||
public struct TransportLocation
|
||||
{
|
||||
public int Id;
|
||||
public int Cost;
|
||||
public int GotoX;
|
||||
public int GotoY;
|
||||
public string Type;
|
||||
public string LocationTitle;
|
||||
}
|
||||
|
||||
public struct TransportPoint
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
public int[] Locations;
|
||||
}
|
||||
|
||||
public static List<TransportPoint> TransportPoints = new List<TransportPoint>();
|
||||
public static List<TransportLocation> TransportLocations = new List<TransportLocation>();
|
||||
|
||||
|
||||
public static TransportPoint GetTransportPoint(int x, int y)
|
||||
{
|
||||
foreach(TransportPoint transportPoint in TransportPoints)
|
||||
{
|
||||
if (transportPoint.X == x && transportPoint.Y == y)
|
||||
{
|
||||
return transportPoint;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Cannot find transport point at x:" + x + "y:" + y);
|
||||
}
|
||||
|
||||
public static TransportLocation GetTransportLocation(int id)
|
||||
{
|
||||
foreach (TransportLocation transportLocation in TransportLocations)
|
||||
{
|
||||
if (transportLocation.Id == id)
|
||||
{
|
||||
return transportLocation;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Cannot find transport location at Id:" + id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
39
Horse Isle Server/HorseIsleServer/Game/Services/Vet.cs
Normal file
39
Horse Isle Server/HorseIsleServer/Game/Services/Vet.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
class Vet
|
||||
{
|
||||
|
||||
public static List<Vet> Vets = new List<Vet>();
|
||||
|
||||
public Vet(int id, double price)
|
||||
{
|
||||
Id = id;
|
||||
PriceMultiplier = price;
|
||||
Vets.Add(this);
|
||||
}
|
||||
|
||||
public int Id;
|
||||
public double PriceMultiplier;
|
||||
public int CalculatePrice(int health)
|
||||
{
|
||||
double price = (1000.0 - (double)health) * PriceMultiplier;
|
||||
return Convert.ToInt32(Math.Round(price));
|
||||
}
|
||||
|
||||
public static Vet GetVetById(int id)
|
||||
{
|
||||
foreach(Vet vet in Vets)
|
||||
{
|
||||
if (id == vet.Id)
|
||||
return vet;
|
||||
}
|
||||
throw new KeyNotFoundException("Vet with id: " + id + " Not found.");
|
||||
}
|
||||
}
|
||||
}
|
165
Horse Isle Server/HorseIsleServer/Game/SwfModules/Brickpoet.cs
Normal file
165
Horse Isle Server/HorseIsleServer/Game/SwfModules/Brickpoet.cs
Normal file
|
@ -0,0 +1,165 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.SwfModules
|
||||
{
|
||||
class Brickpoet
|
||||
{
|
||||
public struct PoetryEntry {
|
||||
public int Id;
|
||||
public string Word;
|
||||
public int Room;
|
||||
|
||||
}
|
||||
|
||||
public class PoetryPeice
|
||||
{
|
||||
public PoetryPeice(int PoetId, int RoomId, string PeiceWord)
|
||||
{
|
||||
if(!Database.GetPoetExist(PoetId, RoomId))
|
||||
{
|
||||
Id = PoetId;
|
||||
x = GameServer.RandomNumberGenerator.Next(0, 365);
|
||||
y = GameServer.RandomNumberGenerator.Next(0, 280);
|
||||
Word = PeiceWord;
|
||||
roomId = RoomId;
|
||||
Database.AddPoetWord(PoetId, x, y, RoomId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Id = PoetId;
|
||||
roomId = RoomId;
|
||||
Word = PeiceWord;
|
||||
x = Database.GetPoetPositionX(Id, roomId);
|
||||
y = Database.GetPoetPositionY(Id, roomId);
|
||||
}
|
||||
}
|
||||
public int Id;
|
||||
public int RoomId
|
||||
{
|
||||
get
|
||||
{
|
||||
return roomId;
|
||||
}
|
||||
}
|
||||
public int X
|
||||
{
|
||||
get
|
||||
{
|
||||
return x;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPoetPosition(Id, value, y, roomId);
|
||||
x = value;
|
||||
}
|
||||
|
||||
}
|
||||
public int Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return y;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPoetPosition(Id, x, value, roomId);
|
||||
y = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string Word;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
private int roomId;
|
||||
|
||||
}
|
||||
|
||||
public static List<PoetryEntry> PoetList = new List<PoetryEntry>();
|
||||
private static List<PoetryPeice[]> poetryRooms = new List<PoetryPeice[]>();
|
||||
public static PoetryPeice[][] PoetryRooms
|
||||
{
|
||||
get
|
||||
{
|
||||
return poetryRooms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private static PoetryEntry[] getPoetsInRoom(int roomId)
|
||||
{
|
||||
List<PoetryEntry> entries = new List<PoetryEntry>();
|
||||
|
||||
foreach(PoetryEntry poet in PoetList.ToArray())
|
||||
{
|
||||
if(poet.Room == roomId)
|
||||
{
|
||||
entries.Add(poet);
|
||||
}
|
||||
}
|
||||
|
||||
return entries.ToArray();
|
||||
}
|
||||
private static PoetryPeice[] getPoetryRoom(int roomId)
|
||||
{
|
||||
PoetryEntry[] poetryEntries = getPoetsInRoom(roomId);
|
||||
List<PoetryPeice> peices = new List<PoetryPeice>();
|
||||
foreach (PoetryEntry poetryEntry in poetryEntries)
|
||||
{
|
||||
PoetryPeice peice = new PoetryPeice(poetryEntry.Id, roomId, poetryEntry.Word);
|
||||
peices.Add(peice);
|
||||
}
|
||||
|
||||
return peices.ToArray();
|
||||
}
|
||||
|
||||
public static PoetryPeice[] GetPoetryRoom(int roomId)
|
||||
{
|
||||
foreach(PoetryPeice[] peices in PoetryRooms)
|
||||
{
|
||||
if (peices[0].RoomId == roomId)
|
||||
return peices;
|
||||
}
|
||||
throw new KeyNotFoundException("No poetry room of id: " + roomId + " exists.");
|
||||
}
|
||||
public static PoetryPeice GetPoetryPeice(PoetryPeice[] room, int id)
|
||||
{
|
||||
foreach(PoetryPeice peice in room)
|
||||
{
|
||||
if (peice.Id == id)
|
||||
return peice;
|
||||
}
|
||||
throw new KeyNotFoundException("Peice with id: " + id + " not found in room.");
|
||||
}
|
||||
public static void LoadPoetryRooms()
|
||||
{
|
||||
List<int> rooms = new List<int>();
|
||||
foreach(PoetryEntry entry in PoetList)
|
||||
{
|
||||
if (!rooms.Contains(entry.Room))
|
||||
rooms.Add(entry.Room);
|
||||
}
|
||||
|
||||
foreach(int room in rooms)
|
||||
{
|
||||
Logger.InfoPrint("Loading poetry room: " + room.ToString());
|
||||
poetryRooms.Add(getPoetryRoom(room));
|
||||
if (!Database.LastPlayerExist("P" + room))
|
||||
Database.AddLastPlayer("P" + room, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
117
Horse Isle Server/HorseIsleServer/Game/Tracking.cs
Normal file
117
Horse Isle Server/HorseIsleServer/Game/Tracking.cs
Normal file
|
@ -0,0 +1,117 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
class Tracking
|
||||
{
|
||||
public enum TrackableItem
|
||||
{
|
||||
PirateTreasure,
|
||||
Transport,
|
||||
HorseCapture,
|
||||
Crafting,
|
||||
WishingWell,
|
||||
Training,
|
||||
ArenaLoss,
|
||||
Trading,
|
||||
HorseLease,
|
||||
AutoSells,
|
||||
PegasusTeamup,
|
||||
TackShopGiveaway,
|
||||
QuizWin,
|
||||
RiddleWin,
|
||||
IsleCardsGameWin,
|
||||
HorsePawn,
|
||||
WaterbaloonGameWin,
|
||||
UnicornTeamup,
|
||||
PotOfGold,
|
||||
GameUpdates,
|
||||
UnipegTeamup
|
||||
}
|
||||
|
||||
public class TrackedItem
|
||||
{
|
||||
public TrackedItem(User sbaseUser, TrackableItem what, int itmcount)
|
||||
{
|
||||
What = what;
|
||||
count = itmcount;
|
||||
baseUser = sbaseUser;
|
||||
}
|
||||
|
||||
public TrackableItem What;
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return count;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetTrackedItemCount(baseUser.Id, What, value);
|
||||
count = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int count;
|
||||
private User baseUser;
|
||||
}
|
||||
private List<TrackedItem> trackingItems = new List<TrackedItem>();
|
||||
private User baseUser;
|
||||
public TrackedItem[] TrackingItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return trackingItems.ToArray();
|
||||
}
|
||||
}
|
||||
public Tracking(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
|
||||
for(int i = 0; i < 20; i++)
|
||||
{
|
||||
TrackableItem item = (TrackableItem)i;
|
||||
if(Database.HasTrackedItem(user.Id, item))
|
||||
{
|
||||
TrackedItem trackedItem = new TrackedItem(baseUser, item, Database.GetTrackedCount(user.Id, item));
|
||||
trackingItems.Add(trackedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TrackedItem GetTrackedItem(TrackableItem what)
|
||||
{
|
||||
foreach(TrackedItem trackedItem in TrackingItems)
|
||||
{
|
||||
if (trackedItem.What == what)
|
||||
return trackedItem;
|
||||
}
|
||||
|
||||
// if it doesnt exist- create it
|
||||
TrackedItem item = new TrackedItem(baseUser, what, 0);
|
||||
Database.AddTrackedItem(baseUser.Id, what, 0);
|
||||
trackingItems.Add(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public struct TrackedItemStatsMenu
|
||||
{
|
||||
public string What;
|
||||
public string Value;
|
||||
}
|
||||
public static List<TrackedItemStatsMenu> TrackedItemsStatsMenu = new List<TrackedItemStatsMenu>();
|
||||
public static string GetTrackedItemsStatsMenuName(TrackableItem item)
|
||||
{
|
||||
foreach(TrackedItemStatsMenu trackedItem in TrackedItemsStatsMenu)
|
||||
{
|
||||
if (trackedItem.What == item.ToString())
|
||||
return trackedItem.Value;
|
||||
}
|
||||
|
||||
throw new KeyNotFoundException("no such tracked item found.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
269
Horse Isle Server/HorseIsleServer/Game/World.cs
Normal file
269
Horse Isle Server/HorseIsleServer/Game/World.cs
Normal file
|
@ -0,0 +1,269 @@
|
|||
using System.Collections.Generic;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
|
||||
class World
|
||||
{
|
||||
public struct Isle
|
||||
{
|
||||
public int StartX;
|
||||
public int EndX;
|
||||
public int StartY;
|
||||
public int EndY;
|
||||
public int Tileset;
|
||||
public string Name;
|
||||
}
|
||||
public struct Town
|
||||
{
|
||||
public int StartX;
|
||||
public int EndX;
|
||||
public int StartY;
|
||||
public int EndY;
|
||||
public string Name;
|
||||
}
|
||||
public struct Area
|
||||
{
|
||||
public int StartX;
|
||||
public int EndX;
|
||||
public int StartY;
|
||||
public int EndY;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
public struct Zone
|
||||
{
|
||||
public int StartX;
|
||||
public int EndX;
|
||||
public int StartY;
|
||||
public int EndY;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
|
||||
public struct Time
|
||||
{
|
||||
public int Minutes;
|
||||
public int Days;
|
||||
public int Years;
|
||||
}
|
||||
|
||||
public struct SpecialTile
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
|
||||
public string Title;
|
||||
public string Description;
|
||||
|
||||
public string Code;
|
||||
public int ExitX;
|
||||
public int ExitY;
|
||||
|
||||
public string AutoplaySwf;
|
||||
public string TypeFlag;
|
||||
}
|
||||
public static Time ServerTime = new Time();
|
||||
|
||||
public static List<Isle> Isles = new List<Isle>();
|
||||
public static List<Town> Towns = new List<Town>();
|
||||
public static List<Area> Areas = new List<Area>();
|
||||
public static List<Zone> Zones = new List<Zone>();
|
||||
|
||||
public static List<SpecialTile> SpecialTiles = new List<SpecialTile>();
|
||||
public static void TickWorldClock()
|
||||
{
|
||||
ServerTime.Minutes += 1;
|
||||
|
||||
int hours = ServerTime.Minutes / 60;
|
||||
|
||||
// Periodically write time to database:
|
||||
if (ServerTime.Minutes % 10 == 0) // every 10-in-game minutes)
|
||||
Database.SetServerTime(ServerTime.Minutes, ServerTime.Days, ServerTime.Years);
|
||||
|
||||
if (hours == 24) // 1 day
|
||||
{
|
||||
ServerTime.Days += 1;
|
||||
ServerTime.Minutes = 0;
|
||||
}
|
||||
|
||||
if (ServerTime.Days == 366) // 1 year!
|
||||
{
|
||||
ServerTime.Days = 0;
|
||||
ServerTime.Years += 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReadWorldData()
|
||||
{
|
||||
Logger.DebugPrint("Reading time from database...");
|
||||
ServerTime.Minutes = Database.GetServerTime();
|
||||
ServerTime.Days = Database.GetServerDay();
|
||||
ServerTime.Years = Database.GetServerYear();
|
||||
Logger.InfoPrint("It is " + ServerTime.Minutes / 60 + ":" + ServerTime.Minutes % 60 + " on Day " + ServerTime.Days + " in Year " + ServerTime.Years + "!!!");
|
||||
}
|
||||
|
||||
public static bool InZone(int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetZone(x, y);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static bool InArea(int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetArea(x, y);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool InTown(int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetTown(x, y);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool InSpecialTile(int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetSpecialTile(x, y);
|
||||
return true;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool InIsle(int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetIsle(x, y);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static Zone GetZoneByName(string name)
|
||||
{
|
||||
foreach(Zone zone in Zones)
|
||||
{
|
||||
if (zone.Name == name)
|
||||
return zone;
|
||||
}
|
||||
throw new KeyNotFoundException("Zone not found.");
|
||||
}
|
||||
public static SpecialTile[] GetSpecialTilesByName(string name)
|
||||
{
|
||||
List<SpecialTile> tiles = new List<SpecialTile>();
|
||||
foreach(SpecialTile tile in SpecialTiles)
|
||||
{
|
||||
if(tile.Title == name)
|
||||
{
|
||||
tiles.Add(tile);
|
||||
}
|
||||
}
|
||||
return tiles.ToArray();
|
||||
}
|
||||
public static SpecialTile GetSpecialTile(int x, int y)
|
||||
{
|
||||
foreach(SpecialTile specialTile in SpecialTiles)
|
||||
{
|
||||
if(specialTile.X == x && specialTile.Y == y)
|
||||
{
|
||||
return specialTile;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("x,y not in a special tile!");
|
||||
}
|
||||
public static Isle GetIsle(int x, int y)
|
||||
{
|
||||
foreach(Isle isle in Isles)
|
||||
{
|
||||
|
||||
if (isle.StartX <= x && isle.EndX >= x && isle.StartY <= y && isle.EndY >= y)
|
||||
{
|
||||
return isle;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("x,y not in an isle!");
|
||||
}
|
||||
|
||||
public static Zone GetZone(int x, int y)
|
||||
{
|
||||
foreach (Zone zone in Zones)
|
||||
{
|
||||
|
||||
if (zone.StartX <= x && zone.EndX >= x && zone.StartY <= y && zone.EndY >= y)
|
||||
{
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("x,y not in an zone!");
|
||||
}
|
||||
public static Area GetArea(int x, int y)
|
||||
{
|
||||
foreach (Area area in Areas)
|
||||
{
|
||||
|
||||
if (area.StartX <= x && area.EndX >= x && area.StartY <= y && area.EndY >= y)
|
||||
{
|
||||
return area;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("x,y not in an area!");
|
||||
}
|
||||
|
||||
public static Town GetTown(int x, int y)
|
||||
{
|
||||
foreach (Town town in Towns)
|
||||
{
|
||||
|
||||
if (town.StartX <= x && town.EndX >= x && town.StartY <= y && town.EndY >= y)
|
||||
{
|
||||
return town;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("x,y not in a town!");
|
||||
}
|
||||
|
||||
public static bool CanDropItems(int x, int y)
|
||||
{
|
||||
if (World.InSpecialTile(x, y))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(x, y);
|
||||
if (tile.Code != null)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string GetWeather()
|
||||
{
|
||||
return Database.GetWorldWeather();
|
||||
}
|
||||
}
|
||||
}
|
39
Horse Isle Server/HorseIsleServer/HorseIsleServer.csproj
Normal file
39
Horse Isle Server/HorseIsleServer/HorseIsleServer.csproj
Normal file
|
@ -0,0 +1,39 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>HISP</RootNamespace>
|
||||
<LangVersion>7.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon></ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="icon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MySqlConnector" Version="1.2.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(SolutionDir)..\DataCollection\GameData.json" "$(TargetDir)GameData.json" /Y
|
||||
copy "$(SolutionDir)..\DataCollection\HI1.MAP" "$(TargetDir)HI1.MAP" /Y</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>HorseIsleServer</ActiveDebugProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
97
Horse Isle Server/HorseIsleServer/Player/Award.cs
Normal file
97
Horse Isle Server/HorseIsleServer/Player/Award.cs
Normal file
|
@ -0,0 +1,97 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class Award
|
||||
{
|
||||
public struct AwardEntry
|
||||
{
|
||||
public int Id;
|
||||
public int Sort;
|
||||
public string Title;
|
||||
public int IconId;
|
||||
public int MoneyBonus;
|
||||
public string CompletionText;
|
||||
public string Description;
|
||||
}
|
||||
|
||||
public static AwardEntry[] GlobalAwardList;
|
||||
|
||||
public static AwardEntry GetAwardById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
AwardEntry award = GlobalAwardList[id - 1];
|
||||
if (award.Id == id)
|
||||
return award;
|
||||
}
|
||||
catch (Exception) { };
|
||||
|
||||
foreach(AwardEntry award in GlobalAwardList)
|
||||
{
|
||||
if (award.Id == id)
|
||||
return award;
|
||||
}
|
||||
|
||||
throw new KeyNotFoundException("Award ID " + id + " Does not exist.");
|
||||
}
|
||||
|
||||
|
||||
private List<AwardEntry> awardsEarned;
|
||||
private User baseUser;
|
||||
public AwardEntry[] AwardsEarned
|
||||
{
|
||||
get
|
||||
{
|
||||
return awardsEarned.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAward(AwardEntry award)
|
||||
{
|
||||
foreach(AwardEntry awardEntry in AwardsEarned)
|
||||
{
|
||||
if (awardEntry.Id == award.Id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddAward(AwardEntry award,bool addToDatabase=true)
|
||||
{
|
||||
if (HasAward(award))
|
||||
return;
|
||||
|
||||
if (addToDatabase)
|
||||
{
|
||||
Database.AddAward(baseUser.Id, award.Id);
|
||||
|
||||
baseUser.Money += award.MoneyBonus;
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(award.CompletionText, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
baseUser.LoggedinClient.SendPacket(chatPacket);
|
||||
}
|
||||
|
||||
|
||||
awardsEarned.Add(award);
|
||||
}
|
||||
|
||||
public Award(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
int[] awards = Database.GetAwards(user.Id);
|
||||
awardsEarned = new List<AwardEntry>();
|
||||
|
||||
foreach (int awardid in awards)
|
||||
{
|
||||
AddAward(GetAwardById(awardid), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
using HISP.Game;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player.Equips
|
||||
{
|
||||
class CompetitionGear
|
||||
{
|
||||
public const int MISC_FLAG_HEAD = 1;
|
||||
public const int MISC_FLAG_BODY = 2;
|
||||
public const int MISC_FLAG_LEGS = 3;
|
||||
public const int MISC_FLAG_FEET = 4;
|
||||
|
||||
private int playerId;
|
||||
public CompetitionGear(int PlayerId)
|
||||
{
|
||||
playerId = PlayerId;
|
||||
if (!Database.HasCompetitionGear(PlayerId))
|
||||
Database.InitCompetitionGear(PlayerId);
|
||||
int itemId = Database.GetCompetitionGearHeadPeice(PlayerId);
|
||||
if (itemId != 0)
|
||||
head = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetCompetitionGearBodyPeice(PlayerId);
|
||||
if (itemId != 0)
|
||||
body = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetCompetitionGearLegPeice(PlayerId);
|
||||
if (itemId != 0)
|
||||
legs = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetCompetitionGearFeetPeice(PlayerId);
|
||||
if (itemId != 0)
|
||||
feet = Item.GetItemById(itemId);
|
||||
|
||||
}
|
||||
public Item.ItemInformation Head
|
||||
{
|
||||
get
|
||||
{
|
||||
return head;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
head = null;
|
||||
Database.SetCompetitionGearHeadPeice(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetCompetitionGearHeadPeice(playerId, value.Id);
|
||||
head = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Body
|
||||
{
|
||||
get
|
||||
{
|
||||
return body;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
body = null;
|
||||
Database.SetCompetitionGearBodyPeice(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetCompetitionGearBodyPeice(playerId, value.Id);
|
||||
body = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Legs
|
||||
{
|
||||
get
|
||||
{
|
||||
return legs;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
legs = null;
|
||||
Database.SetCompetitionGearLegPeice(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetCompetitionGearLegPeice(playerId, value.Id);
|
||||
legs = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Feet
|
||||
{
|
||||
get
|
||||
{
|
||||
return feet;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
feet = null;
|
||||
Database.SetCompetitionGearFeetPeice(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetCompetitionGearFeetPeice(playerId, value.Id);
|
||||
feet = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Item.ItemInformation head;
|
||||
private Item.ItemInformation body;
|
||||
private Item.ItemInformation legs;
|
||||
private Item.ItemInformation feet;
|
||||
|
||||
}
|
||||
}
|
112
Horse Isle Server/HorseIsleServer/Player/Equips/Jewelry.cs
Normal file
112
Horse Isle Server/HorseIsleServer/Player/Equips/Jewelry.cs
Normal file
|
@ -0,0 +1,112 @@
|
|||
using HISP.Game;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player.Equips
|
||||
{
|
||||
class Jewelry
|
||||
{
|
||||
|
||||
private int playerId;
|
||||
public Jewelry(int PlayerId)
|
||||
{
|
||||
playerId = PlayerId;
|
||||
if (!Database.HasJewelry(PlayerId))
|
||||
Database.InitJewelry(PlayerId);
|
||||
int itemId = Database.GetJewelrySlot1(PlayerId);
|
||||
if (itemId != 0)
|
||||
slot1 = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetJewelrySlot2(PlayerId);
|
||||
if (itemId != 0)
|
||||
slot2 = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetJewelrySlot3(PlayerId);
|
||||
if (itemId != 0)
|
||||
slot3 = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetJewelrySlot4(PlayerId);
|
||||
if (itemId != 0)
|
||||
slot4 = Item.GetItemById(itemId);
|
||||
|
||||
}
|
||||
public Item.ItemInformation Slot1
|
||||
{
|
||||
get
|
||||
{
|
||||
return slot1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
slot1 = null;
|
||||
Database.SetJewelrySlot1(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetJewelrySlot1(playerId, value.Id);
|
||||
slot1 = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Slot2
|
||||
{
|
||||
get
|
||||
{
|
||||
return slot2;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
slot2 = null;
|
||||
Database.SetJewelrySlot2(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetJewelrySlot2(playerId, value.Id);
|
||||
slot2 = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Slot3
|
||||
{
|
||||
get
|
||||
{
|
||||
return slot3;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
slot3 = null;
|
||||
Database.SetJewelrySlot3(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetJewelrySlot3(playerId, value.Id);
|
||||
slot3 = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Slot4
|
||||
{
|
||||
get
|
||||
{
|
||||
return slot4;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
slot4 = null;
|
||||
Database.SetJewelrySlot4(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetJewelrySlot4(playerId, value.Id);
|
||||
slot4 = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Item.ItemInformation slot1;
|
||||
private Item.ItemInformation slot2;
|
||||
private Item.ItemInformation slot3;
|
||||
private Item.ItemInformation slot4;
|
||||
|
||||
}
|
||||
}
|
65
Horse Isle Server/HorseIsleServer/Player/Friends.cs
Normal file
65
Horse Isle Server/HorseIsleServer/Player/Friends.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System.Collections.Generic;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class Friends
|
||||
{
|
||||
private User baseUser;
|
||||
public List<int> List;
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return List.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public Friends(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
List = new List<int>();
|
||||
|
||||
int[] friends = Database.GetBuddyList(user.Id);
|
||||
foreach(int friendId in friends)
|
||||
{
|
||||
List.Add(friendId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void RemoveFriend(int userid)
|
||||
{
|
||||
Database.RemoveBuddy(baseUser.Id, userid);
|
||||
|
||||
// Remove buddy from there list if they are logged in
|
||||
try
|
||||
{
|
||||
|
||||
User removeFrom = GameServer.GetUserById(userid);
|
||||
removeFrom.Friends.List.Remove(baseUser.Id);
|
||||
}
|
||||
catch (KeyNotFoundException) { /* User is ofline, remove from database is sufficent */ };
|
||||
|
||||
|
||||
baseUser.Friends.List.Remove(userid);
|
||||
}
|
||||
public void AddFriend(User userToFriend)
|
||||
{
|
||||
bool pendingRequest = Database.IsPendingBuddyRequestExist(baseUser.Id, userToFriend.Id);
|
||||
if (pendingRequest)
|
||||
{
|
||||
Database.AcceptBuddyRequest(baseUser.Id, userToFriend.Id);
|
||||
|
||||
List.Add(userToFriend.Id);
|
||||
userToFriend.Friends.List.Add(baseUser.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
Database.AddPendingBuddyRequest(baseUser.Id, userToFriend.Id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
106
Horse Isle Server/HorseIsleServer/Player/Highscore.cs
Normal file
106
Horse Isle Server/HorseIsleServer/Player/Highscore.cs
Normal file
|
@ -0,0 +1,106 @@
|
|||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class Highscore
|
||||
{
|
||||
public class HighscoreTableEntry
|
||||
{
|
||||
public int UserId;
|
||||
public string GameName;
|
||||
public int Wins;
|
||||
public int Looses;
|
||||
public int TimesPlayed;
|
||||
public int Score;
|
||||
public string Type;
|
||||
}
|
||||
public HighscoreTableEntry[] HighscoreList
|
||||
{
|
||||
get
|
||||
{
|
||||
return highScoreList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private User baseUser;
|
||||
private List<HighscoreTableEntry> highScoreList = new List<HighscoreTableEntry>();
|
||||
|
||||
public Highscore(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
HighscoreTableEntry[] highscores = Database.GetPlayerHighScores(user.Id);
|
||||
foreach (HighscoreTableEntry highscore in highscores)
|
||||
highScoreList.Add(highscore);
|
||||
}
|
||||
public HighscoreTableEntry GetHighscore(string gameTitle)
|
||||
{
|
||||
foreach (HighscoreTableEntry highscore in HighscoreList)
|
||||
{
|
||||
if (highscore.GameName == gameTitle)
|
||||
{
|
||||
return highscore;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Highscore for " + gameTitle + " Not found.");
|
||||
}
|
||||
public bool HasHighscore(string gameTitle)
|
||||
{
|
||||
foreach(HighscoreTableEntry highscore in HighscoreList)
|
||||
{
|
||||
if(highscore.GameName == gameTitle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool UpdateHighscore(string gameTitle, int score, bool time)
|
||||
{
|
||||
bool isNewScore = true;
|
||||
|
||||
if (!HasHighscore(gameTitle))
|
||||
{
|
||||
string type = time ? "TIME" : "SCORE";
|
||||
Database.AddNewHighscore(baseUser.Id, gameTitle, score, type);
|
||||
|
||||
HighscoreTableEntry newHighscore = new HighscoreTableEntry();
|
||||
newHighscore.UserId = baseUser.Id;
|
||||
newHighscore.GameName = gameTitle;
|
||||
newHighscore.Wins = 0;
|
||||
newHighscore.Looses = 0;
|
||||
newHighscore.TimesPlayed = 1;
|
||||
newHighscore.Score = score;
|
||||
newHighscore.Type = type;
|
||||
highScoreList.Add(newHighscore);
|
||||
|
||||
return isNewScore;
|
||||
}
|
||||
else
|
||||
{
|
||||
int currentScore = GetHighscore(gameTitle).Score;
|
||||
if (score < currentScore)
|
||||
{
|
||||
score = currentScore;
|
||||
isNewScore = false;
|
||||
}
|
||||
|
||||
Database.UpdateHighscore(baseUser.Id, gameTitle, score);
|
||||
|
||||
for(int i = 0; i < highScoreList.Count; i++)
|
||||
{
|
||||
|
||||
if(highScoreList[i].GameName == gameTitle)
|
||||
{
|
||||
highScoreList[i].TimesPlayed += 1;
|
||||
highScoreList[i].Score = score;
|
||||
}
|
||||
}
|
||||
|
||||
return isNewScore;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
16
Horse Isle Server/HorseIsleServer/Player/Mailbox.cs
Normal file
16
Horse Isle Server/HorseIsleServer/Player/Mailbox.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class Mailbox
|
||||
{
|
||||
private User baseUser;
|
||||
public int MailCount;
|
||||
|
||||
public Mailbox(User user)
|
||||
{
|
||||
MailCount = Database.CheckMailcount(user.Id);
|
||||
baseUser = user;
|
||||
}
|
||||
}
|
||||
}
|
53
Horse Isle Server/HorseIsleServer/Player/PlayerQuests.cs
Normal file
53
Horse Isle Server/HorseIsleServer/Player/PlayerQuests.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System.Collections.Generic;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class PlayerQuests
|
||||
{
|
||||
private List<TrackedQuest> trackedQuests = new List<TrackedQuest>();
|
||||
public User BaseUser;
|
||||
public TrackedQuest[] QuestList
|
||||
{
|
||||
get
|
||||
{
|
||||
return trackedQuests.ToArray();
|
||||
}
|
||||
}
|
||||
public void Add(int questId, int timesCompleted)
|
||||
{
|
||||
TrackedQuest quest = new TrackedQuest(BaseUser.Id, questId, 0);
|
||||
quest.TimesCompleted = timesCompleted;
|
||||
trackedQuests.Add(quest);
|
||||
}
|
||||
public int GetTrackedQuestAmount(int questId)
|
||||
{
|
||||
foreach(TrackedQuest quest in QuestList)
|
||||
{
|
||||
if (quest.QuestId == questId)
|
||||
return quest.TimesCompleted;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void TrackQuest(int questId)
|
||||
{
|
||||
foreach (TrackedQuest quest in QuestList)
|
||||
{
|
||||
if (quest.QuestId == questId)
|
||||
{
|
||||
quest.TimesCompleted++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Add(questId, 1);
|
||||
}
|
||||
public PlayerQuests(User user)
|
||||
{
|
||||
BaseUser = user;
|
||||
TrackedQuest[] quests = Database.GetTrackedQuests(user.Id);
|
||||
foreach (TrackedQuest quest in quests)
|
||||
trackedQuests.Add(quest);
|
||||
}
|
||||
}
|
||||
}
|
30
Horse Isle Server/HorseIsleServer/Player/TrackedQuest.cs
Normal file
30
Horse Isle Server/HorseIsleServer/Player/TrackedQuest.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using HISP.Server;
|
||||
namespace HISP
|
||||
{
|
||||
class TrackedQuest
|
||||
{
|
||||
public TrackedQuest(int playerID, int questID, int timesComplete)
|
||||
{
|
||||
playerId = playerID;
|
||||
QuestId = questID;
|
||||
timesCompleted = timesComplete;
|
||||
}
|
||||
public int QuestId;
|
||||
private int playerId;
|
||||
public int TimesCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
return timesCompleted;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetTrackedQuestCompletedCount(playerId, QuestId, value);
|
||||
timesCompleted = value;
|
||||
}
|
||||
}
|
||||
private int timesCompleted;
|
||||
|
||||
}
|
||||
}
|
455
Horse Isle Server/HorseIsleServer/Player/User.cs
Normal file
455
Horse Isle Server/HorseIsleServer/Player/User.cs
Normal file
|
@ -0,0 +1,455 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HISP.Game;
|
||||
using HISP.Server;
|
||||
using HISP.Player.Equips;
|
||||
using HISP.Game.Services;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Game.Horse;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class User
|
||||
{
|
||||
|
||||
public int Id;
|
||||
public string Username;
|
||||
public bool Administrator;
|
||||
public bool Moderator;
|
||||
public bool NewPlayer = false;
|
||||
public GameClient LoggedinClient;
|
||||
public CompetitionGear EquipedCompetitionGear;
|
||||
public Jewelry EquipedJewelry;
|
||||
public bool MuteAds = false;
|
||||
public bool MuteGlobal = false;
|
||||
public bool MuteIsland = false;
|
||||
public bool MuteNear = false;
|
||||
public bool MuteHere = false;
|
||||
public bool MuteBuddy = false;
|
||||
public bool MutePrivateMessage = false;
|
||||
public bool MuteBuddyRequests = false;
|
||||
public bool MuteSocials = false;
|
||||
public bool MuteAll = false;
|
||||
public bool MuteLogins = false;
|
||||
public bool NoClip = false;
|
||||
public string Gender;
|
||||
public bool MetaPriority = false;
|
||||
|
||||
public bool Idle;
|
||||
public int Facing;
|
||||
public Mailbox MailBox;
|
||||
public Friends Friends;
|
||||
public string Password; // For chat filter.
|
||||
public PlayerInventory Inventory;
|
||||
public Npc.NpcEntry LastTalkedToNpc;
|
||||
public Shop LastShoppedAt;
|
||||
public Inn LastVisitedInn;
|
||||
public HorseInventory HorseInventory;
|
||||
public HorseInstance LastViewedHorse;
|
||||
public HorseInstance CurrentlyRidingHorse;
|
||||
public Tracking TrackedItems;
|
||||
public PlayerQuests Quests;
|
||||
public Highscore Highscores;
|
||||
public Award Awards;
|
||||
public int CapturingHorseId;
|
||||
public DateTime LoginTime;
|
||||
|
||||
public DateTime SubscribedUntil
|
||||
{
|
||||
get
|
||||
{
|
||||
return Converters.UnixTimeStampToDateTime(subscribedUntil);
|
||||
}
|
||||
}
|
||||
public int FreeMinutes
|
||||
{
|
||||
get
|
||||
{
|
||||
int freeTime = Database.GetFreeTime(Id);
|
||||
return freeTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetFreeTime(Id, value);
|
||||
}
|
||||
}
|
||||
public bool Subscribed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConfigReader.AllUsersSubbed)
|
||||
return true;
|
||||
|
||||
int Timestamp = Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds());
|
||||
if(Timestamp > subscribedUntil && subscribed) // sub expired.
|
||||
{
|
||||
Logger.InfoPrint(Username + "'s Subscription expired. (timestamp now: " + Timestamp + " exp date: " + subscribedUntil+" )");
|
||||
Database.SetUserSubscriptionStatus(this.Id, false);
|
||||
subscribed = false;
|
||||
}
|
||||
|
||||
return subscribed;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetUserSubscriptionStatus(this.Id, value);
|
||||
}
|
||||
}
|
||||
public bool Stealth
|
||||
{
|
||||
get
|
||||
{
|
||||
return stealth;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
Database.RemoveOnlineUser(this.Id);
|
||||
else
|
||||
Database.AddOnlineUser(this.Id, this.Administrator, this.Moderator, this.Subscribed);
|
||||
|
||||
stealth = value;
|
||||
}
|
||||
}
|
||||
public int ChatViolations
|
||||
{
|
||||
get
|
||||
{
|
||||
return chatViolations;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetChatViolations(value,Id);
|
||||
chatViolations = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string PrivateNotes
|
||||
{
|
||||
get
|
||||
{
|
||||
return privateNotes;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
Database.SetPlayerNotes(Id, value);
|
||||
privateNotes = value;
|
||||
}
|
||||
}
|
||||
public string ProfilePage {
|
||||
get
|
||||
{
|
||||
return profilePage;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
Database.SetPlayerProfile(value, Id);
|
||||
profilePage = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Money
|
||||
{
|
||||
get
|
||||
{
|
||||
return money;
|
||||
}
|
||||
set
|
||||
{
|
||||
money = value;
|
||||
Database.SetPlayerMoney(value, Id);
|
||||
GameServer.UpdatePlayer(LoggedinClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Experience
|
||||
{
|
||||
get
|
||||
{
|
||||
return experience;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetExperience(Id, value);
|
||||
experience = value;
|
||||
}
|
||||
}
|
||||
public int QuestPoints
|
||||
{
|
||||
get
|
||||
{
|
||||
return questPoints;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPlayerQuestPoints(value, Id);
|
||||
questPoints = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double BankInterest
|
||||
{
|
||||
get
|
||||
{
|
||||
return Database.GetPlayerBankInterest(Id);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 9999999999.9999)
|
||||
value = 9999999999.9999;
|
||||
|
||||
Database.SetPlayerBankInterest(value, Id);
|
||||
}
|
||||
}
|
||||
public double BankMoney
|
||||
{
|
||||
get
|
||||
{
|
||||
return bankMoney;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 9999999999.9999)
|
||||
value = 9999999999.9999;
|
||||
|
||||
Database.SetPlayerBankMoney(value, Id);
|
||||
bankMoney = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int X
|
||||
{
|
||||
get
|
||||
{
|
||||
return x;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPlayerX(value, Id);
|
||||
x = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return y;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPlayerY(value, Id);
|
||||
y = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int CharacterId
|
||||
{
|
||||
get
|
||||
{
|
||||
return charId;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPlayerCharId(value, Id);
|
||||
charId = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Hunger
|
||||
{
|
||||
get
|
||||
{
|
||||
return hunger;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 1000)
|
||||
value = 1000;
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
Database.SetPlayerHunger(Id, value);
|
||||
hunger = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Thirst
|
||||
{
|
||||
get
|
||||
{
|
||||
return thirst;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 1000)
|
||||
value = 1000;
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
Database.SetPlayerThirst(Id, value);
|
||||
thirst = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Tiredness
|
||||
{
|
||||
get
|
||||
{
|
||||
return tired;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 1000)
|
||||
value = 1000;
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
Database.SetPlayerTiredness(Id, value);
|
||||
tired = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int chatViolations;
|
||||
private int charId;
|
||||
private int subscribedUntil;
|
||||
private bool subscribed;
|
||||
private string profilePage;
|
||||
private string privateNotes;
|
||||
private int x;
|
||||
private bool stealth = false;
|
||||
private int y;
|
||||
private int money;
|
||||
private int questPoints;
|
||||
private double bankMoney;
|
||||
private int experience;
|
||||
private int hunger;
|
||||
private int thirst;
|
||||
private int tired;
|
||||
|
||||
|
||||
public byte[] SecCodeSeeds = new byte[3];
|
||||
public int SecCodeInc = 0;
|
||||
public int SecCodeCount = 0;
|
||||
|
||||
|
||||
public int GetPlayerListIcon()
|
||||
{
|
||||
int icon = -1;
|
||||
if (NewPlayer)
|
||||
icon = Messages.NewUserIcon;
|
||||
if (Subscribed)
|
||||
{
|
||||
int months = (DateTime.UtcNow.Month - SubscribedUntil.Month) + 12 * (DateTime.UtcNow.Year - SubscribedUntil.Year);
|
||||
if (months <= 1)
|
||||
icon = Messages.MonthSubscriptionIcon;
|
||||
else if (months <= 3)
|
||||
icon = Messages.ThreeMonthSubscripitionIcon;
|
||||
else
|
||||
icon = Messages.YearSubscriptionIcon;
|
||||
}
|
||||
if (Moderator)
|
||||
icon = Messages.ModeratorIcon;
|
||||
if (Administrator)
|
||||
icon = Messages.AdminIcon;
|
||||
|
||||
return icon;
|
||||
}
|
||||
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()
|
||||
{
|
||||
var i = 0;
|
||||
SecCodeCount++;
|
||||
SecCodeSeeds[SecCodeCount % 3] = (byte)(SecCodeSeeds[SecCodeCount % 3] + SecCodeInc);
|
||||
SecCodeSeeds[SecCodeCount % 3] = (byte)(SecCodeSeeds[SecCodeCount % 3] % 92);
|
||||
i = SecCodeSeeds[0] + SecCodeSeeds[1] * SecCodeSeeds[2] - SecCodeSeeds[1];
|
||||
i = Math.Abs(i);
|
||||
i = i % 92;
|
||||
|
||||
byte[] SecCode = new byte[4];
|
||||
SecCode[0] = (byte)(SecCodeSeeds[0] + 33);
|
||||
SecCode[1] = (byte)(SecCodeSeeds[1] + 33);
|
||||
SecCode[2] = (byte)(SecCodeSeeds[2] + 33);
|
||||
SecCode[3] = (byte)(i + 33);
|
||||
Logger.DebugPrint("Expecting "+Username+" To send Sec Code: "+BitConverter.ToString(SecCode).Replace("-", " "));
|
||||
return SecCode;
|
||||
}
|
||||
|
||||
|
||||
public User(GameClient baseClient, int UserId)
|
||||
{
|
||||
if (!Database.CheckUserExist(UserId))
|
||||
throw new KeyNotFoundException("User " + UserId + " not found in database!");
|
||||
|
||||
if (!Database.CheckUserExtExists(UserId))
|
||||
{
|
||||
Database.CreateUserExt(UserId);
|
||||
NewPlayer = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
EquipedCompetitionGear = new CompetitionGear(UserId);
|
||||
EquipedJewelry = new Jewelry(UserId);
|
||||
|
||||
Id = UserId;
|
||||
Username = Database.GetUsername(UserId);
|
||||
|
||||
Administrator = Database.CheckUserIsAdmin(Username);
|
||||
Moderator = Database.CheckUserIsModerator(Username);
|
||||
|
||||
chatViolations = Database.GetChatViolations(UserId);
|
||||
x = Database.GetPlayerX(UserId);
|
||||
y = Database.GetPlayerY(UserId);
|
||||
charId = Database.GetPlayerCharId(UserId);
|
||||
|
||||
Facing = PacketBuilder.DIRECTION_DOWN;
|
||||
experience = Database.GetExperience(UserId);
|
||||
money = Database.GetPlayerMoney(UserId);
|
||||
bankMoney = Database.GetPlayerBankMoney(UserId);
|
||||
questPoints = Database.GetPlayerQuestPoints(UserId);
|
||||
subscribed = Database.IsUserSubscribed(UserId);
|
||||
subscribedUntil = Database.GetUserSubscriptionExpireDate(UserId);
|
||||
profilePage = Database.GetPlayerProfile(UserId);
|
||||
privateNotes = Database.GetPlayerNotes(UserId);
|
||||
hunger = Database.GetPlayerHunger(UserId);
|
||||
thirst = Database.GetPlayerThirst(UserId);
|
||||
tired = Database.GetPlayerTiredness(UserId);
|
||||
|
||||
Gender = Database.GetGender(UserId);
|
||||
MailBox = new Mailbox(this);
|
||||
Highscores = new Highscore(this);
|
||||
Awards = new Award(this);
|
||||
TrackedItems = new Tracking(this);
|
||||
HorseInventory = new HorseInventory(this);
|
||||
|
||||
// Generate SecCodes
|
||||
|
||||
|
||||
SecCodeSeeds[0] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
|
||||
SecCodeSeeds[1] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
|
||||
SecCodeSeeds[2] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
|
||||
SecCodeInc = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
|
||||
|
||||
|
||||
Friends = new Friends(this);
|
||||
LoginTime = DateTime.UtcNow;
|
||||
LoggedinClient = baseClient;
|
||||
Inventory = new PlayerInventory(this);
|
||||
Quests = new PlayerQuests(this);
|
||||
}
|
||||
}
|
||||
}
|
30
Horse Isle Server/HorseIsleServer/Program.cs
Normal file
30
Horse Isle Server/HorseIsleServer/Program.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using HISP.Game;
|
||||
using HISP.Game.Horse;
|
||||
using HISP.Game.SwfModules;
|
||||
using HISP.Security;
|
||||
using HISP.Server;
|
||||
namespace HISP
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.Title = "HISP - Horse Isle Server Emulator";
|
||||
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
|
||||
ConfigReader.OpenConfig();
|
||||
CrossDomainPolicy.GetPolicy();
|
||||
Database.OpenDatabase();
|
||||
GameDataJson.ReadGamedata();
|
||||
Map.OpenMap();
|
||||
World.ReadWorldData();
|
||||
DroppedItems.Init();
|
||||
WildHorse.Init();
|
||||
Brickpoet.LoadPoetryRooms();
|
||||
GameServer.StartServer();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
36
Horse Isle Server/HorseIsleServer/Properties/AssemblyInfo.cs
Normal file
36
Horse Isle Server/HorseIsleServer/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("HorseIsleServer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("HorseIsleServer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("c48cbd82-ab30-494a-8ffa-4de7069b5827")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
108
Horse Isle Server/HorseIsleServer/Properties/Resources.Designer.cs
generated
Normal file
108
Horse Isle Server/HorseIsleServer/Properties/Resources.Designer.cs
generated
Normal file
|
@ -0,0 +1,108 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace HISP.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HISP.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <cross-domain-policy>
|
||||
/// <allow-access-from domain="*" to-ports="12321" secure="false"/>
|
||||
///</cross-domain-policy>.
|
||||
/// </summary>
|
||||
internal static string DefaultCrossDomain {
|
||||
get {
|
||||
return ResourceManager.GetString("DefaultCrossDomain", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to # HorseIsleServer Default Configuration File
|
||||
///
|
||||
///# Ip address the server will bind to (default: 0.0.0.0 ALL INTERFACES)
|
||||
///ip=0.0.0.0
|
||||
///# Port the server will bind to (default: 12321)
|
||||
///port=12321
|
||||
///
|
||||
///# MariaDB Database
|
||||
///db_ip=127.0.0.1
|
||||
///db_name=beta
|
||||
///db_username=root
|
||||
///db_password=test123
|
||||
///db_port=3306
|
||||
///
|
||||
///# Map Data
|
||||
///map=HI1.MAP
|
||||
///
|
||||
///# JSON Format Data
|
||||
///
|
||||
///gamedata=gamedata.json
|
||||
///
|
||||
///# Cross-Domain Policy File
|
||||
///crossdomain=CrossDomainPolicy.xml
|
||||
///
|
||||
///# Red Text Stating "Todays Note:"
|
||||
///motd=April 11, 2020. New breed, C [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string DefaultServerProperties {
|
||||
get {
|
||||
return ResourceManager.GetString("DefaultServerProperties", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
127
Horse Isle Server/HorseIsleServer/Properties/Resources.resx
Normal file
127
Horse Isle Server/HorseIsleServer/Properties/Resources.resx
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="DefaultCrossDomain" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\default_cross_domain.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="DefaultServerProperties" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Server.properties;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
</root>
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:15584/",
|
||||
"sslPort": 44326
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"HorseIsleServer": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<cross-domain-policy>
|
||||
<allow-access-from domain="*" to-ports="12321" secure="false"/>
|
||||
</cross-domain-policy>
|
|
@ -0,0 +1,47 @@
|
|||
# HISP Default Configuration File
|
||||
|
||||
# Ip address the server will bind to (default: 0.0.0.0 ALL INTERFACES)
|
||||
ip=0.0.0.0
|
||||
# Port the server will bind to (default: 12321)
|
||||
port=12321
|
||||
|
||||
# MariaDB Database
|
||||
db_ip=127.0.0.1
|
||||
db_name=beta
|
||||
db_username=root
|
||||
db_password=test123
|
||||
db_port=3306
|
||||
|
||||
# Map Data
|
||||
map=HI1.MAP
|
||||
|
||||
# JSON Format Data
|
||||
gamedata=gamedata.json
|
||||
|
||||
# Cross-Domain Policy File
|
||||
crossdomain=CrossDomainPolicy.xml
|
||||
|
||||
# Red Text Stating "Todays Note:"
|
||||
motd=April 11, 2020. New breed, Camarillo White Horse. Two new quests.
|
||||
|
||||
# Chat Filter Settings
|
||||
|
||||
# Wether to block 'bad' words
|
||||
# ex 'Fuck You!' gets blocked
|
||||
enable_word_filter=true
|
||||
|
||||
# Wether to expand slang.
|
||||
# ex 'lol' becomes '*laughing out loud!*'
|
||||
# (NOTE: This feature is also used to filter some less-'bad' words disabling it will allow users to say them!)
|
||||
enable_corrections=true
|
||||
|
||||
# Wether or not to consider all users "Subscribers"
|
||||
all_users_subscribed=false
|
||||
|
||||
# Equation is: BANK_BALANCE * (1/INTREST_RATE);
|
||||
# on All servers except Black its 8, on black its 3.
|
||||
# but of course you can make it whatever you want
|
||||
intrest_rate=8
|
||||
|
||||
# Should print extra debug logs
|
||||
debug=false
|
87
Horse Isle Server/HorseIsleServer/Security/Authentication.cs
Normal file
87
Horse Isle Server/HorseIsleServer/Security/Authentication.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Security
|
||||
{
|
||||
class Authentication
|
||||
{
|
||||
public static string DecryptLogin(string encpass)
|
||||
{
|
||||
string decrypt = "";
|
||||
string ROTPOOL = "bl7Jgk61IZdnY mfDN5zjM2XLqTCty4WSEoKR3BFVQsaUhHOAx0rPwp9uc8iGve";
|
||||
string POSPOOL = "DQc3uxiGsKZatMmOS5qYveN71zoPTk8yU0H2w9VjprBXWn l4FJd6IRbhgACfEL";
|
||||
string ROTPOOL2 = "evGi8cu9pwPr0xAOHhUasQVFB3RKoESW4ytCTqLX2Mjz5NDfm YndZI16kgJ7lb";
|
||||
|
||||
|
||||
int i = 0;
|
||||
int ii = 0;
|
||||
while (i < encpass.Length)
|
||||
{
|
||||
int ROT = ROTPOOL.IndexOf(encpass[i].ToString());
|
||||
int POS = POSPOOL.IndexOf(encpass[i + 1].ToString());
|
||||
POS -= (ROT + ii);
|
||||
if (POS < 0)
|
||||
{
|
||||
POS = (POS / -1) - 1;
|
||||
|
||||
while (POS >= ROTPOOL.Length)
|
||||
{
|
||||
POS -= ROTPOOL.Length;
|
||||
}
|
||||
|
||||
decrypt += ROTPOOL2[POS];
|
||||
}
|
||||
else
|
||||
{
|
||||
while (POS >= ROTPOOL.Length)
|
||||
{
|
||||
POS -= ROTPOOL.Length;
|
||||
}
|
||||
|
||||
decrypt += ROTPOOL[POS];
|
||||
}
|
||||
|
||||
i += 2;
|
||||
ii += 1;
|
||||
}
|
||||
return decrypt.Replace(" ", "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static byte[] HashAndSalt(string plaintext, byte[] salt)
|
||||
{
|
||||
byte[] plaintextBytes = Encoding.UTF8.GetBytes(plaintext);
|
||||
|
||||
SHA512 sha512 = new SHA512Managed();
|
||||
byte[] hash = sha512.ComputeHash(plaintextBytes);
|
||||
|
||||
for (int i = 0; i < hash.Length; i++)
|
||||
{
|
||||
hash[i] ^= salt[i];
|
||||
}
|
||||
|
||||
|
||||
byte[] finalHash = sha512.ComputeHash(hash);
|
||||
|
||||
return finalHash;
|
||||
}
|
||||
|
||||
public static bool CheckPassword(string username, string password)
|
||||
{
|
||||
if(Database.CheckUserExist(username))
|
||||
{
|
||||
byte[] expectedPassword = Database.GetPasswordHash(username);
|
||||
byte[] salt = Database.GetPasswordSalt(username);
|
||||
byte[] hashedPassword = HashAndSalt(password, salt);
|
||||
|
||||
if (Enumerable.SequenceEqual(expectedPassword, hashedPassword))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using HISP.Properties;
|
||||
using System;
|
||||
using System.IO;
|
||||
using HISP.Server;
|
||||
namespace HISP.Security
|
||||
{
|
||||
class CrossDomainPolicy
|
||||
{
|
||||
public static byte[] GetPolicy()
|
||||
{
|
||||
if (!File.Exists(ConfigReader.CrossDomainPolicyFile)) {
|
||||
if (ConfigReader.Debug)
|
||||
Console.WriteLine("[DEBUG] Cross-Domain-Policy file not found, using default");
|
||||
File.WriteAllText(ConfigReader.CrossDomainPolicyFile, Resources.DefaultCrossDomain);
|
||||
}
|
||||
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
byte[] policyFileBytes = File.ReadAllBytes(ConfigReader.CrossDomainPolicyFile);
|
||||
ms.Write(policyFileBytes, 0x00, policyFileBytes.Length);
|
||||
ms.WriteByte(0x00);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] policyFileData = ms.ToArray();
|
||||
ms.Close();
|
||||
|
||||
return policyFileData;
|
||||
}
|
||||
}
|
||||
}
|
22
Horse Isle Server/HorseIsleServer/Security/RandomID.cs
Normal file
22
Horse Isle Server/HorseIsleServer/Security/RandomID.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
namespace HISP.Security
|
||||
{
|
||||
class RandomID
|
||||
{
|
||||
private static int prevId = 0;
|
||||
public static int NextRandomId(int randomId=-1)
|
||||
{
|
||||
int rndmId = 0;
|
||||
|
||||
if (randomId == -1)
|
||||
rndmId = prevId+1;
|
||||
else
|
||||
rndmId = randomId;
|
||||
|
||||
if (rndmId >= prevId)
|
||||
prevId = rndmId;
|
||||
|
||||
return rndmId;
|
||||
}
|
||||
}
|
||||
}
|
121
Horse Isle Server/HorseIsleServer/Server/ConfigReader.cs
Normal file
121
Horse Isle Server/HorseIsleServer/Server/ConfigReader.cs
Normal file
|
@ -0,0 +1,121 @@
|
|||
using HISP.Properties;
|
||||
using System.IO;
|
||||
|
||||
namespace HISP.Server
|
||||
{
|
||||
|
||||
class ConfigReader
|
||||
{
|
||||
public static int Port;
|
||||
public static string BindIP;
|
||||
|
||||
public static string DatabaseIP;
|
||||
public static string DatabaseUsername;
|
||||
public static string DatabaseName;
|
||||
public static string DatabasePassword;
|
||||
public static int DatabasePort;
|
||||
public static int IntrestRate;
|
||||
public static string Motd;
|
||||
public static string MapFile;
|
||||
public static string GameDataFile;
|
||||
public static string CrossDomainPolicyFile;
|
||||
|
||||
public static bool Debug;
|
||||
public static bool AllUsersSubbed;
|
||||
public static bool BadWords;
|
||||
public static bool DoCorrections;
|
||||
|
||||
public const int MAX_STACK = 40;
|
||||
|
||||
private static string ConfigurationFileName = "server.properties";
|
||||
public static void OpenConfig()
|
||||
{
|
||||
if (!File.Exists(ConfigurationFileName))
|
||||
{
|
||||
Logger.WarnPrint(ConfigurationFileName+" not found! writing default.");
|
||||
File.WriteAllText(ConfigurationFileName,Resources.DefaultServerProperties);
|
||||
Logger.InfoPrint("! Its very likely database connection will fail...");
|
||||
}
|
||||
|
||||
string[] configFile = File.ReadAllLines(ConfigurationFileName);
|
||||
foreach (string setting in configFile)
|
||||
{
|
||||
/*
|
||||
* Avoid crashing.
|
||||
*/
|
||||
if (setting.Length < 1)
|
||||
continue;
|
||||
if (setting[0] == '#')
|
||||
continue;
|
||||
if (!setting.Contains("="))
|
||||
continue;
|
||||
|
||||
string[] dataPair = setting.Split('=');
|
||||
|
||||
string key = dataPair[0];
|
||||
string data = dataPair[1];
|
||||
/*
|
||||
* Parse configuration file
|
||||
*/
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case "port":
|
||||
Port = int.Parse(data);
|
||||
break;
|
||||
case "ip":
|
||||
BindIP = data;
|
||||
break;
|
||||
case "db_ip":
|
||||
DatabaseIP = data;
|
||||
break;
|
||||
case "db_username":
|
||||
DatabaseUsername = data;
|
||||
break;
|
||||
case "db_password":
|
||||
DatabasePassword = data;
|
||||
break;
|
||||
case "db_name":
|
||||
DatabaseName = data;
|
||||
break;
|
||||
case "db_port":
|
||||
DatabasePort = int.Parse(data);
|
||||
break;
|
||||
case "map":
|
||||
MapFile = data;
|
||||
break;
|
||||
case "motd":
|
||||
Motd = data;
|
||||
break;
|
||||
case "gamedata":
|
||||
GameDataFile = data;
|
||||
break;
|
||||
case "crossdomain":
|
||||
CrossDomainPolicyFile = data;
|
||||
break;
|
||||
case "all_users_subscribed":
|
||||
AllUsersSubbed = data == "true";
|
||||
break;
|
||||
case "enable_corrections":
|
||||
BadWords = data == "true";
|
||||
break;
|
||||
case "enable_word_filter":
|
||||
DoCorrections = data == "true";
|
||||
break;
|
||||
case "intrest_rate":
|
||||
IntrestRate = int.Parse(data);
|
||||
break;
|
||||
case "debug":
|
||||
Debug = data == "true";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
47
Horse Isle Server/HorseIsleServer/Server/Converters.cs
Normal file
47
Horse Isle Server/HorseIsleServer/Server/Converters.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Server
|
||||
{
|
||||
class Converters
|
||||
{
|
||||
// Thanks Stackoverflow (https://stackoverflow.com/questions/321370/how-can-i-convert-a-hex-string-to-a-byte-array)
|
||||
private static int getHexVal(char hex)
|
||||
{
|
||||
int val = (int)hex;
|
||||
//For uppercase A-F letters:
|
||||
//return val - (val < 58 ? 48 : 55);
|
||||
//For lowercase a-f letters:
|
||||
//return val - (val < 58 ? 48 : 87);
|
||||
//Or the two combined, but a bit slower:
|
||||
return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
|
||||
}
|
||||
public static byte[] StringToByteArray(string hex)
|
||||
{
|
||||
if (hex.Length % 2 == 1)
|
||||
throw new ArgumentException("The binary key cannot have an odd number of digits");
|
||||
|
||||
byte[] arr = new byte[hex.Length >> 1];
|
||||
|
||||
for (int i = 0; i < hex.Length >> 1; ++i)
|
||||
{
|
||||
arr[i] = (byte)((getHexVal(hex[i << 1]) << 4) + (getHexVal(hex[(i << 1) + 1])));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
|
||||
{
|
||||
// Unix timestamp is seconds past epoch
|
||||
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
|
||||
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
|
||||
return dtDateTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
3497
Horse Isle Server/HorseIsleServer/Server/Database.cs
Normal file
3497
Horse Isle Server/HorseIsleServer/Server/Database.cs
Normal file
File diff suppressed because it is too large
Load diff
338
Horse Isle Server/HorseIsleServer/Server/GameClient.cs
Normal file
338
Horse Isle Server/HorseIsleServer/Server/GameClient.cs
Normal file
|
@ -0,0 +1,338 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using HISP.Player;
|
||||
using HISP.Game;
|
||||
using HISP.Game.Horse;
|
||||
|
||||
namespace HISP.Server
|
||||
{
|
||||
class GameClient
|
||||
{
|
||||
public Socket ClientSocket;
|
||||
public string RemoteIp;
|
||||
|
||||
public bool LoggedIn = false;
|
||||
public User LoggedinUser;
|
||||
|
||||
private Thread recvPackets;
|
||||
|
||||
private Timer updateTimer;
|
||||
private Timer inactivityTimer;
|
||||
|
||||
private Timer warnTimer;
|
||||
private Timer kickTimer;
|
||||
private Timer minuteTimer;
|
||||
|
||||
|
||||
private int keepAliveInterval = 60 * 1000;
|
||||
private int updateInterval = 60 * 1000;
|
||||
|
||||
private int totalMinutesElapsed = 0;
|
||||
private int oneMinute = 60 * 1000;
|
||||
private int warnInterval = GameServer.IdleWarning * 60 * 1000;
|
||||
private int kickInterval = GameServer.IdleTimeout * 60 * 1000;
|
||||
|
||||
private void minuteTimerTick(object state)
|
||||
{
|
||||
totalMinutesElapsed++;
|
||||
if (LoggedIn)
|
||||
{
|
||||
LoggedinUser.FreeMinutes -= 1;
|
||||
if (LoggedinUser.FreeMinutes <= 0)
|
||||
{
|
||||
LoggedinUser.FreeMinutes = 0;
|
||||
if (!LoggedinUser.Subscribed && !LoggedinUser.Moderator && !LoggedinUser.Administrator)
|
||||
Kick(Messages.KickReasonNoTime);
|
||||
}
|
||||
|
||||
// unsure of actural timings, would be more or less impossible to know
|
||||
// without the original source code :(
|
||||
// From testing hunger seemed to go down fastest, then thirst, and finally tiredness.
|
||||
|
||||
|
||||
foreach(HorseInstance horse in LoggedinUser.HorseInventory.HorseList)
|
||||
{
|
||||
if (totalMinutesElapsed % 2 == 0)
|
||||
{
|
||||
horse.BasicStats.Thirst--;
|
||||
horse.BasicStats.Hunger--;
|
||||
}
|
||||
if (totalMinutesElapsed % 2 == 0 && (horse.BasicStats.Thirst <= 100 || horse.BasicStats.Thirst <= 100 || horse.BasicStats.Tiredness <= 100))
|
||||
horse.BasicStats.Health--;
|
||||
|
||||
if (totalMinutesElapsed % 60 == 0)
|
||||
{
|
||||
horse.BasicStats.Mood--;
|
||||
horse.BasicStats.Shoes--;
|
||||
horse.BasicStats.Tiredness--;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (totalMinutesElapsed % 1 == 0)
|
||||
LoggedinUser.Thirst--;
|
||||
|
||||
if (totalMinutesElapsed % 5 == 0)
|
||||
LoggedinUser.Hunger--;
|
||||
|
||||
if (totalMinutesElapsed % 10 == 0)
|
||||
LoggedinUser.Tiredness--;
|
||||
}
|
||||
|
||||
minuteTimer.Change(oneMinute, oneMinute);
|
||||
}
|
||||
private void keepAliveTimerTick(object state)
|
||||
{
|
||||
Logger.DebugPrint("Sending keep-alive packet to "+ LoggedinUser.Username);
|
||||
byte[] updatePacket = PacketBuilder.CreateKeepAlive();
|
||||
SendPacket(updatePacket);
|
||||
}
|
||||
|
||||
private void warnTimerTick(object state)
|
||||
{
|
||||
Logger.DebugPrint("Sending inactivity warning to: " + RemoteIp);
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatIdleWarningMessage(), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
SendPacket(chatPacket);
|
||||
if (LoggedIn)
|
||||
LoggedinUser.Idle = true;
|
||||
warnTimer.Dispose();
|
||||
warnTimer = null;
|
||||
|
||||
}
|
||||
|
||||
private void kickTimerTick(object state)
|
||||
{
|
||||
Kick(Messages.FormatIdleKickMessage());
|
||||
}
|
||||
private void updateTimerTick(object state)
|
||||
{
|
||||
GameServer.UpdateWorld(this);
|
||||
GameServer.UpdatePlayer(this);
|
||||
}
|
||||
public void Login(int id)
|
||||
{
|
||||
// Check for duplicate
|
||||
foreach(GameClient Client in GameServer.ConnectedClients)
|
||||
{
|
||||
if(Client.LoggedIn)
|
||||
{
|
||||
if (Client.LoggedinUser.Id == id)
|
||||
Client.Kick(Messages.KickReasonDuplicateLogin);
|
||||
}
|
||||
}
|
||||
|
||||
LoggedinUser = new User(this,id);
|
||||
LoggedIn = true;
|
||||
|
||||
updateTimer = new Timer(new TimerCallback(updateTimerTick), null, updateInterval, updateInterval);
|
||||
inactivityTimer = new Timer(new TimerCallback(keepAliveTimerTick), null, keepAliveInterval, keepAliveInterval);
|
||||
}
|
||||
private void receivePackets()
|
||||
{
|
||||
// HI1 Packets are terminates by 0x00 so we have to read until we receive that terminator
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
while(ClientSocket.Connected)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ClientSocket.Available >= 1)
|
||||
{
|
||||
byte[] buffer = new byte[ClientSocket.Available];
|
||||
ClientSocket.Receive(buffer);
|
||||
|
||||
|
||||
foreach (Byte b in buffer)
|
||||
{
|
||||
ms.WriteByte(b);
|
||||
if (b == 0x00)
|
||||
{
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] fullPacket = ms.ToArray();
|
||||
parsePackets(fullPacket);
|
||||
|
||||
ms.Close();
|
||||
ms = new MemoryStream();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch(SocketException e)
|
||||
{
|
||||
Logger.ErrorPrint("Socket exception occured: " + e.Message);
|
||||
Disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void parsePackets(byte[] Packet)
|
||||
{
|
||||
if (Packet.Length < 1)
|
||||
{
|
||||
Logger.ErrorPrint("Received an invalid packet (size: "+Packet.Length+")");
|
||||
}
|
||||
byte identifier = Packet[0];
|
||||
|
||||
// Reset timers
|
||||
|
||||
|
||||
if (inactivityTimer != null && identifier != PacketBuilder.PACKET_KEEP_ALIVE)
|
||||
{
|
||||
if (LoggedIn)
|
||||
LoggedinUser.Idle = false;
|
||||
inactivityTimer.Change(keepAliveInterval, keepAliveInterval);
|
||||
}
|
||||
|
||||
if (kickTimer != null && identifier != PacketBuilder.PACKET_KEEP_ALIVE)
|
||||
kickTimer = new Timer(new TimerCallback(kickTimerTick), null, kickInterval, kickInterval);
|
||||
|
||||
if (warnTimer != null && identifier != PacketBuilder.PACKET_KEEP_ALIVE)
|
||||
warnTimer = new Timer(new TimerCallback(warnTimerTick), null, warnInterval, warnInterval);
|
||||
|
||||
if (!LoggedIn) // Must be either login or policy-file-request
|
||||
{
|
||||
if (Encoding.UTF8.GetString(Packet).StartsWith("<policy-file-request/>")) // Policy File Request
|
||||
{
|
||||
GameServer.OnCrossdomainPolicyRequest(this);
|
||||
}
|
||||
switch (identifier)
|
||||
{
|
||||
case PacketBuilder.PACKET_LOGIN:
|
||||
GameServer.OnLoginRequest(this, Packet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (identifier)
|
||||
{
|
||||
case PacketBuilder.PACKET_LOGIN:
|
||||
GameServer.OnUserInfoRequest(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_MOVE:
|
||||
GameServer.OnMovementPacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_PLAYERINFO:
|
||||
GameServer.OnPlayerInfoPacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_PLAYER:
|
||||
GameServer.OnProfilePacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_CHAT:
|
||||
GameServer.OnChatPacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_CLICK:
|
||||
GameServer.OnClickPacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_KEEP_ALIVE:
|
||||
GameServer.OnKeepAlive(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_TRANSPORT:
|
||||
GameServer.OnTransportUsed(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_INVENTORY:
|
||||
GameServer.OnInventoryRequested(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_DYNAMIC_BUTTON:
|
||||
GameServer.OnDynamicButtonPressed(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_DYNAMIC_INPUT:
|
||||
GameServer.OnDynamicInputReceived(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_ITEM_INTERACTION:
|
||||
GameServer.OnItemInteraction(this,Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_QUIT:
|
||||
GameServer.OnQuitPacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_NPC:
|
||||
GameServer.OnNpcInteraction(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_SWFMODULE:
|
||||
GameServer.OnSwfModuleCommunication(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_HORSE:
|
||||
GameServer.OnHorseInteraction(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_WISH:
|
||||
GameServer.OnWish(this, Packet);
|
||||
break;
|
||||
default:
|
||||
Logger.ErrorPrint("Unimplemented Packet: " + BitConverter.ToString(Packet).Replace('-', ' '));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
|
||||
if(updateTimer != null)
|
||||
updateTimer.Dispose();
|
||||
if(inactivityTimer != null)
|
||||
inactivityTimer.Dispose();
|
||||
if(warnTimer != null)
|
||||
warnTimer.Dispose();
|
||||
if(kickTimer != null)
|
||||
kickTimer.Dispose();
|
||||
|
||||
GameServer.OnDisconnect(this);
|
||||
LoggedIn = false;
|
||||
LoggedinUser = null;
|
||||
ClientSocket.Close();
|
||||
ClientSocket.Dispose();
|
||||
//recvPackets.Anort();
|
||||
}
|
||||
|
||||
public void Kick(string Reason)
|
||||
{
|
||||
byte[] kickPacket = PacketBuilder.CreateKickMessage(Reason);
|
||||
SendPacket(kickPacket);
|
||||
Disconnect();
|
||||
|
||||
Logger.InfoPrint("CLIENT: "+RemoteIp+" KICKED for: "+Reason);
|
||||
}
|
||||
|
||||
public void SendPacket(byte[] PacketData)
|
||||
{
|
||||
try
|
||||
{
|
||||
ClientSocket.Send(PacketData);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorPrint("Exception occured: " + e.Message);
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public GameClient(Socket clientSocket)
|
||||
{
|
||||
ClientSocket = clientSocket;
|
||||
RemoteIp = clientSocket.RemoteEndPoint.ToString();
|
||||
|
||||
Logger.DebugPrint("Client connected @ " + RemoteIp);
|
||||
|
||||
kickTimer = new Timer(new TimerCallback(kickTimerTick), null, kickInterval, kickInterval);
|
||||
warnTimer = new Timer(new TimerCallback(warnTimerTick), null, warnInterval, warnInterval);
|
||||
minuteTimer = new Timer(new TimerCallback(minuteTimerTick), null, oneMinute, oneMinute);
|
||||
|
||||
recvPackets = new Thread(() =>
|
||||
{
|
||||
receivePackets();
|
||||
});
|
||||
recvPackets.Start();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
1048
Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs
Normal file
1048
Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs
Normal file
File diff suppressed because it is too large
Load diff
3913
Horse Isle Server/HorseIsleServer/Server/GameServer.cs
Normal file
3913
Horse Isle Server/HorseIsleServer/Server/GameServer.cs
Normal file
File diff suppressed because it is too large
Load diff
32
Horse Isle Server/HorseIsleServer/Server/Logger.cs
Normal file
32
Horse Isle Server/HorseIsleServer/Server/Logger.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
|
||||
namespace HISP.Server
|
||||
{
|
||||
class Logger
|
||||
{
|
||||
public static void HackerPrint(string text) // When someone is obviously cheating.
|
||||
{
|
||||
ConsoleColor prevColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("[HACK] " + text);
|
||||
Console.ForegroundColor = prevColor;
|
||||
}
|
||||
public static void DebugPrint(string text)
|
||||
{
|
||||
if (ConfigReader.Debug)
|
||||
Console.WriteLine("[DEBUG] " + text);
|
||||
}
|
||||
public static void WarnPrint(string text)
|
||||
{
|
||||
Console.WriteLine("[WARN] " + text);
|
||||
}
|
||||
public static void ErrorPrint(string text)
|
||||
{
|
||||
Console.WriteLine("[ERROR] " + text);
|
||||
}
|
||||
public static void InfoPrint(string text)
|
||||
{
|
||||
Console.WriteLine("[INFO] " + text);
|
||||
}
|
||||
}
|
||||
}
|
844
Horse Isle Server/HorseIsleServer/Server/PacketBuilder.cs
Normal file
844
Horse Isle Server/HorseIsleServer/Server/PacketBuilder.cs
Normal file
|
@ -0,0 +1,844 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using HISP.Game;
|
||||
using HISP.Game.Horse;
|
||||
using HISP.Game.SwfModules;
|
||||
|
||||
namespace HISP.Server
|
||||
{
|
||||
class PacketBuilder
|
||||
{
|
||||
|
||||
public const byte PACKET_TERMINATOR = 0x00;
|
||||
public const byte PACKET_CLIENT_TERMINATOR = 0x0A;
|
||||
|
||||
|
||||
public const byte PACKET_LOGIN = 0x7F;
|
||||
public const byte PACKET_CHAT = 0x14;
|
||||
public const byte PACKET_MOVE = 0x15;
|
||||
public const byte PACKET_CLICK = 0x77;
|
||||
public const byte PACKET_USERINFO = 0x81;
|
||||
public const byte PACKET_WORLD = 0x7A;
|
||||
public const byte PACKET_BASE_STATS = 0x7B;
|
||||
public const byte PACKET_SWF_CUTSCENE = 0x29;
|
||||
public const byte PACKET_SWF_MODULE_FORCE = 0x28;
|
||||
public const byte PACKET_SWF_MODULE_GENTLE = 0x2A;
|
||||
public const byte PACKET_PLACE_INFO = 0x1E;
|
||||
public const byte PACKET_HORSE = 0x19;
|
||||
public const byte PACKET_AREA_DEFS = 0x79;
|
||||
public const byte PACKET_ITEM_INTERACTION = 0x1E;
|
||||
public const byte PACKET_ANNOUNCEMENT = 0x7E;
|
||||
public const byte PACKET_TILE_FLAGS = 0x75;
|
||||
public const byte PACKET_PLAYSOUND = 0x23;
|
||||
public const byte PACKET_KEEP_ALIVE = 0x7C;
|
||||
public const byte PACKET_DYNAMIC_BUTTON = 0x45;
|
||||
public const byte PACKET_DYNAMIC_INPUT = 0x46;
|
||||
public const byte PACKET_PLAYER = 0x18;
|
||||
public const byte PACKET_INVENTORY = 0x17;
|
||||
public const byte PACKET_TRANSPORT = 0x29;
|
||||
public const byte PACKET_KICK = 0x80;
|
||||
public const byte PACKET_LEAVE = 0x7D;
|
||||
public const byte PACKET_NPC = 0x28;
|
||||
public const byte PACKET_QUIT = 0x7D;
|
||||
public const byte PACKET_PLAYERINFO = 0x16;
|
||||
public const byte PACKET_INFORMATION = 0x28;
|
||||
public const byte PACKET_WISH = 0x2C;
|
||||
public const byte PACKET_SWFMODULE = 0x50;
|
||||
|
||||
public const byte HORSE_LIST = 0x0A;
|
||||
public const byte HORSE_LOOK = 0x14;
|
||||
public const byte HORSE_FEED = 0x15;
|
||||
public const byte HORSE_PET = 0x18;
|
||||
public const byte HORSE_PROFILE = 0x2C;
|
||||
public const byte HORSE_PROFILE_EDIT = 0x14;
|
||||
public const byte HORSE_TRY_CAPTURE = 0x1C;
|
||||
public const byte HORSE_RELEASE = 0x19;
|
||||
public const byte HORSE_TACK = 0x16;
|
||||
public const byte HORSE_DRINK = 0x2B;
|
||||
public const byte HORSE_GIVE_FEED = 0x1B;
|
||||
public const byte HORSE_TACK_EQUIP = 0x3C;
|
||||
public const byte HORSE_TACK_UNEQUIP = 0x3D;
|
||||
public const byte HORSE_VET_SERVICE = 0x2A;
|
||||
public const byte HORSE_VET_SERVICE_ALL = 0x2F;
|
||||
public const byte HORSE_MOUNT = 0x46;
|
||||
public const byte HORSE_DISMOUNT = 0x47;
|
||||
public const byte HORSE_ESCAPE = 0x1E;
|
||||
public const byte HORSE_CAUGHT = 0x1D;
|
||||
|
||||
public const byte SWFMODULE_BRICKPOET = 0x5A;
|
||||
|
||||
public const byte BRICKPOET_LIST_ALL = 0x14;
|
||||
public const byte BRICKPOET_MOVE = 0x55;
|
||||
|
||||
public const byte WISH_MONEY = 0x31;
|
||||
public const byte WISH_ITEMS = 0x32;
|
||||
public const byte WISH_WORLDPEACE = 0x33;
|
||||
|
||||
public const byte SECCODE_QUEST = 0x32;
|
||||
public const byte SECCODE_GIVE_ITEM = 0x28;
|
||||
public const byte SECCODE_DELETE_ITEM = 0x29;
|
||||
public const byte SECCODE_SCORE = 0x3D;
|
||||
public const byte SECCODE_TIME = 0x3E;
|
||||
public const byte SECCODE_MONEY = 0x1E;
|
||||
public const byte SECCODE_AWARD = 0x33;
|
||||
|
||||
public const byte NPC_START_CHAT = 0x14;
|
||||
public const byte NPC_CONTINUE_CHAT = 0x15;
|
||||
|
||||
public const byte PLAYERINFO_LEAVE = 0x16;
|
||||
public const byte PLAYERINFO_UPDATE_OR_CREATE = 0x15;
|
||||
public const byte PLAYERINFO_PLAYER_LIST = 0x14;
|
||||
|
||||
public const byte PROFILE_HIGHSCORES_LIST = 0x51;
|
||||
public const byte PROFILE_BESTTIMES_LIST = 0x52;
|
||||
|
||||
public const byte VIEW_PROFILE = 0x14;
|
||||
public const byte SAVE_PROFILE = 0x15;
|
||||
|
||||
public const byte AREA_SEPERATOR = 0x5E;
|
||||
public const byte AREA_TOWN = 0x54;
|
||||
public const byte AREA_AREA = 0x41;
|
||||
public const byte AREA_ISLE = 0x49;
|
||||
|
||||
public const byte MOVE_UP = 0x14;
|
||||
public const byte MOVE_DOWN = 0x15;
|
||||
public const byte MOVE_RIGHT = 0x16;
|
||||
public const byte MOVE_LEFT = 0x17;
|
||||
public const byte MOVE_ESCAPE = 0x18;
|
||||
public const byte MOVE_UPDATE = 0x0A;
|
||||
|
||||
|
||||
public const byte CHAT_BOTTOM_LEFT = 0x14;
|
||||
public const byte CHAT_BOTTOM_RIGHT = 0x15;
|
||||
public const byte CHAT_DM_RIGHT = 0x16;
|
||||
|
||||
public const byte ITEM_INFORMATON = 0x14;
|
||||
public const byte ITEM_INFORMATON_ID = 0x15;
|
||||
public const byte NPC_INFORMATION = 0x16;
|
||||
|
||||
public const byte ITEM_DROP = 0x1E;
|
||||
public const byte ITEM_PICKUP = 0x14;
|
||||
public const byte ITEM_PICKUP_ALL = 0x15;
|
||||
public const byte ITEM_BUY = 0x33;
|
||||
public const byte ITEM_BUY_AND_CONSUME = 0x34;
|
||||
public const byte ITEM_BUY_5 = 0x35;
|
||||
public const byte ITEM_BUY_25 = 0x37;
|
||||
public const byte ITEM_SELL = 0x3C;
|
||||
public const byte ITEM_SELL_ALL = 0x3D;
|
||||
public const byte ITEM_WEAR = 0x46;
|
||||
public const byte ITEM_REMOVE = 0x47;
|
||||
public const byte ITEM_CONSUME = 0x51;
|
||||
public const byte ITEM_DRINK = 0x52;
|
||||
public const byte ITEM_BINOCULARS = 0x5C;
|
||||
public const byte ITEM_MAGNIFYING = 0x5D;
|
||||
public const byte ITEM_RAKE = 0x5B;
|
||||
public const byte ITEM_SHOVEL = 0x5A;
|
||||
|
||||
public const byte LOGIN_INVALID_USER_PASS = 0x15;
|
||||
public const byte LOGIN_CUSTOM_MESSAGE = 0x16;
|
||||
public const byte LOGIN_SUCCESS = 0x14;
|
||||
|
||||
public const byte DIRECTION_UP = 0;
|
||||
public const byte DIRECTION_RIGHT = 1;
|
||||
public const byte DIRECTION_DOWN = 2;
|
||||
public const byte DIRECTION_LEFT = 3;
|
||||
public const byte DIRECTION_TELEPORT = 4;
|
||||
public const byte DIRECTION_NONE = 10;
|
||||
|
||||
public static byte[] CreateBrickPoetMovePacket(Brickpoet.PoetryPeice peice)
|
||||
{
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PacketBuilder.PACKET_SWFMODULE);
|
||||
ms.WriteByte(PacketBuilder.BRICKPOET_MOVE);
|
||||
string packetStr = "|";
|
||||
packetStr += peice.Id + "|";
|
||||
packetStr += peice.X + "|";
|
||||
packetStr += peice.Y + "|";
|
||||
packetStr += "^";
|
||||
|
||||
byte[] infoBytes = Encoding.UTF8.GetBytes(packetStr);
|
||||
ms.Write(infoBytes, 0x00, infoBytes.Length);
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
return ms.ToArray();
|
||||
}
|
||||
public static byte[] CreateBrickPoetListPacket(Brickpoet.PoetryPeice[] room)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PacketBuilder.PACKET_SWFMODULE);
|
||||
string packetStr = "";
|
||||
foreach(Brickpoet.PoetryPeice peice in room)
|
||||
{
|
||||
packetStr += "A";
|
||||
packetStr += "|";
|
||||
packetStr += peice.Id;
|
||||
packetStr += "|";
|
||||
packetStr += peice.Word.ToUpper();
|
||||
packetStr += "|";
|
||||
packetStr += peice.X;
|
||||
packetStr += "|";
|
||||
packetStr += peice.Y;
|
||||
packetStr += "|";
|
||||
packetStr += "^";
|
||||
}
|
||||
byte[] packetBytes = Encoding.UTF8.GetBytes(packetStr);
|
||||
ms.Write(packetBytes, 0x00, packetBytes.Length);
|
||||
ms.WriteByte(PacketBuilder.PACKET_TERMINATOR);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
return ms.ToArray();
|
||||
}
|
||||
public static byte[] CreatePlaysoundPacket(string sound)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_PLAYSOUND);
|
||||
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(sound);
|
||||
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[] CreatePlayerLeavePacket(string username)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
ms.WriteByte(PACKET_PLAYERINFO);
|
||||
ms.WriteByte(PLAYERINFO_LEAVE);
|
||||
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(username);
|
||||
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[] CreatePlayerInfoUpdateOrCreate(int x, int y, int facing, int charId, string username)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
ms.WriteByte(PACKET_PLAYERINFO);
|
||||
ms.WriteByte(PLAYERINFO_UPDATE_OR_CREATE);
|
||||
|
||||
ms.WriteByte((byte)(((x - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((x - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((y - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((y - 1) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(facing + 20));
|
||||
|
||||
ms.WriteByte((byte)((charId / 64) + 20)); //6
|
||||
ms.WriteByte((byte)((charId % 64) + 20)); //7
|
||||
|
||||
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(username);
|
||||
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[] CreateLoginPacket(bool Success, string message="")
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_LOGIN);
|
||||
if (message != "")
|
||||
ms.WriteByte(LOGIN_CUSTOM_MESSAGE);
|
||||
else if (Success)
|
||||
ms.WriteByte(LOGIN_SUCCESS);
|
||||
else
|
||||
ms.WriteByte(LOGIN_INVALID_USER_PASS);
|
||||
|
||||
byte[] loginFailMessage = Encoding.UTF8.GetBytes(message);
|
||||
ms.Write(loginFailMessage, 0x00, loginFailMessage.Length);
|
||||
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
||||
return Packet;
|
||||
}
|
||||
|
||||
public static byte[] CreateProfilePacket(string userProfile)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
ms.WriteByte(PACKET_PLAYER);
|
||||
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(userProfile);
|
||||
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[] CreateHorseRidePacket(int x, int y, int charId, int facing, int direction, bool walk)
|
||||
{
|
||||
// Header information
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_MOVE);
|
||||
|
||||
ms.WriteByte((byte)(((x - 4) / 64) + 20)); //1
|
||||
ms.WriteByte((byte)(((x - 4) % 64) + 20)); //2
|
||||
|
||||
ms.WriteByte((byte)(((y - 1) / 64) + 20)); //3
|
||||
ms.WriteByte((byte)(((y - 1) % 64) + 20)); //4
|
||||
|
||||
ms.WriteByte((byte)(facing + 20)); //5
|
||||
|
||||
ms.WriteByte((byte)((charId / 64) + 20)); //6
|
||||
ms.WriteByte((byte)((charId % 64) + 20)); //7
|
||||
|
||||
ms.WriteByte((byte)(direction + 20)); //8
|
||||
|
||||
ms.WriteByte((byte)(Convert.ToInt32(walk) + 20)); //9\
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] packetData = ms.ToArray();
|
||||
ms.Dispose();
|
||||
return packetData;
|
||||
}
|
||||
|
||||
public static byte[] CreateMovementPacket(int x, int y,int charId,int facing, int direction, bool walk)
|
||||
{
|
||||
// Header information
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_MOVE);
|
||||
|
||||
ms.WriteByte((byte)(((x-4) / 64) + 20)); //1
|
||||
ms.WriteByte((byte)(((x-4) % 64) + 20)); //2
|
||||
|
||||
ms.WriteByte((byte)(((y-1) / 64) + 20)); //3
|
||||
ms.WriteByte((byte)(((y-1) % 64) + 20)); //4
|
||||
|
||||
ms.WriteByte((byte)(facing + 20)); //5
|
||||
|
||||
ms.WriteByte((byte)((charId / 64) + 20)); //6
|
||||
ms.WriteByte((byte)((charId % 64) + 20)); //7
|
||||
ms.WriteByte((byte)(direction + 20)); //8
|
||||
ms.WriteByte((byte)(Convert.ToInt32(walk) + 20)); //9
|
||||
|
||||
|
||||
// Map Data
|
||||
bool moveTwo = false;
|
||||
if(direction >= 20)
|
||||
{
|
||||
direction -= 20;
|
||||
moveTwo = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int ystart = y - 4;
|
||||
int xstart = x - 6;
|
||||
int xend = xstart + 12;
|
||||
int yend = ystart + 9;
|
||||
|
||||
if (direction == DIRECTION_UP)
|
||||
{
|
||||
int totalY = 0;
|
||||
if (moveTwo)
|
||||
{
|
||||
ystart++;
|
||||
totalY = 1;
|
||||
}
|
||||
|
||||
for (int yy = ystart; yy >= ystart - totalY; yy--)
|
||||
{
|
||||
for (int xx = xstart; xx <= xend; xx++)
|
||||
{
|
||||
int tileId = Map.GetTileId(xx, yy, false);
|
||||
int otileId = Map.GetTileId(xx, yy, true);
|
||||
|
||||
if (tileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
tileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)tileId);
|
||||
|
||||
if (otileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
otileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)otileId);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (direction == DIRECTION_LEFT)
|
||||
{
|
||||
int totalX = 0;
|
||||
if (moveTwo)
|
||||
{
|
||||
xstart++;
|
||||
totalX = 1;
|
||||
}
|
||||
|
||||
for (int xx = xstart; xx >= xstart - totalX; xx--)
|
||||
{
|
||||
for (int yy = ystart; yy <= yend; yy++)
|
||||
{
|
||||
int tileId = Map.GetTileId(xx, yy, false);
|
||||
int otileId = Map.GetTileId(xx, yy, true);
|
||||
|
||||
|
||||
|
||||
if (tileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
tileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)tileId);
|
||||
|
||||
if (otileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
otileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)otileId);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (direction == DIRECTION_RIGHT)
|
||||
{
|
||||
int totalX = 0;
|
||||
if (moveTwo)
|
||||
{
|
||||
xend--;
|
||||
totalX = 1;
|
||||
}
|
||||
|
||||
for (int xx = xend; xx <= xend + totalX; xx++)
|
||||
{
|
||||
|
||||
for (int yy = ystart; yy <= yend; yy++)
|
||||
{
|
||||
int tileId = Map.GetTileId(xx, yy, false);
|
||||
int otileId = Map.GetTileId(xx, yy, true);
|
||||
|
||||
|
||||
if (tileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
tileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)tileId);
|
||||
|
||||
if (otileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
otileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)otileId);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (direction == DIRECTION_DOWN)
|
||||
{
|
||||
int totalY = 0;
|
||||
if (moveTwo)
|
||||
{
|
||||
yend--;
|
||||
totalY = 1;
|
||||
}
|
||||
|
||||
for (int yy = yend; yy <= yend + totalY; yy++)
|
||||
{
|
||||
|
||||
for (int xx = xstart; xx <= xend; xx++)
|
||||
{
|
||||
int tileId = Map.GetTileId(xx, yy, false);
|
||||
int otileId = Map.GetTileId(xx, yy, true);
|
||||
|
||||
|
||||
if (tileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
tileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)tileId);
|
||||
|
||||
if (otileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
otileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)otileId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (direction == DIRECTION_TELEPORT)
|
||||
{
|
||||
for(int rely = 0; rely <= 9; rely++)
|
||||
{
|
||||
for (int relx = 0; relx <= 12; relx++)
|
||||
{
|
||||
int tileId = Map.GetTileId(xstart + relx, ystart + rely, false);
|
||||
int otileId = Map.GetTileId(xstart + relx, ystart + rely, true);
|
||||
|
||||
if(tileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
tileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)tileId);
|
||||
|
||||
if (otileId >= 190)
|
||||
{
|
||||
ms.WriteByte((byte)190);
|
||||
otileId -= 100;
|
||||
}
|
||||
ms.WriteByte((byte)otileId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
||||
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)
|
||||
{
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(formattedText);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
ms.WriteByte(PACKET_PLACE_INFO);
|
||||
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[] CreateChat(string formattedText, byte chatWindow)
|
||||
{
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(formattedText);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
ms.WriteByte(PACKET_CHAT);
|
||||
ms.WriteByte(chatWindow);
|
||||
|
||||
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[] CreateWorldData(int gameTime, int gameDay, int gameYear, string weather)
|
||||
{
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(weather);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_WORLD);
|
||||
|
||||
ms.WriteByte((byte)((gameTime / 64) + 20));
|
||||
ms.WriteByte((byte)((gameTime % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)((gameDay / 64) + 20));
|
||||
ms.WriteByte((byte)((gameDay % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)((gameYear / 64) + 20));
|
||||
ms.WriteByte((byte)((gameYear % 64) + 20));
|
||||
|
||||
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[] CreateKeepAlive()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
ms.WriteByte(PACKET_KEEP_ALIVE);
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
||||
return Packet;
|
||||
}
|
||||
public static byte[] CreatePlaceData(World.Isle[] isles, World.Town[] towns, World.Area[] areas)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_AREA_DEFS);
|
||||
|
||||
// Write Towns
|
||||
|
||||
foreach (World.Town town in towns)
|
||||
{
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(town.Name);
|
||||
|
||||
ms.WriteByte(AREA_SEPERATOR);
|
||||
ms.WriteByte(AREA_TOWN);
|
||||
|
||||
ms.WriteByte((byte)(((town.StartX - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((town.StartX - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((town.EndX - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((town.EndX - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((town.StartY - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((town.StartY - 1) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((town.EndY - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((town.EndY - 1) % 64) + 20));
|
||||
|
||||
|
||||
ms.Write(strBytes, 0x00, strBytes.Length);
|
||||
}
|
||||
|
||||
// Write Areas
|
||||
|
||||
foreach (World.Area area in areas)
|
||||
{
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(area.Name);
|
||||
|
||||
ms.WriteByte(AREA_SEPERATOR);
|
||||
ms.WriteByte(AREA_AREA);
|
||||
|
||||
ms.WriteByte((byte)(((area.StartX - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((area.StartX - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((area.EndX - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((area.EndX - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((area.StartY - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((area.StartY - 1) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((area.EndY - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((area.EndY - 1) % 64) + 20));
|
||||
|
||||
|
||||
ms.Write(strBytes, 0x00, strBytes.Length);
|
||||
}
|
||||
|
||||
// Write Isles
|
||||
|
||||
foreach (World.Isle isle in isles)
|
||||
{
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(isle.Name);
|
||||
|
||||
ms.WriteByte(AREA_SEPERATOR);
|
||||
ms.WriteByte(AREA_ISLE);
|
||||
|
||||
ms.WriteByte((byte)(((isle.StartX - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.StartX - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((isle.EndX - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.EndX - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((isle.StartY - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.StartY - 1) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)(((isle.EndY - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.EndY - 1) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)isle.Tileset.ToString()[0]);
|
||||
|
||||
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[] CreatePlayerData(int money, int playerCount, int mail)
|
||||
{
|
||||
byte[] moneyStrBytes = Encoding.UTF8.GetBytes(money.ToString("N0"));
|
||||
byte[] playerStrBytes = Encoding.UTF8.GetBytes(playerCount.ToString("N0"));
|
||||
byte[] mailStrBytes = Encoding.UTF8.GetBytes(mail.ToString("N0"));
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_BASE_STATS);
|
||||
ms.Write(moneyStrBytes, 0x00, moneyStrBytes.Length);
|
||||
ms.WriteByte((byte)'|');
|
||||
ms.Write(playerStrBytes, 0x00, playerStrBytes.Length);
|
||||
ms.WriteByte((byte)'|');
|
||||
ms.Write(mailStrBytes, 0x00, mailStrBytes.Length);
|
||||
ms.WriteByte((byte)'|');
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
||||
return Packet;
|
||||
}
|
||||
|
||||
public static byte[] CreateTileOverlayFlags(int[] tileDepthFlags)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_TILE_FLAGS);
|
||||
|
||||
foreach(int tileDepthFlag in tileDepthFlags)
|
||||
{
|
||||
ms.WriteByte((byte)tileDepthFlag.ToString()[0]);
|
||||
}
|
||||
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
||||
return Packet;
|
||||
}
|
||||
|
||||
public static byte[] CreateSecCode(byte[] SecCodeSeed, int SecCodeInc, bool Admin, bool Moderator)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_USERINFO);
|
||||
|
||||
ms.WriteByte((byte)(SecCodeSeed[0] + 33));
|
||||
ms.WriteByte((byte)(SecCodeSeed[1] + 33));
|
||||
ms.WriteByte((byte)(SecCodeSeed[2] + 33));
|
||||
ms.WriteByte((byte)(SecCodeInc + 33));
|
||||
|
||||
char userType = 'N'; // Normal?
|
||||
if (Moderator)
|
||||
userType = 'M';
|
||||
if (Admin)
|
||||
userType = 'A';
|
||||
|
||||
ms.WriteByte((byte)userType);
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
||||
return Packet;
|
||||
}
|
||||
public static byte[] CreateSwfModulePacket(string swf,byte type)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(type);
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(swf);
|
||||
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[] CreateAnnouncement(string announcement)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_ANNOUNCEMENT);
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(announcement);
|
||||
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[] CreateKickMessage(string reason)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_KICK);
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(reason);
|
||||
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[] CreateMotd()
|
||||
{
|
||||
string formattedMotd = Messages.FormatMOTD();
|
||||
return CreateAnnouncement(formattedMotd);
|
||||
}
|
||||
public static byte[] CreateWelcomeMessage(string username)
|
||||
{
|
||||
string formattedStr = Messages.FormatWelcomeMessage(username);
|
||||
return CreateChat(formattedStr, CHAT_BOTTOM_RIGHT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
BIN
Horse Isle Server/HorseIsleServer/icon.ico
Normal file
BIN
Horse Isle Server/HorseIsleServer/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
Loading…
Add table
Add a link
Reference in a new issue