1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-19 08:36:34 +09:00

XNA extensions updated to use NetBuffer and VS2010

This commit is contained in:
lidgren
2012-07-02 07:14:21 +00:00
parent e0c3a34b91
commit 90ba729c35
3 changed files with 68 additions and 37 deletions

View File

@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 10.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2008 # Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren XNA Extensions", "Lidgren XNA Extensions\Lidgren XNA Extensions.csproj", "{2B661ABD-63A8-4916-A94B-034729231271}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren XNA Extensions", "Lidgren XNA Extensions\Lidgren XNA Extensions.csproj", "{2B661ABD-63A8-4916-A94B-034729231271}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "..\Lidgren.Network\Lidgren.Network.csproj", "{FA245447-5F23-4AA1-BD5F-8D2DDF33CFBD}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "..\Lidgren.Network\Lidgren.Network.csproj", "{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,10 +15,10 @@ Global
{2B661ABD-63A8-4916-A94B-034729231271}.Debug|Any CPU.Build.0 = Debug|Any CPU {2B661ABD-63A8-4916-A94B-034729231271}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B661ABD-63A8-4916-A94B-034729231271}.Release|Any CPU.ActiveCfg = Release|Any CPU {2B661ABD-63A8-4916-A94B-034729231271}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B661ABD-63A8-4916-A94B-034729231271}.Release|Any CPU.Build.0 = Release|Any CPU {2B661ABD-63A8-4916-A94B-034729231271}.Release|Any CPU.Build.0 = Release|Any CPU
{FA245447-5F23-4AA1-BD5F-8D2DDF33CFBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA245447-5F23-4AA1-BD5F-8D2DDF33CFBD}.Debug|Any CPU.Build.0 = Debug|Any CPU {49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA245447-5F23-4AA1-BD5F-8D2DDF33CFBD}.Release|Any CPU.ActiveCfg = Release|Any CPU {49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA245447-5F23-4AA1-BD5F-8D2DDF33CFBD}.Release|Any CPU.Build.0 = Release|Any CPU {49BA1C69-6104-41AC-A5D8-B54FA9F696E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -12,6 +12,21 @@
<AssemblyName>Lidgren.Network.Xna</AssemblyName> <AssemblyName>Lidgren.Network.Xna</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -21,6 +36,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -29,6 +45,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" /> <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
@@ -36,14 +53,6 @@
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="XNAExtensions.cs" /> <Compile Include="XNAExtensions.cs" />
@@ -55,6 +64,28 @@
<Name>Lidgren.Network</Name> <Name>Lidgren.Network</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -13,7 +13,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Write a Point /// Write a Point
/// </summary> /// </summary>
public static void Write(this NetOutgoingMessage message, Point value) public static void Write(this NetBuffer message, Point value)
{ {
message.Write(value.X); message.Write(value.X);
message.Write(value.Y); message.Write(value.Y);
@@ -22,7 +22,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Read a Point /// Read a Point
/// </summary> /// </summary>
public static Point ReadPoint(this NetIncomingMessage message) public static Point ReadPoint(this NetBuffer message)
{ {
return new Point(message.ReadInt32(), message.ReadInt32()); return new Point(message.ReadInt32(), message.ReadInt32());
} }
@@ -30,7 +30,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Write a Single with half precision (16 bits) /// Write a Single with half precision (16 bits)
/// </summary> /// </summary>
public static void WriteHalfPrecision(this NetOutgoingMessage message, float value) public static void WriteHalfPrecision(this NetBuffer message, float value)
{ {
message.Write(new HalfSingle(value).PackedValue); message.Write(new HalfSingle(value).PackedValue);
} }
@@ -38,7 +38,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a half precision Single written using WriteHalfPrecision(float) /// Reads a half precision Single written using WriteHalfPrecision(float)
/// </summary> /// </summary>
public static float ReadHalfPrecisionSingle(this NetIncomingMessage message) public static float ReadHalfPrecisionSingle(this NetBuffer message)
{ {
HalfSingle h = new HalfSingle(); HalfSingle h = new HalfSingle();
h.PackedValue = message.ReadUInt16(); h.PackedValue = message.ReadUInt16();
@@ -48,7 +48,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Writes a Vector2 /// Writes a Vector2
/// </summary> /// </summary>
public static void Write(this NetOutgoingMessage message, Vector2 vector) public static void Write(this NetBuffer message, Vector2 vector)
{ {
message.Write(vector.X); message.Write(vector.X);
message.Write(vector.Y); message.Write(vector.Y);
@@ -57,7 +57,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a Vector2 /// Reads a Vector2
/// </summary> /// </summary>
public static Vector2 ReadVector2(this NetIncomingMessage message) public static Vector2 ReadVector2(this NetBuffer message)
{ {
Vector2 retval; Vector2 retval;
retval.X = message.ReadSingle(); retval.X = message.ReadSingle();
@@ -68,7 +68,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Writes a Vector3 /// Writes a Vector3
/// </summary> /// </summary>
public static void Write(this NetOutgoingMessage message, Vector3 vector) public static void Write(this NetBuffer message, Vector3 vector)
{ {
message.Write(vector.X); message.Write(vector.X);
message.Write(vector.Y); message.Write(vector.Y);
@@ -78,7 +78,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Writes a Vector3 at half precision /// Writes a Vector3 at half precision
/// </summary> /// </summary>
public static void WriteHalfPrecision(this NetOutgoingMessage message, Vector3 vector) public static void WriteHalfPrecision(this NetBuffer message, Vector3 vector)
{ {
message.Write(new HalfSingle(vector.X).PackedValue); message.Write(new HalfSingle(vector.X).PackedValue);
message.Write(new HalfSingle(vector.Y).PackedValue); message.Write(new HalfSingle(vector.Y).PackedValue);
@@ -88,7 +88,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a Vector3 /// Reads a Vector3
/// </summary> /// </summary>
public static Vector3 ReadVector3(this NetIncomingMessage message) public static Vector3 ReadVector3(this NetBuffer message)
{ {
Vector3 retval; Vector3 retval;
retval.X = message.ReadSingle(); retval.X = message.ReadSingle();
@@ -100,7 +100,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Writes a Vector3 at half precision /// Writes a Vector3 at half precision
/// </summary> /// </summary>
public static Vector3 ReadHalfPrecisionVector3(this NetIncomingMessage message) public static Vector3 ReadHalfPrecisionVector3(this NetBuffer message)
{ {
HalfSingle hx = new HalfSingle(); HalfSingle hx = new HalfSingle();
hx.PackedValue = message.ReadUInt16(); hx.PackedValue = message.ReadUInt16();
@@ -121,7 +121,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Writes a Vector4 /// Writes a Vector4
/// </summary> /// </summary>
public static void Write(this NetOutgoingMessage message, Vector4 vector) public static void Write(this NetBuffer message, Vector4 vector)
{ {
message.Write(vector.X); message.Write(vector.X);
message.Write(vector.Y); message.Write(vector.Y);
@@ -132,7 +132,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a Vector4 /// Reads a Vector4
/// </summary> /// </summary>
public static Vector4 ReadVector4(this NetIncomingMessage message) public static Vector4 ReadVector4(this NetBuffer message)
{ {
Vector4 retval; Vector4 retval;
retval.X = message.ReadSingle(); retval.X = message.ReadSingle();
@@ -147,7 +147,7 @@ namespace Lidgren.Network.Xna
/// Writes a unit vector (ie. a vector of length 1.0, for example a surface normal) /// Writes a unit vector (ie. a vector of length 1.0, for example a surface normal)
/// using specified number of bits /// using specified number of bits
/// </summary> /// </summary>
public static void WriteUnitVector3(this NetOutgoingMessage message, Vector3 unitVector, int numberOfBits) public static void WriteUnitVector3(this NetBuffer message, Vector3 unitVector, int numberOfBits)
{ {
float x = unitVector.X; float x = unitVector.X;
float y = unitVector.Y; float y = unitVector.Y;
@@ -164,7 +164,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a unit vector written using WriteUnitVector3(numberOfBits) /// Reads a unit vector written using WriteUnitVector3(numberOfBits)
/// </summary> /// </summary>
public static Vector3 ReadUnitVector3(this NetIncomingMessage message, int numberOfBits) public static Vector3 ReadUnitVector3(this NetBuffer message, int numberOfBits)
{ {
int halfBits = numberOfBits / 2; int halfBits = numberOfBits / 2;
float phi = message.ReadSignedSingle(halfBits) * (float)Math.PI; float phi = message.ReadSignedSingle(halfBits) * (float)Math.PI;
@@ -182,7 +182,7 @@ namespace Lidgren.Network.Xna
/// Writes a unit quaternion using the specified number of bits per element /// Writes a unit quaternion using the specified number of bits per element
/// for a total of 4 x bitsPerElements bits. Suggested value is 8 to 24 bits. /// for a total of 4 x bitsPerElements bits. Suggested value is 8 to 24 bits.
/// </summary> /// </summary>
public static void WriteRotation(this NetOutgoingMessage message, Quaternion quaternion, int bitsPerElement) public static void WriteRotation(this NetBuffer message, Quaternion quaternion, int bitsPerElement)
{ {
if (quaternion.X > 1.0f) if (quaternion.X > 1.0f)
quaternion.X = 1.0f; quaternion.X = 1.0f;
@@ -210,7 +210,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a unit quaternion written using WriteRotation(... ,bitsPerElement) /// Reads a unit quaternion written using WriteRotation(... ,bitsPerElement)
/// </summary> /// </summary>
public static Quaternion ReadRotation(this NetIncomingMessage message, int bitsPerElement) public static Quaternion ReadRotation(this NetBuffer message, int bitsPerElement)
{ {
Quaternion retval; Quaternion retval;
retval.X = message.ReadSignedSingle(bitsPerElement); retval.X = message.ReadSignedSingle(bitsPerElement);
@@ -223,7 +223,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Writes an orthonormal matrix (rotation, translation but not scaling or projection) /// Writes an orthonormal matrix (rotation, translation but not scaling or projection)
/// </summary> /// </summary>
public static void WriteMatrix(this NetOutgoingMessage message, ref Matrix matrix) public static void WriteMatrix(this NetBuffer message, ref Matrix matrix)
{ {
Quaternion rot = Quaternion.CreateFromRotationMatrix(matrix); Quaternion rot = Quaternion.CreateFromRotationMatrix(matrix);
WriteRotation(message, rot, 24); WriteRotation(message, rot, 24);
@@ -235,7 +235,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Writes an orthonormal matrix (rotation, translation but no scaling or projection) /// Writes an orthonormal matrix (rotation, translation but no scaling or projection)
/// </summary> /// </summary>
public static void WriteMatrix(this NetOutgoingMessage message, Matrix matrix) public static void WriteMatrix(this NetBuffer message, Matrix matrix)
{ {
Quaternion rot = Quaternion.CreateFromRotationMatrix(matrix); Quaternion rot = Quaternion.CreateFromRotationMatrix(matrix);
WriteRotation(message, rot, 24); WriteRotation(message, rot, 24);
@@ -247,7 +247,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a matrix written using WriteMatrix() /// Reads a matrix written using WriteMatrix()
/// </summary> /// </summary>
public static Matrix ReadMatrix(this NetIncomingMessage message) public static Matrix ReadMatrix(this NetBuffer message)
{ {
Quaternion rot = ReadRotation(message, 24); Quaternion rot = ReadRotation(message, 24);
Matrix retval = Matrix.CreateFromQuaternion(rot); Matrix retval = Matrix.CreateFromQuaternion(rot);
@@ -260,7 +260,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a matrix written using WriteMatrix() /// Reads a matrix written using WriteMatrix()
/// </summary> /// </summary>
public static void ReadMatrix(this NetIncomingMessage message, ref Matrix destination) public static void ReadMatrix(this NetBuffer message, ref Matrix destination)
{ {
Quaternion rot = ReadRotation(message, 24); Quaternion rot = ReadRotation(message, 24);
destination = Matrix.CreateFromQuaternion(rot); destination = Matrix.CreateFromQuaternion(rot);
@@ -272,7 +272,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Writes a bounding sphere /// Writes a bounding sphere
/// </summary> /// </summary>
public static void Write(this NetOutgoingMessage message, BoundingSphere bounds) public static void Write(this NetBuffer message, BoundingSphere bounds)
{ {
message.Write(bounds.Center.X); message.Write(bounds.Center.X);
message.Write(bounds.Center.Y); message.Write(bounds.Center.Y);
@@ -283,7 +283,7 @@ namespace Lidgren.Network.Xna
/// <summary> /// <summary>
/// Reads a bounding sphere written using Write(message, BoundingSphere) /// Reads a bounding sphere written using Write(message, BoundingSphere)
/// </summary> /// </summary>
public static BoundingSphere ReadBoundingSphere(this NetIncomingMessage message) public static BoundingSphere ReadBoundingSphere(this NetBuffer message)
{ {
BoundingSphere retval; BoundingSphere retval;
retval.Center.X = message.ReadSingle(); retval.Center.X = message.ReadSingle();