77
88// -------------------------------------------------------------------------------
99
10- CDriverLevelTextures g_levTextures;
11-
1210// 16 bit color to BGRA
1311// originalTransparencyKey makes it pink
1412TVec4D<ubyte> rgb5a1_ToBGRA8 (ushort color, bool originalTransparencyKey /* = true*/ )
@@ -115,10 +113,12 @@ void CTexturePage::ConvertIndexedTextureToRGBA(uint* dest_color_data, int detail
115113 if (clut == nullptr )
116114 clut = &bitmap.clut [detail];
117115
118- int ox = m_details[detail].x ;
119- int oy = m_details[detail].y ;
120- int w = m_details[detail].width ;
121- int h = m_details[detail].height ;
116+ TEXINF& texInfo = m_details[detail].info ;
117+
118+ int ox = texInfo.x ;
119+ int oy = texInfo.y ;
120+ int w = texInfo.width ;
121+ int h = texInfo.height ;
122122
123123 if (w == 0 )
124124 w = 256 ;
@@ -172,8 +172,15 @@ void CTexturePage::InitFromFile(int id, TEXPAGE_POS& tp, IVirtualStream* pFile)
172172 if (m_numDetails)
173173 {
174174 // read texture detail info
175- m_details = new TEXINF[m_numDetails];
176- pFile->Read (m_details, m_numDetails, sizeof (TEXINF));
175+ m_details = new TexDetailInfo_t[m_numDetails];
176+
177+ for (int i = 0 ; i < m_numDetails; i++)
178+ {
179+ m_details[i].numExtraCLUTs = 0 ;
180+ memset (m_details[i].extraCLUTs , 0 , sizeof (m_details[i].extraCLUTs ));
181+
182+ pFile->Read (&m_details[i].info , 1 , sizeof (TEXINF));
183+ }
177184 }
178185 else
179186 m_details = nullptr ;
@@ -257,11 +264,11 @@ bool CTexturePage::LoadTPageAndCluts(IVirtualStream* pFile, bool isSpooled)
257264// -------------------------------------------------------------------------------
258265// searches for detail in this TPAGE
259266// -------------------------------------------------------------------------------
260- TEXINF * CTexturePage::FindTextureDetail (const char * name) const
267+ TexDetailInfo_t * CTexturePage::FindTextureDetail (const char * name) const
261268{
262269 for (int i = 0 ; i < m_numDetails; i++)
263270 {
264- const char * pTexName = g_levTextures. GetTextureDetailName (&m_details[i]);
271+ const char * pTexName = m_owner-> GetTextureDetailName (&m_details[i]. info );
265272
266273 if (!strcmp (pTexName, name)) // FIXME: hashing and case insensitive?
267274 return &m_details[i];
@@ -270,7 +277,7 @@ TEXINF* CTexturePage::FindTextureDetail(const char* name) const
270277 return nullptr ;
271278}
272279
273- TEXINF * CTexturePage::GetTextureDetail (int num) const
280+ TexDetailInfo_t * CTexturePage::GetTextureDetail (int num) const
274281{
275282 return &m_details[num];
276283}
@@ -387,6 +394,8 @@ void CDriverLevelTextures::LoadTextureInfoLump(IVirtualStream* pFile)
387394 for (int i = 0 ; i < numPages; i++)
388395 {
389396 CTexturePage& tp = m_texPages[i];
397+ tp.m_owner = this ;
398+
390399 tp.InitFromFile (i, tpage_position[i], pFile);
391400 }
392401
@@ -486,6 +495,10 @@ void CDriverLevelTextures::ProcessPalletLump(IVirtualStream* pFile)
486495
487496 pFile->Read (clutTablePtr, 16 , sizeof (ushort));
488497
498+ // reference
499+ TexDetailInfo_t& detail = m_texPages[data.tpage ].m_details [info.texnum ];
500+ detail.extraCLUTs [data.palette ] = &data.clut ;
501+
489502 added_cluts++;
490503
491504 // only in D1 we need to check count
@@ -497,12 +510,14 @@ void CDriverLevelTextures::ProcessPalletLump(IVirtualStream* pFile)
497510 }
498511 else
499512 {
500- // Msg(" reference clut: %d, tex %d\n", info.clut_number, info.texnum);
501-
502513 ExtClutData_t& data = m_extraPalettes[info.clut_number ];
503514
504515 // add texture number to existing clut
505516 data.texnum [data.texcnt ++] = info.texnum ;
517+
518+ // reference
519+ TexDetailInfo_t& detail = m_texPages[data.tpage ].m_details [info.texnum ];
520+ detail.extraCLUTs [data.palette ] = &data.clut ;
506521 }
507522 }
508523
@@ -514,11 +529,11 @@ void CDriverLevelTextures::ProcessPalletLump(IVirtualStream* pFile)
514529
515530// ----------------------------------------------------------------------------------------------------
516531
517- TEXINF * CDriverLevelTextures::FindTextureDetail (const char * name) const
532+ TexDetailInfo_t * CDriverLevelTextures::FindTextureDetail (const char * name) const
518533{
519534 for (int i = 0 ; i < m_numTexPages; i++)
520535 {
521- TEXINF * found = m_texPages[i].FindTextureDetail (name);
536+ TexDetailInfo_t * found = m_texPages[i].FindTextureDetail (name);
522537
523538 if (found)
524539 return found;
0 commit comments