Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
leezer3 committed Jul 3, 2018
2 parents 70a8b6e + f9afb75 commit 86b1376
Show file tree
Hide file tree
Showing 64 changed files with 1,697 additions and 1,178 deletions.
17 changes: 17 additions & 0 deletions OpenBVE.sln
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Texture.Dds", "source\Plugi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Formats.Msts", "source\Plugins\Formats.Msts\Formats.Msts.csproj", "{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sound.MP3", "source\Plugins\Sound.MP3\Sound.MP3.csproj", "{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -223,15 +225,29 @@ Global
{EEC75E83-E284-44E0-B321-3F5C6512074F}.Release|x86.ActiveCfg = Release|x86
{EEC75E83-E284-44E0-B321-3F5C6512074F}.Release|x86.Build.0 = Release|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Debug|Any CPU.ActiveCfg = Debug|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Debug|Any CPU.Build.0 = Debug|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Debug|Mixed Platforms.Build.0 = Debug|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Debug|x86.ActiveCfg = Debug|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Debug|x86.Build.0 = Debug|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Release|Any CPU.ActiveCfg = Release|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Release|Any CPU.Build.0 = Release|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Release|Mixed Platforms.ActiveCfg = Release|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Release|Mixed Platforms.Build.0 = Release|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Release|x86.ActiveCfg = Release|x86
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA}.Release|x86.Build.0 = Release|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Debug|Any CPU.ActiveCfg = Debug|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Debug|Any CPU.Build.0 = Debug|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Debug|Mixed Platforms.Build.0 = Debug|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Debug|x86.ActiveCfg = Debug|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Debug|x86.Build.0 = Debug|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Release|Any CPU.ActiveCfg = Release|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Release|Any CPU.Build.0 = Release|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Release|Mixed Platforms.ActiveCfg = Release|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Release|Mixed Platforms.Build.0 = Release|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Release|x86.ActiveCfg = Release|x86
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -245,6 +261,7 @@ Global
{E9B64673-65B7-4D77-A4DB-4B441A7C9197} = {3D6660F8-52D2-4A30-8F1E-1922DDCF10F9}
{EEC75E83-E284-44E0-B321-3F5C6512074F} = {16553295-E70F-4596-AA78-848EEA576C4A}
{E81B7BD8-A326-47D3-B7EE-E9C7D4D119FA} = {16553295-E70F-4596-AA78-848EEA576C4A}
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E} = {16553295-E70F-4596-AA78-848EEA576C4A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {50B52A67-69B1-4B19-A59C-FF058FD9EBDF}
Expand Down
7 changes: 7 additions & 0 deletions assets/Plugins/Sound.MP3.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="..\..\" />
</assemblyBinding>
</runtime>
</configuration>
7 changes: 7 additions & 0 deletions assets/Plugins/Sound.RiffWave.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="..\..\" />
</assemblyBinding>
</runtime>
</configuration>
Binary file modified dependencies/AtsPluginProxy.dll
Binary file not shown.
Binary file added dependencies/NAudio.dll
Binary file not shown.
31 changes: 31 additions & 0 deletions licenses/NAudio.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Microsoft Public License (Ms-PL)

This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

1. Definitions

The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.

A "contribution" is the original software, or any additions or changes to the software.

A "contributor" is any person that distributes its contribution under this license.

"Licensed patents" are a contributor's patent claims that read directly on its contribution.

2. Grant of Rights

(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.

(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

3. Conditions and Limitations

(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.

(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.

(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.

(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.

(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
30 changes: 29 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ SOUND_FLAC_FILE :=Data/Plugins/Sound.Flac.dll
SOUND_RIFFWAVE_ROOT :=source/Plugins/Sound.RiffWave
SOUND_RIFFWAVE_FILE :=Data/Plugins/Sound.RiffWave.dll

SOUND_MP3_ROOT :=source/Plugins/Sound.MP3
SOUND_MP3_FILE :=Data/Plugins/Sound.MP3.dll

TEXTURE_ACE_ROOT :=source/Plugins/Texture.Ace
TEXTURE_ACE_FILE :=Data/Plugins/Texture.Ace.dll

Expand Down Expand Up @@ -238,6 +241,7 @@ clean:
rm -f bin*/Data/Plugins/OpenBveAts.dll* bin*/Data/Plugins/OpenBveAts.pdb
rm -f bin*/Data/Plugins/Sound.Flac.dll* bin*/Data/Plugins/Sound.Flac.pdb
rm -f bin*/Data/Plugins/Sound.RiffWave.dll* bin*/Data/Plugins/Sound.RiffWave.pdb
rm -f bin*/Data/Plugins/Sound.MP3.dll* bin*/Data/Plugins/Sound.MP3.pdb
rm -f bin*/Data/Plugins/Texture.Ace.dll* bin*/Data/Plugins/Texture.Ace.pdb
rm -f bin*/Data/Plugins/Texture.BmpGifJpegPngTiff.dll* bin*/Data/Plugins/Texture.BmpGifJpegPngTiff.pdb
rm -f bin*/Data/Plugins/Texture.Dds.dll* bin*/Data/Plugins/Texture.Dds.pdb
Expand Down Expand Up @@ -333,6 +337,7 @@ $(DEBUG_DIR)/$(OPEN_BVE_FILE): $(DEBUG_DIR)/$(OPEN_BVE_API_FILE)
$(DEBUG_DIR)/$(OPEN_BVE_FILE): $(DEBUG_DIR)/$(OPEN_BVE_ATS_FILE)
$(DEBUG_DIR)/$(OPEN_BVE_FILE): $(DEBUG_DIR)/$(SOUND_FLAC_FILE)
$(DEBUG_DIR)/$(OPEN_BVE_FILE): $(DEBUG_DIR)/$(SOUND_RIFFWAVE_FILE)
$(DEBUG_DIR)/$(OPEN_BVE_FILE): $(DEBUG_DIR)/$(SOUND_MP3_FILE)
$(DEBUG_DIR)/$(OPEN_BVE_FILE): $(DEBUG_DIR)/$(TEXTURE_ACE_FILE)
$(DEBUG_DIR)/$(OPEN_BVE_FILE): $(DEBUG_DIR)/$(TEXTURE_BGJPT_FILE)
$(DEBUG_DIR)/$(OPEN_BVE_FILE): $(DEBUG_DIR)/$(TEXTURE_DDS_FILE)
Expand All @@ -343,6 +348,7 @@ $(RELEASE_DIR)/$(OPEN_BVE_FILE): $(RELEASE_DIR)/$(OPEN_BVE_API_FILE)
$(RELEASE_DIR)/$(OPEN_BVE_FILE): $(RELEASE_DIR)/$(OPEN_BVE_ATS_FILE)
$(RELEASE_DIR)/$(OPEN_BVE_FILE): $(RELEASE_DIR)/$(SOUND_FLAC_FILE)
$(RELEASE_DIR)/$(OPEN_BVE_FILE): $(RELEASE_DIR)/$(SOUND_RIFFWAVE_FILE)
$(RELEASE_DIR)/$(OPEN_BVE_FILE): $(RELEASE_DIR)/$(SOUND_MP3_FILE)
$(RELEASE_DIR)/$(OPEN_BVE_FILE): $(RELEASE_DIR)/$(TEXTURE_ACE_FILE)
$(RELEASE_DIR)/$(OPEN_BVE_FILE): $(RELEASE_DIR)/$(TEXTURE_BGJPT_FILE)
$(RELEASE_DIR)/$(OPEN_BVE_FILE): $(RELEASE_DIR)/$(TEXTURE_DDS_FILE)
Expand Down Expand Up @@ -473,7 +479,29 @@ $(RELEASE_DIR)/$(SOUND_RIFFWAVE_FILE): $(RELEASE_DIR)/$(OPEN_BVE_API_FILE)
$(DEBUG_DIR)/$(SOUND_RIFFWAVE_FILE) $(RELEASE_DIR)/$(SOUND_RIFFWAVE_FILE): $(SOUND_RIFFWAVE_SRC) $(SOUND_RIFFWAVE_RESOURCE)
@echo $(COLOR_MAGENTA)Building $(COLOR_CYAN)$(SOUND_RIFFWAVE_OUT)$(COLOR_END)
@$(CSC) /out:$(SOUND_RIFFWAVE_OUT) /target:library $(SOUND_RIFFWAVE_SRC) $(ARGS) $(SOUND_RIFFWAVE_DOC) \
/reference:$(OPEN_BVE_API_OUT) $(addprefix /resource:, $(SOUND_RIFFWAVE_RESOURCE))
/reference:$(OPEN_BVE_API_OUT) /reference:$(OUTPUT_DIR)/NAudio.dll $(addprefix /resource:, $(SOUND_RIFFWAVE_RESOURCE))

#############
# Sound.MP3 #
#############

SOUND_MP3_FOLDERS := . Properties
SOUND_MP3_FOLDERS := $(addprefix $(SOUND_MP3_ROOT)/, $(SOUND_MP3_FOLDERS))
SOUND_MP3_SRC := $(foreach sdir, $(SOUND_MP3_FOLDERS), $(wildcard $(sdir)/*.cs))
SOUND_MP3_DOC := $(addprefix /doc:, $(foreach sdir, $(SOUND_MP3_FOLDERS), $(wildcard $(sdir)/*.xml)))
SOUND_MP3_RESX := $(foreach sdir, $(SOUND_MP3_FOLDERS), $(wildcard $(sdir)/*.resx))
SOUND_MP3_RESOURCE := $(addprefix $(SOUND_MP3_ROOT)/, $(subst /,., $(subst /./,/, $(patsubst $(dir $(SOUND_MP3_ROOT))%.resx, %.resources, $(SOUND_MP3_RESX)))))
SOUND_MP3_OUT =$(OUTPUT_DIR)/$(SOUND_MP3_FILE)

$(call create_resource, $(SOUND_MP3_RESOURCE), $(SOUND_MP3_RESX))

$(DEBUG_DIR)/$(SOUND_MP3_FILE): $(DEBUG_DIR)/$(OPEN_BVE_API_FILE)
$(RELEASE_DIR)/$(SOUND_MP3_FILE): $(RELEASE_DIR)/$(OPEN_BVE_API_FILE)

$(DEBUG_DIR)/$(SOUND_MP3_FILE) $(RELEASE_DIR)/$(SOUND_MP3_FILE): $(SOUND_MP3_SRC) $(SOUND_MP3_RESOURCE)
@echo $(COLOR_MAGENTA)Building $(COLOR_CYAN)$(SOUND_MP3_OUT)$(COLOR_END)
@$(CSC) /out:$(SOUND_MP3_OUT) /target:library $(SOUND_MP3_SRC) $(ARGS) $(SOUND_MP3_DOC) \
/reference:$(OPEN_BVE_API_OUT) /reference:$(OUTPUT_DIR)/NAudio.dll $(addprefix /resource:, $(SOUND_MP3_RESOURCE))

###############
# Texture.Ace #
Expand Down
43 changes: 4 additions & 39 deletions source/ObjectViewer/InterfaceS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// ╚══════════════════════════════════════════════════════════════╝

using System;
using OpenBveApi;
using OpenBveApi.Math;

namespace OpenBve {
Expand Down Expand Up @@ -145,8 +146,9 @@ internal struct Options {


// try parse time
internal static bool TryParseTime(string Expression, out double Value) {
Expression = TrimInside(Expression);
internal static bool TryParseTime(string Expression, out double Value)
{
Expression = Expression.TrimInside();
if (Expression.Length != 0) {
System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture;
int i = Expression.IndexOf('.');
Expand Down Expand Up @@ -178,49 +180,12 @@ internal static bool TryParseTime(string Expression, out double Value) {
return false;
}

// trim inside
private static string TrimInside(string Expression) {
System.Text.StringBuilder Builder = new System.Text.StringBuilder(Expression.Length);
for (int i = 0; i < Expression.Length; i++) {
char c = Expression[i];
if (!char.IsWhiteSpace(c)) {
Builder.Append(c);
}
} return Builder.ToString();
}

// ================================

// round to power of two
internal static int RoundToPowerOfTwo(int Value) {
Value -= 1;
for (int i = 1; i < sizeof(int) * 8; i *= 2) {
Value = Value | Value >> i;
} return Value + 1;
}

// convert newlines to crlf
internal static string ConvertNewlinesToCrLf(string Text) {
System.Text.StringBuilder Builder = new System.Text.StringBuilder();
for (int i = 0; i < Text.Length; i++) {
int a = char.ConvertToUtf32(Text, i);
if (a == 0xD & i < Text.Length - 1) {
int b = char.ConvertToUtf32(Text, i + 1);
if (b == 0xA) {
Builder.Append("\r\n");
i++;
} else {
Builder.Append("\r\n");
}
} else if (a == 0xA | a == 0xC | a == 0xD | a == 0x85 | a == 0x2028 | a == 0x2029) {
Builder.Append("\r\n");
} else if (a < 0x10000) {
Builder.Append(Text[i]);
} else {
Builder.Append(Text.Substring(i, 2));
i++;
}
} return Builder.ToString();
}
}
}
6 changes: 5 additions & 1 deletion source/ObjectViewer/ObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,11 @@ internal static UnifiedObject LoadObject(string FileName, System.Text.Encoding E
Interface.AddMessage(Interface.MessageType.Error, false, "The file extension is not supported: " + FileName);
return null;
}
Result.OptimizeObject(PreserveVertices);

if (Result != null)
{
Result.OptimizeObject(PreserveVertices);
}
return Result;
#if !DEBUG
} catch (Exception ex) {
Expand Down
78 changes: 58 additions & 20 deletions source/ObjectViewer/Parsers/WavefrontObjParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ internal Material()
}
private class MeshBuilder
{
internal List<VertexTemplate> Vertices;
internal List<Vertex> Vertices;
internal List<World.MeshFace> Faces;
internal Material[] Materials;
internal MeshBuilder()
{
this.Vertices = new List<VertexTemplate>();
this.Vertices = new List<Vertex>();
this.Faces = new List<World.MeshFace>();
this.Materials = new Material[] { };
}
Expand Down Expand Up @@ -165,26 +165,43 @@ internal static ObjectManager.StaticObject ReadObject(string FileName, System.Te
//Creates a new face

//Create the temp list to hook out the vertices
List<VertexTemplate> vertices = new List<VertexTemplate>();
List<Vertex> vertices = new List<Vertex>();
List<Vector3> normals = new List<Vector3>();
for (int f = 1; f < Arguments.Count; f++)
{
Vertex newVertex = new Vertex();
string[] faceArguments = Arguments[f].Split(new char[] {'/'} , StringSplitOptions.None);
int idx;
if (!int.TryParse(faceArguments[0], out idx) || idx > tempVertices.Count)
if (!int.TryParse(faceArguments[0], out idx))
{
Interface.AddMessage(Interface.MessageType.Warning, false, "Invalid Vertex index in Face " + f + " at Line " + i);
continue;
}
newVertex.Coordinates = tempVertices[idx - 1];

int currentVertex = tempVertices.Count;
if (idx != Math.Abs(idx))
{
//Offset, so we seem to need to add one....
currentVertex++;
currentVertex += idx;
}
else
{
currentVertex = idx;
}
if (currentVertex > tempVertices.Count)
{
Interface.AddMessage(Interface.MessageType.Warning, false, "Vertex index " + idx + " was greater than the available number of vertices in Face " + f + " at Line " + i);
continue;
}
newVertex.Coordinates = tempVertices[currentVertex - 1];
if (faceArguments.Length <= 1)
{
normals.Add(new Vector3());
}
else
{
if (!int.TryParse(faceArguments[1], out idx) || idx > tempCoords.Count)
if (!int.TryParse(faceArguments[1], out idx))
{
if (!string.IsNullOrEmpty(faceArguments[1]))
{
Expand All @@ -194,7 +211,22 @@ internal static ObjectManager.StaticObject ReadObject(string FileName, System.Te
}
else
{
newVertex.TextureCoordinates = tempCoords[idx - 1];
int currentCoord = tempCoords.Count;
if (idx != Math.Abs(idx))
{
//Offset, so we seem to need to add one....
currentCoord++;
currentCoord += idx;
}
if (currentCoord > tempCoords.Count)
{
Interface.AddMessage(Interface.MessageType.Warning, false, "Texture Co-ordinate index " + currentCoord + " was greater than the available number of texture co-ordinates in Face " + f + " at Line " + i);
}
else
{
newVertex.TextureCoordinates = tempCoords[currentCoord - 1];
}

}
}
if (faceArguments.Length <= 2)
Expand All @@ -203,7 +235,7 @@ internal static ObjectManager.StaticObject ReadObject(string FileName, System.Te
}
else
{
if (!int.TryParse(faceArguments[2], out idx) || idx > tempNormals.Count)
if (!int.TryParse(faceArguments[2], out idx))
{
if (!string.IsNullOrEmpty(faceArguments[2]))
{
Expand All @@ -213,25 +245,31 @@ internal static ObjectManager.StaticObject ReadObject(string FileName, System.Te
}
else
{
normals.Add(tempNormals[idx - 1]);
int currentNormal = tempNormals.Count;
if (idx != Math.Abs(idx))
{
//Offset, so we seem to need to add one....
currentNormal++;
currentNormal += idx;
}
if (currentNormal > tempNormals.Count)
{
Interface.AddMessage(Interface.MessageType.Warning, false, "Vertex Normal index " + currentNormal + " was greater than the available number of normals in Face " + f + " at Line " + i);
normals.Add(new Vector3());
}
else
{
normals.Add(tempNormals[currentNormal - 1]);
}
}
}
vertices.Add(newVertex);
}
World.MeshFaceVertex[] Vertices = new World.MeshFaceVertex[vertices.Count];
for (int k = 0; k < vertices.Count; k++)
{
int v = Builder.Vertices.FindIndex(a => a.Equals(vertices[k]));
if (v != -1)
{
Vertices[k].Index = (ushort)v;
}
else
{
Builder.Vertices.Add(vertices[k]);
Vertices[k].Index = (ushort)(Builder.Vertices.Count -1);
}

Builder.Vertices.Add(vertices[k]);
Vertices[k].Index = (ushort)(Builder.Vertices.Count -1);
Vertices[k].Normal = normals[k];
}
Builder.Faces.Add(currentMaterial == -1 ? new World.MeshFace(Vertices, 0) : new World.MeshFace(Vertices, (ushort)currentMaterial));
Expand Down
Loading

0 comments on commit 86b1376

Please sign in to comment.