#include <allegro>
#define CMP_PFX_32 12628
#define CMP_PFX_64 12632
#define PLAYER_32 4148
#define PLAYER_64 4160
#define SHARD_32 212
#define SHARD_64 224
#define MASK_32 28
#define MASK_64 40
#define TUTORIAL 288
int main(int argc, char **argv)
{
char buf[12800];
if (argc != 3)
return 1;
PACKFILE *in = pack_fopen(argv[1], F_READ_PACKED);
PACKFILE *out = pack_fopen(argv[2], F_WRITE_PACKED);
if (!in || !out)
return 2;
if (pack_getc(in) != 'o' || pack_getc(in) != 'k' || pack_getc(in) != 2)
return 3;
pack_fwrite("ok\002", 3, out);
pack_fread (buf, CMP_PFX_32, in);
memset(buf + CMP_PFX_32, 0, CMP_PFX_64 - CMP_PFX_32);
pack_fwrite(buf, CMP_PFX_64, out);
int shard_count = ((int *)buf)[3];
for (int i = 0; i < 33; ++i)
{
pack_fread (buf, PLAYER_32, in);
memset(buf + PLAYER_32 - 8, 0, PLAYER_64 - PLAYER_32 + 8);
pack_fwrite(buf, PLAYER_64, out);
}
for (int i = 0; i < shard_count; ++i)
{
pack_fread (buf, SHARD_32, in);
memset(buf + SHARD_32 - 12, 0, SHARD_64 - SHARD_32 + 12);
pack_fwrite(buf, SHARD_64, out);
pack_fread (buf, MASK_32, in);
memset(buf + MASK_32 - 12, 0, MASK_64 - MASK_32 + 12);
pack_fwrite(buf, MASK_64, out);
}
pack_fread (buf, TUTORIAL, in);
pack_fwrite(buf, TUTORIAL, out);
pack_fclose(in);
pack_fclose(out);
return 0;
}