Remove DWORD texture pack IDs from pack interfaces

This commit is contained in:
notmatthewbeshay 2026-03-10 00:55:41 +11:00
parent b47ed0af98
commit 2dbce494d1
11 changed files with 42 additions and 42 deletions

View file

@ -4,7 +4,7 @@
#include "../../../Minecraft.World/IO/Streams/InputOutputStream.h"
#include "../../../Minecraft.World/Util/StringHelpers.h"
AbstractTexturePack::AbstractTexturePack(DWORD id, File *file, const std::wstring &name, TexturePack *fallback) : id(id), name(name)
AbstractTexturePack::AbstractTexturePack(std::uint32_t id, File *file, const std::wstring &name, TexturePack *fallback) : id(id), name(name)
{
// 4J init
textureId = -1;
@ -152,7 +152,7 @@ bool AbstractTexturePack::hasFile(const std::wstring &name, bool allowFallback)
return !hasFile && (allowFallback && fallback != NULL) ? fallback->hasFile(name, allowFallback) : hasFile;
}
DWORD AbstractTexturePack::getId()
std::uint32_t AbstractTexturePack::getId()
{
return id;
}

View file

@ -8,7 +8,7 @@ class BufferedImage;
class AbstractTexturePack : public TexturePack
{
private:
const DWORD id;
const std::uint32_t id;
const std::wstring name;
protected:
@ -36,7 +36,7 @@ private:
int textureId;
protected:
AbstractTexturePack(DWORD id, File *file, const std::wstring &name, TexturePack *fallback);
AbstractTexturePack(std::uint32_t id, File *file, const std::wstring &name, TexturePack *fallback);
private:
static std::wstring trim(std::wstring line);
@ -61,7 +61,7 @@ public:
virtual void load(Textures *textures);
virtual bool hasFile(const std::wstring &name, bool allowFallback);
virtual bool hasFile(const std::wstring &name) = 0;
virtual DWORD getId();
virtual std::uint32_t getId();
virtual std::wstring getName();
virtual std::wstring getDesc1();
virtual std::wstring getDesc2();

View file

@ -50,7 +50,7 @@ namespace
}
}
DLCTexturePack::DLCTexturePack(DWORD id, DLCPack *pack, TexturePack *fallback) : AbstractTexturePack(id, NULL, pack->getName(), fallback)
DLCTexturePack::DLCTexturePack(std::uint32_t id, DLCPack *pack, TexturePack *fallback) : AbstractTexturePack(id, NULL, pack->getName(), fallback)
{
m_dlcInfoPack = pack;
m_dlcDataPack = NULL;
@ -305,7 +305,7 @@ void DLCTexturePack::loadData()
std::wstring DLCTexturePack::getFilePath(DWORD packId, std::wstring filename, bool bAddDataFolder)
std::wstring DLCTexturePack::getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder)
{
return app.getFilePath(packId,filename,bAddDataFolder);
}

View file

@ -22,7 +22,7 @@ private:
public:
using AbstractTexturePack::getResource;
DLCTexturePack(DWORD id, DLCPack *pack, TexturePack *fallback);
DLCTexturePack(std::uint32_t id, DLCPack *pack, TexturePack *fallback);
~DLCTexturePack();
virtual std::wstring getResource(const std::wstring& name);
@ -54,8 +54,8 @@ public:
virtual bool isLoadingData() { return m_bLoadingData; }
private:
static std::wstring getRootPath(DWORD packId, bool allowOverride, bool bAddDataFolder);
static std::wstring getFilePath(DWORD packId, std::wstring filename, bool bAddDataFolder=true);
static std::wstring getRootPath(std::uint32_t packId, bool allowOverride, bool bAddDataFolder);
static std::wstring getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder=true);
public:
static int packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask);

View file

@ -1,7 +1,7 @@
#include "../../Platform/stdafx.h"
#include "FileTexturePack.h"
FileTexturePack::FileTexturePack(DWORD id, File *file, TexturePack *fallback) : AbstractTexturePack(id, file, file->getName(), fallback)
FileTexturePack::FileTexturePack(std::uint32_t id, File *file, TexturePack *fallback) : AbstractTexturePack(id, file, file->getName(), fallback)
{
// 4J Stu - These calls need to be in the most derived version of the class
loadIcon();
@ -83,4 +83,4 @@ bool FileTexturePack::isTerrainUpdateCompatible()
return !hasOldFiles;
#endif
return false;
}
}

