From eeabc3d0e83a3ac7c3298e5e5b342e2ea0a3889b Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 14 Sep 2018 15:40:02 -0700 Subject: [PATCH] Removes redundant returns --- Scripts/Accounting/AccessRestrictions.cs | 1 - Scripts/Commands/Batch.cs | 17 +- .../Quests/Haochi's Trials/Mobiles/Haochi.cs | 1 - .../Quests/Witch Apprentice/Items/HagStew.cs | 1 - Scripts/Engines/Virtues/Honor.cs | 1 - .../Guilds/New Guild System/GuildInfoGump.cs | 2 - Scripts/Gumps/HonorSelf.cs | 1 - Scripts/Items/Maps/TreasureMap.cs | 1 - Scripts/Items/Misc/Corpses/Corpse.cs | 1 - .../Special/Veteran Rewards/StoneAnkh.cs | 1 - Scripts/Mobiles/AI/BaseAI.cs | 1 - Scripts/Mobiles/PlayerMobile.cs | 1 - Scripts/Multis/BaseHouse.cs | 1 - Server/Network/Compression.cs | 1 - Server/Network/NetState.cs | 1 - Server/Network/PacketHandlers.cs | 151 +++++++++--------- 16 files changed, 77 insertions(+), 106 deletions(-) diff --git a/Scripts/Accounting/AccessRestrictions.cs b/Scripts/Accounting/AccessRestrictions.cs index e4cc9387e..66aa3606b 100644 --- a/Scripts/Accounting/AccessRestrictions.cs +++ b/Scripts/Accounting/AccessRestrictions.cs @@ -33,7 +33,6 @@ namespace Server op.WriteLine( "{0}\tPast IP limit threshold\t{1}", ip, DateTime.UtcNow ); e.AllowConnection = false; - return; } } catch diff --git a/Scripts/Commands/Batch.cs b/Scripts/Commands/Batch.cs index c674bf0a8..5b937d566 100644 --- a/Scripts/Commands/Batch.cs +++ b/Scripts/Commands/Batch.cs @@ -41,10 +41,7 @@ namespace Server.Commands { BatchCommand bc = (BatchCommand)BatchCommands[i]; - string commandString, argString; - string[] args; - - bc.GetDetails( out commandString, out argString, out args ); + bc.GetDetails( out string commandString, out string argString, out string[] args ); BaseCommand command = Scope.Commands[commandString]; @@ -174,9 +171,7 @@ namespace Server.Commands [Description( "Allows multiple commands to be run at the same time." )] public static void Batch_OnCommand( CommandEventArgs e ) { - Batch batch = new Batch(); - - e.Mobile.SendGump( new BatchGump( e.Mobile, batch ) ); + e.Mobile.SendGump( new BatchGump( e.Mobile, new Batch() ) ); } } @@ -305,9 +300,7 @@ namespace Server.Commands public override void OnResponse( NetState sender, RelayInfo info ) { - int type, index; - - if ( !SplitButtonID( info.ButtonID, 1, out type, out index ) ) + if ( !SplitButtonID( info.ButtonID, 1, out int type, out int index ) ) return; TextRelay entry = info.GetTextEntry( 0 ); @@ -405,9 +398,7 @@ namespace Server.Commands public override void OnResponse( NetState sender, RelayInfo info ) { - int type, index; - - if ( SplitButtonID( info.ButtonID, 1, out type, out index ) ) + if ( SplitButtonID( info.ButtonID, 1, out int type, out int index ) ) { switch ( type ) { diff --git a/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs b/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs index c37e5b5df..8a0daa3e4 100644 --- a/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs +++ b/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs @@ -151,7 +151,6 @@ namespace Server.Engines.Quests.Samurai player.AddToBackpack( armor ); obj.Complete(); - return; } } } diff --git a/Scripts/Engines/Quests/Witch Apprentice/Items/HagStew.cs b/Scripts/Engines/Quests/Witch Apprentice/Items/HagStew.cs index 40acff241..15dc3ca50 100644 --- a/Scripts/Engines/Quests/Witch Apprentice/Items/HagStew.cs +++ b/Scripts/Engines/Quests/Witch Apprentice/Items/HagStew.cs @@ -49,7 +49,6 @@ namespace Server.Items { Stop(); stew.Visible = true; - return; } } } diff --git a/Scripts/Engines/Virtues/Honor.cs b/Scripts/Engines/Virtues/Honor.cs index 9f055edb0..cdf67526c 100644 --- a/Scripts/Engines/Virtues/Honor.cs +++ b/Scripts/Engines/Virtues/Honor.cs @@ -335,7 +335,6 @@ namespace Server public void OnSourceKilled() { - return; } public void OnTargetKilled() diff --git a/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs b/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs index 65b4a4a7f..2f28fb257 100644 --- a/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs @@ -166,7 +166,6 @@ namespace Server.Guilds { guild.Charter = charter; from.SendLocalizedMessage( 1070775 ); // You submit a new guild charter. - return; } } @@ -183,7 +182,6 @@ namespace Server.Guilds { guild.Website = site; from.SendLocalizedMessage( 1070778 ); // You submit a new guild website. - return; } } } diff --git a/Scripts/Gumps/HonorSelf.cs b/Scripts/Gumps/HonorSelf.cs index 90500b272..2c5cc6365 100644 --- a/Scripts/Gumps/HonorSelf.cs +++ b/Scripts/Gumps/HonorSelf.cs @@ -25,7 +25,6 @@ honor points on yourself?", true, false); } else { - return; } } } diff --git a/Scripts/Items/Maps/TreasureMap.cs b/Scripts/Items/Maps/TreasureMap.cs index a3688c950..3aca23d0b 100644 --- a/Scripts/Items/Maps/TreasureMap.cs +++ b/Scripts/Items/Maps/TreasureMap.cs @@ -325,7 +325,6 @@ namespace Server.Items else if ( m_Map.m_Decoder != from && !m_Map.HasRequiredSkill( from ) ) { from.SendLocalizedMessage( 503031 ); // You did not decode this map and have no clue where to look for the treasure. - return; } else if ( !from.CanBeginAction( typeof( TreasureMap ) ) ) { diff --git a/Scripts/Items/Misc/Corpses/Corpse.cs b/Scripts/Items/Misc/Corpses/Corpse.cs index 64bf1e63d..d5b78a0ee 100644 --- a/Scripts/Items/Misc/Corpses/Corpse.cs +++ b/Scripts/Items/Misc/Corpses/Corpse.cs @@ -1099,7 +1099,6 @@ namespace Server.Items else { from.SendLocalizedMessage( 500446 ); // That is too far away. - return; } } diff --git a/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs b/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs index 4c1d389b0..8bf32f37c 100644 --- a/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs +++ b/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs @@ -90,7 +90,6 @@ namespace Server.Items public override void OnChop( Mobile from ) { from.SendLocalizedMessage( 500489 ); // You can't use an axe on that. - return; } public override void GetProperties( ObjectPropertyList list ) diff --git a/Scripts/Mobiles/AI/BaseAI.cs b/Scripts/Mobiles/AI/BaseAI.cs index 46579550b..9ed2cea9e 100644 --- a/Scripts/Mobiles/AI/BaseAI.cs +++ b/Scripts/Mobiles/AI/BaseAI.cs @@ -2659,7 +2659,6 @@ namespace Server.Mobiles if (loc != Point3D.Zero) { m_Mobile.MoveToWorld(loc, se.Region.Map); - return; } } } diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 56bd25763..5850cd909 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -130,7 +130,6 @@ namespace Server.Mobiles SendLocalizedMessage(1112456); break; // You cannot fly while recovering from a dismount maneuver. } - return; } else if (Hits < 25) // TODO confirm { diff --git a/Scripts/Multis/BaseHouse.cs b/Scripts/Multis/BaseHouse.cs index ff337ec34..5da4eade8 100644 --- a/Scripts/Multis/BaseHouse.cs +++ b/Scripts/Multis/BaseHouse.cs @@ -3519,7 +3519,6 @@ namespace Server.Multis } else if ( targeted is StaticTarget ) { - return; } else { diff --git a/Server/Network/Compression.cs b/Server/Network/Compression.cs index 6d79c744b..06893a90b 100644 --- a/Server/Network/Compression.cs +++ b/Server/Network/Compression.cs @@ -180,7 +180,6 @@ namespace Server.Network { } length = (int)(pOutput - pOutputBuffer); - return; } } } diff --git a/Server/Network/NetState.cs b/Server/Network/NetState.cs index 94381205d..b67f2c7f8 100644 --- a/Server/Network/NetState.cs +++ b/Server/Network/NetState.cs @@ -891,7 +891,6 @@ namespace Server.Network { Console.WriteLine( "Client: {0}: Disconnecting due to inactivity...", this ); Dispose(); - return; } public static void TraceException( Exception ex ) { diff --git a/Server/Network/PacketHandlers.cs b/Server/Network/PacketHandlers.cs index 46394fc66..590054e36 100644 --- a/Server/Network/PacketHandlers.cs +++ b/Server/Network/PacketHandlers.cs @@ -205,8 +205,8 @@ namespace Server.Network { if ( packetID >= 0 && packetID < 0x100 ) return m_ExtendedHandlersLow[packetID]; - PacketHandler handler; - m_ExtendedHandlersHigh.TryGetValue( packetID, out handler ); + + m_ExtendedHandlersHigh.TryGetValue( packetID, out PacketHandler handler ); return handler; } @@ -230,8 +230,8 @@ namespace Server.Network { if ( packetID >= 0 && packetID < 0x100 ) return m_EncodedHandlersLow[packetID]; - EncodedPacketHandler handler; - m_EncodedHandlersHigh.TryGetValue( packetID, out handler ); + + m_EncodedHandlersHigh.TryGetValue( packetID, out EncodedPacketHandler handler ); return handler; } @@ -418,13 +418,14 @@ namespace Server.Network return; List buyList = new List( msgSize / 7 ); - for ( ;msgSize>0;msgSize-=7) + while ( msgSize > 0 ) { byte layer = pvSrc.ReadByte(); Serial serial = pvSrc.ReadInt32(); int amount = pvSrc.ReadInt16(); buyList.Add( new BuyItemResponse( serial, amount ) ); + msgSize -= 7; } if ( buyList.Count > 0 && vendor is IVendor v && v.OnBuyItems( state.Mobile, buyList ) ) @@ -768,9 +769,7 @@ namespace Server.Network } case 0x24: // Use skill { - int skillIndex; - - if ( !int.TryParse( command.Split( ' ' )[0], out skillIndex ) ) + if ( !int.TryParse( command.Split( ' ' )[0], out int skillIndex ) ) break; Skills.UseSkill( m, skillIndex ); @@ -779,9 +778,7 @@ namespace Server.Network } case 0x43: // Open spellbook { - int booktype; - - if ( !int.TryParse( command, out booktype ) ) + if ( !int.TryParse( command, out int booktype ) ) booktype = 1; EventSink.InvokeOpenSpellbookRequest( new OpenSpellbookRequestEventArgs( m, booktype ) ); @@ -1115,93 +1112,91 @@ namespace Server.Network Target t = from.Target; - if ( t != null ) - { - TargetProfile prof = TargetProfile.Acquire( t.GetType() ); + if (t == null) + return; - prof?.Start(); + TargetProfile prof = TargetProfile.Acquire( t.GetType() ); + prof?.Start(); - try { - if ( x == -1 && y == -1 && !serial.IsValid ) - { - // User pressed escape - t.Cancel( from, TargetCancelType.Canceled ); - } - else if ( Target.TargetIDValidation && t.TargetID != targetID ) - { - // Sanity, prevent fake target - return; - } - else - { - object toTarget; + try { + if ( x == -1 && y == -1 && !serial.IsValid ) + { + // User pressed escape + t.Cancel( from, TargetCancelType.Canceled ); + } + else if ( Target.TargetIDValidation && t.TargetID != targetID ) + { + // Sanity, prevent fake target + } + else + { + object toTarget; - if ( type == 1 ) + if ( type == 1 ) + { + if ( graphic == 0 ) { - if ( graphic == 0 ) + toTarget = new LandTarget( new Point3D( x, y, z ), from.Map ); + } + else + { + Map map = from.Map; + + if ( map == null || map == Map.Internal ) { - toTarget = new LandTarget( new Point3D( x, y, z ), from.Map ); + t.Cancel( from, TargetCancelType.Canceled ); + return; } else { - Map map = from.Map; + StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y, !t.DisallowMultis ); - if ( map == null || map == Map.Internal ) + bool valid = false; + + if ( state.HighSeas ) { + ItemData id = TileData.ItemTable[graphic&TileData.MaxItemValue]; + if ( id.Surface ) { + z -= id.Height; + } + } + + for ( int i = 0; !valid && i < tiles.Length; ++i ) + { + if ( tiles[i].Z == z && tiles[i].ID == graphic ) + valid = true; + } + + if ( !valid ) { t.Cancel( from, TargetCancelType.Canceled ); return; } else { - StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y, !t.DisallowMultis ); - - bool valid = false; - - if ( state.HighSeas ) { - ItemData id = TileData.ItemTable[graphic&TileData.MaxItemValue]; - if ( id.Surface ) { - z -= id.Height; - } - } - - for ( int i = 0; !valid && i < tiles.Length; ++i ) - { - if ( tiles[i].Z == z && tiles[i].ID == graphic ) - valid = true; - } - - if ( !valid ) - { - t.Cancel( from, TargetCancelType.Canceled ); - return; - } - else - { - toTarget = new StaticTarget( new Point3D( x, y, z ), graphic ); - } + toTarget = new StaticTarget( new Point3D( x, y, z ), graphic ); } } } - else if ( serial.IsMobile ) - { - toTarget = World.FindMobile( serial ); - } - else if ( serial.IsItem ) - { - toTarget = World.FindItem( serial ); - } - else - { - t.Cancel( from, TargetCancelType.Canceled ); - return; - } - - t.Invoke( from, toTarget ); } - } finally - { - prof?.Finish(); + else if ( serial.IsMobile ) + { + toTarget = World.FindMobile( serial ); + } + else if ( serial.IsItem ) + { + toTarget = World.FindItem( serial ); + } + else + { + t.Cancel( from, TargetCancelType.Canceled ); + return; + } + + t.Invoke( from, toTarget ); } + } finally + { + prof?.Finish(); } }