RakNetDefines.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __RAKNET_DEFINES_H
  11. #define __RAKNET_DEFINES_H
  12. // If you want to change these defines, put them in RakNetDefinesOverrides so your changes are not lost when updating RakNet
  13. // The user should not edit this file
  14. #include "RakNetDefinesOverrides.h"
  15. /// Define __GET_TIME_64BIT to have RakNet::TimeMS use a 64, rather than 32 bit value. A 32 bit value will overflow after about 5 weeks.
  16. /// However, this doubles the bandwidth use for sending times, so don't do it unless you have a reason to.
  17. /// Comment out if you are using the iPod Touch TG. See http://www.jenkinssoftware.com/forum/index.php?topic=2717.0
  18. /// This must be the same on all systems, or they won't connect
  19. #ifndef __GET_TIME_64BIT
  20. #define __GET_TIME_64BIT 1
  21. #endif
  22. // Define _FILE_AND_LINE_ to "",0 if you want to strip out file and line info for memory tracking from the EXE
  23. #ifndef _FILE_AND_LINE_
  24. #define _FILE_AND_LINE_ __FILE__,__LINE__
  25. #endif
  26. /// Define __BITSTREAM_NATIVE_END to NOT support endian swapping in the BitStream class. This is faster and is what you should use
  27. /// unless you actually plan to have different endianness systems connect to each other
  28. /// Enabled by default.
  29. // #define __BITSTREAM_NATIVE_END
  30. /// Maximum (stack) size to use with _alloca before using new and delete instead.
  31. #ifndef MAX_ALLOCA_STACK_ALLOCATION
  32. #define MAX_ALLOCA_STACK_ALLOCATION 1048576
  33. #endif
  34. // Use WaitForSingleObject instead of sleep.
  35. // Defining it plays nicer with other systems, and uses less CPU, but gives worse RakNet performance
  36. // Undefining it uses more CPU time, but is more responsive and faster.
  37. #ifndef _WIN32_WCE
  38. #define USE_WAIT_FOR_MULTIPLE_EVENTS
  39. #endif
  40. /// Uncomment to use RakMemoryOverride for custom memory tracking
  41. /// See RakMemoryOverride.h.
  42. #ifndef _USE_RAK_MEMORY_OVERRIDE
  43. #define _USE_RAK_MEMORY_OVERRIDE 0
  44. #endif
  45. /// If defined, OpenSSL is enabled for the class TCPInterface
  46. /// This is necessary to use the SendEmail class with Google POP servers
  47. /// Note that OpenSSL carries its own license restrictions that you should be aware of. If you don't agree, don't enable this define
  48. /// This also requires that you enable header search paths to DependentExtensions\openssl-1.0.0d
  49. // #define OPEN_SSL_CLIENT_SUPPORT
  50. #ifndef OPEN_SSL_CLIENT_SUPPORT
  51. #define OPEN_SSL_CLIENT_SUPPORT 0
  52. #endif
  53. /// Threshold at which to do a malloc / free rather than pushing data onto a fixed stack for the bitstream class
  54. /// Arbitrary size, just picking something likely to be larger than most packets
  55. #ifndef BITSTREAM_STACK_ALLOCATION_SIZE
  56. #define BITSTREAM_STACK_ALLOCATION_SIZE 256
  57. #endif
  58. // Redefine if you want to disable or change the target for debug RAKNET_DEBUG_PRINTF
  59. #ifndef RAKNET_DEBUG_PRINTF
  60. #define RAKNET_DEBUG_PRINTF printf
  61. #endif
  62. // Maximum number of local IP addresses supported
  63. #ifndef MAXIMUM_NUMBER_OF_INTERNAL_IDS
  64. #define MAXIMUM_NUMBER_OF_INTERNAL_IDS 10
  65. #endif
  66. #ifndef RakAssert
  67. #if defined(__native_client__)
  68. #define RakAssert(x)
  69. #else
  70. #if defined(_DEBUG)
  71. #define RakAssert(x) assert(x);
  72. #else
  73. #define RakAssert(x)
  74. #endif
  75. #endif
  76. #endif
  77. /// This controls the amount of memory used per connection.
  78. /// This many datagrams are tracked by datagramNumber. If more than this many datagrams are sent, then an ack for an older datagram would be ignored
  79. /// This results in an unnecessary resend in that case
  80. #ifndef DATAGRAM_MESSAGE_ID_ARRAY_LENGTH
  81. #define DATAGRAM_MESSAGE_ID_ARRAY_LENGTH 512
  82. #endif
  83. /// This is the maximum number of reliable user messages that can be on the wire at a time
  84. /// If this is too low, then high ping connections with a large throughput will be underutilized
  85. /// This will be evident because RakNetStatistics::messagesInSend buffer will increase over time, yet at the same time the outgoing bandwidth per second is less than your connection supports
  86. #ifndef RESEND_BUFFER_ARRAY_LENGTH
  87. #define RESEND_BUFFER_ARRAY_LENGTH 512
  88. #define RESEND_BUFFER_ARRAY_MASK 511
  89. #endif
  90. /// Uncomment if you want to link in the DLMalloc library to use with RakMemoryOverride
  91. // #define _LINK_DL_MALLOC
  92. #ifndef GET_TIME_SPIKE_LIMIT
  93. /// Workaround for http://support.microsoft.com/kb/274323
  94. /// If two calls between RakNet::GetTime() happen farther apart than this time in microseconds, this delta will be returned instead
  95. /// Note: This will cause ID_TIMESTAMP to be temporarily inaccurate if you set a breakpoint that pauses the UpdateNetworkLoop() thread in RakPeer
  96. /// Define in RakNetDefinesOverrides.h to enable (non-zero) or disable (0)
  97. #define GET_TIME_SPIKE_LIMIT 0
  98. #endif
  99. // Use sliding window congestion control instead of ping based congestion control
  100. #ifndef USE_SLIDING_WINDOW_CONGESTION_CONTROL
  101. #define USE_SLIDING_WINDOW_CONGESTION_CONTROL 1
  102. #endif
  103. // When a large message is arriving, preallocate the memory for the entire block
  104. // This results in large messages not taking up time to reassembly with memcpy, but is vulnerable to attackers causing the host to run out of memory
  105. #ifndef PREALLOCATE_LARGE_MESSAGES
  106. #define PREALLOCATE_LARGE_MESSAGES 0
  107. #endif
  108. #ifndef RAKNET_SUPPORT_IPV6
  109. #define RAKNET_SUPPORT_IPV6 0
  110. #endif
  111. #ifndef RAKSTRING_TYPE
  112. #if defined(_UNICODE)
  113. #define RAKSTRING_TYPE RakWString
  114. #define RAKSTRING_TYPE_IS_UNICODE 1
  115. #else
  116. #define RAKSTRING_TYPE RakString
  117. #define RAKSTRING_TYPE_IS_UNICODE 0
  118. #endif
  119. #endif
  120. #ifndef RPC4_GLOBAL_REGISTRATION_MAX_FUNCTIONS
  121. #define RPC4_GLOBAL_REGISTRATION_MAX_FUNCTIONS 48
  122. #endif
  123. #ifndef RPC4_GLOBAL_REGISTRATION_MAX_FUNCTION_NAME_LENGTH
  124. #define RPC4_GLOBAL_REGISTRATION_MAX_FUNCTION_NAME_LENGTH 48
  125. #endif
  126. #ifndef XBOX_BYPASS_SECURITY
  127. #define XBOX_BYPASS_SECURITY 1
  128. #endif
  129. // Controls how many allocations occur at once for the memory pool of incoming datagrams waiting to be transferred between the recvfrom thread and the main update thread
  130. // Has large effect on memory usage, per instance of RakPeer. Approximately MAXIMUM_MTU_SIZE*BUFFERED_PACKETS_PAGE_SIZE bytes, once after calling RakPeer::Startup()
  131. #ifndef BUFFERED_PACKETS_PAGE_SIZE
  132. #define BUFFERED_PACKETS_PAGE_SIZE 8
  133. #endif
  134. // Controls how many allocations occur at once for the memory pool of incoming or outgoing datagrams.
  135. // Has small effect on memory usage per connection. Uses about 256 bytes*INTERNAL_PACKET_PAGE_SIZE per connection
  136. #ifndef INTERNAL_PACKET_PAGE_SIZE
  137. #define INTERNAL_PACKET_PAGE_SIZE 8
  138. #endif
  139. // If defined to 1, the user is responsible for calling RakPeer::RunUpdateCycle and RakPeer::RunRecvfrom
  140. #ifndef RAKPEER_USER_THREADED
  141. #define RAKPEER_USER_THREADED 0
  142. #endif
  143. #ifndef USE_ALLOCA
  144. #define USE_ALLOCA 1
  145. #endif
  146. //#define USE_THREADED_SEND
  147. #endif // __RAKNET_DEFINES_H
粤ICP备19079148号