You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

extlist.ts 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. export interface Extlist {
  2. numMons: number;
  3. numCards: number;
  4. checksum: number;
  5. entries: ExtlistEntry[];
  6. }
  7. export interface ExtlistEntry {
  8. isCards: boolean;
  9. id: number;
  10. width: number;
  11. height: number;
  12. numFrames: number;
  13. frameRate: number;
  14. checksum: number;
  15. size: number;
  16. lastUpdate: number;
  17. compressedSize: number;
  18. compressedChecksum: number;
  19. }
  20. export const Extlist = {
  21. load(buf: Buffer): Extlist {
  22. const numMons = buf.readUInt32LE(0);
  23. const numCards = buf.readUInt32LE(4);
  24. const sig = buf.readUInt32LE(8);
  25. const checksum = buf.readUInt32LE(12);
  26. if (sig !== 0x31545845) { // EXT1
  27. throw new Error('invalid extlist.bin signature');
  28. }
  29. const entries: ExtlistEntry[] = [];
  30. const numEntries = numMons + numCards;
  31. const compressedInfoOffset = 0x10 + numEntries * 24;
  32. for (let i = 0; i < numEntries; i++) {
  33. const flags = buf.readUInt16LE(0x10 + i * 24 + 0);
  34. const isCards = (flags & 0x4000) !== 0;
  35. const id = flags & ~0x4000;
  36. if (id === 0) continue;
  37. entries.push({
  38. isCards,
  39. id,
  40. width: buf.readUInt16LE(0x10 + i * 24 + 6),
  41. height: buf.readUInt16LE(0x10 + i * 24 + 8),
  42. numFrames: buf.readUInt16LE(0x10 + i * 24 + 10),
  43. frameRate: buf.readUInt16LE(0x10 + i * 24 + 12),
  44. checksum: buf.readUInt16LE(0x10 + i * 24 + 14),
  45. size: buf.readUInt32LE(0x10 + i * 24 + 16),
  46. lastUpdate: buf.readUInt32LE(0x10 + i * 24 + 20),
  47. compressedSize: buf.readUInt32LE(compressedInfoOffset + i * 8 + 0),
  48. compressedChecksum: buf.readUInt32LE(compressedInfoOffset + i * 8 + 4),
  49. });
  50. }
  51. return {
  52. numMons,
  53. numCards,
  54. checksum,
  55. entries,
  56. };
  57. },
  58. };

智龙迷城队伍图制作工具