Lieber Besucher, herzlich willkommen bei: AnnoZone Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »mrboese« (24. Oktober 2009, 16:56)
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 |
<AssetList> <ToolOneVersion>3</ToolOneVersion> <Groups> <Group> <Name>Objects</Name> <Groups> <Group> <Name>PlayerBuildings</Name> <Groups> usw. |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Saheike« (24. Oktober 2009, 17:18)
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »mrboese« (25. Oktober 2009, 20:36)
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »mrboese« (28. November 2009, 20:57)
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
/// process the archive and add them to the list void processArchive() { Header header; BlockHeader block; DirEntry[] directory; ubyte[] buffer; bool done = false; // for loop _numFiles = 0; _archive = []; // for memoryresident data uint offset, compressed, datasize; File hIn = new File(); size_t filePos; // current offset in the file hIn.open(_archivename, FileMode.In); // read header hIn.readExact(&header, Header.sizeof); if (header.magic[0..18] != "Resource File V2.0"w) throw new Exception("No valid 1404 RDA file!"); hIn.seekSet(header.firstBlock); while(!done) { // get block header hIn.readExact(&block, BlockHeader.sizeof); // strangely an empty block exists in Data5.rda if (block.numFiles == 0) { if (block.nextBlock >= hIn.size()) done = true; else hIn.seekSet(block.nextBlock); continue; } // get the directory before it hIn.seekCur(- cast(int)block.dirSize - cast(int)BlockHeader.sizeof); // if block data is memoryresident, the block is preceded by compressed and uncompressed size if (block.flags & 4) hIn.seekCur(-8); buffer.length = block.dirSize; hIn.readExact(buffer.ptr, buffer.length); if (block.flags & 2) // if it is encrypted decrypt(buffer); if (block.flags & 1) // if it is compressed { // debug _form.log("Starting decompression..."); buffer = cast(ubyte[]) uncompress(buffer, block.decompressedSize); } directory = cast(DirEntry[]) buffer; // memoryresident data? if (block.flags & 4) { hIn.read(compressed); hIn.read(datasize); offset = cast(uint)(hIn.position - 8 - block.dirSize - compressed); } // is this the last block? if (block.nextBlock >= hIn.size()) done = true; else hIn.seekSet(block.nextBlock); /* if (block.flags & 8) // if files are deleted { debug listView.addRow([]); continue; } */ _archive ~= Block(block, offset, compressed, datasize, directory.dup); } } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Hoenir« (28. November 2009, 21:16)
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »mrboese« (28. November 2009, 21:21)
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
/// extract files in the archive void extract(cstring path) { File hIn, hOut; ubyte[] buffer = new ubyte[10_485_760], data; int counter = -1; // to count the file index, starts with 0 chdir(path); hIn = new File(_archivename); foreach (block; _archive) { if (block.head.flags & 4) // memoryresident { hIn.seekSet(block.offset); if (buffer.length < block.compressed) buffer.length = block.compressed; hIn.readExact(buffer.ptr, block.compressed); data = buffer[0 .. block.compressed]; if (block.head.flags & 2) decrypt(data); if (block.head.flags & 1) data = cast(ubyte[]) uncompress(data, block.datasize); } foreach (entry; block.directory) { counter++; // if files are marked as deleted if (block.head.flags & 8) continue; // create the necessary directories uint pos, lastpos; auto name = toUTF8(entry.filename); while (name[pos] != '\0') { if (name[pos] == '/') { if (!exists(name[lastpos .. pos])) mkdir(name[lastpos .. pos]); chdir(name[lastpos .. pos]); lastpos = pos+1; } pos++; } // write out the file try { // writefln(name[lastpos .. pos]); hOut = new File(name[lastpos .. pos], FileMode.Out); if (entry.compressed == 0 && entry.offset == 0) continue; if (block.head.flags & 4) // memoryresident { hOut.writeExact(data.ptr + entry.offset, entry.filesize); } else { if (entry.compressed != 0) // to support empty files { hIn.seekSet(entry.offset); if (buffer.length < entry.compressed) buffer.length = entry.compressed; hIn.readExact(buffer.ptr, entry.compressed); data = buffer[0 .. entry.compressed]; // create a view into the buffer if (block.head.flags & 2) decrypt(data); if (block.head.flags & 1) data = cast(ubyte[]) uncompress(data, entry.filesize); // if we have a savegame, also decompress the save.sww if (name[0 .. 8] == "save.sww") { uint size = *cast(uint *)(data.ptr+4); // data = cast(ubyte[]) uncompress(data[8 .. $], size); } hOut.writeExact(data.ptr, data.length); // free the uncompressed data buffer if ((block.head.flags & 1)) // || (name[0 .. 8] == "save.sww")) delete data; } } } catch(Exception e) { writefln("Error while writing out file %s: %s", name, e.toString()); } finally { hOut.close(); if (entry.timestamp) setTimes(name[lastpos .. pos], entry.timestamp); chdir(path); // change back to the base folder } } // foreach (entry; block.directory) // free the memory used by memoryresident data if ((block.head.flags & 4) && (block.head.flags & 1)) delete data; } // foreach (block; _archive) } |