[Pkg-cli-apps-commits] [SCM] openbve branch, upstream, updated. upstream/1.4.0.10-2-gd39c75d

Paul Sladen debian at paul.sladen.org
Wed Apr 18 20:29:06 UTC 2012


The following commit has been merged in the upstream branch:
commit d39c75d8f3c989055854758166c37d9010f50695
Author: Michelle Boucquemont <reschanger at gmail.com>
Date:   Wed Apr 18 21:26:22 2012 +0100

    import openbve_stable_source.zip 1.4.1.2 (2012-04-18)
    
    v1.4.1.2 (2012-04-18)
    
    * Translations
      Added translation for the Finnish (fi-FI) language.
    * Bugfix
      The /route and /train command-line arguments were broken
      and would crash the program with an unhandled exception.
    
    v1.4.1.1 (2012-04-12)
    
    * Translations
      Added translation for the Ukrainian (uk-UA) language.
    * Internet
      The options.cfg now allows to set up a proxy server
      with credentials for connecting to the internet.

diff --git a/openBVE/OpenBve/Audio/Sounds.cs b/openBVE/OpenBve/Audio/Sounds.cs
index fcd76f1..22df37a 100644
--- a/openBVE/OpenBve/Audio/Sounds.cs
+++ b/openBVE/OpenBve/Audio/Sounds.cs
@@ -56,7 +56,7 @@ namespace OpenBve {
 		// --- inverse distance clamp model ---
 		
 		internal static double LogClampFactor = -15.0;
-		internal const double MinLogClampFactor = -30.0;
+		internal const double MinLogClampFactor = -20.0;
 		internal const double MaxLogClampFactor = -1.0;
 
 		
diff --git a/openBVE/OpenBve/OldCode/Interface.cs b/openBVE/OpenBve/OldCode/Interface.cs
index 94102d6..4077d52 100644
--- a/openBVE/OpenBve/OldCode/Interface.cs
+++ b/openBVE/OpenBve/OldCode/Interface.cs
@@ -115,6 +115,9 @@ namespace OpenBve {
 			internal bool DisableDisplayLists;
 			internal bool LoadInAdvance;
 			internal bool NoTextureResize;
+			internal string ProxyUrl;
+			internal string ProxyUserName;
+			internal string ProxyPassword;
 			internal Options() {
 				this.LanguageCode = "en-US";
 				this.FullscreenMode = false;
@@ -159,6 +162,9 @@ namespace OpenBve {
 				this.DisableDisplayLists = false;
 				this.LoadInAdvance = false;
 				this.NoTextureResize = false;
+				this.ProxyUrl = string.Empty;
+				this.ProxyUserName = string.Empty;
+				this.ProxyPassword = string.Empty;
 			}
 		}
 		internal static Options CurrentOptions;
@@ -424,6 +430,18 @@ namespace OpenBve {
 											Interface.CurrentOptions.TrainFolder = Value;
 											break;
 									} break;
+								case "proxy":
+									switch (Key) {
+										case "url":
+											Interface.CurrentOptions.ProxyUrl = Value;
+											break;
+										case "username":
+											Interface.CurrentOptions.ProxyUserName = Value;
+											break;
+										case "password":
+											Interface.CurrentOptions.ProxyPassword = Value;
+											break;
+									} break;
 								case "recentlyusedroutes":
 									{
 										int n = Interface.CurrentOptions.RecentlyUsedRoutes.Length;
@@ -577,6 +595,11 @@ namespace OpenBve {
 			}
 			Builder.AppendLine("number = " + CurrentOptions.SoundNumber.ToString(Culture));
 			Builder.AppendLine();
+			Builder.AppendLine("[proxy]");
+			Builder.AppendLine("url = " + CurrentOptions.ProxyUrl);
+			Builder.AppendLine("username = " + CurrentOptions.ProxyUserName);
+			Builder.AppendLine("password = " + CurrentOptions.ProxyPassword);
+			Builder.AppendLine();
 			Builder.AppendLine("[folders]");
 			Builder.AppendLine("route = " + CurrentOptions.RouteFolder);
 			Builder.AppendLine("train = " + CurrentOptions.TrainFolder);
diff --git a/openBVE/OpenBve/OldCode/formMain.Start.cs b/openBVE/OpenBve/OldCode/formMain.Start.cs
index 0d42ef2..f61ce28 100644
--- a/openBVE/OpenBve/OldCode/formMain.Start.cs
+++ b/openBVE/OpenBve/OldCode/formMain.Start.cs
@@ -78,14 +78,17 @@ namespace OpenBve {
 					node.ImageKey = "folder";
 					node.SelectedImageKey = "folder";
 					string title = Path.GetFileNameWithoutExtension(directory);
-					bool found = false;
-					foreach (string keyword in keywords) {
-						if (title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) {
-							found = true;
-							break;
+					if (keywords.Length != 0) {
+						List<string> remaining = new List<string>();
+						foreach (string keyword in keywords) {
+							if (title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) < 0) {
+								remaining.Add(keyword);
+							}
 						}
+						AddRoutes(node.Nodes, directory, remaining.ToArray(), metadata);
+					} else {
+						AddRoutes(node.Nodes, directory, keywords, metadata);
 					}
-					AddRoutes(node.Nodes, directory, found ? new string[] { } : keywords, metadata);
 				}
 				string[] files = Directory.GetFiles(path);
 				foreach (string file in files) {
@@ -223,14 +226,17 @@ namespace OpenBve {
 						node.ImageKey = "folder";
 						node.SelectedImageKey = "folder";
 						string title = Path.GetFileNameWithoutExtension(directory);
-						bool found = false;
-						foreach (string keyword in keywords) {
-							if (title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) {
-								found = true;
-								break;
+						if (keywords.Length != 0) {
+							List<string> remaining = new List<string>();
+							foreach (string keyword in keywords) {
+								if (title.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) < 0) {
+									remaining.Add(keyword);
+								}
 							}
+							AddTrains(node.Nodes, directory, remaining.ToArray(), metadata);
+						} else {
+							AddTrains(node.Nodes, directory, keywords, metadata);
 						}
-						AddTrains(node.Nodes, directory, found ? new string[] { } : keywords, metadata);
 					}
 				}
 			}
diff --git a/openBVE/OpenBve/OldCode/formMain.cs b/openBVE/OpenBve/OldCode/formMain.cs
index 4165cf3..18f2ae8 100644
--- a/openBVE/OpenBve/OldCode/formMain.cs
+++ b/openBVE/OpenBve/OldCode/formMain.cs
@@ -18,16 +18,17 @@ namespace OpenBve {
 			internal string TrainFolder;
 			internal System.Text.Encoding TrainEncoding;
 		}
-		internal static MainDialogResult ShowMainDialog() {
+		internal static MainDialogResult ShowMainDialog(MainDialogResult initial) {
 			formMain Dialog = new formMain();
+			Dialog.Result = initial;
 			Dialog.ShowDialog();
-			MainDialogResult Result = Dialog.Result;
+			MainDialogResult result = Dialog.Result;
 			Dialog.Dispose();
-			return Result;
+			return result;
 		}
 
 		// members
-		private MainDialogResult Result = new MainDialogResult();
+		private MainDialogResult Result;
 		private int[] EncodingCodepages = new int[0];
 		private Image JoystickImage = null;
 		private string[] LanguageFiles = new string[0];
@@ -390,10 +391,10 @@ namespace OpenBve {
 			}
 			// result
 			Result.Start = false;
-			Result.RouteFile = null;
-			Result.RouteEncoding = System.Text.Encoding.UTF8;
-			Result.TrainFolder = null;
-			Result.TrainEncoding = System.Text.Encoding.UTF8;
+//			Result.RouteFile = null;
+//			Result.RouteEncoding = System.Text.Encoding.UTF8;
+//			Result.TrainFolder = null;
+//			Result.TrainEncoding = System.Text.Encoding.UTF8;
 		}
 
 		// apply language
@@ -1054,7 +1055,7 @@ namespace OpenBve {
 						DevelopmentText.AppendLine(Lines[k]);
 					}
 					bool Found = false;
-					if (IsNewVersionHigher(Application.ProductVersion, StableVersion)) {
+					if (ManagedContent.CompareVersions(Application.ProductVersion, StableVersion) < 0) {
 						string Message = Interface.GetInterfaceString("panel_updates_new") + StableText.ToString().Trim();
 						Message = Message.Replace("[version]", StableVersion);
 						Message = Message.Replace("[date]", StableDate);
@@ -1063,7 +1064,7 @@ namespace OpenBve {
 					}
 					#pragma warning disable 0162 // Unreachable code
 					if (Program.IsDevelopmentVersion) {
-						if (IsNewVersionHigher(Application.ProductVersion, DevelopmentVersion)) {
+						if (ManagedContent.CompareVersions(Application.ProductVersion, DevelopmentVersion) < 0) {
 							string Message = Interface.GetInterfaceString("panel_updates_new") + DevelopmentText.ToString().Trim();
 							Message = Message.Replace("[version]", DevelopmentVersion);
 							Message = Message.Replace("[date]", DevelopmentDate);
@@ -1083,23 +1084,6 @@ namespace OpenBve {
 			this.Cursor = Cursors.Default;
 			CurrentlyCheckingForUpdates = false;
 		}
-		private bool IsNewVersionHigher(string Current, string New) {
-			System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture;
-			string[] a = Current.Split('.');
-			string[] b = New.Split('.');
-			if (a.Length < b.Length) {
-				Array.Resize<string>(ref a, b.Length);
-			} else if (a.Length > b.Length) {
-				Array.Resize<string>(ref b, a.Length);
-			}
-			for (int i = 0; i < a.Length; i++) {
-				int x = a[i] != null ? int.Parse(a[i], Culture) : 0;
-				int y = b[i] != null ? int.Parse(b[i], Culture) : 0;
-				if (x < y) return true;
-				if (x > y) return false;
-			}
-			return false;
-		}
 
 		// close
 		private void buttonClose_Click(object sender, EventArgs e) {
diff --git a/openBVE/OpenBve/OpenBve.csproj b/openBVE/OpenBve/OpenBve.csproj
index ac3a160..b54803e 100644
--- a/openBVE/OpenBve/OpenBve.csproj
+++ b/openBVE/OpenBve/OpenBve.csproj
@@ -24,7 +24,7 @@
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
+    <DebugType>Full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
     <PlatformTarget>x86</PlatformTarget>
@@ -44,6 +44,7 @@
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
     <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+    <StartAction>Project</StartAction>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
     <RegisterForComInterop>False</RegisterForComInterop>
@@ -57,6 +58,9 @@
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
     <Reference Include="System.Drawing" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="Tao.OpenAl">
diff --git a/openBVE/OpenBve/Properties/AssemblyInfo.cs b/openBVE/OpenBve/Properties/AssemblyInfo.cs
index 3d03a49..1bdd194 100644
--- a/openBVE/OpenBve/Properties/AssemblyInfo.cs
+++ b/openBVE/OpenBve/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyProduct("openBVE")]
 [assembly: AssemblyCopyright("(Public Domain) http://trainsimframework.org/")]
 [assembly: ComVisible(false)]
-[assembly: AssemblyVersion("1.4.1.0")]
-[assembly: AssemblyFileVersion("1.4.1.0")]
+[assembly: AssemblyVersion("1.4.1.2")]
+[assembly: AssemblyFileVersion("1.4.1.2")]
 [assembly: CLSCompliant(true)]
 
 namespace OpenBve {
diff --git a/openBVE/OpenBve/System/Internet.cs b/openBVE/OpenBve/System/Internet.cs
index 18bcd7c..dd2629f 100644
--- a/openBVE/OpenBve/System/Internet.cs
+++ b/openBVE/OpenBve/System/Internet.cs
@@ -7,13 +7,30 @@ namespace OpenBve {
 	/// <summary>Provides methods for accessing the internet.</summary>
 	internal static class Internet {
 		
-		/// <summary>Adds some user agent and referer to the web client headers.</summary>
+		private static string UserAgent;
+		static Internet() {
+			string[] agents = new string[] {
+				"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1",
+				"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2",
+				"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
+				"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10",
+				"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
+				"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7",
+				"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7",
+				"Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1",
+				"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7",
+				"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7"
+			};
+			int index = Program.RandomNumberGenerator.Next(0, agents.Length);
+			UserAgent = agents[index];
+		}
+		
+		/// <summary>Adds some user agent and referer to the web client.</summary>
 		/// <param name="client">The web client.</param>
 		/// <param name="url">The URL to be accessed.</param>
 		private static void AddWebClientHeaders(WebClient client, string url) {
-			const string agent = "Mozilla/5.0 (Windows NT 6.2; rv:9.0.1) Gecko/20100101 Firefox/9.0.1";
 			try {
-				client.Headers.Add(HttpRequestHeader.UserAgent, agent);
+				client.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
 			} catch { }
 			if (url.StartsWith("http://")) {
 				int index = url.IndexOf('/', 7);
@@ -26,6 +43,16 @@ namespace OpenBve {
 			}
 		}
 		
+		/// <summary>Adds the user-specified proxy server to the client.</summary>
+		/// <param name="client">The web client.</param>
+		private static void AddWebClientProxy(WebClient client) {
+			if (Interface.CurrentOptions.ProxyUrl.Length != 0) {
+				WebProxy proxy = new WebProxy(Interface.CurrentOptions.ProxyUrl);
+				proxy.Credentials = new NetworkCredential(Interface.CurrentOptions.ProxyUserName, Interface.CurrentOptions.ProxyPassword);
+				client.Proxy = proxy;
+			}
+		}
+		
 		/// <summary>Downloads data from the specified URL.</summary>
 		/// <param name="url">The URL.</param>
 		/// <returns>The data.</returns>
@@ -33,6 +60,7 @@ namespace OpenBve {
 			byte[] bytes;
 			using (WebClient client = new WebClient()) {
 				AddWebClientHeaders(client, url);
+				AddWebClientProxy(client);
 				bytes = client.DownloadData(url);
 			}
 			return bytes;
@@ -48,6 +76,7 @@ namespace OpenBve {
 			try {
 				using (WebClient client = new WebClient()) {
 					AddWebClientHeaders(client, url);
+					AddWebClientProxy(client);
 					using (Stream stream = client.OpenRead(url)) {
 						const int chunkSize = 65536;
 						bytes = new byte[chunkSize];
diff --git a/openBVE/OpenBve/System/Program.cs b/openBVE/OpenBve/System/Program.cs
index 757b8db..1086b16 100644
--- a/openBVE/OpenBve/System/Program.cs
+++ b/openBVE/OpenBve/System/Program.cs
@@ -52,7 +52,27 @@ namespace OpenBve {
 				MessageBox.Show("The file system configuration could not be accessed or is invalid due to the following reason:\n\n" + ex.Message, "openBVE", MessageBoxButtons.OK, MessageBoxIcon.Hand);
 				return;
 			}
+			// --- set up packages ---
 			SetPackageLookupDirectories();
+			// --- load options and controls ---
+			Interface.LoadOptions();
+			Interface.LoadControls(null, out Interface.CurrentControls);
+			{
+				string folder = Program.FileSystem.GetDataFolder("Controls");
+				string file = OpenBveApi.Path.CombineFile(folder, "Default keyboard assignment.controls");
+				Interface.Control[] controls;
+				Interface.LoadControls(file, out controls);
+				Interface.AddControls(ref Interface.CurrentControls, controls);
+			}
+			// --- load language ---
+			{
+				string folder = Program.FileSystem.GetDataFolder("Languages");
+				string file = OpenBveApi.Path.CombineFile(folder, Interface.CurrentOptions.LanguageCode + ".cfg");
+				if (!System.IO.File.Exists(file)) {
+					file = OpenBveApi.Path.CombineFile(folder, "en-US.cfg");
+				}
+				Interface.LoadLanguage(file);
+			}
 			// --- check the command-line arguments for route and train ---
 			formMain.MainDialogResult result = new formMain.MainDialogResult();
 			for (int i = 0; i < args.Length; i++) {
@@ -122,25 +142,6 @@ namespace OpenBve {
 				}
 				Game.Reset(false);
 			}
-			// --- load options and controls ---
-			Interface.LoadOptions();
-			Interface.LoadControls(null, out Interface.CurrentControls);
-			{
-				string folder = Program.FileSystem.GetDataFolder("Controls");
-				string file = OpenBveApi.Path.CombineFile(folder, "Default keyboard assignment.controls");
-				Interface.Control[] controls;
-				Interface.LoadControls(file, out controls);
-				Interface.AddControls(ref Interface.CurrentControls, controls);
-			}
-			// --- load language ---
-			{
-				string folder = Program.FileSystem.GetDataFolder("Languages");
-				string file = OpenBveApi.Path.CombineFile(folder, Interface.CurrentOptions.LanguageCode + ".cfg");
-				if (!System.IO.File.Exists(file)) {
-					file = OpenBveApi.Path.CombineFile(folder, "en-US.cfg");
-				}
-				Interface.LoadLanguage(file);
-			}
 			// --- show the main menu if necessary ---
 			if (result.RouteFile == null | result.TrainFolder == null) {
 				// begin HACK //
@@ -149,10 +150,11 @@ namespace OpenBve {
 					return;
 				}
 				// end HACK //
-				result = formMain.ShowMainDialog();
+				result = formMain.ShowMainDialog(result);
+			} else {
+				result.Start = true;
 			}
 			// --- start the actual program ---
-			Program.SetPackageLookupDirectories();
 			if (result.Start) {
 				if (Initialize()) {
 					MainLoop.StartLoopEx(result);

-- 
openbve



More information about the Pkg-cli-apps-commits mailing list