Stunts Forum

Stunts - the Game => Stunts Reverse Engineering => Topic started by: alanrotoi on December 23, 2021, 01:38:29 AM

Title: 25 minutes replay
Post by: alanrotoi on December 23, 2021, 01:38:29 AM
Easy to reproduce:
1. race against an opponent
2. choose a track with a pipe like in the picture
3. the opponents are very slow in that element so you can stuck them quiet easy
4. I did it crashing against the mid block then he came and couldn't pass. The opponent always choses the right way and as he goes too slow it won't crash againt you.
5. He'll stay there 25 minutes but as I crashed I couldn't save the replay but I could watch it.

I hope this find helps somehow to understand the replay time limit.
Title: Re: 25 minutes replay
Post by: Cas on December 24, 2021, 12:06:57 AM
Oh, so when it reaches 25 minutes, it just stops?  In theory, as long as the player has finished or crashed before 10 minutes have elapsed, the opponent can take whatever amount of time without causing any memory overwrite, since only the key presses from the player are to be stored. However, the current tic number has to be kept track of. For the 10 minute limit (which is a memory region size limit), the number of tics is:

10 (minutes) x 60 (seconds in a minute) x 20 (tics in a second) = 12000

... corresponding to the number of bytes used to store the replay. But even if memory is not a concern, for a 16 bit unsigned integer, this counter should overflow at 65536 and if it's signed, at 32768. The images show that this stops exactly at 25 minutes, which equals 30000 tics, suggesting a good round number lower than 32768 was picked by the programmer to prevent the overflow and that the replay is stopped preemptively.
Title: Re: 25 minutes replay
Post by: Daniel3D on December 24, 2021, 11:27:31 AM
Even if the replay is stored at half the ticks (like I had at first because of a not ideal DOSBox setup) the replay file is about half the size but still capped at 25 minutes.
Title: Re: 25 minutes replay
Post by: afullo on December 24, 2021, 09:51:16 PM
The overflow at 32768 tics can be confirmed by taking a penalty time such that the sum with the elapsed time is higher than 27:18.35 (32767 tics): the total time would be displayed as negative, as in an earlier topic from 2018 I already showed (I'm from phone and unable to link it on the fly, but in the case I will be able later).
Title: Re: 25 minutes replay
Post by: Daniel3D on December 24, 2021, 10:29:06 PM
Quote from: afullo on December 24, 2021, 09:51:16 PM
The overflow at 32768 tics can be confirmed by taking a penalty time such that the sum with the elapsed time is higher than 27:18.35 (32767 tics): the total time would be displayed as negative, as in an earlier topic from 2018 I already showed (I'm from phone and unable to link it on the fly, but in the case I will be able later).
http://forum.stunts.hu/index.php?topic=3409.msg72638#msg72638 (http://forum.stunts.hu/index.php?topic=3409.msg72638#msg72638)
Here is the post.
Title: Re: 25 minutes replay
Post by: alanrotoi on December 24, 2021, 11:14:34 PM
So, is it possible to make more space for player replays?  ::)
Title: Re: 25 minutes replay
Post by: Daniel3D on December 25, 2021, 08:43:36 AM
No. You get memory overflow problems.
Title: Re: 25 minutes replay
Post by: Cas on December 26, 2021, 04:49:18 PM
Wow!  Looking at that post, I realise how volatile my memory is  ;D

And yes, I remember having tested at low frequency, whether the 10 minute limit could be exceeded safely and the result was a negative. I don't remember, however, whether Stunts would stop normally or crash.