Raptor007 / aq2-tng

Action Quake 2: The Next Generation. Raptor007's sandbox for testing changes. When verified stable, this code is pushed to the official aq2-tng repo:
https://github.com/aq2-tng/aq2-tng/tree/bots
4 stars 2 forks source link

'nextmap' is wrong with 'rrot 1' #79

Closed Raptor007 closed 3 years ago

Raptor007 commented 4 years ago

The nextmap command returns the wrong map name with rrot 1 (random map rotation). This might have gotten broken when I sorted the votemap list alphabetically, or it might have been broken before that.

Raptor007 commented 4 years ago

The problem is that it doesn't choose the random map until the current map ends. What nextmap shows is the next map in sequential rotation. To fix this, it'll need to select the random map in advance.

Also, should remove the srand(rand()); on every map change, and start the game with a single srand(time(NULL)); instead. https://www.geeksforgeeks.org/rand-and-srand-in-ccpp/

Raptor007 commented 4 years ago

I think the cleanest way is to choose a random number from 1 to num_maps - 1 when it starts playing a new map, and then nextmap and EndDMLevel will advance that many if rrot is enabled. This will also provide a safer mechanism to avoid playing the same map twice than the current strategy of check and re-roll.