Removing dead crap from repos

git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@2048 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
chrisf
2008-07-20 18:26:03 +00:00
parent b77a116f60
commit 6f8919d301
17 changed files with 82 additions and 113 deletions

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using IjwFramework.Delegates;
namespace OpenRa.Game
{
@@ -23,40 +22,37 @@ namespace OpenRa.Game
public void Play( string sequenceName )
{
PlayThen( sequenceName, delegate { } );
PlayThen(sequenceName, () => { });
}
public void PlayRepeating( string sequenceName )
{
PlayThen( sequenceName, delegate { PlayRepeating( sequenceName ); } );
PlayThen( sequenceName, () => PlayRepeating( sequenceName ) );
}
public void PlayThen( string sequenceName, MethodInvoker after )
public void PlayThen( string sequenceName, Action after )
{
tickAlways = false;
currentSequence = SequenceProvider.GetSequence( name, sequenceName );
frame = 0;
tickFunc = delegate
tickFunc = _ =>
{
++frame;
if( frame >= currentSequence.Length )
{
frame = currentSequence.Length - 1;
tickFunc = delegate { };
tickFunc = t => { };
after();
}
};
}
public void PlayFetchIndex( string sequenceName, Provider<int> func )
public void PlayFetchIndex( string sequenceName, Func<int> func )
{
tickAlways = true;
currentSequence = SequenceProvider.GetSequence( name, sequenceName );
frame = func();
tickFunc = delegate
{
frame = func();
};
tickFunc = t => frame = func();
}
int timeUntilNextFrame;

View File

@@ -11,7 +11,7 @@ namespace OpenRa.Game
{
this.owner = owner;
animation.PlayThen( "make", delegate { animation.PlayRepeating( "idle" ); } );
animation.PlayThen( "make", () => animation.PlayRepeating( "idle" ) );
owner.TechTree.Build( name, true );
}

View File

@@ -10,7 +10,7 @@ namespace OpenRa.Game
public ConstructionYard( int2 location, Player owner, Game game )
: base( "fact", location, owner, game )
{
animation.PlayThen( "make", delegate { animation.PlayRepeating( "build" ); } );
animation.PlayThen("make", () => animation.PlayRepeating("build"));
}
}
}

View File

@@ -4,7 +4,6 @@ using System.Text;
using OpenRa.FileFormats;
using System.Drawing;
using IjwFramework.Delegates;
namespace OpenRa.Game
{
@@ -23,12 +22,12 @@ namespace OpenRa.Game
public readonly Dictionary<int, Player> players = new Dictionary<int, Player>();
// temporary, until we remove all the subclasses of Building
public Dictionary<string, Provider<Building, int2, Player>> buildingCreation = new Dictionary<string, Provider<Building, int2, Player>>();
public Dictionary<string, Func<int2, Player, Building>> buildingCreation = new Dictionary<string, Func<int2, Player, Building>>();
public Game(string mapName, Renderer renderer, int2 clientSize)
{
for( int i = 0 ; i < 8 ; i++ )
players.Add( i, new Player( i, string.Format( "Multi{0}", i ), OpenRa.TechTree.Race.Soviet ) );
for (int i = 0; i < 8; i++)
players.Add(i, new Player(i, string.Format("Multi{0}", i), OpenRa.TechTree.Race.Soviet));
map = new Map(new IniFile(FileSystem.Open(mapName)));
FileSystem.Mount(new Package(map.Theater + ".mix"));
@@ -46,29 +45,17 @@ namespace OpenRa.Game
network = new Network();
buildingCreation.Add( "fact",
delegate( int2 location, Player owner )
{
return new ConstructionYard( location, owner, this );
} );
buildingCreation.Add( "proc",
delegate( int2 location, Player owner )
{
return new Refinery( location, owner, this );
} );
buildingCreation.Add("fact", (location, owner) => new ConstructionYard(location, owner, this));
buildingCreation.Add("proc", (location, owner) => new Refinery(location, owner, this));
string[] buildings = { "powr", "apwr", "weap", "barr", "atek", "stek", "dome" };
foreach (string s in buildings)
AddBuilding(s);
}
void AddBuilding( string name )
void AddBuilding(string name)
{
buildingCreation.Add( name,
delegate( int2 location, Player owner )
{
return new Building( name, location, owner, this );
} );
buildingCreation.Add(name, (location, owner) => new Building(name, location, owner, this));
}
public void Tick()
@@ -77,9 +64,6 @@ namespace OpenRa.Game
Queue<Packet> stuffFromOtherPlayers = network.Tick(); // todo: actually use the orders!
}
public void Issue(IOrder order)
{
order.Apply( this );
}
public void Issue(IOrder order) { order.Apply(this); }
}
}

