From 3e05ba60deae4a2a45965b6c996294a2cb11b84c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 27 Feb 2016 08:54:37 +1100 Subject: [PATCH] Make jump height calculation more precise and only show three significant figures (Thanks MrGoober), also always show generate/load options but disabled in multiplayer. --- .../2D/Screens/Menu/HacksSettingsScreen.cs | 22 +++++++--- ClassicalSharp/2D/Screens/Menu/PauseScreen.cs | 44 ++++++++++--------- .../Entities/LocalPlayer.Physics.cs | 5 +-- ClassicalSharp/Entities/Player.Shadows.cs | 2 +- ClassicalSharp/Game/Game.Properties.cs | 2 +- ClassicalSharp/Game/Game.cs | 4 +- .../Network/NetworkProcessor.CPE.cs | 4 +- ClassicalSharp/Network/NetworkProcessor.cs | 2 +- ClassicalSharp/Utils/Options.cs | 2 +- 9 files changed, 48 insertions(+), 39 deletions(-) diff --git a/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs index 08471aa94..b20c3db53 100644 --- a/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs @@ -32,7 +32,7 @@ namespace ClassicalSharp { Options.Set( OptionsKey.CameraClipping, v == "yes" ); } ), Make( -140, 0, "Jump height", OnWidgetClick, - g => g.LocalPlayer.JumpHeight.ToString(), + g => g.LocalPlayer.JumpHeight.ToString( "F3" ), (g, v) => g.LocalPlayer.CalculateJumpVelocity( Single.Parse( v ) ) ), Make( -140, 50, "Double jump", OnWidgetClick, @@ -41,10 +41,10 @@ namespace ClassicalSharp { Options.Set( OptionsKey.DoubleJump, v == "yes" ); } ), // Column 2 - Make( 140, -150, "Liquids breakable", OnWidgetClick, - g => g.LiquidsBreakable ? "yes" : "no", - (g, v) => { g.LiquidsBreakable = v == "yes"; - Options.Set( OptionsKey.LiquidsBreakable, v == "yes" ); } ), + Make( 140, -150, "Modifiable liquids", OnWidgetClick, + g => g.ModifiableLiquids ? "yes" : "no", + (g, v) => { g.ModifiableLiquids = v == "yes"; + Options.Set( OptionsKey.ModifiableLiquids, v == "yes" ); } ), Make( 140, -100, "Pushback placing", OnWidgetClick, g => g.LocalPlayer.Hacks.PushbackPlacing ? "yes" : "no", @@ -109,9 +109,17 @@ namespace ClassicalSharp { void MakeDescriptions() { descriptions = new string[widgets.Length][]; + descriptions[2] = new [] { + "&eIf camera clipping is set to true, then the third person", + "&ecameras will limit their zoom distance if they hit a solid block.", + }; + descriptions[3] = new [] { + "&eSets how many blocks high you can jump up.", + "&eNote: You jump much higher when holding down the speed key binding.", + }; descriptions[5] = new [] { - "&eIf breaking liquids is set to true, then water/lava", - "&ecan be deleted the same way as any regular block.", + "&eIf modifiable liquids is set to true, then water/lava can", + "&ebe placed and deleted the same way as any other block.", }; descriptions[6] = new [] { "&eWhen this is active, placing blocks that intersect your own position", diff --git a/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs b/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs index b2a708577..47b58e5f5 100644 --- a/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs @@ -44,11 +44,9 @@ namespace ClassicalSharp { // Column 2 Make( 140, -150, "Save level", (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), - !game.Network.IsSinglePlayer ? null : - Make( 140, -100, "Load level", + Make( 140, -100, "Load level", (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), - !game.Network.IsSinglePlayer ? null : - Make( 140, -50, "Generate level", + Make( 140, -50, "Generate level", (g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ), Make( 140, 0, "Select texture pack", (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ), @@ -64,40 +62,44 @@ namespace ClassicalSharp { MakeBack( true, titleFont, (g, w) => g.SetNewScreen( null ) ), }; + if( !game.Network.IsSinglePlayer ) { + widgets[6].Disabled = true; + widgets[7].Disabled = true; + } } void MakeClassic() { widgets = new Widget[] { MakeClassic( 0, -100, "Options", - (g, w) => g.SetNewScreen( new ClassicOptionsScreen( g ) ) ), - !game.Network.IsSinglePlayer ? null : - MakeClassic( 0, -50, "Generate level", - (g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ), - !game.Network.IsSinglePlayer ? null : - MakeClassic( 0, 0, "Load level", - (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), + (g, w) => g.SetNewScreen( new ClassicOptionsScreen( g ) ) ), + + MakeClassic( 0, -50, "Generate level", + (g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ), + + MakeClassic( 0, 0, "Load level", + (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), MakeClassic( 0, 50, "Save level", - (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), + (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), MakeBack( true, titleFont, (g, w) => g.SetNewScreen( null ) ), game.PureClassicMode ? null : MakeClassic( 0, 150, "Nostalgia options", - (g, w) => g.SetNewScreen( new NostalgiaScreen( g ) ) ), + (g, w) => g.SetNewScreen( new NostalgiaScreen( g ) ) ), }; + if( !game.Network.IsSinglePlayer ) { + widgets[1].Disabled = true; + widgets[2].Disabled = true; + } } void CheckHacksAllowed( object sender, EventArgs e ) { - for( int i = 0; i < widgets.Length; i++ ) { - if( widgets[i] == null ) continue; - widgets[i].Disabled = false; - } - if( !game.LocalPlayer.Hacks.CanAnyHacks && !game.UseClassicOptions ) { - widgets[3].Disabled = true; // env settings - widgets[8].Disabled = true; // select texture pack - } + if( game.UseClassicOptions ) return; + + widgets[3].Disabled = !game.LocalPlayer.Hacks.CanAnyHacks; // env settings + widgets[8].Disabled = !game.LocalPlayer.Hacks.CanAnyHacks; // select texture pack } ButtonWidget Make( int x, int y, string text, Action onClick ) { diff --git a/ClassicalSharp/Entities/LocalPlayer.Physics.cs b/ClassicalSharp/Entities/LocalPlayer.Physics.cs index c49f4e494..043bc7b74 100644 --- a/ClassicalSharp/Entities/LocalPlayer.Physics.cs +++ b/ClassicalSharp/Entities/LocalPlayer.Physics.cs @@ -232,9 +232,8 @@ namespace ClassicalSharp { if( jumpHeight >= 512 ) jumpVel = 16.5f; if( jumpHeight >= 768 ) jumpVel = 22.5f; - while( GetMaxHeight( jumpVel ) <= jumpHeight ) { - jumpVel += 0.01f; - } + while( GetMaxHeight( jumpVel ) <= jumpHeight ) + jumpVel += 0.001f; } static double GetMaxHeight( float u ) { diff --git a/ClassicalSharp/Entities/Player.Shadows.cs b/ClassicalSharp/Entities/Player.Shadows.cs index 4c0e165c1..8cef05c4c 100644 --- a/ClassicalSharp/Entities/Player.Shadows.cs +++ b/ClassicalSharp/Entities/Player.Shadows.cs @@ -19,7 +19,7 @@ namespace ClassicalSharp { int coordsCount = 0; Vector3I* coords = stackalloc Vector3I[4]; for( int i = 0; i < 4; i++ ) - coords[i] = Vector3I.Zero; + coords[i] = new Vector3I( int.MinValue ); if( mode == EntityShadow.SnapToBlock ) { vb = game.Graphics.texVb; verts = game.Graphics.texVerts; diff --git a/ClassicalSharp/Game/Game.Properties.cs b/ClassicalSharp/Game/Game.Properties.cs index 9c3ef6d1f..5a74695a1 100644 --- a/ClassicalSharp/Game/Game.Properties.cs +++ b/ClassicalSharp/Game/Game.Properties.cs @@ -140,7 +140,7 @@ namespace ClassicalSharp { public bool ClickableChat = false, HideGui = false, ShowFPS = true; internal float HotbarScale = 1, ChatScale = 1, InventoryScale = 1; public bool ViewBobbing, ShowBlockInHand; - public bool UseSound, UseMusic, LiquidsBreakable; + public bool UseSound, UseMusic, ModifiableLiquids; public Vector3 CurrentCameraPos; diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index f00020298..15bc1da8e 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -142,7 +142,7 @@ namespace ClassicalSharp { MapBordersRenderer.Init(); Picking = new PickedPosRenderer( this ); AudioPlayer = new AudioPlayer( this ); - LiquidsBreakable = Options.GetBool( OptionsKey.LiquidsBreakable, false ); + ModifiableLiquids = Options.GetBool( OptionsKey.ModifiableLiquids, false ); AxisLinesRenderer = new AxisLinesRenderer( this ); LoadIcon(); @@ -494,7 +494,7 @@ namespace ClassicalSharp { return false; if( !BlockInfo.IsLiquid[block] ) return true; - return !LiquidsBreakable ? false : + return !ModifiableLiquids ? false : Inventory.CanPlace[block] && Inventory.CanDelete[block]; } diff --git a/ClassicalSharp/Network/NetworkProcessor.CPE.cs b/ClassicalSharp/Network/NetworkProcessor.CPE.cs index 4fbe56b68..71d63258a 100644 --- a/ClassicalSharp/Network/NetworkProcessor.CPE.cs +++ b/ClassicalSharp/Network/NetworkProcessor.CPE.cs @@ -349,8 +349,8 @@ namespace ClassicalSharp { p.CheckHacksConsistency(); float jumpHeight = reader.ReadInt16() / 32f; - if( jumpHeight < 0 ) jumpHeight = 39/32f; - p.CalculateJumpVelocity( jumpHeight ); + if( jumpHeight < 0 ) p.jumpVel = 0.42f; + else p.CalculateJumpVelocity( jumpHeight ); p.serverJumpVel = p.jumpVel; game.Events.RaiseHackPermissionsChanged(); } diff --git a/ClassicalSharp/Network/NetworkProcessor.cs b/ClassicalSharp/Network/NetworkProcessor.cs index 1e6feecaf..95868c17e 100644 --- a/ClassicalSharp/Network/NetworkProcessor.cs +++ b/ClassicalSharp/Network/NetworkProcessor.cs @@ -82,7 +82,7 @@ namespace ClassicalSharp { // Workaround for older D3 servers which wrote one byte too many for HackControl packets. if( opcode == 0xFF && lastOpcode == PacketId.CpeHackControl ) { reader.Remove( 1 ); - game.LocalPlayer.CalculateJumpVelocity( 39/32f ); // assume default jump height + game.LocalPlayer.jumpVel = 0.42f; // assume default jump height game.LocalPlayer.serverJumpVel = game.LocalPlayer.jumpVel; continue; } diff --git a/ClassicalSharp/Utils/Options.cs b/ClassicalSharp/Utils/Options.cs index e54c94755..0a157aa82 100644 --- a/ClassicalSharp/Utils/Options.cs +++ b/ClassicalSharp/Utils/Options.cs @@ -25,7 +25,7 @@ namespace ClassicalSharp { public const string HacksEnabled = "hacks-hacksenabled"; public const string FieldOfView = "hacks-fov"; public const string Speed = "hacks-speedmultiplier"; - public const string LiquidsBreakable = "hacks-liquidsbreakable"; + public const string ModifiableLiquids = "hacks-liquidsbreakable"; public const string PushbackPlacing = "hacks-pushbackplacing"; public const string NoclipSlide = "hacks-noclipslide"; public const string CameraClipping = "hacks-cameraclipping";