From 25639bc65900980af893b4bf6355263b8c2a2238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Fri, 5 Jun 2009 17:09:54 +0200 Subject: [PATCH] Move Game.TextureMap to TextureMap --- engine/inc/C4Game.h | 1 - engine/inc/C4Texture.h | 2 ++ engine/inc/C4Wrappers.h | 2 +- engine/src/C4EditCursor.cpp | 2 +- engine/src/C4Landscape.cpp | 46 ++++++++++++++++++------------------- engine/src/C4Material.cpp | 12 +++++----- engine/src/C4Script.cpp | 4 ++-- engine/src/C4Texture.cpp | 4 +++- engine/src/C4ToolsDlg.cpp | 20 ++++++++-------- 9 files changed, 48 insertions(+), 45 deletions(-) diff --git a/engine/inc/C4Game.h b/engine/inc/C4Game.h index 24feb3993..49875d7ec 100644 --- a/engine/inc/C4Game.h +++ b/engine/inc/C4Game.h @@ -90,7 +90,6 @@ class C4Game ~C4Game(); public: C4DefList Defs; - C4TextureMap TextureMap; C4RankSystem Rank; C4GraphicsSystem GraphicsSystem; C4MessageInput MessageInput; diff --git a/engine/inc/C4Texture.h b/engine/inc/C4Texture.h index 800c0ac9e..d62f3b2f4 100644 --- a/engine/inc/C4Texture.h +++ b/engine/inc/C4Texture.h @@ -95,4 +95,6 @@ class C4TextureMap BOOL AddTexture(const char *szTexture, CSurface * sfcSurface); }; +extern C4TextureMap TextureMap; + #endif diff --git a/engine/inc/C4Wrappers.h b/engine/inc/C4Wrappers.h index 5c6291e6c..cd95a1850 100644 --- a/engine/inc/C4Wrappers.h +++ b/engine/inc/C4Wrappers.h @@ -144,7 +144,7 @@ inline int32_t PixCol2Mat(BYTE pixc) int32_t iTex = PixCol2Tex(pixc); if(!iTex) return MNone; // Get material-texture mapping - const C4TexMapEntry *pTex = Game.TextureMap.GetEntry(iTex); + const C4TexMapEntry *pTex = ::TextureMap.GetEntry(iTex); // Return material return pTex ? pTex->GetMaterialIndex() : MNone; } diff --git a/engine/src/C4EditCursor.cpp b/engine/src/C4EditCursor.cpp index a8ecd5d46..c231472cd 100644 --- a/engine/src/C4EditCursor.cpp +++ b/engine/src/C4EditCursor.cpp @@ -712,7 +712,7 @@ void C4EditCursor::ApplyToolPicker() // Material-texture from map if (byIndex=Game.Landscape.GetMapIndex(X/Game.Landscape.MapZoom,Y/Game.Landscape.MapZoom)) { - const C4TexMapEntry *pTex = Game.TextureMap.GetEntry(byIndex & (IFT-1)); + const C4TexMapEntry *pTex = ::TextureMap.GetEntry(byIndex & (IFT-1)); if(pTex) { Console.ToolsDlg.SelectMaterial(pTex->GetMaterialName()); diff --git a/engine/src/C4Landscape.cpp b/engine/src/C4Landscape.cpp index 7d0c47f2a..f88927071 100644 --- a/engine/src/C4Landscape.cpp +++ b/engine/src/C4Landscape.cpp @@ -185,7 +185,7 @@ int32_t C4Landscape::DoScan(int32_t cx, int32_t cy, int32_t mat, int32_t dir) // nothing to do? if (!conv_to_tex) return 0; // find material - int32_t conv_to = Game.TextureMap.GetEntry(conv_to_tex)->GetMaterialIndex(); + int32_t conv_to = ::TextureMap.GetEntry(conv_to_tex)->GetMaterialIndex(); // find mat top int32_t mconv = Game.Material.Map[mat].TempConvStrength, mconvs = mconv; @@ -368,7 +368,7 @@ void C4Landscape::ChunkOZoom(CSurface8 * sfcMap, int32_t iMapX, int32_t iMapY, i int32_t iIFT; BYTE byMapPixel, byMapPixelBelow; int iMapWidth,iMapHeight; - C4Material *pMaterial = Game.TextureMap.GetEntry(iTexture)->GetMaterial(); + C4Material *pMaterial = ::TextureMap.GetEntry(iTexture)->GetMaterial(); if(!pMaterial) return; int32_t iChunkType=pMaterial->MapChunkType; BYTE byColor=MatTex2PixCol(iTexture); @@ -552,7 +552,7 @@ CSurface8 * C4Landscape::CreateMap() // Fill sfcMap C4MapCreator MapCreator; MapCreator.Create(sfcMap, - Game.C4S.Landscape, Game.TextureMap, + Game.C4S.Landscape, ::TextureMap, TRUE,Game.StartupPlayerCount); return sfcMap; @@ -565,7 +565,7 @@ CSurface8 * C4Landscape::CreateMapS2(C4Group &ScenFile) // create map creator if (!pMapCreator) - pMapCreator = new C4MapCreatorS2(&Game.C4S.Landscape, &Game.TextureMap, &Game.Material, Game.StartupPlayerCount); + pMapCreator = new C4MapCreatorS2(&Game.C4S.Landscape, &::TextureMap, &Game.Material, Game.StartupPlayerCount); // read file pMapCreator->ReadFile(C4CFN_DynLandscape, &ScenFile); @@ -2154,7 +2154,7 @@ BOOL C4Landscape::SaveMap(C4Group &hGroup) // Create map palette BYTE bypPalette[3*256]; - Game.TextureMap.StoreMapPalette(bypPalette,Game.Material); + ::TextureMap.StoreMapPalette(bypPalette,Game.Material); // Save map surface if (!Map->Save(Config.AtTempPath(C4CFN_TempMap), bypPalette)) @@ -2172,7 +2172,7 @@ BOOL C4Landscape::SaveMap(C4Group &hGroup) bool C4Landscape::SaveTextures(C4Group &hGroup) { // if material-texture-combinations have been added, write the texture map - if (Game.TextureMap.fEntriesAdded) + if (::TextureMap.fEntriesAdded) { C4Group *pMatGroup = new C4Group(); bool fSuccess=false; @@ -2184,7 +2184,7 @@ bool C4Landscape::SaveTextures(C4Group &hGroup) // create at temp path if (pMatGroup->Open(Config.AtTempPath(C4CFN_Material), TRUE)) // write to it - if (Game.TextureMap.SaveMap(*pMatGroup, C4CFN_TexMap)) + if (::TextureMap.SaveMap(*pMatGroup, C4CFN_TexMap)) // close (flush) if (pMatGroup->Close()) // add it @@ -2196,7 +2196,7 @@ bool C4Landscape::SaveTextures(C4Group &hGroup) else // simply write it to the local material file if (pMatGroup->OpenAsChild(&hGroup, C4CFN_Material)) - fSuccess = Game.TextureMap.SaveMap(*pMatGroup, C4CFN_TexMap); + fSuccess = ::TextureMap.SaveMap(*pMatGroup, C4CFN_TexMap); // close material group again if (pMatGroup->IsOpen()) pMatGroup->Close(); delete pMatGroup; @@ -2231,7 +2231,7 @@ BOOL C4Landscape::GetMapColorIndex(const char *szMaterial, const char *szTexture // Material-Texture else { - if (!(rbyCol=Game.TextureMap.GetIndex(szMaterial,szTexture))) return FALSE; + if (!(rbyCol=::TextureMap.GetIndex(szMaterial,szTexture))) return FALSE; if (fIFT) rbyCol+=IFT; } // Found @@ -2392,7 +2392,7 @@ BOOL C4Landscape::DrawChunks(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, i BOOL C4Landscape::DrawQuad(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2, int32_t iX3, int32_t iY3, int32_t iX4, int32_t iY4, const char *szMaterial, bool fIFT) { // get texture - int32_t iMatTex = Game.TextureMap.GetIndexMatTex(szMaterial); + int32_t iMatTex = ::TextureMap.GetIndexMatTex(szMaterial); if(!iMatTex) return FALSE; // prepate pixel count update C4Rect BoundingBox(iX1, iY1, 1, 1); @@ -2557,7 +2557,7 @@ DWORD C4Landscape::GetClrByTex(int32_t iX, int32_t iY) DWORD dwPix = Surface8->pPal->GetClr(pix); // get texture map entry for pixel const C4TexMapEntry *pTex; - if(pix && (pTex = Game.TextureMap.GetEntry(PixCol2Tex(pix)))) + if(pix && (pTex = ::TextureMap.GetEntry(PixCol2Tex(pix)))) { // pattern color pTex->getPattern().PatternClr(iX, iY, pix, dwPix, Application.DDraw->Pal); @@ -2578,7 +2578,7 @@ BOOL C4Landscape::DrawMap(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, co FakeLS.MapWdt.Set(iMapWdt, 0, iMapWdt, iMapWdt); FakeLS.MapHgt.Set(iMapHgt, 0, iMapHgt, iMapHgt); // create map creator - C4MapCreatorS2 MapCreator(&FakeLS, &Game.TextureMap, &Game.Material, Game.StartupPlayerCount); + C4MapCreatorS2 MapCreator(&FakeLS, &::TextureMap, &Game.Material, Game.StartupPlayerCount); // read file MapCreator.ReadScript(szMapDef); // render map @@ -2663,13 +2663,13 @@ BOOL C4Landscape::SetTextureIndex(const char *szMatTex, BYTE iNewIndex, bool fIn // get last mat index - returns zero for not found (valid for insertion mode) StdStrBuf Material, Texture; Material.CopyUntil(szMatTex, '-'); Texture.Copy(SSearch(szMatTex, "-")); - BYTE iOldIndex = (szMatTex && *szMatTex) ? Game.TextureMap.GetIndex(Material.getData(), Texture.getData(), FALSE) : 0; + BYTE iOldIndex = (szMatTex && *szMatTex) ? ::TextureMap.GetIndex(Material.getData(), Texture.getData(), FALSE) : 0; // insertion mode? if (fInsert) { // there must be room to move up to BYTE byLastMoveIndex = C4M_MaxTexIndex - 1; - while (Game.TextureMap.GetEntry(byLastMoveIndex)) + while (::TextureMap.GetEntry(byLastMoveIndex)) if (--byLastMoveIndex == iNewIndex) { DebugLogF("Cannot insert new texture %s to index %d: No room for insertion.", (const char *) szMatTex, (int) iNewIndex); @@ -2678,10 +2678,10 @@ BOOL C4Landscape::SetTextureIndex(const char *szMatTex, BYTE iNewIndex, bool fIn // then move up all other textures first // could do this in one loop, but it's just a developement call anyway, so move one index at a time while (--byLastMoveIndex >= iNewIndex) - if (Game.TextureMap.GetEntry(byLastMoveIndex)) + if (::TextureMap.GetEntry(byLastMoveIndex)) { ReplaceMapColor(byLastMoveIndex, byLastMoveIndex+1); - Game.TextureMap.MoveIndex(byLastMoveIndex, byLastMoveIndex+1); + ::TextureMap.MoveIndex(byLastMoveIndex, byLastMoveIndex+1); } // new insertion desired? if (szMatTex && *szMatTex) @@ -2690,14 +2690,14 @@ BOOL C4Landscape::SetTextureIndex(const char *szMatTex, BYTE iNewIndex, bool fIn if (iOldIndex) { ReplaceMapColor(iOldIndex, iNewIndex); - Game.TextureMap.MoveIndex(iOldIndex, iNewIndex); + ::TextureMap.MoveIndex(iOldIndex, iNewIndex); } else { StdStrBuf Material, Texture; Material.CopyUntil(szMatTex, '-'); Texture.Copy(SSearch(szMatTex, "-")); // new insertion - if (!Game.TextureMap.AddEntry(iNewIndex, Material.getData(), Texture.getData())) + if (!::TextureMap.AddEntry(iNewIndex, Material.getData(), Texture.getData())) { LogF("Cannot insert new texture %s to index %d: Texture map entry error", (const char *) szMatTex, (int) iNewIndex); return FALSE; @@ -2711,7 +2711,7 @@ BOOL C4Landscape::SetTextureIndex(const char *szMatTex, BYTE iNewIndex, bool fIn { // new index must not be occupied const C4TexMapEntry *pOld; - if ((pOld = Game.TextureMap.GetEntry(iNewIndex)) && !pOld->isNull()) + if ((pOld = ::TextureMap.GetEntry(iNewIndex)) && !pOld->isNull()) { DebugLogF("Cannot move texture %s to index %d: Index occupied by %s-%s.", (const char *) szMatTex, (int) iNewIndex, pOld->GetMaterialName(), pOld->GetTextureName()); return FALSE; @@ -2725,7 +2725,7 @@ BOOL C4Landscape::SetTextureIndex(const char *szMatTex, BYTE iNewIndex, bool fIn // update map ReplaceMapColor(iOldIndex, iNewIndex); // change to new index in texmap - Game.TextureMap.MoveIndex(iOldIndex, iNewIndex); + ::TextureMap.MoveIndex(iOldIndex, iNewIndex); // done, success return TRUE; } @@ -2761,7 +2761,7 @@ bool C4Landscape::Mat2Pal() int32_t tex,rgb; for (tex=0; texisNull()) continue; // colors @@ -2930,9 +2930,9 @@ void C4Landscape::RemoveUnusedTexMapEntries() // remove unused for (iMatTex = 1; iMatTex < C4M_MaxTexIndex; ++iMatTex) if (!fTexUsage[iMatTex]) - Game.TextureMap.RemoveEntry(iMatTex); + ::TextureMap.RemoveEntry(iMatTex); // flag rewrite - Game.TextureMap.fEntriesAdded = true; + ::TextureMap.fEntriesAdded = true; } bool C4Landscape::DebugSave(const char *szFilename) diff --git a/engine/src/C4Material.cpp b/engine/src/C4Material.cpp index 664c12b89..e398781a6 100644 --- a/engine/src/C4Material.cpp +++ b/engine/src/C4Material.cpp @@ -394,7 +394,7 @@ void C4MaterialMap::CrossMapMaterials() // Called after load const char *szTextureOverlay = NULL; // newgfx: init pattern if (Map[cnt].sTextureOverlay.getLength()) - if (Game.TextureMap.GetTexture(Map[cnt].sTextureOverlay.getLength())) + if (::TextureMap.GetTexture(Map[cnt].sTextureOverlay.getLength())) { szTextureOverlay = Map[cnt].sTextureOverlay.getData(); // backwards compatibility: if a pattern was specified although the no-pattern flag was set, overwrite that flag @@ -408,13 +408,13 @@ void C4MaterialMap::CrossMapMaterials() // Called after load if (!szTextureOverlay) szTextureOverlay = "Smooth"; // search/create entry in texmap - Map[cnt].DefaultMatTex = Game.TextureMap.GetIndex(Map[cnt].Name, szTextureOverlay, TRUE, + Map[cnt].DefaultMatTex = ::TextureMap.GetIndex(Map[cnt].Name, szTextureOverlay, TRUE, FormatString("DefaultMatTex of mat %s", Map[cnt].Name).getData()); // init PXS facet SURFACE sfcTexture; C4Texture * Texture; if (Map[cnt].sPXSGfx.getLength()) - if (Texture=Game.TextureMap.GetTexture(Map[cnt].sPXSGfx.getData())) + if (Texture=::TextureMap.GetTexture(Map[cnt].sPXSGfx.getData())) if (sfcTexture=Texture->Surface32) Map[cnt].PXSFace.Set(sfcTexture, Map[cnt].PXSGfxRt.x, Map[cnt].PXSGfxRt.y, Map[cnt].PXSGfxRt.Wdt, Map[cnt].PXSGfxRt.Hgt); // evaluate reactions for that material @@ -499,13 +499,13 @@ void C4MaterialMap::CrossMapMaterials() // Called after load for (cnt=0; cntGetTextureName()); @@ -5072,7 +5072,7 @@ static bool FnDrawModLandscape(C4AulContext *cctx, long iX, long iY, long iWdt, } // apply buffer - //Application.DDraw->DefinePattern(Game.TextureMap.GetTexture("Smooth2")); + //Application.DDraw->DefinePattern(::TextureMap.GetTexture("Smooth2")); pZ=map; for (int y=iY; y