From 955422b6ee292a169932608c2749f540c33ef1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Sat, 9 May 2009 17:08:10 +0200 Subject: [PATCH] Remove three color landscape textures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit committer: Günther Brammer --- engine/inc/C4Texture.h | 2 -- engine/src/C4Texture.cpp | 57 ++++++---------------------------- standard/inc/StdDDraw2.h | 1 - standard/src/StdDDraw2.cpp | 63 ++++++-------------------------------- 4 files changed, 19 insertions(+), 104 deletions(-) diff --git a/engine/inc/C4Texture.h b/engine/inc/C4Texture.h index 395076d68..1bba353d2 100644 --- a/engine/inc/C4Texture.h +++ b/engine/inc/C4Texture.h @@ -29,7 +29,6 @@ class C4Texture C4Texture(); ~C4Texture(); CSurface * Surface32; - CSurface8 * Surface8; protected: char Name[C4M_MaxName+1]; C4Texture *Next; @@ -91,7 +90,6 @@ class C4TextureMap BOOL AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture); protected: BOOL AddTexture(const char *szTexture, CSurface * sfcSurface); - BOOL AddTexture(const char *szTexture, CSurface8 * sfcSurface); }; #endif diff --git a/engine/src/C4Texture.cpp b/engine/src/C4Texture.cpp index 569df13fc..baf52f423 100644 --- a/engine/src/C4Texture.cpp +++ b/engine/src/C4Texture.cpp @@ -35,7 +35,6 @@ C4Texture::C4Texture() { Name[0]=0; - Surface8=NULL; Surface32=NULL; Next=NULL; } @@ -43,7 +42,6 @@ C4Texture::C4Texture() C4Texture::~C4Texture() { #ifdef C4ENGINE - delete Surface8; delete Surface32; #endif } @@ -101,10 +99,7 @@ bool C4TexMapEntry::Init() if (iOverlayType & C4MatOv_Exact) iZoom=1; if (iOverlayType & C4MatOv_HugeZoom) iZoom=4; // Create pattern - if (sfcTexture->Surface32) - MatPattern.Set(sfcTexture->Surface32, iZoom, fMono); - else - MatPattern.Set(sfcTexture->Surface8, iZoom, fMono); + MatPattern.Set(sfcTexture->Surface32, iZoom, fMono); MatPattern.SetColors(pMaterial->Color, pMaterial->Alpha); #endif return true; @@ -154,17 +149,6 @@ BOOL C4TextureMap::AddTexture(const char *szTexture, CSurface * sfcSurface) return TRUE; } -BOOL C4TextureMap::AddTexture(const char *szTexture, CSurface8 * sfcSurface) - { - C4Texture *pTexture; - if (!(pTexture=new C4Texture)) return FALSE; - SCopy(szTexture,pTexture->Name,C4M_MaxName); - pTexture->Surface8=sfcSurface; - pTexture->Next=FirstTexture; - FirstTexture=pTexture; - return TRUE; - } - void C4TextureMap::Clear() { for(int32_t i = 1; i < C4M_MaxTexIndex; i++) @@ -288,53 +272,32 @@ bool C4TextureMap::SaveMap(C4Group &hGroup, const char *szEntryName) } int32_t C4TextureMap::LoadTextures(C4Group &hGroup, C4Group* OverloadFile) - { - int32_t texnum=0; - + { + int32_t texnum=0; #ifdef C4ENGINE - // overload: load from other file if (OverloadFile) texnum+=LoadTextures(*OverloadFile); - char texname[256+1]; + char texname[256+1]; C4Surface *ctex; - size_t binlen; + size_t binlen; // newgfx: load PNG-textures first - hGroup.ResetSearch(); - while (hGroup.AccessNextEntry(C4CFN_PNGFiles,&binlen,texname)) - { - // check if it already exists in the map - SReplaceChar(texname,'.',0); - if (GetTexture(texname)) continue; - SAppend(".png", texname); - // load - if (ctex=GroupReadSurfacePNG(hGroup)) - { - SReplaceChar(texname,'.',0); - if (AddTexture(texname,ctex)) texnum++; - else delete ctex; - } - } - // Load all bitmap files from group hGroup.ResetSearch(); - CSurface8 *ctex8; - while (hGroup.AccessNextEntry(C4CFN_BitmapFiles,&binlen,texname)) + while (hGroup.AccessNextEntry(C4CFN_PNGFiles,&binlen,texname)) { // check if it already exists in the map SReplaceChar(texname,'.',0); if (GetTexture(texname)) continue; - SAppend(".bmp", texname); - if (ctex8=GroupReadSurface8(hGroup)) + SAppend(".png", texname); + // load + if (ctex=GroupReadSurfacePNG(hGroup)) { - ctex8->AllowColor(0,2,TRUE); SReplaceChar(texname,'.',0); - if (AddTexture(texname,ctex8)) texnum++; + if (AddTexture(texname,ctex)) texnum++; else delete ctex; } } - #endif - return texnum; } diff --git a/standard/inc/StdDDraw2.h b/standard/inc/StdDDraw2.h index 37e723d96..1c7959e3d 100644 --- a/standard/inc/StdDDraw2.h +++ b/standard/inc/StdDDraw2.h @@ -124,7 +124,6 @@ class CPattern private: // pattern surface for new-style patterns class CSurface *sfcPattern32; - class CSurface8 *sfcPattern8; // Faster access uint32_t * CachedPattern; int Wdt; int Hgt; // pattern zoom factor; 0 means no zoom diff --git a/standard/src/StdDDraw2.cpp b/standard/src/StdDDraw2.cpp index 910311aae..164ce650e 100644 --- a/standard/src/StdDDraw2.cpp +++ b/standard/src/StdDDraw2.cpp @@ -99,7 +99,6 @@ CPattern& CPattern::operator=(const CPattern& nPattern) { pClrs = nPattern.pClrs; pAlpha = nPattern.pAlpha; - sfcPattern8 = nPattern.sfcPattern8; sfcPattern32 = nPattern.sfcPattern32; if (sfcPattern32) sfcPattern32->Lock(); delete [] CachedPattern; @@ -144,29 +143,10 @@ bool CPattern::Set(SURFACE sfcSource, int iZoom, bool fMonochrome) return true; } -bool CPattern::Set(CSurface8 * sfcSource, int iZoom, bool fMonochrome) - { - // Safety - if (!sfcSource) return false; - // Clear existing pattern - Clear(); - // new style: simply store pattern for modulation or shifting, which will be decided upon use - sfcPattern8=sfcSource; - Wdt = sfcPattern8->Wdt; - Hgt = sfcPattern8->Hgt; - // set zoom - Zoom=iZoom; - // set flags - Monochrome=fMonochrome; - CachedPattern = 0; - return true; - } - CPattern::CPattern() { // disable sfcPattern32=NULL; - sfcPattern8=NULL; CachedPattern = 0; Zoom=0; Monochrome=false; @@ -183,52 +163,27 @@ void CPattern::Clear() // clear field sfcPattern32=NULL; } - sfcPattern8 = NULL; delete[] CachedPattern; CachedPattern = 0; } bool CPattern::PatternClr(int iX, int iY, BYTE &byClr, DWORD &dwClr, CStdPalette &rPal) const { - // pattern assigned? - if (!sfcPattern32 && !sfcPattern8) return false; + if (!CachedPattern) return false; // position zoomed? if (Zoom) { iX/=Zoom; iY/=Zoom; } // modulate position ((unsigned int &)iX) %= Wdt; ((unsigned int &)iY) %= Hgt; - // new style: modulate clr - if (CachedPattern) + // modulate clr + DWORD dwPix = CachedPattern[iY * Wdt + iX]; + if (byClr) { - DWORD dwPix = CachedPattern[iY * Wdt + iX]; - if (byClr) - { - if (Monochrome) - ModulateClrMonoA(dwClr, BYTE(dwPix), BYTE(dwPix>>24)); - else - ModulateClrA(dwClr, dwPix); - LightenClr(dwClr); - } - else dwClr=dwPix; - } - // old style? - else if (sfcPattern8) - { - // if color triplet is given, use it - BYTE byShift = sfcPattern8->GetPix(iX, iY); - if (pClrs) - { - // IFT (alpha only) - int iAShift=0; if (byClr & 0xf0) iAShift = 3; - // compose color - dwClr = RGB(pClrs[byShift*3+2], pClrs[byShift*3+1], pClrs[byShift*3])+(pAlpha[byShift+iAShift]<<24); - } + if (Monochrome) + ModulateClrMonoA(dwClr, BYTE(dwPix), BYTE(dwPix>>24)); else - { - // shift color index and return indexed color - byClr+=byShift; - dwClr=rPal.GetClr(byClr); - } + ModulateClrA(dwClr, dwPix); + LightenClr(dwClr); } - // success + else dwClr=dwPix; return true; }