Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -1,127 +1,130 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Server.Engines.PartySystem;
|
||||
using Server.Guilds;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public static partial class MapUO
|
||||
{
|
||||
private static class Settings
|
||||
{
|
||||
public const bool PartyTrack = true;
|
||||
public const bool GuildTrack = true;
|
||||
public const bool GuildHitsPercent = true;
|
||||
}
|
||||
public static class MapUO
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Settings.PartyTrack)
|
||||
ProtocolExtensions.Register(0x00, true, OnPartyTrack);
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if ( Settings.PartyTrack )
|
||||
ProtocolExtensions.Register( 0x00, true, OnPartyTrack );
|
||||
if (Settings.GuildTrack)
|
||||
ProtocolExtensions.Register(0x01, true, OnGuildTrack);
|
||||
}
|
||||
|
||||
if ( Settings.GuildTrack )
|
||||
ProtocolExtensions.Register( 0x01, true, OnGuildTrack );
|
||||
}
|
||||
private static void OnPartyTrack(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
Party party = Party.Get(from);
|
||||
|
||||
private static void OnPartyTrack( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
Party party = Party.Get( from );
|
||||
if (party != null)
|
||||
{
|
||||
Packets.PartyTrack packet = new Packets.PartyTrack(from, party);
|
||||
|
||||
if ( party != null )
|
||||
{
|
||||
Packets.PartyTrack packet = new Packets.PartyTrack( from, party );
|
||||
if (packet.UnderlyingStream.Length > 8)
|
||||
state.Send(packet);
|
||||
}
|
||||
}
|
||||
|
||||
if ( packet.UnderlyingStream.Length > 8 )
|
||||
state.Send( packet );
|
||||
}
|
||||
}
|
||||
private static void OnGuildTrack(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
private static void OnGuildTrack( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
if (from.Guild is Guild guild)
|
||||
{
|
||||
bool locations = pvSrc.ReadByte() != 0;
|
||||
|
||||
if ( from.Guild is Guild guild )
|
||||
{
|
||||
bool locations = pvSrc.ReadByte() != 0;
|
||||
Packets.GuildTrack packet = new Packets.GuildTrack(from, guild, locations);
|
||||
|
||||
Packets.GuildTrack packet = new Packets.GuildTrack( from, guild, locations );
|
||||
if (packet.UnderlyingStream.Length > (locations ? 9 : 5))
|
||||
state.Send(packet);
|
||||
}
|
||||
else
|
||||
{
|
||||
state.Send(new Packets.GuildTrack());
|
||||
}
|
||||
}
|
||||
|
||||
if ( packet.UnderlyingStream.Length > ( locations ? 9 : 5 ) )
|
||||
state.Send( packet );
|
||||
}
|
||||
else
|
||||
state.Send( new Packets.GuildTrack() );
|
||||
}
|
||||
private static class Settings
|
||||
{
|
||||
public const bool PartyTrack = true;
|
||||
public const bool GuildTrack = true;
|
||||
public const bool GuildHitsPercent = true;
|
||||
}
|
||||
|
||||
private static class Packets
|
||||
{
|
||||
public sealed class PartyTrack : ProtocolExtension
|
||||
{
|
||||
public PartyTrack( Mobile from, Party party ) : base( 0x01, ( ( party.Members.Count - 1 ) * 9 ) + 4 )
|
||||
{
|
||||
for ( int i = 0; i < party.Members.Count; ++i )
|
||||
{
|
||||
PartyMemberInfo pmi = (PartyMemberInfo)party.Members[i];
|
||||
private static class Packets
|
||||
{
|
||||
public sealed class PartyTrack : ProtocolExtension
|
||||
{
|
||||
public PartyTrack(Mobile from, Party party) : base(0x01, (party.Members.Count - 1) * 9 + 4)
|
||||
{
|
||||
for (int i = 0; i < party.Members.Count; ++i)
|
||||
{
|
||||
PartyMemberInfo pmi = party.Members[i];
|
||||
|
||||
if ( pmi == null || pmi.Mobile == from )
|
||||
continue;
|
||||
if (pmi == null || pmi.Mobile == from)
|
||||
continue;
|
||||
|
||||
Mobile mob = pmi.Mobile;
|
||||
Mobile mob = pmi.Mobile;
|
||||
|
||||
if ( Utility.InUpdateRange( from, mob ) && from.CanSee( mob ) )
|
||||
continue;
|
||||
if (Utility.InUpdateRange(from, mob) && from.CanSee(mob))
|
||||
continue;
|
||||
|
||||
m_Stream.Write( (int) mob.Serial );
|
||||
m_Stream.Write( (short) mob.X );
|
||||
m_Stream.Write( (short) mob.Y );
|
||||
m_Stream.Write( (byte) (mob.Map?.MapID ?? 0) );
|
||||
}
|
||||
m_Stream.Write(mob.Serial);
|
||||
m_Stream.Write((short)mob.X);
|
||||
m_Stream.Write((short)mob.Y);
|
||||
m_Stream.Write((byte)(mob.Map?.MapID ?? 0));
|
||||
}
|
||||
|
||||
m_Stream.Write( (int) 0 );
|
||||
}
|
||||
}
|
||||
m_Stream.Write(0);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class GuildTrack : ProtocolExtension
|
||||
{
|
||||
public GuildTrack() : base( 0x02, 5 )
|
||||
{
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (int) 0 );
|
||||
}
|
||||
public sealed class GuildTrack : ProtocolExtension
|
||||
{
|
||||
public GuildTrack() : base(0x02, 5)
|
||||
{
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write(0);
|
||||
}
|
||||
|
||||
public GuildTrack( Mobile from, Guild guild, bool locations ) : base( 0x02, ( ( guild.Members.Count - 1 ) * ( locations ? 10 : 4 ) ) + 5 )
|
||||
{
|
||||
m_Stream.Write( (byte) ( locations ? 1 : 0 ) );
|
||||
public GuildTrack(Mobile from, Guild guild, bool locations) : base(0x02,
|
||||
(guild.Members.Count - 1) * (locations ? 10 : 4) + 5)
|
||||
{
|
||||
m_Stream.Write((byte)(locations ? 1 : 0));
|
||||
|
||||
for ( int i = 0; i < guild.Members.Count; ++i )
|
||||
{
|
||||
Mobile mob = guild.Members[i];
|
||||
for (int i = 0; i < guild.Members.Count; ++i)
|
||||
{
|
||||
Mobile mob = guild.Members[i];
|
||||
|
||||
if ( mob == null || mob == from || mob.NetState == null )
|
||||
continue;
|
||||
if (mob == null || mob == from || mob.NetState == null)
|
||||
continue;
|
||||
|
||||
if ( locations && Utility.InUpdateRange( from, mob ) && from.CanSee( mob ) )
|
||||
continue;
|
||||
if (locations && Utility.InUpdateRange(from, mob) && from.CanSee(mob))
|
||||
continue;
|
||||
|
||||
m_Stream.Write( (int) mob.Serial );
|
||||
m_Stream.Write(mob.Serial);
|
||||
|
||||
if ( locations )
|
||||
{
|
||||
m_Stream.Write( (short) mob.X );
|
||||
m_Stream.Write( (short) mob.Y );
|
||||
m_Stream.Write( (byte) (mob.Map?.MapID ?? 0) );
|
||||
if (locations)
|
||||
{
|
||||
m_Stream.Write((short)mob.X);
|
||||
m_Stream.Write((short)mob.Y);
|
||||
m_Stream.Write((byte)(mob.Map?.MapID ?? 0));
|
||||
|
||||
if ( Settings.GuildHitsPercent && mob.Alive )
|
||||
m_Stream.Write( (byte) ( mob.Hits / Math.Max( mob.HitsMax, 1.0 ) * 100 ) );
|
||||
else
|
||||
m_Stream.Write( (byte) 0 );
|
||||
}
|
||||
}
|
||||
if (Settings.GuildHitsPercent && mob.Alive)
|
||||
m_Stream.Write((byte)(mob.Hits / Math.Max(mob.HitsMax, 1.0) * 100));
|
||||
else
|
||||
m_Stream.Write((byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
m_Stream.Write( (int) 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Stream.Write(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue