Invalid map number in recorded demo

In the last released version of Heretic (and possibly earlier versions), it is possible to record a demo which has an invalid map number saved within it. Attempting to replay the demo will replay it on an unpredictable map slot and so it will appear to desync.

How to reproduce
You must invoke Heretic using and  arguments, but only pass one argument to, which expects two:

heretic -warp 1 -record zomg3

The game will start on Episode 1, Map 1, despite you not having specified the arguments to correctly.

Attempting to play back the demo however will result in playback on a different map (in this case, E1M9).

Cause
When Heretic starts up, it handles the argument before. The code in to handle warping looks at two arguments that follow  in the command line but does not make sure that they are valid numbers. Instead the numeric value is used, whatever that is.

p = M_CheckParmWithArgs("-warp", 2); if (p && p < myargc - 2) {       startepisode = myargv[p + 1][0] - '0'; startmap = myargv[p + 2][0] - '0';

In the above example, it would treat '1' as the episode number and '-' as the map number, which equals 45.

The argument is handled next, by  which simply writes out the value of the map number to the demo, and so in this case writes out 45.

When the game starts, later code has ignored the invalid episode/map number and so the game starts on E1M1.