Permalink
Browse files

Merge pull request #102 from icebreakersentertainment/master_issue_77…

…_fix

fix for when we only have one message type
  • Loading branch information...
gafferongames committed Oct 10, 2018
2 parents 4e1abba + b76b932 commit e65878b3dc15be3d81bc199478ba7af5cdb4747c
Showing with 6 additions and 10 deletions.
  1. +6 −10 yojimbo.h
View
@@ -870,11 +870,7 @@ namespace yojimbo
inline int bits_required( uint32_t min, uint32_t max )
{
#ifdef __GNUC__
return 32 - __builtin_clz( max - min );
#else // #ifdef __GNUC__
return ( min == max ) ? 0 : log2( max - min ) + 1;
#endif // #ifdef __GNUC__
}
/**
@@ -2098,7 +2094,7 @@ namespace yojimbo
bool SerializeInteger( int32_t value, int32_t min, int32_t max )
{
yojimbo_assert( min < max );
yojimbo_assert( min <= max );
yojimbo_assert( value >= min );
yojimbo_assert( value <= max );
const int bits = bits_required( min, max );
@@ -2258,7 +2254,7 @@ namespace yojimbo
bool SerializeInteger( int32_t & value, int32_t min, int32_t max )
{
yojimbo_assert( min < max );
yojimbo_assert( min <= max );
const int bits = bits_required( min, max );
if ( m_reader.WouldReadPastEnd( bits ) )
return false;
@@ -2410,7 +2406,7 @@ namespace yojimbo
bool SerializeInteger( int32_t value, int32_t min, int32_t max )
{
(void) value;
yojimbo_assert( min < max );
yojimbo_assert( min <= max );
yojimbo_assert( value >= min );
yojimbo_assert( value <= max );
const int bits = bits_required( min, max );
@@ -2753,7 +2749,7 @@ namespace yojimbo
#define serialize_int( stream, value, min, max ) \
do \
{ \
yojimbo_assert( min < max ); \
yojimbo_assert( min <= max ); \
int32_t int32_value = 0; \
if ( Stream::IsWriting ) \
{ \
@@ -3342,7 +3338,7 @@ namespace yojimbo
#define read_int( stream, value, min, max ) \
do \
{ \
yojimbo_assert( min < max ); \
yojimbo_assert( min <= max ); \
int32_t int32_value = 0; \
if ( !stream.SerializeInteger( int32_value, min, max ) ) \
{ \
@@ -3388,7 +3384,7 @@ namespace yojimbo
#define write_int( stream, value, min, max ) \
do \
{ \
yojimbo_assert( min < max ); \
yojimbo_assert( min <= max ); \
yojimbo_assert( value >= min ); \
yojimbo_assert( value <= max ); \
int32_t int32_value = (int32_t) value; \

0 comments on commit e65878b

Please sign in to comment.