Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #102 from icebreakersentertainment/master_issue_77…
Browse files Browse the repository at this point in the history
…_fix

fix for when we only have one message type
  • Loading branch information
gafferongames committed Oct 10, 2018
2 parents 4e1abba + b76b932 commit e65878b
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions yojimbo.h
Expand Up @@ -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__
}

/**
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) \
{ \
Expand Down Expand Up @@ -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 ) ) \
{ \
Expand Down Expand Up @@ -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; \
Expand Down

0 comments on commit e65878b

Please sign in to comment.