This commit is contained in:
SilicaAndPina 2020-10-21 14:13:30 +13:00
parent 39e0dbf612
commit 09a0fce73d
9 changed files with 53 additions and 6 deletions

View file

@ -38,6 +38,8 @@
"transport_format":"^LTransport via %METHOD% to %PLACE%^R1^I%ICON%^T4Trip Costs $%COST% one way. ^B1M%XY%^BY%ID%",
"exit_this_place":"^X",
"end_of_meta":"^Z",
"back_to_map":"^M",
"inventory_format":"^ATYour Inventory^H<B>You are carrying the following %ITEMCOUNT% different items:</B> (%MAXITEMS% max)",
"nearby":{
"players_nearby":"<B>Players Nearby:</B>",
"east":"<B>East:</B>",
@ -494,6 +496,7 @@
}
},
"item":{
"max_carryable":40,
"item_list":[
{
"id": 1,

View file

@ -158,6 +158,9 @@ namespace Horse_Isle_Server
case PacketBuilder.PACKET_TRANSPORT:
Server.OnTransportUsed(this, Packet);
break;
case PacketBuilder.PACKET_INVENTORY:
Server.OnInventoryRequested(this, Packet);
break;
default:
Logger.ErrorPrint("Unimplemented Packet: " + BitConverter.ToString(Packet).Replace('-', ' '));
break;

View file

@ -4,9 +4,6 @@ using Newtonsoft.Json;
namespace Horse_Isle_Server
{
class Gamedata
{
@ -235,6 +232,7 @@ namespace Horse_Isle_Server
Messages.DirectChatFormatForSender = gameData.messages.chat.for_sender.dm_format;
Messages.ModChatFormatForSender = gameData.messages.chat.for_sender.mod_format;
Messages.AdminChatFormatForSender = gameData.messages.chat.for_sender.admin_format;
Messages.PasswordNotice = gameData.messages.chat.password_included;
Messages.CapsNotice = gameData.messages.chat.caps_notice;
@ -248,8 +246,10 @@ namespace Horse_Isle_Server
Messages.Seperator = gameData.messages.meta.seperator;
Messages.TileFormat = gameData.messages.meta.tile_format;
Messages.TransportFormat = gameData.messages.meta.transport_format;
Messages.InventoryFormat = gameData.messages.meta.inventory_format;
Messages.NothingMessage = gameData.messages.meta.nothing_message;
Messages.ExitThisPlace = gameData.messages.meta.exit_this_place;
Messages.BackToMap = gameData.messages.meta.back_to_map;
Messages.MetaTerminator = gameData.messages.meta.end_of_meta;
Messages.NearbyPlayers = gameData.messages.meta.nearby.players_nearby;
@ -284,6 +284,10 @@ namespace Horse_Isle_Server
Server.IdleWarning = gameData.messages.disconnect.client_timeout.warn_after;
Server.IdleTimeout = gameData.messages.disconnect.client_timeout.kick_after;
// Inventory
Inventory.DefaultInventoryMax = gameData.item.max_carryable;
// Swf
Messages.WagonCutscene = gameData.transport.wagon_cutscene;
Messages.BoatCutscene = gameData.transport.boat_cutscene;

View file

@ -79,6 +79,7 @@
<Compile Include="Database.cs" />
<Compile Include="Friends.cs" />
<Compile Include="Gamedata.cs" />
<Compile Include="Inventory.cs" />
<Compile Include="Logger.cs" />
<Compile Include="ConfigReader.cs" />
<Compile Include="CrossDomainPolicy.cs" />

View file

@ -41,8 +41,8 @@ namespace Horse_Isle_Server
public static string AdminChatFormatForSender;
public static string ModChatFormatForSender;
public static string ChatViolationMessageFormat;
public static int RequiredChatViolations;
public static string ChatViolationMessageFormat;
public static string PasswordNotice;
public static string CapsNotice;
@ -62,7 +62,10 @@ namespace Horse_Isle_Server
public static string TileFormat;
public static string NothingMessage;
public static string Seperator;
public static string InventoryFormat;
public static string ExitThisPlace;
public static string BackToMap;
public static string MetaTerminator;
// Disconnect Messages
@ -79,6 +82,10 @@ namespace Horse_Isle_Server
return ChatViolationMessageFormat.Replace("%AMOUNT%", RequiredChatViolations.ToString()).Replace("%REASON%", violationReason.Message);
}
public static string FormatInventoryMeta(int itemCount, int maxItems)
{
return InventoryFormat.Replace("%ITEMCOUNT%", itemCount.ToString()).Replace("%MAXITEMS%", maxItems.ToString());
}
// Meta
public static string FormatTransportMessage(string method, string place, int cost, int id, int x, int y)
{

View file

@ -125,6 +125,14 @@ namespace Horse_Isle_Server
return message;
}
public static string BuildInventoryInfo(Inventory inv)
{
string message = "";
message += Messages.FormatInventoryMeta(inv.ItemList.Count, inv.MaxItems);
return message;
}
public static string BuildMetaInfo(int x, int y)
{
string message = "";

View file

@ -26,6 +26,7 @@ namespace Horse_Isle_Server
public const byte PACKET_PLAYSOUND = 0x23;
public const byte PACKET_KEEP_ALIVE = 0x7C;
public const byte PACKET_PROFILE = 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;
@ -329,7 +330,7 @@ namespace Horse_Isle_Server
return Packet;
}
public static byte[] CreatePlaceInfo(string formattedText)
public static byte[] CreateMetaPacket(string formattedText)
{
byte[] strBytes = Encoding.UTF8.GetBytes(formattedText);

View file

@ -424,6 +424,23 @@ namespace Horse_Isle_Server
sender.SendPacket(chatPacketSender);
}
public static void OnInventoryRequested(Client sender, byte[] packet)
{
if (!sender.LoggedIn)
{
Logger.ErrorPrint(sender.RemoteIp + " Sent chat packet when not logged in.");
return;
}
if (packet.Length < 2)
{
Logger.ErrorPrint(sender.RemoteIp + " Sent an invalid chat packet.");
return;
}
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildInventoryInfo(sender.LoggedinUser.ItemInventory));
sender.SendPacket(metaPacket);
}
public static void OnLoginRequest(Client sender, byte[] packet)
{
Logger.DebugPrint("Login request received from: " + sender.RemoteIp);
@ -688,7 +705,7 @@ namespace Horse_Isle_Server
return;
LocationStr = Meta.BuildSpecialTileInfo(specialTile);
}
byte[] AreaMessage = PacketBuilder.CreatePlaceInfo(LocationStr);
byte[] AreaMessage = PacketBuilder.CreateMetaPacket(LocationStr);
forClient.SendPacket(AreaMessage);
}

View file

@ -29,6 +29,7 @@ namespace Horse_Isle_Server
public Mailbox MailBox;
public Friends Friends;
public string Password; // For chat filter.
public Inventory ItemInventory;
public int ChatViolations
{
get
@ -161,6 +162,8 @@ namespace Horse_Isle_Server
NewPlayer = true;
}
ItemInventory = new Inventory();
Id = UserId;
Username = Database.GetUsername(UserId);