View file

@ -12,7 +12,7 @@ private:
//ZipFile *zipFile;
public:
FileTexturePack(DWORD id, File *file, TexturePack *fallback);
FileTexturePack(std::uint32_t id, File *file, TexturePack *fallback);
//@Override
void unload(Textures *textures);

View file

@ -1,7 +1,7 @@
#include "../../Platform/stdafx.h"
#include "FolderTexturePack.h"
FolderTexturePack::FolderTexturePack(DWORD id, const std::wstring &name, File *folder, TexturePack *fallback) : AbstractTexturePack(id, folder, name, fallback)
FolderTexturePack::FolderTexturePack(std::uint32_t id, const std::wstring &name, File *folder, TexturePack *fallback) : AbstractTexturePack(id, folder, name, fallback)
{
// 4J Stu - These calls need to be in the most derived version of the class
loadIcon();
@ -107,4 +107,4 @@ void FolderTexturePack::unloadUI()
}
AbstractTexturePack::unloadUI();
#endif
}
}

View file

@ -8,7 +8,7 @@ private:
bool bUILoaded;
public:
FolderTexturePack(DWORD id, const std::wstring &name, File *folder, TexturePack *fallback);
FolderTexturePack(std::uint32_t id, const std::wstring &name, File *folder, TexturePack *fallback);
protected:
//@Override
@ -23,4 +23,4 @@ public:
virtual std::wstring getPath(bool bTitleUpdateTexture = false);
virtual void loadUI();
virtual void unloadUI();
};
};

View file

@ -22,7 +22,7 @@ public:
virtual void load(Textures *textures) = 0;
virtual InputStream *getResource(const std::wstring &name, bool allowFallback) = 0;// throws IOException;
//virtual InputStream *getResource(const std::wstring &name) = 0;// throws IOException;
virtual DWORD getId() = 0;
virtual std::uint32_t getId() = 0;
virtual std::wstring getName() = 0;
virtual std::wstring getDesc1() = 0;
virtual std::wstring getDesc2() = 0;

View file

@ -291,19 +291,19 @@ bool TexturePackRepository::canUseWebSkin()
return false;
}
std::vector< std::pair<DWORD,std::wstring> > *TexturePackRepository::getTexturePackIdNames()
std::vector< std::pair<std::uint32_t,std::wstring> > *TexturePackRepository::getTexturePackIdNames()
{
std::vector< std::pair<DWORD,std::wstring> > *packList = new std::vector< std::pair<DWORD,std::wstring> >();
std::vector< std::pair<std::uint32_t,std::wstring> > *packList = new std::vector< std::pair<std::uint32_t,std::wstring> >();
for(AUTO_VAR(it,texturePacks->begin()); it != texturePacks->end(); ++it)
{
TexturePack *pack = *it;
packList->push_back( std::pair<DWORD,std::wstring>(pack->getId(),pack->getName()) );
packList->push_back( std::pair<std::uint32_t,std::wstring>(pack->getId(),pack->getName()) );
}
return packList;
}
bool TexturePackRepository::selectTexturePackById(DWORD id)
bool TexturePackRepository::selectTexturePackById(std::uint32_t id)
{
bool bDidSelect = false;
@ -352,7 +352,7 @@ bool TexturePackRepository::selectTexturePackById(DWORD id)
return bDidSelect;
}
TexturePack *TexturePackRepository::getTexturePackById(DWORD id)
TexturePack *TexturePackRepository::getTexturePackById(std::uint32_t id)
{
AUTO_VAR(it, cacheById.find(id));
if(it != cacheById.end())
@ -363,27 +363,27 @@ TexturePack *TexturePackRepository::getTexturePackById(DWORD id)
return NULL;
}
TexturePack *TexturePackRepository::addTexturePackFromDLC(DLCPack *dlcPack, DWORD id)
TexturePack *TexturePackRepository::addTexturePackFromDLC(DLCPack *dlcPack, std::uint32_t id)
{
TexturePack *newPack = NULL;
// 4J-PB - The City texture pack went out with a child id for the texture pack of 1 instead of zero
// we need to mask off the child id here to deal with this
DWORD dwParentID=id&0xFFFFFF; // child id is <<24 and Or'd with parent
const std::uint32_t parentId = id & 0xFFFFFFu; // child id is <<24 and Or'd with parent
if(dlcPack != NULL)
{
newPack = new DLCTexturePack(dwParentID, dlcPack, DEFAULT_TEXTURE_PACK);
newPack = new DLCTexturePack(parentId, dlcPack, DEFAULT_TEXTURE_PACK);
texturePacks->push_back(newPack);
cacheById[dwParentID] = newPack;
cacheById[parentId] = newPack;
#ifndef _CONTENT_PACKAGE
if(dlcPack->hasPurchasedFile(DLCManager::e_DLCType_TexturePack,L""))
{
wprintf(L"Added new FULL DLCTexturePack: %ls - id=%d\n", dlcPack->getName().c_str(),dwParentID );
wprintf(L"Added new FULL DLCTexturePack: %ls - id=%u\n", dlcPack->getName().c_str(), parentId );
}
else
{
wprintf(L"Added new TRIAL DLCTexturePack: %ls - id=%d\n", dlcPack->getName().c_str(),dwParentID );
wprintf(L"Added new TRIAL DLCTexturePack: %ls - id=%u\n", dlcPack->getName().c_str(), parentId );
}
#endif
}
@ -398,7 +398,7 @@ void TexturePackRepository::clearInvalidTexturePacks()
}
}
void TexturePackRepository::removeTexturePackById(DWORD id)
void TexturePackRepository::removeTexturePackById(std::uint32_t id)
{
AUTO_VAR(it, cacheById.find(id));
if(it != cacheById.end())
@ -450,7 +450,7 @@ TexturePack *TexturePackRepository::getTexturePackByIndex(unsigned int index)
return pack;
}
unsigned int TexturePackRepository::getTexturePackIndex(unsigned int id)
unsigned int TexturePackRepository::getTexturePackIndex(std::uint32_t id)
{
int currentIndex = 0;
for(AUTO_VAR(it,texturePacks->begin()); it != texturePacks->end(); ++it)
@ -461,4 +461,4 @@ unsigned int TexturePackRepository::getTexturePackIndex(unsigned int id)
}
if(currentIndex >= texturePacks->size()) currentIndex = 0;
return currentIndex;
}
}

