From 357b20619a29f47e0fd46ed2c94b0daac4ffeb4d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 14 Feb 2016 10:26:39 +1100 Subject: [PATCH] Fix update script on linux not restarting launcher. --- ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs | 11 +++++------ ClassicalSharp/Entities/EntityList.cs | 1 - ClassicalSharp/Particles/ParticleSpawner.cs | 2 -- ClassicalSharp/Rendering/MapRenderer.cs | 8 +++----- Launcher2/Updater/Patcher.cs | 7 +++---- Launcher2/Updater/Scripts.cs | 8 +++----- OpenTK/Platform/X11/Functions.cs | 4 +--- OpenTK/Platform/X11/X11GLNative.cs | 2 -- 8 files changed, 15 insertions(+), 28 deletions(-) diff --git a/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs b/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs index 7625c0ba8..09cbdeeb2 100644 --- a/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs +++ b/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs @@ -106,13 +106,12 @@ namespace ClassicalSharp { } public override void MoveTo( int newX, int newY ) { - int deltaX = newX - X; - int deltaY = newY - Y; + int dx = newX - X, dy = newY - Y; X = newX; Y = newY; - chatCaretTexture.X1 += deltaX; - chatCaretTexture.Y1 += deltaY; - chatInputTexture.X1 += deltaX; - chatInputTexture.Y1 += deltaY; + chatCaretTexture.X1 += dx; + chatCaretTexture.Y1 += dy; + chatInputTexture.X1 += dx; + chatInputTexture.Y1 += dy; } static bool IsInvalidChar( char c ) { diff --git a/ClassicalSharp/Entities/EntityList.cs b/ClassicalSharp/Entities/EntityList.cs index 3dbf41df1..cbf1232e2 100644 --- a/ClassicalSharp/Entities/EntityList.cs +++ b/ClassicalSharp/Entities/EntityList.cs @@ -58,7 +58,6 @@ namespace ClassicalSharp { api.AlphaTest = true; LocalPlayer localP = game.LocalPlayer; Vector3 eyePos = localP.EyePosition; - Vector3 dir = Utils.GetDirVector( localP.HeadYawRadians, localP.PitchRadians ); closestId = 255; if( NamesMode != NameMode.AllNames ) diff --git a/ClassicalSharp/Particles/ParticleSpawner.cs b/ClassicalSharp/Particles/ParticleSpawner.cs index 0f348d908..a6da8fb2e 100644 --- a/ClassicalSharp/Particles/ParticleSpawner.cs +++ b/ClassicalSharp/Particles/ParticleSpawner.cs @@ -38,8 +38,6 @@ namespace ClassicalSharp.Particles { rec.V1 = baseRec.V1 + rnd.Next( minV, maxUsedV ) * vScale; rec.U2 = Math.Min( baseRec.U1 + maxU * uScale, rec.U1 + 4 * uScale ) - 0.01f * uScale; rec.V2 = Math.Min( baseRec.V1 + maxV * vScale, rec.V1 + 4 * vScale ) - 0.01f * vScale; - int pixU1 = (int)(rec.U1 / uScale), pixU2 = (int)(rec.U2 / uScale); - int pixV1 = (int)(rec.V1 / vScale), pixV2 = (int)(rec.V2 / vScale); double life = 0.3 + rnd.NextDouble() * 0.7; TerrainParticle p = AddParticle( terrainParticles, ref terrainCount, false ); diff --git a/ClassicalSharp/Rendering/MapRenderer.cs b/ClassicalSharp/Rendering/MapRenderer.cs index 93755b67a..1ffa31d55 100644 --- a/ClassicalSharp/Rendering/MapRenderer.cs +++ b/ClassicalSharp/Rendering/MapRenderer.cs @@ -28,7 +28,7 @@ namespace ClassicalSharp { Game game; IGraphicsApi api; - int _1Dcount = 1, _1DUsed = 1; + int _1DUsed = 1; ChunkMeshBuilder builder; BlockInfo info; @@ -41,7 +41,6 @@ namespace ClassicalSharp { public MapRenderer( Game game ) { this.game = game; - _1Dcount = game.TerrainAtlas1D.TexIds.Length; _1DUsed = game.TerrainAtlas1D.CalcMaxUsedRow( game.TerrainAtlas, game.BlockInfo ); RecalcBooleans( true ); @@ -89,9 +88,8 @@ namespace ClassicalSharp { } void TerrainAtlasChanged( object sender, EventArgs e ) { - _1Dcount = game.TerrainAtlas1D.TexIds.Length; - bool fullResetRequired = elementsPerBitmap != game.TerrainAtlas1D.elementsPerBitmap; - if( fullResetRequired ) + bool refreshRequired = elementsPerBitmap != game.TerrainAtlas1D.elementsPerBitmap; + if( refreshRequired ) Refresh(); elementsPerBitmap = game.TerrainAtlas1D.elementsPerBitmap; diff --git a/Launcher2/Updater/Patcher.cs b/Launcher2/Updater/Patcher.cs index 6c1c66206..450c96947 100644 --- a/Launcher2/Updater/Patcher.cs +++ b/Launcher2/Updater/Patcher.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.IO; using System.Net; using System.Runtime.InteropServices; +using System.Threading; using ClassicalSharp.TexturePack; namespace Launcher2.Updater { @@ -14,8 +15,8 @@ namespace Launcher2.Updater { byte[] zipData = client.DownloadData( UpdateCheckTask.UpdatesUri + dir ); MakeUpdatesFolder( zipData ); } - if( !OpenTK.Configuration.RunningOnWindows ) return; LaunchUpdateScript(); + Thread.Sleep( 200 ); Process.GetCurrentProcess().Kill(); } @@ -32,10 +33,8 @@ namespace Launcher2.Updater { int code = chmod( path, (flags << 6) | (flags << 3) | 4 ); if( code != 0 ) throw new InvalidOperationException( "chmod returned : " + code ); - info = new ProcessStartInfo( "/bin/bash", "-c " + path ); + info = new ProcessStartInfo( "xterm", '"' + path + '"'); } - // TODO: delete directory - // TODO: why no start new window? info.CreateNoWindow = false; info.UseShellExecute = false; Process.Start( info ); diff --git a/Launcher2/Updater/Scripts.cs b/Launcher2/Updater/Scripts.cs index b5b51a84f..d9085314a 100644 --- a/Launcher2/Updater/Scripts.cs +++ b/Launcher2/Updater/Scripts.cs @@ -49,16 +49,14 @@ echo Extracting files from CS_Update folder UPDATEDIR=""`pwd`/CS_Update/"" find ""$UPDATEDIR"" -name '*.*' | xargs cp -t `pwd` +rm -r ""$UPDATEDIR"" echo Starting launcher again if [ -f ""Launcher.exe"" ]; then -mono Launcher.exe & +mono Launcher.exe else -mono Launcher2.exe & +mono Launcher2.exe fi -disown -echo Waiting -sleep 10 "; } } diff --git a/OpenTK/Platform/X11/Functions.cs b/OpenTK/Platform/X11/Functions.cs index cd301af52..6af4cadf1 100644 --- a/OpenTK/Platform/X11/Functions.cs +++ b/OpenTK/Platform/X11/Functions.cs @@ -213,9 +213,7 @@ namespace OpenTK.Platform.X11 { public static IntPtr CreatePixmapFromImage(Display display, System.Drawing.Bitmap image) { - int width = image.Width; - int height = image.Height; - int size = width * height; + int width = image.Width, height = image.Height; System.Drawing.Imaging.BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadOnly, diff --git a/OpenTK/Platform/X11/X11GLNative.cs b/OpenTK/Platform/X11/X11GLNative.cs index 108539510..d87eb34ba 100644 --- a/OpenTK/Platform/X11/X11GLNative.cs +++ b/OpenTK/Platform/X11/X11GLNative.cs @@ -56,7 +56,6 @@ namespace OpenTK.Platform.X11 { IntPtr net_wm_icon; IntPtr net_frame_extents; - IntPtr motif_wm_hints; static readonly IntPtr xa_cardinal = (IntPtr)6; static readonly IntPtr _remove = (IntPtr)0; @@ -190,7 +189,6 @@ namespace OpenTK.Platform.X11 { net_wm_state_maximized_vertical = API.XInternAtom(window.Display, "_NET_WM_STATE_MAXIMIZED_VERT", false); net_wm_icon = API.XInternAtom(window.Display, "_NEW_WM_ICON", false); net_frame_extents = API.XInternAtom(window.Display, "_NET_FRAME_EXTENTS", false); - motif_wm_hints = API.XInternAtom(window.Display, "_MOTIF_WM_HINTS", true); } void SetWindowMinMax(short min_width, short min_height, short max_width, short max_height) {