git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1297 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
48
OpenRa.DataStructures/OpenRa.DataStructures.csproj
Normal file
48
OpenRa.DataStructures/OpenRa.DataStructures.csproj
Normal file
@@ -0,0 +1,48 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenRa.DataStructures</RootNamespace>
|
||||
<AssemblyName>OpenRa.DataStructures</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PriorityQueue.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tuple.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
133
OpenRa.DataStructures/PriorityQueue.cs
Normal file
133
OpenRa.DataStructures/PriorityQueue.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace OpenRa.DataStructures
|
||||
{
|
||||
class PriorityQueue<T>
|
||||
where T : IComparable<T>
|
||||
{
|
||||
List<T[]> items = new List<T[]>();
|
||||
int level;
|
||||
int index;
|
||||
|
||||
public PriorityQueue()
|
||||
{
|
||||
items.Add( new T[ 1 ] );
|
||||
}
|
||||
|
||||
public void Add( T item )
|
||||
{
|
||||
int addLevel = level;
|
||||
int addIndex = index;
|
||||
|
||||
while( addLevel >= 1 && Above( addLevel, addIndex ).CompareTo( item ) > 0 )
|
||||
{
|
||||
items[ addLevel ][ addIndex ] = Above( addLevel, addIndex );
|
||||
--addLevel;
|
||||
addIndex >>= 1;
|
||||
}
|
||||
|
||||
items[ addLevel ][ addIndex ] = item;
|
||||
|
||||
++index;
|
||||
if( index >= ( 1 << level ) )
|
||||
{
|
||||
index = 0;
|
||||
++level;
|
||||
items.Add( new T[ 1 << level ] );
|
||||
}
|
||||
}
|
||||
|
||||
T At( int level, int index )
|
||||
{
|
||||
return items[ level ][ index ];
|
||||
}
|
||||
|
||||
T Above( int level, int index )
|
||||
{
|
||||
return items[ level - 1 ][ index >> 1 ];
|
||||
}
|
||||
|
||||
T Last()
|
||||
{
|
||||
int lastLevel = level;
|
||||
int lastIndex = index;
|
||||
--lastIndex;
|
||||
if( lastIndex < 0 )
|
||||
{
|
||||
--lastLevel;
|
||||
lastIndex = ( 1 << lastLevel ) - 1;
|
||||
}
|
||||
return At( lastLevel, lastIndex );
|
||||
}
|
||||
|
||||
public T Pop()
|
||||
{
|
||||
if( level == 0 && index == 0 )
|
||||
throw new InvalidOperationException( "Attempting to pop empty PriorityQueue" );
|
||||
|
||||
T ret = At( 0, 0 );
|
||||
BubbleInto( 0, 0, Last() );
|
||||
--index;
|
||||
if( index < 0 )
|
||||
{
|
||||
--level;
|
||||
index = ( 1 << level ) - 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void BubbleInto( int intoLevel, int intoIndex, T val )
|
||||
{
|
||||
int downLevel = intoLevel + 1;
|
||||
int downIndex = intoIndex << 1;
|
||||
|
||||
if( downLevel > level || ( downLevel == level && downIndex >= index ))
|
||||
{
|
||||
items[ intoLevel ][ intoIndex ] = val;
|
||||
return;
|
||||
}
|
||||
|
||||
if( downLevel == level && downIndex == index - 1 )
|
||||
{
|
||||
//Log.Write( "one-option bubble" );
|
||||
}
|
||||
else if( At( downLevel, downIndex ).CompareTo( At( downLevel, downIndex + 1 ) ) < 0 )
|
||||
{
|
||||
//Log.Write( "left bubble" );
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Write( "right bubble" );
|
||||
++downIndex;
|
||||
}
|
||||
|
||||
if( val.CompareTo( At( downLevel, downIndex ) ) <= 0 )
|
||||
{
|
||||
items[ intoLevel ][ intoIndex ] = val;
|
||||
return;
|
||||
}
|
||||
|
||||
items[ intoLevel ][ intoIndex ] = At( downLevel, downIndex );
|
||||
BubbleInto( downLevel, downIndex, val );
|
||||
}
|
||||
|
||||
//void Invariant()
|
||||
//{
|
||||
// for( int i = 1 ; i < level ; i++ )
|
||||
// for( int j = 0 ; j < RowLength( i ) ; j++ )
|
||||
// if( At( i, j ).CompareTo( Above( i, j ) ) < 0 )
|
||||
// System.Diagnostics.Debug.Assert( At( i, j ).CompareTo( Above( i, j ) ) < 0, "At( i, j ) > Above( i, j )" );
|
||||
//}
|
||||
|
||||
private int RowLength( int i )
|
||||
{
|
||||
if( i == level )
|
||||
return index;
|
||||
return ( 1 << i );
|
||||
}
|
||||
}
|
||||
}
|
||||
35
OpenRa.DataStructures/Properties/AssemblyInfo.cs
Normal file
35
OpenRa.DataStructures/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle( "OpenRa.DataStructures" )]
|
||||
[assembly: AssemblyDescription( "" )]
|
||||
[assembly: AssemblyConfiguration( "" )]
|
||||
[assembly: AssemblyCompany( "" )]
|
||||
[assembly: AssemblyProduct( "OpenRa.DataStructures" )]
|
||||
[assembly: AssemblyCopyright( "Copyright © 2007" )]
|
||||
[assembly: AssemblyTrademark( "" )]
|
||||
[assembly: AssemblyCulture( "" )]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible( false )]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid( "fdbd08da-dde2-4eaf-9a8c-4bc63ac5b074" )]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion( "1.0.0.0" )]
|
||||
[assembly: AssemblyFileVersion( "1.0.0.0" )]
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.FileFormats
|
||||
namespace OpenRa.DataStructures
|
||||
{
|
||||
public class Tuple<A>
|
||||
{
|
||||
@@ -52,7 +52,6 @@
|
||||
<Compile Include="ShpReader.cs" />
|
||||
<Compile Include="Terrain.cs" />
|
||||
<Compile Include="TileSet.cs" />
|
||||
<Compile Include="Tuple.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -45,10 +45,17 @@ namespace OpenRa.Game
|
||||
};
|
||||
}
|
||||
|
||||
double timeUntilNextFrame;
|
||||
|
||||
Action<double> tickFunc;
|
||||
public void Tick( double t )
|
||||
{
|
||||
tickFunc( t );
|
||||
timeUntilNextFrame -= t;
|
||||
while( timeUntilNextFrame <= 0 )
|
||||
{
|
||||
tickFunc( t );
|
||||
timeUntilNextFrame += ( 40.0 / 1000.0 ); // 25 fps == 40 ms
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace OpenRa.Game
|
||||
world.Add( new Refinery( new int2( 7, 5 ), 2 ) );
|
||||
|
||||
sidebar = new Sidebar(Race.Soviet, renderer, viewport);
|
||||
|
||||
}
|
||||
|
||||
void PrecacheStructure(string name)
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
<Compile Include="Animation.cs" />
|
||||
<Compile Include="Building.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="PathFinder.cs" />
|
||||
<Compile Include="Sequence.cs" />
|
||||
<Compile Include="ConstructionYard.cs" />
|
||||
<Compile Include="float2.cs" />
|
||||
|
||||
@@ -21,8 +21,9 @@ namespace OpenRa.Game
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
File.WriteAllText( "error.log", e.ToString() );
|
||||
throw;
|
||||
File.WriteAllText( "error.log", e.ToString() );
|
||||
Log.Write( "{0}", e.ToString() );
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using OpenRa.FileFormats;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using OpenRa.DataStructures;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa.TechTree
|
||||
{
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
<Compile Include="TechTree.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRa.DataStructures\OpenRa.DataStructures.csproj">
|
||||
<Project>{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}</Project>
|
||||
<Name>OpenRa.DataStructures</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\OpenRa.FileFormats\OpenRa.FileFormats.csproj">
|
||||
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
|
||||
<Name>OpenRa.FileFormats</Name>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenRa.FileFormats;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using OpenRa.DataStructures;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa.TechTree
|
||||
{
|
||||
|
||||
12
OpenRa.sln
12
OpenRa.sln
@@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.TechTree", "OpenRa.T
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.BlockCacheVisualizer", "OpenRa.BlockCacheVisualizer\OpenRa.BlockCacheVisualizer.csproj", "{127D13D1-3589-4240-A33B-70C3A25536A4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.DataStructures", "OpenRa.DataStructures\OpenRa.DataStructures.csproj", "{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -89,6 +91,16 @@ Global
|
||||
{127D13D1-3589-4240-A33B-70C3A25536A4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{127D13D1-3589-4240-A33B-70C3A25536A4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{127D13D1-3589-4240-A33B-70C3A25536A4}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user