2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-22 09:56:22 +01:00

engine: common: mod_bmodel: add function Mod_DecompressVisTo that will copy fat vis data into the provided buffer

This commit is contained in:
Alibek Omarov 2024-05-26 23:12:16 +03:00
parent 2ad6511c31
commit 9150b770e4

View File

@ -578,6 +578,42 @@ void Mod_PrintWorldStats_f( void )
===============================================================================
*/
/*
===================
Mod_DecompressPVS
TODO: replace all Mod_DecompressPVS calls by this
===================
*/
static void Mod_DecompressPVSTo( byte *const out, const byte *in, size_t visbytes )
{
byte *dst = out;
if( !in ) // no visinfo, make all visible
{
memset( out, 0xFF, visbytes );
return;
}
while( dst < out + visbytes )
{
if( *in ) // uncompressed
{
*dst++ = *in++;
}
else // zero repeated `c` times
{
size_t c = in[1];
if( c > out + visbytes - dst )
c = out + visbytes - dst;
memset( dst, 0, c );
in += 2;
dst += c;
}
}
}
/*
===================
Mod_DecompressPVS
@ -585,40 +621,7 @@ Mod_DecompressPVS
*/
static byte *Mod_DecompressPVS( const byte *in, int visbytes )
{
byte *out;
int c;
out = g_visdata;
if( !in )
{
// no vis info, so make all visible
while( visbytes )
{
*out++ = 0xff;
visbytes--;
}
return g_visdata;
}
do
{
if( *in )
{
*out++ = *in++;
continue;
}
c = in[1];
in += 2;
while( c )
{
*out++ = 0;
c--;
}
} while( out - g_visdata < visbytes );
Mod_DecompressPVSTo( g_visdata, in, visbytes );
return g_visdata;
}