MCPcopy Create free account
hub / github.com/Segs/Segs / packColor

Method packColor

Projects/CoX/Common/GameData/GameDataStore.cpp:159–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157 // ColorAndPartPacker interface
158public:
159 void packColor(uint32_t col, BitStream &bs) const override
160 {
161 uint32_t cache_idx=0;
162 uint32_t prev_val=0;
163 if(col && m_colors.find_index(col,cache_idx,prev_val,false))
164 {
165 cache_idx+=1;
166 }
167 bs.StoreBits(1,(cache_idx||col==0));
168 if(cache_idx||col==0)
169 {
170 bs.StorePackedBits(colorcachecount_bitlength,cache_idx);
171 }
172 else
173 {
174 bs.StoreBits(32,col);
175 }
176
177 }
178
179 void unpackColor(BitStream &bs, uint32_t &tgt)const override
180 {

Callers 1

serializetoFunction · 0.80

Calls 3

find_indexMethod · 0.80
StoreBitsMethod · 0.45
StorePackedBitsMethod · 0.45

Tested by

no test coverage detected