M_AssignSpraycans: Fix off-by-one in shuffled prepended colours causing crashes

The prepended colour list passed to M_Shuffle_UINT16 was off by one, leading to possible pollution of the region with an uninitialised value.

For some reason, some people's machines guarantee clean stack memory on game startup, while other people's do not. This is why some people were crashing on Spray Can list generation and some weren't.

The stack memory was DEFINITELY not clean by the time you could navigate to the gamedata clear menu, which is why that was crashing without fail.
This commit is contained in:
toaster 2023-08-24 21:32:41 +01:00
parent 9076b3c99b
commit 6d5770ff5a

View file

@ -746,7 +746,7 @@ static void M_AssignSpraycans(void)
if (prependlen)
{
// Swap the early colours for random order
M_Shuffle_UINT16(tempcanlist + prependoffset - prependlen, prependlen);
M_Shuffle_UINT16(tempcanlist + prependoffset - (prependlen - 1), prependlen);
// Put at the front of the main list
// (technically reverses the prepend order, but it