mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r16305) -Codechange: force-enable extra sync checking when random debugging is enable and give the calling location of Chance16(R) instead of the Random call within those functions.
This commit is contained in:
parent
3a15860df7
commit
043c3c8b06
@ -135,10 +135,14 @@ static FORCEINLINE bool Chance16I(const uint a, const uint b, const uint32 r)
|
|||||||
* @param b The denominator of the fraction
|
* @param b The denominator of the fraction
|
||||||
* @return True with (a/b) probability
|
* @return True with (a/b) probability
|
||||||
*/
|
*/
|
||||||
|
#ifdef RANDOM_DEBUG
|
||||||
|
#define Chance16(a, b) Chance16I(a, b, DoRandom(__LINE__, __FILE__))
|
||||||
|
#else
|
||||||
static FORCEINLINE bool Chance16(const uint a, const uint b)
|
static FORCEINLINE bool Chance16(const uint a, const uint b)
|
||||||
{
|
{
|
||||||
return Chance16I(a, b, Random());
|
return Chance16I(a, b, Random());
|
||||||
}
|
}
|
||||||
|
#endif /* RANDOM_DEBUG */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flips a coin with a given probability and saves the randomize-number in a variable.
|
* Flips a coin with a given probability and saves the randomize-number in a variable.
|
||||||
@ -155,10 +159,14 @@ static FORCEINLINE bool Chance16(const uint a, const uint b)
|
|||||||
* @param r The variable to save the randomize-number from Random()
|
* @param r The variable to save the randomize-number from Random()
|
||||||
* @return True in (a/b) percent
|
* @return True in (a/b) percent
|
||||||
*/
|
*/
|
||||||
|
#ifdef RANDOM_DEBUG
|
||||||
|
#define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r))
|
||||||
|
#else
|
||||||
static FORCEINLINE bool Chance16R(const uint a, const uint b, uint32 &r)
|
static FORCEINLINE bool Chance16R(const uint a, const uint b, uint32 &r)
|
||||||
{
|
{
|
||||||
r = Random();
|
r = Random();
|
||||||
return Chance16I(a, b, r);
|
return Chance16I(a, b, r);
|
||||||
}
|
}
|
||||||
|
#endif /* RANDOM_DEBUG */
|
||||||
|
|
||||||
#endif /* RANDOM_FUNC_HPP */
|
#endif /* RANDOM_FUNC_HPP */
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "../command_type.h"
|
#include "../command_type.h"
|
||||||
|
|
||||||
|
#ifdef RANDOM_DEBUG
|
||||||
/**
|
/**
|
||||||
* If this line is enable, every frame will have a sync test
|
* If this line is enable, every frame will have a sync test
|
||||||
* this is not needed in normal games. Normal is like 1 sync in 100
|
* this is not needed in normal games. Normal is like 1 sync in 100
|
||||||
@ -27,13 +28,14 @@
|
|||||||
* option enabled to make it to work. If one of the two has it disabled
|
* option enabled to make it to work. If one of the two has it disabled
|
||||||
* nothing will happen.
|
* nothing will happen.
|
||||||
*/
|
*/
|
||||||
//#define ENABLE_NETWORK_SYNC_EVERY_FRAME
|
#define ENABLE_NETWORK_SYNC_EVERY_FRAME
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In theory sending 1 of the 2 seeds is enough to check for desyncs
|
* In theory sending 1 of the 2 seeds is enough to check for desyncs
|
||||||
* so in theory, this next define can be left off.
|
* so in theory, this next define can be left off.
|
||||||
*/
|
*/
|
||||||
//#define NETWORK_SEND_DOUBLE_SEED
|
#define NETWORK_SEND_DOUBLE_SEED
|
||||||
|
#endif /* RANDOM_DEBUG */
|
||||||
|
|
||||||
enum MapPacket {
|
enum MapPacket {
|
||||||
MAP_PACKET_START,
|
MAP_PACKET_START,
|
||||||
|
Loading…
Reference in New Issue
Block a user