misc.c
changeset 260 32fcaaf9f4ef
parent 256 f7c6267731fb
child 271 35431b3d53ca
equal deleted inserted replaced
259:81c264db62f6 260:32fcaaf9f4ef
    13 static INLINE uint32 ROR(uint32 x, int n)
    13 static INLINE uint32 ROR(uint32 x, int n)
    14 {
    14 {
    15 	return (x >> n) + (x << ((sizeof(x)*8)-n));
    15 	return (x >> n) + (x << ((sizeof(x)*8)-n));
    16 }
    16 }
    17 
    17 
    18 /* Fuck bitch code, most probably one of the loops (tileloop, vehicleloop, etc.) 
    18 // For multiplayer, we introduced this new way of random-seeds
    19  * doesn't set up/reset _current_player so the normal random below fails #$%@$#!
    19 //  It is player-based, so 2 clients can do 2 commands at the same time
    20  * The old code below is prune to desyncs because randoms interfere.
    20 //  without the game desyncing.
    21  * SO FIND THE OFFENDING LOOP AND FIX IT ONCE AND FOR ALL */
    21 // It is not used for non-multiplayer games
    22 #undef NORMAL_RANDOM // unuseable game, desyncs way too fast
    22 #ifdef ENABLE_NETWORK
       
    23 	#define PLAYER_SEED_RANDOM
       
    24 #else
       
    25 	#undef PLAYER_SEED_RANDOM
       
    26 #endif
       
    27 
    23 uint32 Random()
    28 uint32 Random()
    24 {
    29 {
    25 #ifdef NORMAL_RANDOM
    30 #ifdef PLAYER_SEED_RANDOM
    26 	if (_current_player>=MAX_PLAYERS) {
    31 	if (_current_player>=MAX_PLAYERS || !_networking) {
    27 		uint32 s = _random_seeds[0][0];
    32 		uint32 s = _random_seeds[0][0];
    28 		uint32 t = _random_seeds[0][1];
    33 		uint32 t = _random_seeds[0][1];
    29 		_random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7);
    34 		_random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7);
    30 		return _random_seeds[0][1] = ROR(s, 3);
    35 		return _random_seeds[0][1] = ROR(s, 3);
    31 	} else {
    36 	} else {