View file

@ -7,9 +7,9 @@ class Minecraft;
class TexturePackRepository
{
public:
static const DWORD DEFAULT_TEXTURE_PACK_ID = 0;
static const DWORD FOLDER_TEST_TEXTURE_PACK_ID = 1;
static const DWORD DLC_TEST_TEXTURE_PACK_ID = 2;
static constexpr std::uint32_t DEFAULT_TEXTURE_PACK_ID = 0;
static constexpr std::uint32_t FOLDER_TEST_TEXTURE_PACK_ID = 1;
static constexpr std::uint32_t DLC_TEST_TEXTURE_PACK_ID = 2;
private:
static TexturePack *DEFAULT_TEXTURE_PACK;
TexturePack *m_dummyTexturePack;
@ -21,7 +21,7 @@ private:
std::vector<TexturePack *> *texturePacks;
std::vector<TexturePack *> m_texturePacksToDelete;
std::unordered_map<DWORD, TexturePack *> cacheById;
std::unordered_map<std::uint32_t, TexturePack *> cacheById;
TexturePack *selected;
TexturePack *lastSelected;
@ -60,18 +60,18 @@ public:
bool isUsingDefaultSkin() { return selected == DEFAULT_TEXTURE_PACK; } // 4J Added
TexturePack *getDefault() { return DEFAULT_TEXTURE_PACK; } // 4J Added
std::vector< std::pair<DWORD,std::wstring> > *getTexturePackIdNames();
bool selectTexturePackById(DWORD id); // 4J Added
TexturePack *getTexturePackById(DWORD id); // 4J Added
std::vector< std::pair<std::uint32_t,std::wstring> > *getTexturePackIdNames();
bool selectTexturePackById(std::uint32_t id); // 4J Added
TexturePack *getTexturePackById(std::uint32_t id); // 4J Added
TexturePack *addTexturePackFromDLC(DLCPack *dlcPack, DWORD id);
TexturePack *addTexturePackFromDLC(DLCPack *dlcPack, std::uint32_t id);
void clearInvalidTexturePacks();
void updateUI();
bool needsUIUpdate();
private:
void removeTexturePackById(DWORD id);
void removeTexturePackById(std::uint32_t id);
public:
unsigned int getTexturePackCount();
TexturePack *getTexturePackByIndex(unsigned int index);
unsigned int getTexturePackIndex(unsigned int id);
unsigned int getTexturePackIndex(std::uint32_t id);
};