mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 13:45:42 +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
|
||||
{
|
||||
int offsetBy = 0;
|
||||
if (baseHorse.Equipment.Companion != null)
|
||||
offsetBy += getOffetFrom(baseHorse.Equipment.Companion);
|
||||
return offsetBy;
|
||||
return baseHorse.Equipment.Companion.GetMiscFlag(0);
|
||||
}
|
||||
}
|
||||
public int TackOffset
|
||||
|
@ -134,11 +131,11 @@ namespace HISP.Game.Horse
|
|||
{
|
||||
int offsetBy = 0;
|
||||
if (baseHorse.Equipment.Saddle != null)
|
||||
offsetBy += getOffetFrom(baseHorse.Equipment.Saddle);
|
||||
offsetBy += getOffsetFrom(baseHorse.Equipment.Saddle);
|
||||
if (baseHorse.Equipment.SaddlePad != null)
|
||||
offsetBy += getOffetFrom(baseHorse.Equipment.SaddlePad);
|
||||
offsetBy += getOffsetFrom(baseHorse.Equipment.SaddlePad);
|
||||
if (baseHorse.Equipment.Bridle != null)
|
||||
offsetBy += getOffetFrom(baseHorse.Equipment.Bridle);
|
||||
offsetBy += getOffsetFrom(baseHorse.Equipment.Bridle);
|
||||
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;
|
||||
foreach (Item.Effects effect in baseHorse.Equipment.Bridle.Effects)
|
||||
|
|
|
@ -40,6 +40,14 @@ namespace HISP.Game.Items
|
|||
|
||||
public SpawnRules SpawnParamaters;
|
||||
|
||||
public int GetMiscFlag(int no)
|
||||
{
|
||||
if(MiscFlags.Length <= no)
|
||||
return 0;
|
||||
else
|
||||
return MiscFlags[no];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct ThrowableItem
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace HISP.Game.Items
|
|||
{
|
||||
foreach(Item.ItemInformation tackItem in TackItems)
|
||||
{
|
||||
if(tackItem.MiscFlags[0] == 1) // Saddle
|
||||
if(tackItem.GetMiscFlag(0) == 1) // Saddle
|
||||
return tackItem;
|
||||
}
|
||||
throw new KeyNotFoundException("Saddle not found.");
|
||||
|
@ -46,7 +46,7 @@ namespace HISP.Game.Items
|
|||
{
|
||||
foreach(Item.ItemInformation tackItem in TackItems)
|
||||
{
|
||||
if(tackItem.MiscFlags[0] == 2) // SaddlePad
|
||||
if(tackItem.GetMiscFlag(0) == 2) // SaddlePad
|
||||
return tackItem;
|
||||
}
|
||||
throw new KeyNotFoundException("SaddlePad not found.");
|
||||
|
@ -56,7 +56,7 @@ namespace HISP.Game.Items
|
|||
{
|
||||
foreach(Item.ItemInformation tackItem in TackItems)
|
||||
{
|
||||
if(tackItem.MiscFlags[0] == 3) // Bridle
|
||||
if(tackItem.GetMiscFlag(0) == 3) // Bridle
|
||||
return tackItem;
|
||||
}
|
||||
throw new KeyNotFoundException("GetBridle not found.");
|
||||
|
@ -79,6 +79,18 @@ namespace HISP.Game.Items
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -526,7 +526,7 @@ namespace HISP.Game
|
|||
}
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -330,7 +330,7 @@ namespace HISP.Game
|
|||
{
|
||||
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 swf = "breedviewer.swf?terrain=book2&breed=tackonly";
|
||||
|
@ -361,6 +361,23 @@ namespace HISP.Game
|
|||
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()
|
||||
{
|
||||
string message = "";
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace HISP.Server
|
|||
private Timer kickTimer;
|
||||
private Timer minuteTimer;
|
||||
|
||||
|
||||
private bool isDisconnecting = false;
|
||||
private int keepAliveInterval = 60 * 1000;
|
||||
private int updateInterval = 60 * 1000;
|
||||
|
||||
|
@ -132,13 +132,16 @@ namespace HISP.Server
|
|||
updateTimer = new Timer(new TimerCallback(updateTimerTick), null, updateInterval, updateInterval);
|
||||
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
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
while(ClientSocket.Connected)
|
||||
{
|
||||
if(isDisconnecting)
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
if (ClientSocket.Available >= 1)
|
||||
|
@ -149,6 +152,9 @@ namespace HISP.Server
|
|||
|
||||
foreach (Byte b in buffer)
|
||||
{
|
||||
if(isDisconnecting)
|
||||
break;
|
||||
|
||||
ms.WriteByte(b);
|
||||
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()
|
||||
{
|
||||
|
||||
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();
|
||||
// Cant outright stop threads anymore in .NET core,
|
||||
// Lets just let the thread stop gracefully.
|
||||
|
||||
this.isDisconnecting = true;
|
||||
}
|
||||
|
||||
public void Kick(string Reason)
|
||||
|
|
|
@ -578,7 +578,7 @@ namespace HISP.Server
|
|||
Item.ItemInformation itemInfo = Item.GetItemById(itemId);
|
||||
if (itemInfo.Type == "TACK")
|
||||
{
|
||||
switch (itemInfo.MiscFlags[0])
|
||||
switch (itemInfo.GetMiscFlag(0))
|
||||
{
|
||||
case 1: // Saddle
|
||||
if(sender.LoggedinUser.LastViewedHorse.Equipment.Saddle != null)
|
||||
|
@ -1269,6 +1269,16 @@ namespace HISP.Server
|
|||
sender.SendPacket(metaPacket);
|
||||
}
|
||||
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
|
||||
if (sender.LoggedinUser.LastViewedHorse != null)
|
||||
{
|
||||
|
@ -1338,11 +1348,6 @@ namespace HISP.Server
|
|||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAllStats(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "9": // View Tack
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildTackLibary());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "53": // Misc Stats / Tracked Items
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMiscStats(sender.LoggedinUser));
|
||||
|
@ -2849,13 +2854,7 @@ namespace HISP.Server
|
|||
Item.ItemInformation itemInf = instance.GetItemInfo();
|
||||
if(itemInf.Type == "CLOTHES")
|
||||
{
|
||||
if (itemInf.MiscFlags.Length <= 0)
|
||||
{
|
||||
Logger.ErrorPrint(itemInf.Name + " Has no misc flags.");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (itemInf.MiscFlags[0])
|
||||
switch (itemInf.GetMiscFlag(0))
|
||||
{
|
||||
case CompetitionGear.MISC_FLAG_HEAD:
|
||||
if (sender.LoggedinUser.EquipedCompetitionGear.Head == null)
|
||||
|
@ -2897,6 +2896,9 @@ namespace HISP.Server
|
|||
sender.LoggedinUser.EquipedCompetitionGear.Feet = itemInf;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Logger.ErrorPrint(itemInf.Name + " Has unknown misc flags.");
|
||||
return;
|
||||
}
|
||||
sender.LoggedinUser.Inventory.Remove(instance);
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatEquipCompetitionGearMessage(itemInf.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
|
|
Loading…
Add table
Reference in a new issue