private static int ReadResources(BinaryReader br) { // Read all raw resources from DATA.WAR without processing them (yet) int result = 0; for (int i = 0; i < nrOfEntries; i++) { // Happens with demo data if (offsets[i] == 0xFFFFFFFF) { rawResources.Add(null); continue; } br.BaseStream.Seek((long)offsets[i], SeekOrigin.Begin); int compr_length = GetLength(br, i); long offset = br.BaseStream.Position; WarResource resource = new WarResource(br, offset, compr_length, i); rawResources.Add(resource); result++; } return(result); }
private static void WriteResource(BinaryWriter writer, WarResource res) { writer.Write((ushort)res.data.Length); writer.Write((byte)0); byte comprFlag = 0; writer.Write(comprFlag); writer.Write(res.data); }
internal void DumpResource(int index, WarResource res, bool writeToConsole = true, string filename = null) { #if !NETFX_CORE if (index < 0 || index >= Count || this[index] == null || res == null) { return; } if (writeToConsole) { Console.WriteLine(index.ToString("000") + ": " + this[index].text + " (" + res.data.Length + " bytes)"); Console.Write(((0 / 64) * 64).ToString("x4") + ": "); for (int b = 0; b < res.data.Length; b++) { Console.Write(res.data[b].ToString("x2")); Console.Write(" "); if (b % 64 == 63) { Console.WriteLine(); Console.Write((((b + 1) / 64) * 64).ToString("x4") + ": "); } } Console.WriteLine(); Console.WriteLine(); for (int b = 0; b < res.data.Length / 2; b++) { if (res.data[b] >= 32) Console.Write((char)res.data[b] + " "); else Console.Write(" "); if (b % 64 == 63) { Console.WriteLine(); Console.Write((((b + 1) / 64) * 64).ToString("x4") + ": "); } } Console.WriteLine(); } if (filename != null) { System.IO.File.WriteAllBytes(filename, res.data); } #endif }
private static int ReadResources(BinaryReader br) { // Read all raw resources from DATA.WAR without processing them (yet) int result = 0; for (int i = 0; i < nrOfEntries; i++) { // Happens with demo data if (offsets[i] == 0xFFFFFFFF) { rawResources.Add(null); continue; } br.BaseStream.Seek((long)offsets[i], SeekOrigin.Begin); int compr_length = GetLength(br, i); long offset = br.BaseStream.Position; WarResource resource = new WarResource(br, offset, compr_length, i); rawResources.Add(resource); result++; } return result; }
private static BasicResource CreateResource(int index) { WarResource resource = rawResources[index]; KnowledgeEntry ke = KnowledgeBase[index]; ContentFileType fileType = ContentFileType.FileUnknown; if (ke != null) { fileType = ke.type; } switch (fileType) { case ContentFileType.FileCursor: { WarResource palRes = null; if (ke != null) { palRes = rawResources[ke.param]; } return(new CursorResource(resource, palRes)); } case ContentFileType.FileImage: { WarResource palRes = null; if (ke != null) { palRes = rawResources[ke.param]; } return(new ImageResource(resource, palRes, rawResources[191])); } case ContentFileType.FileLevelInfo: return(new LevelInfoResource(resource)); case ContentFileType.FileLevelPassable: return(new LevelPassableResource(resource)); case ContentFileType.FileLevelVisual: return(new LevelVisualResource(resource)); case ContentFileType.FilePalette: return(new PaletteResource(resource)); case ContentFileType.FilePaletteShort: return(new PaletteResource(resource)); case ContentFileType.FileSprite: { WarResource palRes = null; if (ke != null) { palRes = rawResources[ke.param]; } return(new SpriteResource(resource, palRes, rawResources[191])); } case ContentFileType.FileTable: return(new TableResource(resource)); case ContentFileType.FileText: return(new TextResource(resource)); case ContentFileType.FileTiles: return(new RawResource(resource, ContentFileType.FileTiles)); case ContentFileType.FileTileSet: return(new RawResource(resource, ContentFileType.FileTileSet)); case ContentFileType.FileUI: return(new UIResource(resource)); case ContentFileType.FileVOC: return(new RawResource(resource, ContentFileType.FileVOC)); case ContentFileType.FileWave: return(new RawResource(resource, ContentFileType.FileWave)); case ContentFileType.FileXMID: return(new RawResource(resource, ContentFileType.FileXMID)); default: return(new RawResource(resource, ContentFileType.FileUnknown)); } }
/// <summary> /// Create map tileset /// </summary> internal MapTileset(Tileset setTilesetType, WarResource setTileset, WarResource setTiles, PaletteResource setTilesetPal) { tiles = setTiles; tileset = setTileset; tilesetPal = setTilesetPal; tilesetType = setTilesetType; CreateTiles(); CreateRoadTypes(); }
/// <summary> /// Load all tilesets /// </summary> internal static void LoadAllTilesets() { // TODO: FIXME with new WarFile resource loading strategy WarResource tileset = ((RawResource)WarFile.GetResourceByName("Barrens 1")).Resource; WarResource tiles = ((RawResource)WarFile.GetResourceByName("Barrens 2")).Resource; PaletteResource tilesPAL = WarFile.GetResourceByName("Barrens 3") as PaletteResource; MapTileset swamp = new MapTileset(Tileset.Swamp, tileset, tiles, tilesPAL); knownTilesets.Add(swamp); tileset = ((RawResource)WarFile.GetResourceByName("Summer 1")).Resource; tiles = ((RawResource)WarFile.GetResourceByName("Summer 2")).Resource; tilesPAL = WarFile.GetResourceByName("Summer 3") as PaletteResource; MapTileset summer = new MapTileset(Tileset.Summer, tileset, tiles, tilesPAL); knownTilesets.Add(summer); if (WarFile.IsDemo == false) { tileset = ((RawResource)WarFile.GetResourceByName("Dungeon 1")).Resource; tiles = ((RawResource)WarFile.GetResourceByName("Dungeon 2")).Resource; tilesPAL = WarFile.GetResourceByName("Dungeon 3") as PaletteResource; MapTileset dungeon = new MapTileset(Tileset.Dungeon, tileset, tiles, tilesPAL); knownTilesets.Add(dungeon); } }