OK, assuming there's no such tool, I wrote one.
Here you go:
/* FEB 2014:
* Reads thru' the sections of .chk file (as outlined in
http://www.staredit.net/starcraft/Scenario.chk#Section_headers )
* Returns the number of human players.
*/
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <string.h>
# include <errno.h>
# include <fcntl.h>
int
main (int argc, char ** argv) {
int fd = 0,
n = 0,
i = 0,
humans = 0;
char buf [2048] = { 0 },
* new = NULL;
unsigned long kolku = 0;
if (argc < 2) {
fprintf (stderr, "%s scenario.chk\n", argv [0]);
exit (EXIT_FAILURE);
}
fd = open (argv [1], O_RDWR, 0);
if (-1 == fd) {
fprintf (stderr, "open: %s: %s\n", argv [1], strerror (errno));
exit (EXIT_FAILURE);
}
while (1) {
memset (buf, 0x00, sizeof (buf));
/* 4-byte starts with the name of the section, always. */
n = read (fd, buf, 4);
if (n != 4) {
fprintf (stderr, "Either we read it all, or wrong datafile given (we need scenario.chk, not mopaq file)\n");
break;
}
/* What follows is unsigned long telling us how long this section actually is. */
n = read (fd, &kolku, sizeof (unsigned long));
fprintf (stdout, "buf = '%s', n = %d, kolku = %ld\n", buf, n, kolku);
/* We need at least `kolku' bytes. */
new = malloc (kolku + 1);
if (new == NULL) {
fprintf (stderr, "Definitely buy RAM.. malloc failed!\n");
exit (EXIT_FAILURE);
}
read (fd, new, kolku); /* read them anyway. If its the section we need, OK, if not - we just skip it. */
if (strcmp (buf, "OWNR") == 0) {
/* THIS is the section we're interested in. Check it out. */
if (kolku != 12) {
/* Should be fixed 12 here, according to
http://www.staredit.net/starcraft/Scenario.chk#Section_headers */
fprintf (stdout, "Something sinister is going on... kolku != 12..\n");
}
for (i = 0; i < kolku; i ++) {
switch (new [i]) {
case 0:
fprintf (stdout, "%d byte: Inactive player\n", i);
break;
case 1:
fprintf (stdout, "%d byte: Computer (game)\n", i);
break;
case 2:
fprintf (stdout, "%d byte: Occupied by Human player\n", i);
break;
case 3:
fprintf (stdout, "%d byte: Rescue Passive\n", i);
break;
case 4:
fprintf (stdout, "%d byte: Unused\n", i);
break;
case 5:
fprintf (stdout, "%d byte: Computer\n", i);
break;
case 6:
fprintf (stdout, "%d byte: Human (open slot)\n", i);
humans ++;
break;
case 7:
fprintf (stdout, "%d byte: Neutral\n", i);
break;
case 8:
fprintf (stdout, "%d byte: Closed slot\n", i);
break;
default:
/* wat? shouldn't happen */
break;
}
}
}
free (new);
}
close (fd);
fprintf (stdout, "humans = %d\n", humans);
return (0);
}
None.