mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-10 07:05:41 +12:00
Fix ordering and fully implement "View Companion"
This commit is contained in:
parent
bd149e4ecf
commit
7bf0f37427
7 changed files with 91 additions and 43 deletions
|
@ -122,10 +122,7 @@ namespace HISP.Game.Horse
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int offsetBy = 0;
|
return baseHorse.Equipment.Companion.GetMiscFlag(0);
|
||||||
if (baseHorse.Equipment.Companion != null)
|
|
||||||
offsetBy += getOffetFrom(baseHorse.Equipment.Companion);
|
|
||||||
return offsetBy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int TackOffset
|
public int TackOffset
|
||||||
|
@ -134,11 +131,11 @@ namespace HISP.Game.Horse
|
||||||
{
|
{
|
||||||
int offsetBy = 0;
|
int offsetBy = 0;
|
||||||
if (baseHorse.Equipment.Saddle != null)
|
if (baseHorse.Equipment.Saddle != null)
|
||||||
offsetBy += getOffetFrom(baseHorse.Equipment.Saddle);
|
offsetBy += getOffsetFrom(baseHorse.Equipment.Saddle);
|
||||||
if (baseHorse.Equipment.SaddlePad != null)
|
if (baseHorse.Equipment.SaddlePad != null)
|
||||||
offsetBy += getOffetFrom(baseHorse.Equipment.SaddlePad);
|
offsetBy += getOffsetFrom(baseHorse.Equipment.SaddlePad);
|
||||||
if (baseHorse.Equipment.Bridle != null)
|
if (baseHorse.Equipment.Bridle != null)
|
||||||
offsetBy += getOffetFrom(baseHorse.Equipment.Bridle);
|
offsetBy += getOffsetFrom(baseHorse.Equipment.Bridle);
|
||||||
return offsetBy;
|
return offsetBy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +147,7 @@ namespace HISP.Game.Horse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getOffetFrom(Item.ItemInformation tackPeice)
|
private int getOffsetFrom(Item.ItemInformation tackPeice)
|
||||||
{
|
{
|
||||||
int offsetBy = 0;
|
int offsetBy = 0;
|
||||||
foreach (Item.Effects effect in baseHorse.Equipment.Bridle.Effects)
|
foreach (Item.Effects effect in baseHorse.Equipment.Bridle.Effects)
|
||||||
|
|
|
@ -40,6 +40,14 @@ namespace HISP.Game.Items
|
||||||
|
|
||||||
public SpawnRules SpawnParamaters;
|
public SpawnRules SpawnParamaters;
|
||||||
|
|
||||||
|
public int GetMiscFlag(int no)
|
||||||
|
{
|
||||||
|
if(MiscFlags.Length <= no)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return MiscFlags[no];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct ThrowableItem
|
public struct ThrowableItem
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace HISP.Game.Items
|
||||||
{
|
{
|
||||||
foreach(Item.ItemInformation tackItem in TackItems)
|
foreach(Item.ItemInformation tackItem in TackItems)
|
||||||
{
|
{
|
||||||
if(tackItem.MiscFlags[0] == 1) // Saddle
|
if(tackItem.GetMiscFlag(0) == 1) // Saddle
|
||||||
return tackItem;
|
return tackItem;
|
||||||
}
|
}
|
||||||
throw new KeyNotFoundException("Saddle not found.");
|
throw new KeyNotFoundException("Saddle not found.");
|
||||||
|
@ -46,7 +46,7 @@ namespace HISP.Game.Items
|
||||||
{
|
{
|
||||||
foreach(Item.ItemInformation tackItem in TackItems)
|
foreach(Item.ItemInformation tackItem in TackItems)
|
||||||
{
|
{
|
||||||
if(tackItem.MiscFlags[0] == 2) // SaddlePad
|
if(tackItem.GetMiscFlag(0) == 2) // SaddlePad
|
||||||
return tackItem;
|
return tackItem;
|
||||||
}
|
}
|
||||||
throw new KeyNotFoundException("SaddlePad not found.");
|
throw new KeyNotFoundException("SaddlePad not found.");
|
||||||
|
@ -56,7 +56,7 @@ namespace HISP.Game.Items
|
||||||
{
|
{
|
||||||
foreach(Item.ItemInformation tackItem in TackItems)
|
foreach(Item.ItemInformation tackItem in TackItems)
|
||||||
{
|
{
|
||||||
if(tackItem.MiscFlags[0] == 3) // Bridle
|
if(tackItem.GetMiscFlag(0) == 3) // Bridle
|
||||||
return tackItem;
|
return tackItem;
|
||||||
}
|
}
|
||||||
throw new KeyNotFoundException("GetBridle not found.");
|
throw new KeyNotFoundException("GetBridle not found.");
|
||||||
|
@ -79,6 +79,18 @@ namespace HISP.Game.Items
|
||||||
return tackItems.ToArray();
|
return tackItems.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public int SortPosition()
|
||||||
|
{
|
||||||
|
int pos = 0;
|
||||||
|
foreach(Item.ItemInformation tackitem in TackItems)
|
||||||
|
{
|
||||||
|
foreach(Item.Effects effect in tackitem.Effects)
|
||||||
|
{
|
||||||
|
pos += effect.EffectAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private static string capitalizeFirstLetter(string str)
|
private static string capitalizeFirstLetter(string str)
|
||||||
{
|
{
|
||||||
|
|
|
@ -526,7 +526,7 @@ namespace HISP.Game
|
||||||
}
|
}
|
||||||
public static string FormatCompanionViewButton(int iconid, string itemName, string swf)
|
public static string FormatCompanionViewButton(int iconid, string itemName, string swf)
|
||||||
{
|
{
|
||||||
return CompanionViewFormat.Replace("%ICONID%", iconId.ToString()).Replace("%COMPANIONNAME%",itemName).Replace("%SWF%", swf);
|
return CompanionViewFormat.Replace("%ICONID%", iconid.ToString()).Replace("%COMPANIONNAME%",itemName).Replace("%SWF%", swf);
|
||||||
}
|
}
|
||||||
public static string FormatTackSetPeice(string itemName, string itemDescription)
|
public static string FormatTackSetPeice(string itemName, string itemDescription)
|
||||||
{
|
{
|
||||||
|
|
|
@ -330,7 +330,7 @@ namespace HISP.Game
|
||||||
{
|
{
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
||||||
foreach(Tack.TackSet set in Tack.TackSets)
|
foreach(Tack.TackSet set in Tack.TackSets.OrderBy(o => o.SortPosition()).ToArray())
|
||||||
{
|
{
|
||||||
string[] setSwfs = set.GetSwfNames();
|
string[] setSwfs = set.GetSwfNames();
|
||||||
string swf = "breedviewer.swf?terrain=book2&breed=tackonly";
|
string swf = "breedviewer.swf?terrain=book2&breed=tackonly";
|
||||||
|
@ -361,6 +361,23 @@ namespace HISP.Game
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string BuildCompanionLibary()
|
||||||
|
{
|
||||||
|
string message = "";
|
||||||
|
foreach(Item.ItemInformation itm in Item.Items.OrderBy(o => o.GetMiscFlag(0)).ToArray())
|
||||||
|
{
|
||||||
|
if(itm.Type == "COMPANION" && itm.EmbedSwf != null)
|
||||||
|
{
|
||||||
|
string swf = "breedviewer.swf?terrain=book2&breed=tackonly&companion="+itm.EmbedSwf+"&j=";
|
||||||
|
message += Messages.FormatCompanionViewButton(itm.IconId, itm.Name, swf);
|
||||||
|
message += Messages.FormatCompanionEntry(itm.Description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message += Messages.BackToMap;
|
||||||
|
message += Messages.MetaTerminator;
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
public static string BuildHorseReleased()
|
public static string BuildHorseReleased()
|
||||||
{
|
{
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace HISP.Server
|
||||||
private Timer kickTimer;
|
private Timer kickTimer;
|
||||||
private Timer minuteTimer;
|
private Timer minuteTimer;
|
||||||
|
|
||||||
|
private bool isDisconnecting = false;
|
||||||
private int keepAliveInterval = 60 * 1000;
|
private int keepAliveInterval = 60 * 1000;
|
||||||
private int updateInterval = 60 * 1000;
|
private int updateInterval = 60 * 1000;
|
||||||
|
|
||||||
|
@ -132,13 +132,16 @@ namespace HISP.Server
|
||||||
updateTimer = new Timer(new TimerCallback(updateTimerTick), null, updateInterval, updateInterval);
|
updateTimer = new Timer(new TimerCallback(updateTimerTick), null, updateInterval, updateInterval);
|
||||||
inactivityTimer = new Timer(new TimerCallback(keepAliveTimerTick), null, keepAliveInterval, keepAliveInterval);
|
inactivityTimer = new Timer(new TimerCallback(keepAliveTimerTick), null, keepAliveInterval, keepAliveInterval);
|
||||||
}
|
}
|
||||||
private void receivePackets()
|
private bool receivePackets()
|
||||||
{
|
{
|
||||||
// HI1 Packets are terminates by 0x00 so we have to read until we receive that terminator
|
// HI1 Packets are terminates by 0x00 so we have to read until we receive that terminator
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
|
|
||||||
while(ClientSocket.Connected)
|
while(ClientSocket.Connected)
|
||||||
{
|
{
|
||||||
|
if(isDisconnecting)
|
||||||
|
break;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (ClientSocket.Available >= 1)
|
if (ClientSocket.Available >= 1)
|
||||||
|
@ -149,6 +152,9 @@ namespace HISP.Server
|
||||||
|
|
||||||
foreach (Byte b in buffer)
|
foreach (Byte b in buffer)
|
||||||
{
|
{
|
||||||
|
if(isDisconnecting)
|
||||||
|
break;
|
||||||
|
|
||||||
ms.WriteByte(b);
|
ms.WriteByte(b);
|
||||||
if (b == 0x00)
|
if (b == 0x00)
|
||||||
{
|
{
|
||||||
|
@ -172,6 +178,23 @@ namespace HISP.Server
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shutdown sockets
|
||||||
|
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();
|
||||||
|
|
||||||
|
return isDisconnecting; // Stop the thread.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,21 +300,10 @@ namespace HISP.Server
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(updateTimer != null)
|
// Cant outright stop threads anymore in .NET core,
|
||||||
updateTimer.Dispose();
|
// Lets just let the thread stop gracefully.
|
||||||
if(inactivityTimer != null)
|
|
||||||
inactivityTimer.Dispose();
|
this.isDisconnecting = true;
|
||||||
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)
|
public void Kick(string Reason)
|
||||||
|
|
|
@ -578,7 +578,7 @@ namespace HISP.Server
|
||||||
Item.ItemInformation itemInfo = Item.GetItemById(itemId);
|
Item.ItemInformation itemInfo = Item.GetItemById(itemId);
|
||||||
if (itemInfo.Type == "TACK")
|
if (itemInfo.Type == "TACK")
|
||||||
{
|
{
|
||||||
switch (itemInfo.MiscFlags[0])
|
switch (itemInfo.GetMiscFlag(0))
|
||||||
{
|
{
|
||||||
case 1: // Saddle
|
case 1: // Saddle
|
||||||
if(sender.LoggedinUser.LastViewedHorse.Equipment.Saddle != null)
|
if(sender.LoggedinUser.LastViewedHorse.Equipment.Saddle != null)
|
||||||
|
@ -1269,6 +1269,16 @@ namespace HISP.Server
|
||||||
sender.SendPacket(metaPacket);
|
sender.SendPacket(metaPacket);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "9": // View Tack
|
||||||
|
sender.LoggedinUser.MetaPriority = true;
|
||||||
|
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildTackLibary());
|
||||||
|
sender.SendPacket(metaPacket);
|
||||||
|
break;
|
||||||
|
case "10":
|
||||||
|
sender.LoggedinUser.MetaPriority = true;
|
||||||
|
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildCompanionLibary());
|
||||||
|
sender.SendPacket(metaPacket);
|
||||||
|
break;
|
||||||
case "11": // Randomize horse name
|
case "11": // Randomize horse name
|
||||||
if (sender.LoggedinUser.LastViewedHorse != null)
|
if (sender.LoggedinUser.LastViewedHorse != null)
|
||||||
{
|
{
|
||||||
|
@ -1338,11 +1348,6 @@ namespace HISP.Server
|
||||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAllStats(sender.LoggedinUser));
|
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAllStats(sender.LoggedinUser));
|
||||||
sender.SendPacket(metaPacket);
|
sender.SendPacket(metaPacket);
|
||||||
break;
|
break;
|
||||||
case "9": // View Tack
|
|
||||||
sender.LoggedinUser.MetaPriority = true;
|
|
||||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildTackLibary());
|
|
||||||
sender.SendPacket(metaPacket);
|
|
||||||
break;
|
|
||||||
case "53": // Misc Stats / Tracked Items
|
case "53": // Misc Stats / Tracked Items
|
||||||
sender.LoggedinUser.MetaPriority = true;
|
sender.LoggedinUser.MetaPriority = true;
|
||||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMiscStats(sender.LoggedinUser));
|
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMiscStats(sender.LoggedinUser));
|
||||||
|
@ -2849,13 +2854,7 @@ namespace HISP.Server
|
||||||
Item.ItemInformation itemInf = instance.GetItemInfo();
|
Item.ItemInformation itemInf = instance.GetItemInfo();
|
||||||
if(itemInf.Type == "CLOTHES")
|
if(itemInf.Type == "CLOTHES")
|
||||||
{
|
{
|
||||||
if (itemInf.MiscFlags.Length <= 0)
|
switch (itemInf.GetMiscFlag(0))
|
||||||
{
|
|
||||||
Logger.ErrorPrint(itemInf.Name + " Has no misc flags.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (itemInf.MiscFlags[0])
|
|
||||||
{
|
{
|
||||||
case CompetitionGear.MISC_FLAG_HEAD:
|
case CompetitionGear.MISC_FLAG_HEAD:
|
||||||
if (sender.LoggedinUser.EquipedCompetitionGear.Head == null)
|
if (sender.LoggedinUser.EquipedCompetitionGear.Head == null)
|
||||||
|
@ -2897,6 +2896,9 @@ namespace HISP.Server
|
||||||
sender.LoggedinUser.EquipedCompetitionGear.Feet = itemInf;
|
sender.LoggedinUser.EquipedCompetitionGear.Feet = itemInf;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
Logger.ErrorPrint(itemInf.Name + " Has unknown misc flags.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
sender.LoggedinUser.Inventory.Remove(instance);
|
sender.LoggedinUser.Inventory.Remove(instance);
|
||||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatEquipCompetitionGearMessage(itemInf.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatEquipCompetitionGearMessage(itemInf.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
|
Loading…
Add table
Reference in a new issue