View File

@@ -26,7 +26,7 @@ namespace OpenRa.Game
{
client.EnableBroadcast = true;
Thread receiveThread = new Thread(delegate()
Thread receiveThread = new Thread( () =>
{
for (; ; )
{

View File

@@ -29,6 +29,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -60,6 +61,9 @@
<HintPath>..\..\IjwFramework\IjwFramework\bin\Debug\IjwFramework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
@@ -143,6 +147,9 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram1.cd" />
</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.

View File

@@ -24,10 +24,7 @@ namespace OpenRa.Game
: double.PositiveInfinity;
}
// returns estimate to destination, 0.0 is cell is dest
public delegate double DistanceHeuristic( int2 cell );
public List<int2> FindUnitPath( int2 unitLocation, DistanceHeuristic estimator )
public List<int2> FindUnitPath( int2 unitLocation, Func<int2,double> estimator )
{
int2 startLocation = unitLocation + map.Offset;
@@ -40,7 +37,7 @@ namespace OpenRa.Game
return FindUnitPath( startLocation, estimator, map.Offset, cellInfo );
}
List<int2> FindUnitPath( int2 startLocation, DistanceHeuristic estimator, int2 offset, CellInfo[,] cellInfo )
List<int2> FindUnitPath(int2 startLocation, Func<int2, double> estimator, int2 offset, CellInfo[,] cellInfo)
{
PriorityQueue<PathDistance> queue = new PriorityQueue<PathDistance>();
@@ -108,9 +105,9 @@ namespace OpenRa.Game
new int2( 1, 1 ),
};
public static DistanceHeuristic DefaultEstimator( int2 destination )
public static Func<int2, double> DefaultEstimator(int2 destination)
{
return delegate( int2 here )
return here =>
{
int2 d = ( here - destination ).Abs();
int diag = Math.Min( d.X, d.Y );

View File

@@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenRa.FileFormats;
using System.Drawing;
namespace OpenRa.Game
{
@@ -12,11 +6,11 @@ namespace OpenRa.Game
public Refinery( int2 location, Player owner, Game game )
: base( "proc", location, owner, game )
{
animation.PlayThen("make", delegate
animation.PlayThen("make", () =>
{
animation.PlayRepeating("idle");
game.world.AddFrameEndTask(delegate
game.world.AddFrameEndTask( _ =>
{
Unit harvester = new Unit( "harv", location + new int2( 1, 2 ), owner, game );
harvester.facing = 8;

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using IjwFramework.Delegates;
namespace OpenRa.Game
{

View File

@@ -6,7 +6,6 @@ using System.Drawing;
using Ijw.DirectX;
using System.IO;
using OpenRa.FileFormats;
using IjwFramework.Delegates;
namespace OpenRa.Game
{
@@ -52,7 +51,7 @@ namespace OpenRa.Game
public void DrawWithShader(ShaderQuality quality, Action task)
{
shader.Quality = quality;
shader.Render(task);
shader.Render(() => task());
}
public void DrawBatch<T>(FvfVertexBuffer<T> vertices, IndexBuffer indices,

View File

@@ -7,7 +7,6 @@ using OpenRa.FileFormats;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using IjwFramework.Delegates;
namespace OpenRa.Game
{
@@ -166,9 +165,9 @@ namespace OpenRa.Game
public void Apply( Game game )
{
game.world.AddFrameEndTask( delegate
game.world.AddFrameEndTask( _ =>
{
Provider<Building, int2, Player> newBuilding;
Func<int2, Player, Building> newBuilding;
if( game.buildingCreation.TryGetValue( building.buildingName, out newBuilding ) )
{
Log.Write( "Player \"{0}\" builds {1}", building.owner.PlayerName, building.buildingName );

View File

@@ -36,7 +36,7 @@ namespace OpenRa.Game
{
if (sprites > 0)
{
renderer.DrawWithShader(quality, delegate
renderer.DrawWithShader(quality, () =>
{
vertexBuffer.SetData(vertices);
indexBuffer.SetData(indices);

View File

@@ -31,8 +31,7 @@ namespace OpenRa.Game
static class TerrainCosts
{
static double[][] costs = Util.MakeArray<double[]>( 4,
delegate { return Util.MakeArray<double>( 10,
delegate { return double.PositiveInfinity; } ); } );
a => Util.MakeArray<double>( 10, b => double.PositiveInfinity ));
static TerrainCosts()
{

View File

@@ -25,7 +25,7 @@ namespace OpenRa.Game
public TerrainRenderer(Renderer renderer, Map map, Viewport viewport)
{
this.renderer = renderer;
region = Region.Create(viewport, DockStyle.Left, viewport.Width - 128, Draw, delegate { });
region = Region.Create(viewport, DockStyle.Left, viewport.Width - 128, Draw, (_, e) => { } );
viewport.AddRegion(region);
this.map = map;
@@ -75,13 +75,11 @@ namespace OpenRa.Game
if (firstRow < 0) firstRow = 0;
if (lastRow > map.Height) lastRow = map.Height;
renderer.DrawWithShader(ShaderQuality.Low, delegate
{
renderer.DrawBatch(vertexBuffer, indexBuffer,
new Range<int>(verticesPerRow * firstRow, verticesPerRow * lastRow),
new Range<int>(indicesPerRow * firstRow, indicesPerRow * lastRow),
terrainSheet.Texture);
});
renderer.DrawWithShader(ShaderQuality.Low, () =>
renderer.DrawBatch(vertexBuffer, indexBuffer,
new Range<int>(verticesPerRow * firstRow, verticesPerRow * lastRow),
new Range<int>(indicesPerRow * firstRow, indicesPerRow * lastRow),
terrainSheet.Texture));
}
}
}

View File

@@ -28,11 +28,11 @@ namespace OpenRa.Game
this.unitInfo = Rules.UnitInfo( name );
animation = new Animation( name );
animation.PlayFetchIndex( "idle", delegate { return facing; } );
animation.PlayFetchIndex( "idle", () => facing );
}
static float2[] fvecs = Util.MakeArray<float2>( 32,
delegate( int i ) { return -float2.FromAngle( i / 16.0f * (float)Math.PI ) * new float2( 1f, 1.3f ); } );
static float2[] fvecs = Util.MakeArray<float2>(32,
i => -float2.FromAngle(i / 16.0f * (float)Math.PI) * new float2(1f, 1.3f));
public int GetFacing( float2 d )
{

View File

@@ -48,12 +48,12 @@ namespace OpenRa.Game
{
public static UnitMission Sleep()
{
return delegate { };
return t => { };
}
public static UnitMission Move( Unit unit, int2 destination )
{
return delegate( int t )
return t =>
{
Game game = unit.game;
@@ -92,14 +92,14 @@ namespace OpenRa.Game
public static UnitMission Deploy( Unit unit )
{
return delegate( int t )
return t =>
{
Game game = unit.game;
if( Turn( unit, 12 ) )
return;
game.world.AddFrameEndTask( delegate
game.world.AddFrameEndTask( _ =>
{
game.world.Remove( unit );
game.world.Add( new ConstructionYard( unit.fromCell - new int2( 1, 1 ), unit.owner, game ) );
@@ -112,7 +112,7 @@ namespace OpenRa.Game
public static UnitMission Harvest( Unit unit )
{
UnitMission order = null;
order = delegate
order = t =>
{
// TODO: check that there's actually some ore in this cell :)
@@ -120,15 +120,15 @@ namespace OpenRa.Game
if( Turn( unit, ( unit.facing + 1 ) & ~3 ) )
return;
unit.currentOrder = delegate { };
unit.currentOrder = _ => { };
if( unit.nextOrder == null )
unit.nextOrder = order;
string sequenceName = string.Format( "harvest{0}", unit.facing / 4 );
unit.animation.PlayThen( sequenceName, delegate
unit.animation.PlayThen( sequenceName, () =>
{
unit.currentOrder = null;
unit.animation.PlayFetchIndex( "idle", delegate { return unit.facing; } );
unit.animation.PlayFetchIndex("idle", () => unit.facing);
} );
};
return order;

View File

@@ -10,17 +10,17 @@ namespace OpenRa.Game
{
static class Util
{
static float2 KLerp(float2 o, float2 d, int k)
{
switch (k)
{
case 0: return o;
case 1: return new float2(o.X + d.X, o.Y);
case 2: return new float2(o.X, o.Y + d.Y);
case 3: return new float2(o.X + d.X, o.Y + d.Y);
default: throw new InvalidOperationException();
}
}
static float2 KLerp(float2 o, float2 d, int k)
{
switch (k)
{
case 0: return o;
case 1: return new float2(o.X + d.X, o.Y);
case 2: return new float2(o.X, o.Y + d.Y);
case 3: return new float2(o.X + d.X, o.Y + d.Y);
default: throw new InvalidOperationException();
}
}
public static string[] ReadAllLines(Stream s)
{
@@ -41,22 +41,22 @@ namespace OpenRa.Game
return result;
}
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni)
{
float2 attrib = new float2(palette / 16.0f, channelSelect[(int)r.channel]);
public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni)
{
float2 attrib = new float2(palette / 16.0f, channelSelect[(int)r.channel]);
vertices[nv] = new Vertex(KLerp(o, r.size, 0), r.FastMapTextureCoords(0), attrib);
vertices[nv + 1] = new Vertex(KLerp(o, r.size, 1), r.FastMapTextureCoords(1), attrib);
vertices[nv + 2] = new Vertex(KLerp(o, r.size, 2), r.FastMapTextureCoords(2), attrib);
vertices[nv + 3] = new Vertex(KLerp(o, r.size, 3), r.FastMapTextureCoords(3), attrib);
vertices[nv] = new Vertex(KLerp(o, r.size, 0), r.FastMapTextureCoords(0), attrib);
vertices[nv + 1] = new Vertex(KLerp(o, r.size, 1), r.FastMapTextureCoords(1), attrib);
vertices[nv + 2] = new Vertex(KLerp(o, r.size, 2), r.FastMapTextureCoords(2), attrib);
vertices[nv + 3] = new Vertex(KLerp(o, r.size, 3), r.FastMapTextureCoords(3), attrib);
indices[ni] = (ushort)(nv);
indices[ni + 1] = indices[ni + 3] = (ushort)(nv + 1);
indices[ni + 2] = indices[ni + 5] = (ushort)(nv + 2);
indices[ni + 4] = (ushort)(nv + 3);
}
indices[ni] = (ushort)(nv);
indices[ni + 1] = indices[ni + 3] = (ushort)(nv + 1);
indices[ni + 2] = indices[ni + 5] = (ushort)(nv + 2);
indices[ni + 4] = (ushort)(nv + 3);
}
public static void FastCopyIntoChannel(Sprite dest, byte[] src)
{
@@ -80,18 +80,15 @@ namespace OpenRa.Game
fixed (byte* srcbase = &src[0])
{
byte* s = srcbase;
uint * t = (uint*)bits.Scan0.ToPointer();
uint* t = (uint*)bits.Scan0.ToPointer();
int stride = bits.Stride >> 2;
for (int j = 0; j < height; j++)
{
unsafe
{
uint* p = t;
for (int i = 0; i < width; i++, p++)
*p = (*p & ~mask) | ((mask & ((uint)*s++) << shift));
t += stride;
}
uint* p = t;
for (int i = 0; i < width; i++, p++)
*p = (*p & ~mask) | ((mask & ((uint)*s++) << shift));
t += stride;
}
}
}