//----------------------------------------------------------------------------- // Places Detail Objects in the lump //----------------------------------------------------------------------------- static void SetLumpData( ) { // Sort detail props by leaf qsort( s_DetailObjectLump.Base(), s_DetailObjectLump.Count(), sizeof(DetailObjectLump_t), SortFunc ); GameLumpHandle_t handle = GetGameLumpHandle(GAMELUMP_DETAIL_PROPS); if (handle != InvalidGameLump()) DestroyGameLump(handle); int nDictSize = s_DetailObjectDictLump.Count() * sizeof(DetailObjectDictLump_t); int nSpriteDictSize = s_DetailSpriteDictLump.Count() * sizeof(DetailSpriteDictLump_t); int nObjSize = s_DetailObjectLump.Count() * sizeof(DetailObjectLump_t); int nSize = nDictSize + nSpriteDictSize + nObjSize + 3 * sizeof(int); handle = CreateGameLump( GAMELUMP_DETAIL_PROPS, nSize, 0, GAMELUMP_DETAIL_PROPS_VERSION ); // Serialize the data CUtlBuffer buf( GetGameLump(handle), nSize ); buf.PutInt( s_DetailObjectDictLump.Count() ); if (nDictSize) buf.Put( s_DetailObjectDictLump.Base(), nDictSize ); buf.PutInt( s_DetailSpriteDictLump.Count() ); if (nSpriteDictSize) buf.Put( s_DetailSpriteDictLump.Base(), nSpriteDictSize ); buf.PutInt( s_DetailObjectLump.Count() ); if (nObjSize) buf.Put( s_DetailObjectLump.Base(), nObjSize ); }
void CVradStaticPropMgr::UnserializeStaticProps() { // Unserialize static props, insert them into the appropriate leaves GameLumpHandle_t handle = GetGameLumpHandle( GAMELUMP_STATIC_PROPS ); int size = GameLumpSize( handle ); if (!size) return; if ( GetGameLumpVersion( handle ) != GAMELUMP_STATIC_PROPS_VERSION ) { Error( "Cannot load the static props... encountered a stale map version. Re-vbsp the map." ); } if ( GetGameLump( handle ) ) { CUtlBuffer buf( GetGameLump(handle), size, CUtlBuffer::READ_ONLY ); UnserializeModelDict( buf ); // Skip the leaf list data int count = buf.GetInt(); buf.SeekGet( CUtlBuffer::SEEK_CURRENT, count * sizeof(StaticPropLeafLump_t) ); UnserializeModels( buf ); } }
//----------------------------------------------------------------------------- // Writes the detail lighting lump //----------------------------------------------------------------------------- static void WriteDetailLightingLump( int lumpID, int lumpVersion, CUtlVector<DetailPropLightstylesLump_t> &lumpData ) { GameLumpHandle_t handle = GetGameLumpHandle(lumpID); if (handle != InvalidGameLump()) DestroyGameLump(handle); int lightsize = lumpData.Size() * sizeof(DetailPropLightstylesLump_t); int lumpsize = lightsize + sizeof(int); handle = CreateGameLump( lumpID, lumpsize, 0, lumpVersion ); // Serialize the data CUtlBuffer buf( GetGameLump(handle), lumpsize ); buf.PutInt( lumpData.Size() ); if (lightsize) buf.Put( lumpData.Base(), lightsize ); }
void CVradStaticPropMgr::UnserializeStaticProps() { // Unserialize static props, insert them into the appropriate leaves GameLumpHandle_t handle = GetGameLumpHandle( GAMELUMP_STATIC_PROPS ); int size = GameLumpSize( handle ); if (!size) return; if (GetGameLump( handle )) { CUtlBuffer buf( GetGameLump(handle), size ); UnserializeModelDict( buf ); // Skip the leaf list data int count = buf.GetInt(); buf.SeekGet( CUtlBuffer::SEEK_CURRENT, count * sizeof(StaticPropLeafLump_t) ); UnserializeModels( buf ); } }
//----------------------------------------------------------------------------- // Unserializes the detail props //----------------------------------------------------------------------------- static int UnserializeDetailProps( DetailObjectLump_t*& pProps ) { GameLumpHandle_t handle = GetGameLumpHandle( GAMELUMP_DETAIL_PROPS ); if (GetGameLumpVersion(handle) != GAMELUMP_DETAIL_PROPS_VERSION) return 0; // Unserialize CUtlBuffer buf( GetGameLump(handle), GameLumpSize( handle ), CUtlBuffer::READ_ONLY ); UnserializeModelDict( buf ); UnserializeSpriteDict( buf ); // Now we're pointing to the detail prop data // This actually works because the scope of the game lump data // is global and the buf was just pointing to it. int count = buf.GetInt(); if (count) pProps = (DetailObjectLump_t*)buf.PeekGet(); else pProps = 0; return count; }
// need to do this so that if we are building HDR data, the LDR data is intact, and vice versa.s void UnserializeDetailPropLighting( int lumpID, int lumpVersion, CUtlVector<DetailPropLightstylesLump_t> &lumpData ) { GameLumpHandle_t handle = GetGameLumpHandle( lumpID ); if( handle == InvalidGameLump() ) { return; } if (GetGameLumpVersion(handle) != lumpVersion) return; // Unserialize CUtlBuffer buf( GetGameLump(handle), GameLumpSize( handle ), CUtlBuffer::READ_ONLY ); int count = buf.GetInt(); if( !count ) { return; } lumpData.SetCount( count ); int lightsize = lumpData.Size() * sizeof(DetailPropLightstylesLump_t); buf.Get( lumpData.Base(), lightsize ); }
static void SetLumpData( ) { GameLumpHandle_t handle = GetGameLumpHandle(GAMELUMP_STATIC_PROPS); if (handle != InvalidGameLump()) DestroyGameLump(handle); int dictsize = s_StaticPropDictLump.Size() * sizeof(StaticPropDictLump_t); int objsize = s_StaticPropLump.Size() * sizeof(StaticPropLump_t); int leafsize = s_StaticPropLeafLump.Size() * sizeof(StaticPropLeafLump_t); int size = dictsize + objsize + leafsize + 3 * sizeof(int); handle = CreateGameLump( GAMELUMP_STATIC_PROPS, size, 0, GAMELUMP_STATIC_PROPS_VERSION ); // Serialize the data CUtlBuffer buf( GetGameLump(handle), size ); buf.PutInt( s_StaticPropDictLump.Size() ); if (dictsize) buf.Put( s_StaticPropDictLump.Base(), dictsize ); buf.PutInt( s_StaticPropLeafLump.Size() ); if (leafsize) buf.Put( s_StaticPropLeafLump.Base(), leafsize ); buf.PutInt( s_StaticPropLump.Size() ); if (objsize) buf.Put( s_StaticPropLump.Base(), objsize ); }