Know the exact length of all your myth films - without actually playing them

Talk about anything here.
Post Reply
Wismuth
Posts: 53
Joined: Fri Feb 10, 2006 12:08 pm
Contact:

Post by Wismuth »

While playing around with a hex editor I discovered that the length of each film is encoded as an integer multiple of 1/30 seconds in the 4 bytes starting at offset 0x48 of the file. The length includes Planning Time and 10.00 seconds of "Messing Around Time" after the game is over.

Below is a C program which will decode and display the length of each film given as a command line argument.

Code: Select all

#include <stdio.h>
#include <assert.h>

int main(int argc, char *argv[])
{
    FILE *fp;
    int a, b, c, d;
    int length;
    int i;

    for (i = 1; i < argc; i++) {
        fp = fopen(argv[i], "r");
        assert(fp != NULL);
        fseek(fp, 0x48, SEEK_SET);
        a = fgetc(fp); assert(a != EOF);
        b = fgetc(fp); assert(b != EOF);
        c = fgetc(fp); assert(c != EOF);
        d = fgetc(fp); assert(d != EOF);
        length = a<<24 | b<<16 | c<<8 | d;
        if (length == 0)
            printf("partial film  %s\n", argv[i]);
        else {
            length -= 10*30;
            printf("%d:%02d:%02d.%02d -- %s\n",
                length/30/60/60,
                length/30/60%60,
                length/30%60,
                (length*10+1)/3%100,
                argv[i]);
        }
        fclose(fp);
    }
}
Example of usage (details vary depending on the Operating System):

Code: Select all

> filmlength recordings/Netgame-\ Mar*
0:24:41.60 -- recordings/Netgame- Mar 01 05.07.55 2006
0:22:20.80 -- recordings/Netgame- Mar 10 02.25.40 2006
1:12:30.93 -- recordings/Netgame- Mar 21 06.40.00 2006
The program automatically subtracts the 10 seconds of Messing Around Time so as to display the exact time of Defeat or Victory in Coop games. Unfortunately Planning Time is still included so that a 7min KOTH game with 30sec PT will show up as 0:07:30.00 (assuming it didn't end early).

Films that are incomplete because Myth crashed during the game have no timing information and are displayed as "partial film".

Running the program on zipped films or other kind of files will return non-sensical information. No attempt is made to detect that a file is not a film.[/color]
User avatar
Doobie
Site Admin
Posts: 1121
Joined: Wed Jan 28, 2004 5:34 pm
Location: Calgary Alberta
Contact:

Post by Doobie »

Are you familiar with Baak's myth film tools? I suspect his have this functionality already (and much much more).

gj anyhow
Want to play Myth? New and old Myth players can playmyth online at Mariusnet.com.
KyleMaclean.net
User avatar
William Wallet
Posts: 1494
Joined: Tue Mar 30, 2004 9:40 am
Location: Perth Australia
Contact:

Post by William Wallet »

I tried hex-editing a multiplayer film that had a lot of very brutal arguing in it, so that all the names would be changed to the names of the PlayMyth admins.
It didn't work :(
Okay I got the models but now I'm too dumb to do anything with 'em
Post Reply