Game Development Reference
In-Depth Information
6. We ill an unused part of the buffer with zeros to avoid the noise:
int OldSize = (int)FBuffer.size();
if ( Size > OldSize )
{
FBuffer.resize( Size );
for ( int i = 0 ; i < OldSize - Size ; i++ )
FBuffer[OldSize + i] = 0;
}
7. At the end of ile, we return zero as the decoded data size:
if ( FEof ) { return 0; }
8.
Next, we try to read from the source until we collect the Size bytes:
int BytesRead = 0;
while ( BytesRead < Size )
{
int Ret = ReadFromFile(Size);
9.
If we have the data, increment the counter:
if ( Ret > 0 )
{
BytesRead += Ret;
}
10. If the number of bytes is zero, we have reached the end of the ile:
else if (Ret == 0)
{
FEof = true;
11. The FLoop lag tells us to rewind the stream to the beginning:
if ( FLoop )
{
Seek(0);
FEof = false;
continue;
}
break;
} else
12. Otherwise, we have an error in the stream:
{
Seek( 0 );
FEof = true;
break;
}
}
 
Search WWH ::




Custom Search