- bugfix in Format80

- fixed heisenburg-endianness in map loader
    - THERES A BUG in the mix loading; I need another 4 bytes padding to load temperat.mix and snow.mix (not interior.mix, though)
    - ShpViewer can now load and view map files
    - Copy TEMPERAT, SNOW, INFERIOR (sic) mixes into $(SolutionDir) for this to work
    - Left-click to reload tile-ID file, middle-click scrolls
    - the tile-id file has some collisions between tile-sets, be careful about ordering if you change anything


git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1081 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
bob
2007-06-26 21:25:20 +00:00
parent f87448c958
commit 1438053505
15 changed files with 436 additions and 102 deletions

View File

@@ -27,14 +27,16 @@ namespace OpenRa.FileFormats
if( srcIndex >= destIndex )
throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) );
for( int i = 0 ; i < Math.Min( count, destIndex - srcIndex ) ; i++ )
dest[ destIndex + i ] = dest[ srcIndex + i ];
if( srcIndex + count <= destIndex )
return;
for( int i = destIndex + destIndex - srcIndex ; i < destIndex + count ; i++ )
dest[ i ] = dest[ destIndex - 1 ];
if( destIndex - srcIndex == 1 )
{
for( int i = 0 ; i < count ; i++ )
dest[ destIndex + i ] = dest[ destIndex - 1 ];
}
else
{
for( int i = 0 ; i < count ; i++ )
dest[ destIndex + i ] = dest[ srcIndex + i ];
}
}
public static int DecodeInto( MemoryStream input, byte[] dest )

View File

@@ -4,7 +4,7 @@ using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace MapViewer
namespace OpenRa.FileFormats
{
public class IniFile
{

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using MapViewer;
namespace OpenRa.FileFormats
{
@@ -98,14 +97,14 @@ namespace OpenRa.FileFormats
{
for( int j = 0 ; j < 128 ; j++ )
{
MapTiles[ i, j ].tile = ReadByte( ms );
MapTiles[ i, j ].tile |= (ushort)( ReadByte( ms ) << 8 );
MapTiles[ j, i ].tile = ReadByte( ms );
MapTiles[ j, i ].tile |= (ushort)( ReadByte( ms ) << 8 );
}
}
for( int i = 0 ; i < 128 ; i++ )
for( int j = 0 ; j < 128 ; j++ )
MapTiles[ i, j ].image = ReadByte( ms );
MapTiles[ j, i ].image = ReadByte( ms );
}
}

View File

@@ -35,7 +35,6 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BitmapBuilder.cs" />
@@ -50,6 +49,13 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShpReader.cs" />
<Compile Include="Terrain.cs" />
<Compile Include="TileSet.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRa.Core\OpenRa.Core.csproj">
<Project>{1B60782F-B2DD-43F1-B51D-B798485F317C}</Project>
<Name>OpenRa.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using OpenRa.Core;
namespace OpenRa.FileFormats
{
@@ -122,11 +123,13 @@ namespace OpenRa.FileFormats
s.Seek(2 + 4 + (isRmix ? 4 : 0), SeekOrigin.Begin);
s.Seek(2, SeekOrigin.Current); //dword align
s.Seek( 4, SeekOrigin.Current ); //wtf, i dont know why i need this either :(
if (isEncrypted)
if( isEncrypted )
s.Seek(80, SeekOrigin.Current);
s.Seek(index.Count * PackageEntry.Size + e.Offset, SeekOrigin.Current);
s.Seek( index.Count * PackageEntry.Size + e.Offset, SeekOrigin.Current );
byte[] data = new byte[ e.Length ];
s.Read( data, 0, (int)e.Length );
return new MemoryStream(data);
@@ -140,7 +143,6 @@ namespace OpenRa.FileFormats
{
return GetContent(PackageEntry.HashFilename(filename));
}
}
[Flags]

View File

@@ -24,7 +24,7 @@ namespace OpenRa.FileFormats
Height = reader.ReadUInt16();
if( Width != 24 || Height != 24 )
throw new InvalidDataException();
throw new InvalidDataException( string.Format( "{0}x{1}", Width, Height ) );
NumTiles = reader.ReadUInt16();
reader.ReadUInt16();
@@ -58,7 +58,10 @@ namespace OpenRa.FileFormats
public Bitmap GetTile( int index )
{
return TileBitmaps[ index ];
if( index < TileBitmaps.Count )
return TileBitmaps[ index ];
else
return null;
}
public Bitmap[ , ] GetTiles( int tileNum )

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Globalization;
namespace OpenRa.FileFormats
{
public class TileSet
{
public readonly Dictionary<ushort, Terrain> tiles = new Dictionary<ushort, Terrain>();
public TileSet( Package mixFile, string suffix, Palette pal )
{
StreamReader tileIdFile = File.OpenText( "../../../tileSet.til" );
while( true )
{
string countStr = tileIdFile.ReadLine();
string startStr = tileIdFile.ReadLine();
string pattern = tileIdFile.ReadLine() + suffix;
if( countStr == null || startStr == null || pattern == null )
break;
//try
{
int count = int.Parse( countStr );
int start = int.Parse( startStr, NumberStyles.HexNumber );
for( int i = 0 ; i < count ; i++ )
{
Stream s;
try
{
s = mixFile.GetContent( string.Format( pattern, i + 1 ) );
}
catch { continue; }
Terrain t = new Terrain( s, pal );
if( tiles.ContainsKey( (ushort)( start + i ) ) )
continue;
tiles.Add( (ushort)( start + i ), t );
}
}
//catch { }
}
tileIdFile.Close();
}
}
}