various iggy UI build fixes, format DLC folder

This commit is contained in:
Tropical 2026-03-22 12:36:33 -05:00
parent cf54e2bd0b
commit a403bf5a4a
38 changed files with 1680 additions and 1812 deletions

View file

@ -9,273 +9,252 @@
#include "../../Minecraft.Client/Platform/Xbox/XML/xmlFilesCallback.h"
#endif
namespace
{
constexpr std::size_t AUDIO_DLC_WCHAR_BIN_SIZE = 2;
namespace {
constexpr std::size_t AUDIO_DLC_WCHAR_BIN_SIZE = 2;
#if WCHAR_MAX > 0xFFFF
static std::wstring ReadAudioDlcWString(const void *data)
{
const std::uint16_t *chars = static_cast<const std::uint16_t *>(data);
const std::uint16_t *end = chars;
while(*end != 0)
{
++end;
}
static std::wstring ReadAudioDlcWString(const void* data) {
const std::uint16_t* chars = static_cast<const std::uint16_t*>(data);
const std::uint16_t* end = chars;
while (*end != 0) {
++end;
}
std::wstring out(static_cast<std::size_t>(end - chars), 0);
for(std::size_t i = 0; i < out.size(); ++i)
{
out[i] = static_cast<wchar_t>(chars[i]);
}
return out;
}
std::wstring out(static_cast<std::size_t>(end - chars), 0);
for (std::size_t i = 0; i < out.size(); ++i) {
out[i] = static_cast<wchar_t>(chars[i]);
}
return out;
}
#else
static std::wstring ReadAudioDlcWString(const void *data)
{
return std::wstring(static_cast<const wchar_t *>(data));
}
static std::wstring ReadAudioDlcWString(const void* data) {
return std::wstring(static_cast<const wchar_t*>(data));
}
#endif
template <typename T>
T ReadAudioDlcValue(const std::uint8_t *data, unsigned int offset = 0)
{
T value;
std::memcpy(&value, data + offset, sizeof(value));
return value;
}
template <typename T>
void ReadAudioDlcStruct(T *out, const std::uint8_t *data, unsigned int offset = 0)
{
std::memcpy(out, data + offset, sizeof(*out));
}
inline unsigned int AudioParamAdvance(unsigned int wcharCount)
{
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_PARAM) + wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
}
inline unsigned int AudioDetailAdvance(unsigned int wcharCount)
{
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_DETAILS) + wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
}
inline std::wstring ReadAudioParamString(const std::uint8_t *data, unsigned int offset)
{
return ReadAudioDlcWString(data + offset + offsetof(C4JStorage::DLC_FILE_PARAM, wchData));
}
template <typename T>
T ReadAudioDlcValue(const std::uint8_t* data, unsigned int offset = 0) {
T value;
std::memcpy(&value, data + offset, sizeof(value));
return value;
}
DLCAudioFile::DLCAudioFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_Audio,path)
{
m_pbData = NULL;
m_dataBytes = 0;
template <typename T>
void ReadAudioDlcStruct(T* out, const std::uint8_t* data,
unsigned int offset = 0) {
std::memcpy(out, data + offset, sizeof(*out));
}
void DLCAudioFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
{
m_pbData = pbData;
m_dataBytes = dataBytes;
processDLCDataFile(pbData,dataBytes);
inline unsigned int AudioParamAdvance(unsigned int wcharCount) {
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_PARAM) +
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
}
std::uint8_t *DLCAudioFile::getData(std::uint32_t &dataBytes)
{
dataBytes = m_dataBytes;
return m_pbData;
inline unsigned int AudioDetailAdvance(unsigned int wcharCount) {
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_DETAILS) +
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
}
const WCHAR *DLCAudioFile::wchTypeNamesA[]=
{
L"CUENAME",
L"CREDIT",
inline std::wstring ReadAudioParamString(const std::uint8_t* data,
unsigned int offset) {
return ReadAudioDlcWString(data + offset +
offsetof(C4JStorage::DLC_FILE_PARAM, wchData));
}
} // namespace
DLCAudioFile::DLCAudioFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Audio, path) {
m_pbData = NULL;
m_dataBytes = 0;
}
void DLCAudioFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
m_pbData = pbData;
m_dataBytes = dataBytes;
processDLCDataFile(pbData, dataBytes);
}
std::uint8_t* DLCAudioFile::getData(std::uint32_t& dataBytes) {
dataBytes = m_dataBytes;
return m_pbData;
}
const WCHAR* DLCAudioFile::wchTypeNamesA[] = {
L"CUENAME",
L"CREDIT",
};
DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(const std::wstring &paramName)
{
EAudioParameterType type = e_AudioParamType_Invalid;
DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(
const std::wstring& paramName) {
EAudioParameterType type = e_AudioParamType_Invalid;
for(int i = 0; i < e_AudioParamType_Max; ++i)
{
if(paramName.compare(wchTypeNamesA[i]) == 0)
{
type = (EAudioParameterType)i;
break;
}
}
for (int i = 0; i < e_AudioParamType_Max; ++i) {
if (paramName.compare(wchTypeNamesA[i]) == 0) {
type = (EAudioParameterType)i;
break;
}
}
return type;
return type;
}
void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype, const std::wstring &value)
{
switch(ptype)
{
void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
const std::wstring& value) {
switch (ptype) {
case e_AudioParamType_Credit: // If this parameter exists, then mark
// this as free
// add it to the DLC credits list
case e_AudioParamType_Credit: // If this parameter exists, then mark this as free
//add it to the DLC credits list
// we'll need to justify this text since we don't have a lot of room
// for lines of credits
{
// don't look for duplicate in the music credits
// we'll need to justify this text since we don't have a lot of room for lines of credits
{
// don't look for duplicate in the music credits
// if(app.AlreadySeenCreditText(value)) break;
//if(app.AlreadySeenCreditText(value)) break;
int maximumChars = 55;
int maximumChars = 55;
bool bIsSDMode =
!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
bool bIsSDMode=!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
if (bIsSDMode) {
maximumChars = 45;
}
if(bIsSDMode)
{
maximumChars = 45;
}
switch (XGetLanguage()) {
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
maximumChars = 35;
break;
}
std::wstring creditValue = value;
while (creditValue.length() > maximumChars) {
unsigned int i = 1;
while (i < creditValue.length() &&
(i + 1) <= maximumChars) {
i++;
}
int iLast = (int)creditValue.find_last_of(L" ", i);
switch (XGetLanguage()) {
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
iLast = maximumChars;
break;
default:
iLast = (int)creditValue.find_last_of(L" ", i);
break;
}
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
maximumChars = 35;
break;
}
std::wstring creditValue = value;
while (creditValue.length() > maximumChars)
{
unsigned int i = 1;
while (i < creditValue.length() && (i + 1) <= maximumChars)
{
i++;
}
int iLast=(int)creditValue.find_last_of(L" ",i);
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
iLast = maximumChars;
break;
default:
iLast=(int)creditValue.find_last_of(L" ",i);
break;
}
// if a space was found, include the space on this line
if (iLast != i) {
iLast++;
}
// if a space was found, include the space on this line
if(iLast!=i)
{
iLast++;
}
app.AddCreditText((creditValue.substr(0, iLast)).c_str());
creditValue = creditValue.substr(iLast);
}
app.AddCreditText(creditValue.c_str());
}
break;
case e_AudioParamType_Cuename:
m_parameters[type].push_back(value);
//m_parameters[(int)type] = value;
break;
default:
break;
}
app.AddCreditText((creditValue.substr(0, iLast)).c_str());
creditValue = creditValue.substr(iLast);
}
app.AddCreditText(creditValue.c_str());
}
break;
case e_AudioParamType_Cuename:
m_parameters[type].push_back(value);
// m_parameters[(int)type] = value;
break;
default:
break;
}
}
bool DLCAudioFile::processDLCDataFile(std::uint8_t *pbData, std::uint32_t dataLength)
{
std::unordered_map<int, EAudioParameterType> parameterMapping;
unsigned int uiCurrentByte=0;
bool DLCAudioFile::processDLCDataFile(std::uint8_t* pbData,
std::uint32_t dataLength) {
std::unordered_map<int, EAudioParameterType> parameterMapping;
unsigned int uiCurrentByte = 0;
// File format defined in the AudioPacker
// File format: Version 1
// File format defined in the AudioPacker
// File format: Version 1
unsigned int uiVersion = ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte+=sizeof(int);
unsigned int uiVersion =
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
if(uiVersion < CURRENT_AUDIO_VERSION_NUM)
{
if(pbData!=NULL) delete [] pbData;
app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion);
return false;
}
unsigned int uiParameterTypeCount = ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_PARAM paramBuf;
ReadAudioDlcStruct(&paramBuf, pbData, uiCurrentByte);
for(unsigned int i=0;i<uiParameterTypeCount;i++)
{
// Map DLC strings to application strings, then store the DLC index mapping to application index
std::wstring parameterName = ReadAudioParamString(pbData, uiCurrentByte);
EAudioParameterType type = getParameterType(parameterName);
if( type != e_AudioParamType_Invalid )
{
parameterMapping[paramBuf.dwType] = type;
}
uiCurrentByte += AudioParamAdvance(paramBuf.dwWchCount);
ReadAudioDlcStruct(&paramBuf, pbData, uiCurrentByte);
}
unsigned int uiFileCount = ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_DETAILS fileBuf;
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
if (uiVersion < CURRENT_AUDIO_VERSION_NUM) {
if (pbData != NULL) delete[] pbData;
app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion);
return false;
}
unsigned int tempByteOffset = uiCurrentByte;
for(unsigned int i=0;i<uiFileCount;i++)
{
tempByteOffset += AudioDetailAdvance(fileBuf.dwWchCount);
ReadAudioDlcStruct(&fileBuf, pbData, tempByteOffset);
}
std::uint8_t *pbTemp = &pbData[tempByteOffset];
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
unsigned int uiParameterTypeCount =
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
C4JStorage::DLC_FILE_PARAM paramBuf;
ReadAudioDlcStruct(&paramBuf, pbData, uiCurrentByte);
for(unsigned int i=0;i<uiFileCount;i++)
{
EAudioType type = (EAudioType)fileBuf.dwType;
// Params
unsigned int uiParameterCount = ReadAudioDlcValue<unsigned int>(pbTemp);
pbTemp+=sizeof(int);
ReadAudioDlcStruct(&paramBuf, pbTemp);
for(unsigned int j=0;j<uiParameterCount;j++)
{
//EAudioParameterType paramType = e_AudioParamType_Invalid;
for (unsigned int i = 0; i < uiParameterTypeCount; i++) {
// Map DLC strings to application strings, then store the DLC index
// mapping to application index
std::wstring parameterName =
ReadAudioParamString(pbData, uiCurrentByte);
EAudioParameterType type = getParameterType(parameterName);
if (type != e_AudioParamType_Invalid) {
parameterMapping[paramBuf.dwType] = type;
}
uiCurrentByte += AudioParamAdvance(paramBuf.dwWchCount);
ReadAudioDlcStruct(&paramBuf, pbData, uiCurrentByte);
}
unsigned int uiFileCount =
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
C4JStorage::DLC_FILE_DETAILS fileBuf;
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
AUTO_VAR(it, parameterMapping.find(paramBuf.dwType));
unsigned int tempByteOffset = uiCurrentByte;
for (unsigned int i = 0; i < uiFileCount; i++) {
tempByteOffset += AudioDetailAdvance(fileBuf.dwWchCount);
ReadAudioDlcStruct(&fileBuf, pbData, tempByteOffset);
}
std::uint8_t* pbTemp = &pbData[tempByteOffset];
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
if(it != parameterMapping.end() )
{
addParameter(type, (EAudioParameterType)paramBuf.dwType, ReadAudioParamString(pbTemp, 0));
}
pbTemp += AudioParamAdvance(paramBuf.dwWchCount);
ReadAudioDlcStruct(&paramBuf, pbTemp);
}
// Move the pointer to the start of the next files data;
pbTemp += fileBuf.uiFileSize;
uiCurrentByte += AudioDetailAdvance(fileBuf.dwWchCount);
for (unsigned int i = 0; i < uiFileCount; i++) {
EAudioType type = (EAudioType)fileBuf.dwType;
// Params
unsigned int uiParameterCount = ReadAudioDlcValue<unsigned int>(pbTemp);
pbTemp += sizeof(int);
ReadAudioDlcStruct(&paramBuf, pbTemp);
for (unsigned int j = 0; j < uiParameterCount; j++) {
// EAudioParameterType paramType = e_AudioParamType_Invalid;
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
AUTO_VAR(it, parameterMapping.find(paramBuf.dwType));
}
if (it != parameterMapping.end()) {
addParameter(type, (EAudioParameterType)paramBuf.dwType,
ReadAudioParamString(pbTemp, 0));
}
pbTemp += AudioParamAdvance(paramBuf.dwWchCount);
ReadAudioDlcStruct(&paramBuf, pbTemp);
}
// Move the pointer to the start of the next files data;
pbTemp += fileBuf.uiFileSize;
uiCurrentByte += AudioDetailAdvance(fileBuf.dwWchCount);
return true;
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
}
return true;
}
int DLCAudioFile::GetCountofType(DLCAudioFile::EAudioType eType)
{
return m_parameters[eType].size();
int DLCAudioFile::GetCountofType(DLCAudioFile::EAudioType eType) {
return m_parameters[eType].size();
}
std::wstring &DLCAudioFile::GetSoundName(int iIndex)
{
int iWorldType=e_AudioType_Overworld;
while(iIndex>=m_parameters[iWorldType].size())
{
iIndex-=m_parameters[iWorldType].size();
iWorldType++;
}
return m_parameters[iWorldType].at(iIndex);
std::wstring& DLCAudioFile::GetSoundName(int iIndex) {
int iWorldType = e_AudioType_Overworld;
while (iIndex >= m_parameters[iWorldType].size()) {
iIndex -= m_parameters[iWorldType].size();
iWorldType++;
}
return m_parameters[iWorldType].at(iIndex);
}

View file

@ -1,54 +1,52 @@
#pragma once
#include "DLCFile.h"
class DLCAudioFile : public DLCFile
{
class DLCAudioFile : public DLCFile {
public:
// If you add to the Enum,then you need to add the array of type names
// These are the names used in the XML for the parameters
enum EAudioType {
e_AudioType_Invalid = -1,
// If you add to the Enum,then you need to add the array of type names
// These are the names used in the XML for the parameters
enum EAudioType
{
e_AudioType_Invalid = -1,
e_AudioType_Overworld = 0,
e_AudioType_Nether,
e_AudioType_End,
e_AudioType_Overworld = 0,
e_AudioType_Nether,
e_AudioType_End,
e_AudioType_Max,
};
enum EAudioParameterType {
e_AudioParamType_Invalid = -1,
e_AudioType_Max,
};
enum EAudioParameterType
{
e_AudioParamType_Invalid = -1,
e_AudioParamType_Cuename = 0,
e_AudioParamType_Credit,
e_AudioParamType_Cuename = 0,
e_AudioParamType_Credit,
e_AudioParamType_Max,
e_AudioParamType_Max,
};
static const WCHAR* wchTypeNamesA[e_AudioParamType_Max];
};
static const WCHAR *wchTypeNamesA[e_AudioParamType_Max];
DLCAudioFile(const std::wstring& path);
DLCAudioFile(const std::wstring &path);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes);
virtual std::uint8_t *getData(std::uint32_t &dataBytes);
bool processDLCDataFile(std::uint8_t *pbData, std::uint32_t dataLength);
int GetCountofType(DLCAudioFile::EAudioType ptype);
std::wstring &GetSoundName(int iIndex);
bool processDLCDataFile(std::uint8_t* pbData, std::uint32_t dataLength);
int GetCountofType(DLCAudioFile::EAudioType ptype);
std::wstring& GetSoundName(int iIndex);
private:
using DLCFile::addParameter;
using DLCFile::addParameter;
std::uint8_t *m_pbData;
std::uint32_t m_dataBytes;
static const int CURRENT_AUDIO_VERSION_NUM=1;
//std::unordered_map<int, std::wstring> m_parameters;
std::vector<std::wstring> m_parameters[e_AudioType_Max];
std::uint8_t* m_pbData;
std::uint32_t m_dataBytes;
static const int CURRENT_AUDIO_VERSION_NUM = 1;
// std::unordered_map<int, std::wstring> m_parameters;
std::vector<std::wstring> m_parameters[e_AudioType_Max];
// use the EAudioType to order these
void addParameter(DLCAudioFile::EAudioType type, DLCAudioFile::EAudioParameterType ptype, const std::wstring &value);
DLCAudioFile::EAudioParameterType getParameterType(const std::wstring &paramName);
// use the EAudioType to order these
void addParameter(DLCAudioFile::EAudioType type,
DLCAudioFile::EAudioParameterType ptype,
const std::wstring& value);
DLCAudioFile::EAudioParameterType getParameterType(
const std::wstring& paramName);
};

View file

@ -2,11 +2,9 @@
#include "DLCManager.h"
#include "DLCCapeFile.h"
DLCCapeFile::DLCCapeFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_Cape,path)
{
}
DLCCapeFile::DLCCapeFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Cape, path) {}
void DLCCapeFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
{
app.AddMemoryTextureFile(m_path,pbData,dataBytes);
void DLCCapeFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
app.AddMemoryTextureFile(m_path, pbData, dataBytes);
}

View file

@ -1,10 +1,9 @@
#pragma once
#include "DLCFile.h"
class DLCCapeFile : public DLCFile
{
class DLCCapeFile : public DLCFile {
public:
DLCCapeFile(const std::wstring &path);
DLCCapeFile(const std::wstring& path);
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
};

View file

@ -5,22 +5,21 @@
#include "../../Minecraft.Client/Textures/Packs/TexturePackRepository.h"
#include "../../Minecraft.Client/Textures/Packs/TexturePack.h"
DLCColourTableFile::DLCColourTableFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_ColourTable,path)
{
m_colourTable = NULL;
DLCColourTableFile::DLCColourTableFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_ColourTable, path) {
m_colourTable = NULL;
}
DLCColourTableFile::~DLCColourTableFile()
{
if(m_colourTable != NULL)
{
app.DebugPrintf("Deleting DLCColourTableFile data\n");
delete m_colourTable;
}
DLCColourTableFile::~DLCColourTableFile() {
if (m_colourTable != NULL) {
app.DebugPrintf("Deleting DLCColourTableFile data\n");
delete m_colourTable;
}
}
void DLCColourTableFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
{
ColourTable *defaultColourTable = Minecraft::GetInstance()->skins->getDefault()->getColourTable();
m_colourTable = new ColourTable(defaultColourTable, pbData, dataBytes);
void DLCColourTableFile::addData(std::uint8_t* pbData,
std::uint32_t dataBytes) {
ColourTable* defaultColourTable =
Minecraft::GetInstance()->skins->getDefault()->getColourTable();
m_colourTable = new ColourTable(defaultColourTable, pbData, dataBytes);
}

View file

@ -3,16 +3,15 @@
class ColourTable;
class DLCColourTableFile : public DLCFile
{
class DLCColourTableFile : public DLCFile {
private:
ColourTable *m_colourTable;
ColourTable* m_colourTable;
public:
DLCColourTableFile(const std::wstring &path);
~DLCColourTableFile();
DLCColourTableFile(const std::wstring& path);
~DLCColourTableFile();
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
ColourTable *getColourTable() { return m_colourTable; }
ColourTable* getColourTable() { return m_colourTable; }
};

View file

@ -1,26 +1,22 @@
#include "../../Minecraft.World/Platform/stdafx.h"
#include "DLCFile.h"
DLCFile::DLCFile(DLCManager::EDLCType type, const std::wstring &path)
{
m_type = type;
m_path = path;
DLCFile::DLCFile(DLCManager::EDLCType type, const std::wstring& path) {
m_type = type;
m_path = path;
// store the id
bool dlcSkin = path.substr(0,3).compare(L"dlc") == 0;
// store the id
bool dlcSkin = path.substr(0, 3).compare(L"dlc") == 0;
if(dlcSkin)
{
std::wstring skinValue = path.substr(7,path.size());
skinValue = skinValue.substr(0,skinValue.find_first_of(L'.'));
std::wstringstream ss;
ss << std::dec << skinValue.c_str();
ss >> m_dwSkinId;
m_dwSkinId = MAKE_SKIN_BITMASK(true, m_dwSkinId);
if (dlcSkin) {
std::wstring skinValue = path.substr(7, path.size());
skinValue = skinValue.substr(0, skinValue.find_first_of(L'.'));
std::wstringstream ss;
ss << std::dec << skinValue.c_str();
ss >> m_dwSkinId;
m_dwSkinId = MAKE_SKIN_BITMASK(true, m_dwSkinId);
}
else
{
m_dwSkinId=0;
}
} else {
m_dwSkinId = 0;
}
}

View file

@ -2,25 +2,33 @@
#include <cstdint>
#include "DLCManager.h"
class DLCFile
{
class DLCFile {
protected:
DLCManager::EDLCType m_type;
std::wstring m_path;
std::uint32_t m_dwSkinId;
DLCManager::EDLCType m_type;
std::wstring m_path;
std::uint32_t m_dwSkinId;
public:
DLCFile(DLCManager::EDLCType type, const std::wstring &path);
virtual ~DLCFile() {}
DLCFile(DLCManager::EDLCType type, const std::wstring& path);
virtual ~DLCFile() {}
DLCManager::EDLCType getType() { return m_type; }
std::wstring getPath() { return m_path; }
std::uint32_t getSkinID() { return m_dwSkinId; }
DLCManager::EDLCType getType() { return m_type; }
std::wstring getPath() { return m_path; }
std::uint32_t getSkinID() { return m_dwSkinId; }
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes) {}
virtual std::uint8_t *getData(std::uint32_t &dataBytes) { dataBytes = 0; return NULL; }
virtual void addParameter(DLCManager::EDLCParameterType type, const std::wstring &value) {}
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes) {}
virtual std::uint8_t* getData(std::uint32_t& dataBytes) {
dataBytes = 0;
return NULL;
}
virtual void addParameter(DLCManager::EDLCParameterType type,
const std::wstring& value) {}
virtual std::wstring getParameterAsString(DLCManager::EDLCParameterType type) { return L""; }
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type) { return false;}
virtual std::wstring getParameterAsString(
DLCManager::EDLCParameterType type) {
return L"";
}
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type) {
return false;
}
};

View file

@ -3,8 +3,8 @@
#include "DLCFile.h"
#include "../GameRules/LevelGenerationOptions.h"
class DLCGameRules : public DLCFile
{
class DLCGameRules : public DLCFile {
public:
DLCGameRules(DLCManager::EDLCType type, const std::wstring &path) : DLCFile(type,path) {}
DLCGameRules(DLCManager::EDLCType type, const std::wstring& path)
: DLCFile(type, path) {}
};

View file

@ -2,20 +2,18 @@
#include "DLCManager.h"
#include "DLCGameRulesFile.h"
DLCGameRulesFile::DLCGameRulesFile(const std::wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRules,path)
{
m_pbData = NULL;
m_dataBytes = 0;
DLCGameRulesFile::DLCGameRulesFile(const std::wstring& path)
: DLCGameRules(DLCManager::e_DLCType_GameRules, path) {
m_pbData = NULL;
m_dataBytes = 0;
}
void DLCGameRulesFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
{
m_pbData = pbData;
m_dataBytes = dataBytes;
void DLCGameRulesFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
m_pbData = pbData;
m_dataBytes = dataBytes;
}
std::uint8_t *DLCGameRulesFile::getData(std::uint32_t &dataBytes)
{
dataBytes = m_dataBytes;
return m_pbData;
std::uint8_t* DLCGameRulesFile::getData(std::uint32_t& dataBytes) {
dataBytes = m_dataBytes;
return m_pbData;
}

View file

@ -1,15 +1,14 @@
#pragma once
#include "DLCGameRules.h"
class DLCGameRulesFile : public DLCGameRules
{
class DLCGameRulesFile : public DLCGameRules {
private:
std::uint8_t *m_pbData;
std::uint32_t m_dataBytes;
std::uint8_t* m_pbData;
std::uint32_t m_dataBytes;
public:
DLCGameRulesFile(const std::wstring &path);
DLCGameRulesFile(const std::wstring& path);
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes);
virtual std::uint8_t *getData(std::uint32_t &dataBytes);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
};

View file

@ -9,23 +9,22 @@
#include "DLCManager.h"
#include "DLCGameRulesHeader.h"
DLCGameRulesHeader::DLCGameRulesHeader(const std::wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRulesHeader,path)
{
m_pbData = NULL;
m_dataBytes = 0;
DLCGameRulesHeader::DLCGameRulesHeader(const std::wstring& path)
: DLCGameRules(DLCManager::e_DLCType_GameRulesHeader, path) {
m_pbData = NULL;
m_dataBytes = 0;
m_hasData = false;
m_hasData = false;
m_grfPath = path.substr(0, path.length() - 4) + L".grf";
m_grfPath = path.substr(0, path.length() - 4) + L".grf";
lgo = NULL;
lgo = NULL;
}
void DLCGameRulesHeader::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
{
m_pbData = pbData;
m_dataBytes = dataBytes;
void DLCGameRulesHeader::addData(std::uint8_t* pbData,
std::uint32_t dataBytes) {
m_pbData = pbData;
m_dataBytes = dataBytes;
#if 0
byteArray data(m_pbData, m_dataBytes);
@ -73,20 +72,18 @@ void DLCGameRulesHeader::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
#endif
}
std::uint8_t *DLCGameRulesHeader::getData(std::uint32_t &dataBytes)
{
dataBytes = m_dataBytes;
return m_pbData;
std::uint8_t* DLCGameRulesHeader::getData(std::uint32_t& dataBytes) {
dataBytes = m_dataBytes;
return m_pbData;
}
void DLCGameRulesHeader::setGrfData(std::uint8_t *fData, std::uint32_t dataSize, StringTable *st)
{
if (!m_hasData)
{
m_hasData = true;
//app.m_gameRules.loadGameRules(lgo, fData, fSize);
void DLCGameRulesHeader::setGrfData(std::uint8_t* fData, std::uint32_t dataSize,
StringTable* st) {
if (!m_hasData) {
m_hasData = true;
app.m_gameRules.readRuleFile(lgo, fData, dataSize, st);
}
// app.m_gameRules.loadGameRules(lgo, fData, fSize);
app.m_gameRules.readRuleFile(lgo, fData, dataSize, st);
}
}

View file

@ -3,40 +3,44 @@
#include "DLCGameRules.h"
#include "../GameRules/LevelGenerationOptions.h"
class DLCGameRulesHeader : public DLCGameRules, public JustGrSource
{
class DLCGameRulesHeader : public DLCGameRules, public JustGrSource {
private:
// GR-Header
std::uint8_t* m_pbData;
std::uint32_t m_dataBytes;
// GR-Header
std::uint8_t *m_pbData;
std::uint32_t m_dataBytes;
bool m_hasData;
bool m_hasData;
public:
virtual bool requiresTexturePack() {return m_bRequiresTexturePack;}
virtual std::uint32_t getRequiredTexturePackId() {return m_requiredTexturePackId;}
virtual std::wstring getDefaultSaveName() {return m_defaultSaveName;}
virtual const wchar_t *getWorldName() {return m_worldName.c_str();}
virtual const wchar_t *getDisplayName() {return m_displayName.c_str();}
virtual std::wstring getGrfPath() {return L"GameRules.grf";}
virtual bool requiresTexturePack() { return m_bRequiresTexturePack; }
virtual std::uint32_t getRequiredTexturePackId() {
return m_requiredTexturePackId;
}
virtual std::wstring getDefaultSaveName() { return m_defaultSaveName; }
virtual const wchar_t* getWorldName() { return m_worldName.c_str(); }
virtual const wchar_t* getDisplayName() { return m_displayName.c_str(); }
virtual std::wstring getGrfPath() { return L"GameRules.grf"; }
virtual void setRequiresTexturePack(bool x) {m_bRequiresTexturePack = x;}
virtual void setRequiredTexturePackId(std::uint32_t x) {m_requiredTexturePackId = x;}
virtual void setDefaultSaveName(const std::wstring &x) {m_defaultSaveName = x;}
virtual void setWorldName(const std::wstring & x) {m_worldName = x;}
virtual void setDisplayName(const std::wstring & x) {m_displayName = x;}
virtual void setGrfPath(const std::wstring & x) {m_grfPath = x;}
virtual void setRequiresTexturePack(bool x) { m_bRequiresTexturePack = x; }
virtual void setRequiredTexturePackId(std::uint32_t x) {
m_requiredTexturePackId = x;
}
virtual void setDefaultSaveName(const std::wstring& x) {
m_defaultSaveName = x;
}
virtual void setWorldName(const std::wstring& x) { m_worldName = x; }
virtual void setDisplayName(const std::wstring& x) { m_displayName = x; }
virtual void setGrfPath(const std::wstring& x) { m_grfPath = x; }
LevelGenerationOptions *lgo;
LevelGenerationOptions* lgo;
public:
DLCGameRulesHeader(const std::wstring &path);
DLCGameRulesHeader(const std::wstring& path);
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes);
virtual std::uint8_t *getData(std::uint32_t &dataBytes);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
void setGrfData(std::uint8_t *fData, std::uint32_t dataSize, StringTable *);
void setGrfData(std::uint8_t* fData, std::uint32_t dataSize, StringTable*);
virtual bool ready() { return m_hasData; }
virtual bool ready() { return m_hasData; }
};

View file

@ -3,12 +3,12 @@
#include "DLCLocalisationFile.h"
#include "../../Minecraft.Client/Utils/StringTable.h"
DLCLocalisationFile::DLCLocalisationFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_LocalisationData,path)
{
m_strings = NULL;
DLCLocalisationFile::DLCLocalisationFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_LocalisationData, path) {
m_strings = NULL;
}
void DLCLocalisationFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
{
m_strings = new StringTable(pbData, dataBytes);
void DLCLocalisationFile::addData(std::uint8_t* pbData,
std::uint32_t dataBytes) {
m_strings = new StringTable(pbData, dataBytes);
}

View file

@ -3,16 +3,18 @@
class StringTable;
class DLCLocalisationFile : public DLCFile
{
class DLCLocalisationFile : public DLCFile {
private:
StringTable *m_strings;
StringTable* m_strings;
public:
DLCLocalisationFile(const std::wstring &path);
DLCLocalisationFile(std::uint8_t *pbData, std::uint32_t dataBytes); // when we load in a texture pack details file from TMS++
DLCLocalisationFile(const std::wstring& path);
DLCLocalisationFile(
std::uint8_t* pbData,
std::uint32_t dataBytes); // when we load in a texture pack details
// file from TMS++
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
StringTable *getStringTable() { return m_strings; }
StringTable* getStringTable() { return m_strings; }
};

File diff suppressed because it is too large Load diff

View file

@ -1,100 +1,110 @@
#pragma once
//using namespace std;
// using namespace std;
#include <cstdint>
#include <vector>
class DLCPack;
class DLCSkinFile;
class DLCManager
{
class DLCManager {
public:
enum EDLCType
{
e_DLCType_Skin = 0,
e_DLCType_Cape,
e_DLCType_Texture,
e_DLCType_UIData,
e_DLCType_PackConfig,
e_DLCType_TexturePack,
e_DLCType_LocalisationData,
e_DLCType_GameRules,
e_DLCType_Audio,
e_DLCType_ColourTable,
e_DLCType_GameRulesHeader,
enum EDLCType {
e_DLCType_Skin = 0,
e_DLCType_Cape,
e_DLCType_Texture,
e_DLCType_UIData,
e_DLCType_PackConfig,
e_DLCType_TexturePack,
e_DLCType_LocalisationData,
e_DLCType_GameRules,
e_DLCType_Audio,
e_DLCType_ColourTable,
e_DLCType_GameRulesHeader,
e_DLCType_Max,
e_DLCType_All,
};
e_DLCType_Max,
e_DLCType_All,
};
// If you add to the Enum,then you need to add the array of type names
// These are the names used in the XML for the parameters
enum EDLCParameterType
{
e_DLCParamType_Invalid = -1,
// If you add to the Enum,then you need to add the array of type names
// These are the names used in the XML for the parameters
enum EDLCParameterType {
e_DLCParamType_Invalid = -1,
e_DLCParamType_DisplayName = 0,
e_DLCParamType_ThemeName,
e_DLCParamType_Free, // identify free skins
e_DLCParamType_Credit, // legal credits for DLC
e_DLCParamType_Cape,
e_DLCParamType_Box,
e_DLCParamType_Anim,
e_DLCParamType_PackId,
e_DLCParamType_NetherParticleColour,
e_DLCParamType_EnchantmentTextColour,
e_DLCParamType_EnchantmentTextFocusColour,
e_DLCParamType_DataPath,
e_DLCParamType_PackVersion,
e_DLCParamType_DisplayName = 0,
e_DLCParamType_ThemeName,
e_DLCParamType_Free, // identify free skins
e_DLCParamType_Credit, // legal credits for DLC
e_DLCParamType_Cape,
e_DLCParamType_Box,
e_DLCParamType_Anim,
e_DLCParamType_PackId,
e_DLCParamType_NetherParticleColour,
e_DLCParamType_EnchantmentTextColour,
e_DLCParamType_EnchantmentTextFocusColour,
e_DLCParamType_DataPath,
e_DLCParamType_PackVersion,
e_DLCParamType_Max,
e_DLCParamType_Max,
};
const static WCHAR *wchTypeNamesA[e_DLCParamType_Max];
};
const static WCHAR* wchTypeNamesA[e_DLCParamType_Max];
private:
std::vector<DLCPack *> m_packs;
//bool m_bNeedsUpdated;
bool m_bNeedsCorruptCheck;
unsigned int m_dwUnnamedCorruptDLCCount;
std::vector<DLCPack*> m_packs;
// bool m_bNeedsUpdated;
bool m_bNeedsCorruptCheck;
unsigned int m_dwUnnamedCorruptDLCCount;
public:
DLCManager();
~DLCManager();
DLCManager();
~DLCManager();
static EDLCParameterType getParameterType(const std::wstring &paramName);
static EDLCParameterType getParameterType(const std::wstring& paramName);
unsigned int getPackCount(EDLCType type = e_DLCType_All);
unsigned int getPackCount(EDLCType type = e_DLCType_All);
//bool NeedsUpdated() { return m_bNeedsUpdated; }
//void SetNeedsUpdated(bool val) { m_bNeedsUpdated = val; }
// bool NeedsUpdated() { return m_bNeedsUpdated; }
// void SetNeedsUpdated(bool val) { m_bNeedsUpdated = val; }
bool NeedsCorruptCheck() { return m_bNeedsCorruptCheck; }
void SetNeedsCorruptCheck(bool val) { m_bNeedsCorruptCheck = val; }
bool NeedsCorruptCheck() { return m_bNeedsCorruptCheck; }
void SetNeedsCorruptCheck(bool val) { m_bNeedsCorruptCheck = val; }
void resetUnnamedCorruptCount() { m_dwUnnamedCorruptDLCCount = 0; }
void incrementUnnamedCorruptCount() { ++m_dwUnnamedCorruptDLCCount; }
void resetUnnamedCorruptCount() { m_dwUnnamedCorruptDLCCount = 0; }
void incrementUnnamedCorruptCount() { ++m_dwUnnamedCorruptDLCCount; }
void addPack(DLCPack *pack);
void removePack(DLCPack *pack);
void addPack(DLCPack* pack);
void removePack(DLCPack* pack);
DLCPack *getPack(const std::wstring &name);
DLCPack* getPack(const std::wstring& name);
#ifdef _XBOX_ONE
DLCPack *DLCManager::getPackFromProductID(const std::wstring &productID);
DLCPack* DLCManager::getPackFromProductID(const std::wstring& productID);
#endif
DLCPack *getPack(unsigned int index, EDLCType type = e_DLCType_All);
unsigned int getPackIndex(DLCPack *pack, bool &found, EDLCType type = e_DLCType_All);
DLCSkinFile *getSkinFile(const std::wstring &path); // Will hunt all packs of type skin to find the right skinfile
DLCPack* getPack(unsigned int index, EDLCType type = e_DLCType_All);
unsigned int getPackIndex(DLCPack* pack, bool& found,
EDLCType type = e_DLCType_All);
DLCSkinFile* getSkinFile(
const std::wstring& path); // Will hunt all packs of type skin to find
// the right skinfile
DLCPack *getPackContainingSkin(const std::wstring &path);
unsigned int getPackIndexContainingSkin(const std::wstring &path, bool &found);
DLCPack* getPackContainingSkin(const std::wstring& path);
unsigned int getPackIndexContainingSkin(const std::wstring& path,
bool& found);
unsigned int checkForCorruptDLCAndAlert(bool showMessage = true);
unsigned int checkForCorruptDLCAndAlert(bool showMessage = true);
bool readDLCDataFile(unsigned int &dwFilesProcessed, const std::wstring &path, DLCPack *pack, bool fromArchive = false);
bool readDLCDataFile(unsigned int &dwFilesProcessed, const std::string &path, DLCPack *pack, bool fromArchive = false);
std::uint32_t retrievePackIDFromDLCDataFile(const std::string &path, DLCPack *pack);
bool readDLCDataFile(unsigned int& dwFilesProcessed,
const std::wstring& path, DLCPack* pack,
bool fromArchive = false);
bool readDLCDataFile(unsigned int& dwFilesProcessed,
const std::string& path, DLCPack* pack,
bool fromArchive = false);
std::uint32_t retrievePackIDFromDLCDataFile(const std::string& path,
DLCPack* pack);
private:
bool processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t *pbData, unsigned int dwLength, DLCPack *pack);
bool processDLCDataFile(unsigned int& dwFilesProcessed,
std::uint8_t* pbData, unsigned int dwLength,
DLCPack* pack);
std::uint32_t retrievePackID(std::uint8_t *pbData, unsigned int dwLength, DLCPack *pack);
std::uint32_t retrievePackID(std::uint8_t* pbData, unsigned int dwLength,
DLCPack* pack);
};

View file

@ -11,402 +11,354 @@
#include "DLCColourTableFile.h"
#include "../../Minecraft.World/Util/StringHelpers.h"
DLCPack::DLCPack(const std::wstring &name,std::uint32_t dwLicenseMask)
{
m_dataPath = L"";
m_packName = name;
m_dwLicenseMask=dwLicenseMask;
DLCPack::DLCPack(const std::wstring& name, std::uint32_t dwLicenseMask) {
m_dataPath = L"";
m_packName = name;
m_dwLicenseMask = dwLicenseMask;
#ifdef _XBOX_ONE
m_wsProductId = L"";
m_wsProductId = L"";
#else
m_ullFullOfferId = 0LL;
m_ullFullOfferId = 0LL;
#endif
m_isCorrupt = false;
m_packId = 0;
m_packVersion = 0;
m_parentPack = NULL;
m_dlcMountIndex = -1;
m_isCorrupt = false;
m_packId = 0;
m_packVersion = 0;
m_parentPack = NULL;
m_dlcMountIndex = -1;
#ifdef _XBOX
m_dlcDeviceID = XCONTENTDEVICE_ANY;
m_dlcDeviceID = XCONTENTDEVICE_ANY;
#endif
// This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
m_data = NULL;
// This pointer is for all the data used for this pack, so deleting it
// invalidates ALL of it's children.
m_data = NULL;
}
#ifdef _XBOX_ONE
DLCPack::DLCPack(const std::wstring &name,const std::wstring &productID,std::uint32_t dwLicenseMask)
{
m_dataPath = L"";
m_packName = name;
m_dwLicenseMask=dwLicenseMask;
m_wsProductId = productID;
m_isCorrupt = false;
m_packId = 0;
m_packVersion = 0;
m_parentPack = NULL;
m_dlcMountIndex = -1;
DLCPack::DLCPack(const std::wstring& name, const std::wstring& productID,
std::uint32_t dwLicenseMask) {
m_dataPath = L"";
m_packName = name;
m_dwLicenseMask = dwLicenseMask;
m_wsProductId = productID;
m_isCorrupt = false;
m_packId = 0;
m_packVersion = 0;
m_parentPack = NULL;
m_dlcMountIndex = -1;
// This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
m_data = NULL;
// This pointer is for all the data used for this pack, so deleting it
// invalidates ALL of it's children.
m_data = NULL;
}
#endif
DLCPack::~DLCPack()
{
for(AUTO_VAR(it, m_childPacks.begin()); it != m_childPacks.end(); ++it)
{
delete *it;
}
DLCPack::~DLCPack() {
for (AUTO_VAR(it, m_childPacks.begin()); it != m_childPacks.end(); ++it) {
delete *it;
}
for(unsigned int i = 0; i < DLCManager::e_DLCType_Max; ++i)
{
for(AUTO_VAR(it,m_files[i].begin()); it != m_files[i].end(); ++it)
{
delete *it;
}
}
for (unsigned int i = 0; i < DLCManager::e_DLCType_Max; ++i) {
for (AUTO_VAR(it, m_files[i].begin()); it != m_files[i].end(); ++it) {
delete *it;
}
}
// This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
if(m_data)
{
// This pointer is for all the data used for this pack, so deleting it
// invalidates ALL of it's children.
if (m_data) {
#ifndef _CONTENT_PACKAGE
wprintf(L"Deleting data for DLC pack %ls\n", m_packName.c_str());
wprintf(L"Deleting data for DLC pack %ls\n", m_packName.c_str());
#endif
// For the same reason, don't delete data pointer for any child pack as it just points to a region within the parent pack that has already been freed
if( m_parentPack == NULL )
{
delete [] m_data;
}
}
// For the same reason, don't delete data pointer for any child pack as
// it just points to a region within the parent pack that has already
// been freed
if (m_parentPack == NULL) {
delete[] m_data;
}
}
}
int DLCPack::GetDLCMountIndex()
{
if(m_parentPack != NULL)
{
return m_parentPack->GetDLCMountIndex();
}
return m_dlcMountIndex;
int DLCPack::GetDLCMountIndex() {
if (m_parentPack != NULL) {
return m_parentPack->GetDLCMountIndex();
}
return m_dlcMountIndex;
}
XCONTENTDEVICEID DLCPack::GetDLCDeviceID()
{
if(m_parentPack != NULL )
{
return m_parentPack->GetDLCDeviceID();
}
return m_dlcDeviceID;
XCONTENTDEVICEID DLCPack::GetDLCDeviceID() {
if (m_parentPack != NULL) {
return m_parentPack->GetDLCDeviceID();
}
return m_dlcDeviceID;
}
void DLCPack::addChildPack(DLCPack *childPack)
{
const std::uint32_t packId = childPack->GetPackId();
void DLCPack::addChildPack(DLCPack* childPack) {
const std::uint32_t packId = childPack->GetPackId();
#ifndef _CONTENT_PACKAGE
if(packId > 15)
{
__debugbreak();
}
if (packId > 15) {
__debugbreak();
}
#endif
childPack->SetPackId( (packId<<24) | m_packId );
m_childPacks.push_back(childPack);
childPack->setParentPack(this);
childPack->m_packName = m_packName + childPack->getName();
childPack->SetPackId((packId << 24) | m_packId);
m_childPacks.push_back(childPack);
childPack->setParentPack(this);
childPack->m_packName = m_packName + childPack->getName();
}
void DLCPack::setParentPack(DLCPack *parentPack)
{
m_parentPack = parentPack;
void DLCPack::setParentPack(DLCPack* parentPack) { m_parentPack = parentPack; }
void DLCPack::addParameter(DLCManager::EDLCParameterType type,
const std::wstring& value) {
switch (type) {
case DLCManager::e_DLCParamType_PackId: {
std::uint32_t packId = 0;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for
// artists/people to number manually
ss << std::dec << value.c_str();
ss >> packId;
SetPackId(packId);
} break;
case DLCManager::e_DLCParamType_PackVersion: {
std::uint32_t version = 0;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for
// artists/people to number manually
ss << std::dec << value.c_str();
ss >> version;
SetPackVersion(version);
} break;
case DLCManager::e_DLCParamType_DisplayName:
m_packName = value;
break;
case DLCManager::e_DLCParamType_DataPath:
m_dataPath = value;
break;
default:
m_parameters[(int)type] = value;
break;
}
}
void DLCPack::addParameter(DLCManager::EDLCParameterType type, const std::wstring &value)
{
switch(type)
{
case DLCManager::e_DLCParamType_PackId:
{
std::uint32_t packId = 0;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for artists/people to number manually
ss << std::dec << value.c_str();
ss >> packId;
SetPackId(packId);
}
break;
case DLCManager::e_DLCParamType_PackVersion:
{
std::uint32_t version = 0;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for artists/people to number manually
ss << std::dec << value.c_str();
ss >> version;
SetPackVersion(version);
}
break;
case DLCManager::e_DLCParamType_DisplayName:
m_packName = value;
break;
case DLCManager::e_DLCParamType_DataPath:
m_dataPath = value;
break;
default:
m_parameters[(int)type] = value;
break;
}
bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type,
unsigned int& param) {
AUTO_VAR(it, m_parameters.find((int)type));
if (it != m_parameters.end()) {
switch (type) {
case DLCManager::e_DLCParamType_NetherParticleColour:
case DLCManager::e_DLCParamType_EnchantmentTextColour:
case DLCManager::e_DLCParamType_EnchantmentTextFocusColour: {
std::wstringstream ss;
ss << std::hex << it->second.c_str();
ss >> param;
} break;
default:
param = _fromString<unsigned int>(it->second);
}
return true;
}
return false;
}
bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type, unsigned int &param)
{
AUTO_VAR(it,m_parameters.find((int)type));
if(it != m_parameters.end())
{
switch(type)
{
case DLCManager::e_DLCParamType_NetherParticleColour:
case DLCManager::e_DLCParamType_EnchantmentTextColour:
case DLCManager::e_DLCParamType_EnchantmentTextFocusColour:
{
std::wstringstream ss;
ss << std::hex << it->second.c_str();
ss >> param;
}
break;
default:
param = _fromString<unsigned int>(it->second);
}
return true;
}
return false;
}
DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::wstring& path) {
DLCFile* newFile = NULL;
DLCFile *DLCPack::addFile(DLCManager::EDLCType type, const std::wstring &path)
{
DLCFile *newFile = NULL;
switch (type) {
case DLCManager::e_DLCType_Skin: {
std::vector<std::wstring> splitPath = stringSplit(path, L'/');
std::wstring strippedPath = splitPath.back();
switch(type)
{
case DLCManager::e_DLCType_Skin:
{
std::vector<std::wstring> splitPath = stringSplit(path,L'/');
std::wstring strippedPath = splitPath.back();
newFile = new DLCSkinFile(strippedPath);
newFile = new DLCSkinFile(strippedPath);
// check to see if we can get the full offer id using this skin name
// check to see if we can get the full offer id using this skin name
#ifdef _XBOX_ONE
app.GetDLCFullOfferIDForSkinID(strippedPath,m_wsProductId);
app.GetDLCFullOfferIDForSkinID(strippedPath, m_wsProductId);
#else
ULONGLONG ullVal=0LL;
ULONGLONG ullVal = 0LL;
if(app.GetDLCFullOfferIDForSkinID(strippedPath,&ullVal))
{
m_ullFullOfferId=ullVal;
}
if (app.GetDLCFullOfferIDForSkinID(strippedPath, &ullVal)) {
m_ullFullOfferId = ullVal;
}
#endif
}
break;
case DLCManager::e_DLCType_Cape:
{
std::vector<std::wstring> splitPath = stringSplit(path,L'/');
std::wstring strippedPath = splitPath.back();
newFile = new DLCCapeFile(strippedPath);
}
break;
case DLCManager::e_DLCType_Texture:
newFile = new DLCTextureFile(path);
break;
case DLCManager::e_DLCType_UIData:
newFile = new DLCUIDataFile(path);
break;
case DLCManager::e_DLCType_LocalisationData:
newFile = new DLCLocalisationFile(path);
break;
case DLCManager::e_DLCType_GameRules:
newFile = new DLCGameRulesFile(path);
break;
case DLCManager::e_DLCType_Audio:
newFile = new DLCAudioFile(path);
break;
case DLCManager::e_DLCType_ColourTable:
newFile = new DLCColourTableFile(path);
break;
case DLCManager::e_DLCType_GameRulesHeader:
newFile = new DLCGameRulesHeader(path);
break;
default:
break;
};
} break;
case DLCManager::e_DLCType_Cape: {
std::vector<std::wstring> splitPath = stringSplit(path, L'/');
std::wstring strippedPath = splitPath.back();
newFile = new DLCCapeFile(strippedPath);
} break;
case DLCManager::e_DLCType_Texture:
newFile = new DLCTextureFile(path);
break;
case DLCManager::e_DLCType_UIData:
newFile = new DLCUIDataFile(path);
break;
case DLCManager::e_DLCType_LocalisationData:
newFile = new DLCLocalisationFile(path);
break;
case DLCManager::e_DLCType_GameRules:
newFile = new DLCGameRulesFile(path);
break;
case DLCManager::e_DLCType_Audio:
newFile = new DLCAudioFile(path);
break;
case DLCManager::e_DLCType_ColourTable:
newFile = new DLCColourTableFile(path);
break;
case DLCManager::e_DLCType_GameRulesHeader:
newFile = new DLCGameRulesHeader(path);
break;
default:
break;
};
if( newFile != NULL )
{
m_files[newFile->getType()].push_back(newFile);
}
if (newFile != NULL) {
m_files[newFile->getType()].push_back(newFile);
}
return newFile;
return newFile;
}
// MGH - added this comp func, as the embedded func in find_if was confusing the PS3 compiler
static const std::wstring *g_pathCmpString = NULL;
static bool pathCmp(DLCFile *val)
{
return (g_pathCmpString->compare(val->getPath()) == 0);
// MGH - added this comp func, as the embedded func in find_if was confusing the
// PS3 compiler
static const std::wstring* g_pathCmpString = NULL;
static bool pathCmp(DLCFile* val) {
return (g_pathCmpString->compare(val->getPath()) == 0);
}
bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, const std::wstring &path)
{
bool hasFile = false;
if(type == DLCManager::e_DLCType_All)
{
for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1))
{
hasFile = doesPackContainFile(currentType,path);
if(hasFile) break;
}
}
else
{
g_pathCmpString = &path;
AUTO_VAR(it, std::find_if( m_files[type].begin(), m_files[type].end(), pathCmp ));
hasFile = it != m_files[type].end();
if(!hasFile && m_parentPack )
{
hasFile = m_parentPack->doesPackContainFile(type,path);
}
}
return hasFile;
bool DLCPack::doesPackContainFile(DLCManager::EDLCType type,
const std::wstring& path) {
bool hasFile = false;
if (type == DLCManager::e_DLCType_All) {
for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0;
currentType < DLCManager::e_DLCType_Max;
currentType = (DLCManager::EDLCType)(currentType + 1)) {
hasFile = doesPackContainFile(currentType, path);
if (hasFile) break;
}
} else {
g_pathCmpString = &path;
AUTO_VAR(it, std::find_if(m_files[type].begin(), m_files[type].end(),
pathCmp));
hasFile = it != m_files[type].end();
if (!hasFile && m_parentPack) {
hasFile = m_parentPack->doesPackContainFile(type, path);
}
}
return hasFile;
}
DLCFile *DLCPack::getFile(DLCManager::EDLCType type, unsigned int index)
{
DLCFile *file = NULL;
if(type == DLCManager::e_DLCType_All)
{
for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1))
{
file = getFile(currentType,index);
if(file != NULL) break;
}
}
else
{
if(m_files[type].size() > index) file = m_files[type][index];
if(!file && m_parentPack)
{
file = m_parentPack->getFile(type,index);
}
}
return file;
DLCFile* DLCPack::getFile(DLCManager::EDLCType type, unsigned int index) {
DLCFile* file = NULL;
if (type == DLCManager::e_DLCType_All) {
for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0;
currentType < DLCManager::e_DLCType_Max;
currentType = (DLCManager::EDLCType)(currentType + 1)) {
file = getFile(currentType, index);
if (file != NULL) break;
}
} else {
if (m_files[type].size() > index) file = m_files[type][index];
if (!file && m_parentPack) {
file = m_parentPack->getFile(type, index);
}
}
return file;
}
DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const std::wstring &path)
{
DLCFile *file = NULL;
if(type == DLCManager::e_DLCType_All)
{
for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1))
{
file = getFile(currentType,path);
if(file != NULL) break;
}
}
else
{
g_pathCmpString = &path;
AUTO_VAR(it, std::find_if( m_files[type].begin(), m_files[type].end(), pathCmp ));
DLCFile* DLCPack::getFile(DLCManager::EDLCType type, const std::wstring& path) {
DLCFile* file = NULL;
if (type == DLCManager::e_DLCType_All) {
for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0;
currentType < DLCManager::e_DLCType_Max;
currentType = (DLCManager::EDLCType)(currentType + 1)) {
file = getFile(currentType, path);
if (file != NULL) break;
}
} else {
g_pathCmpString = &path;
AUTO_VAR(it, std::find_if(m_files[type].begin(), m_files[type].end(),
pathCmp));
if(it == m_files[type].end())
{
// Not found
file = NULL;
}
else
{
file = *it;
}
if(!file && m_parentPack)
{
file = m_parentPack->getFile(type,path);
}
}
return file;
if (it == m_files[type].end()) {
// Not found
file = NULL;
} else {
file = *it;
}
if (!file && m_parentPack) {
file = m_parentPack->getFile(type, path);
}
}
return file;
}
unsigned int DLCPack::getDLCItemsCount(DLCManager::EDLCType type /*= DLCManager::e_DLCType_All*/)
{
unsigned int count = 0;
unsigned int DLCPack::getDLCItemsCount(
DLCManager::EDLCType type /*= DLCManager::e_DLCType_All*/) {
unsigned int count = 0;
switch(type)
{
case DLCManager::e_DLCType_All:
for(int i = 0; i < DLCManager::e_DLCType_Max; ++i)
{
count += getDLCItemsCount((DLCManager::EDLCType)i);
}
break;
default:
count = static_cast<unsigned int>(m_files[(int)type].size());
break;
};
return count;
switch (type) {
case DLCManager::e_DLCType_All:
for (int i = 0; i < DLCManager::e_DLCType_Max; ++i) {
count += getDLCItemsCount((DLCManager::EDLCType)i);
}
break;
default:
count = static_cast<unsigned int>(m_files[(int)type].size());
break;
};
return count;
};
unsigned int DLCPack::getFileIndexAt(DLCManager::EDLCType type, const std::wstring &path, bool &found)
{
if(type == DLCManager::e_DLCType_All)
{
app.DebugPrintf("Unimplemented\n");
unsigned int DLCPack::getFileIndexAt(DLCManager::EDLCType type,
const std::wstring& path, bool& found) {
if (type == DLCManager::e_DLCType_All) {
app.DebugPrintf("Unimplemented\n");
#ifndef __CONTENT_PACKAGE
__debugbreak();
__debugbreak();
#endif
return 0;
}
return 0;
}
unsigned int foundIndex = 0;
found = false;
unsigned int index = 0;
for(AUTO_VAR(it, m_files[type].begin()); it != m_files[type].end(); ++it)
{
if(path.compare((*it)->getPath()) == 0)
{
foundIndex = index;
found = true;
break;
}
++index;
}
unsigned int foundIndex = 0;
found = false;
unsigned int index = 0;
for (AUTO_VAR(it, m_files[type].begin()); it != m_files[type].end(); ++it) {
if (path.compare((*it)->getPath()) == 0) {
foundIndex = index;
found = true;
break;
}
++index;
}
return foundIndex;
return foundIndex;
}
bool DLCPack::hasPurchasedFile(DLCManager::EDLCType type, const std::wstring &path)
{
if(type == DLCManager::e_DLCType_All)
{
app.DebugPrintf("Unimplemented\n");
bool DLCPack::hasPurchasedFile(DLCManager::EDLCType type,
const std::wstring& path) {
if (type == DLCManager::e_DLCType_All) {
app.DebugPrintf("Unimplemented\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
__debugbreak();
#endif
return false;
}
return false;
}
#ifndef _CONTENT_PACKAGE
if( app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_UnlockAllDLC) )
{
return true;
}
else
if (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) &
(1L << eDebugSetting_UnlockAllDLC)) {
return true;
} else
#endif
if ( m_dwLicenseMask == 0 )
{
//not purchased.
return false;
}
else
{
//purchased
return true;
}
if (m_dwLicenseMask == 0) {
// not purchased.
return false;
} else {
// purchased
return true;
}
}

View file

@ -1,94 +1,112 @@
#pragma once
//using namespace std;
// using namespace std;
#include <cstdint>
#include "DLCManager.h"
class DLCFile;
class DLCSkinFile;
class DLCPack
{
class DLCPack {
private:
std::vector<DLCFile *> m_files[DLCManager::e_DLCType_Max];
std::vector<DLCPack *> m_childPacks;
DLCPack *m_parentPack;
std::vector<DLCFile*> m_files[DLCManager::e_DLCType_Max];
std::vector<DLCPack*> m_childPacks;
DLCPack* m_parentPack;
std::unordered_map<int, std::wstring> m_parameters;
std::unordered_map<int, std::wstring> m_parameters;
std::wstring m_packName;
std::wstring m_dataPath;
std::uint32_t m_dwLicenseMask;
int m_dlcMountIndex;
XCONTENTDEVICEID m_dlcDeviceID;
std::wstring m_packName;
std::wstring m_dataPath;
std::uint32_t m_dwLicenseMask;
int m_dlcMountIndex;
XCONTENTDEVICEID m_dlcDeviceID;
#ifdef _XBOX_ONE
std::wstring m_wsProductId;
std::wstring m_wsProductId;
#else
ULONGLONG m_ullFullOfferId;
ULONGLONG m_ullFullOfferId;
#endif
bool m_isCorrupt;
std::uint32_t m_packId;
std::uint32_t m_packVersion;
bool m_isCorrupt;
std::uint32_t m_packId;
std::uint32_t m_packVersion;
std::uint8_t *m_data; // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
std::uint8_t*
m_data; // This pointer is for all the data used for this pack, so
// deleting it invalidates ALL of it's children.
public:
DLCPack(const std::wstring &name,std::uint32_t dwLicenseMask);
DLCPack(const std::wstring& name, std::uint32_t dwLicenseMask);
#ifdef _XBOX_ONE
DLCPack(const std::wstring &name,const std::wstring &productID,std::uint32_t dwLicenseMask);
DLCPack(const std::wstring& name, const std::wstring& productID,
std::uint32_t dwLicenseMask);
#endif
~DLCPack();
~DLCPack();
std::wstring getFullDataPath() { return m_dataPath; }
std::wstring getFullDataPath() { return m_dataPath; }
void SetDataPointer(std::uint8_t *pbData) { m_data = pbData; }
void SetDataPointer(std::uint8_t* pbData) { m_data = pbData; }
bool IsCorrupt() { return m_isCorrupt; }
void SetIsCorrupt(bool val) { m_isCorrupt = val; }
bool IsCorrupt() { return m_isCorrupt; }
void SetIsCorrupt(bool val) { m_isCorrupt = val; }
void SetPackId(std::uint32_t id) { m_packId = id; }
std::uint32_t GetPackId() { return m_packId; }
void SetPackId(std::uint32_t id) { m_packId = id; }
std::uint32_t GetPackId() { return m_packId; }
void SetPackVersion(std::uint32_t version) { m_packVersion = version; }
std::uint32_t GetPackVersion() { return m_packVersion; }
void SetPackVersion(std::uint32_t version) { m_packVersion = version; }
std::uint32_t GetPackVersion() { return m_packVersion; }
DLCPack * GetParentPack() { return m_parentPack; }
std::uint32_t GetParentPackId() { return m_parentPack->m_packId; }
DLCPack* GetParentPack() { return m_parentPack; }
std::uint32_t GetParentPackId() { return m_parentPack->m_packId; }
void SetDLCMountIndex(int id) { m_dlcMountIndex = id; }
int GetDLCMountIndex();
void SetDLCDeviceID(XCONTENTDEVICEID deviceId) { m_dlcDeviceID = deviceId; }
XCONTENTDEVICEID GetDLCDeviceID();
void SetDLCMountIndex(int id) { m_dlcMountIndex = id; }
int GetDLCMountIndex();
void SetDLCDeviceID(XCONTENTDEVICEID deviceId) { m_dlcDeviceID = deviceId; }
XCONTENTDEVICEID GetDLCDeviceID();
void addChildPack(DLCPack *childPack);
void setParentPack(DLCPack *parentPack);
void addChildPack(DLCPack* childPack);
void setParentPack(DLCPack* parentPack);
void addParameter(DLCManager::EDLCParameterType type, const std::wstring &value);
bool getParameterAsUInt(DLCManager::EDLCParameterType type, unsigned int &param);
void addParameter(DLCManager::EDLCParameterType type,
const std::wstring& value);
bool getParameterAsUInt(DLCManager::EDLCParameterType type,
unsigned int& param);
void updateLicenseMask(std::uint32_t dwLicenseMask) { m_dwLicenseMask = dwLicenseMask; }
std::uint32_t getLicenseMask() { return m_dwLicenseMask; }
std::wstring getName() { return m_packName; }
void updateLicenseMask(std::uint32_t dwLicenseMask) {
m_dwLicenseMask = dwLicenseMask;
}
std::uint32_t getLicenseMask() { return m_dwLicenseMask; }
std::wstring getName() { return m_packName; }
#ifdef _XBOX_ONE
std::wstring getPurchaseOfferId() { return m_wsProductId; }
std::wstring getPurchaseOfferId() { return m_wsProductId; }
#else
ULONGLONG getPurchaseOfferId() { return m_ullFullOfferId; }
ULONGLONG getPurchaseOfferId() { return m_ullFullOfferId; }
#endif
DLCFile *addFile(DLCManager::EDLCType type, const std::wstring &path);
DLCFile *getFile(DLCManager::EDLCType type, unsigned int index);
DLCFile *getFile(DLCManager::EDLCType type, const std::wstring &path);
DLCFile* addFile(DLCManager::EDLCType type, const std::wstring& path);
DLCFile* getFile(DLCManager::EDLCType type, unsigned int index);
DLCFile* getFile(DLCManager::EDLCType type, const std::wstring& path);
unsigned int getDLCItemsCount(DLCManager::EDLCType type = DLCManager::e_DLCType_All);
unsigned int getFileIndexAt(DLCManager::EDLCType type, const std::wstring &path, bool &found);
bool doesPackContainFile(DLCManager::EDLCType type, const std::wstring &path);
std::uint32_t GetPackID() {return m_packId;}
unsigned int getSkinCount() { return getDLCItemsCount(DLCManager::e_DLCType_Skin); }
unsigned int getSkinIndexAt(const std::wstring &path, bool &found) { return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found); }
DLCSkinFile *getSkinFile(const std::wstring &path) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, path); }
DLCSkinFile *getSkinFile(unsigned int index) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, index); }
bool doesPackContainSkin(const std::wstring &path) { return doesPackContainFile(DLCManager::e_DLCType_Skin, path); }
unsigned int getDLCItemsCount(
DLCManager::EDLCType type = DLCManager::e_DLCType_All);
unsigned int getFileIndexAt(DLCManager::EDLCType type,
const std::wstring& path, bool& found);
bool doesPackContainFile(DLCManager::EDLCType type,
const std::wstring& path);
std::uint32_t GetPackID() { return m_packId; }
bool hasPurchasedFile(DLCManager::EDLCType type, const std::wstring &path);
unsigned int getSkinCount() {
return getDLCItemsCount(DLCManager::e_DLCType_Skin);
}
unsigned int getSkinIndexAt(const std::wstring& path, bool& found) {
return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found);
}
DLCSkinFile* getSkinFile(const std::wstring& path) {
return (DLCSkinFile*)getFile(DLCManager::e_DLCType_Skin, path);
}
DLCSkinFile* getSkinFile(unsigned int index) {
return (DLCSkinFile*)getFile(DLCManager::e_DLCType_Skin, index);
}
bool doesPackContainSkin(const std::wstring& path) {
return doesPackContainFile(DLCManager::e_DLCType_Skin, path);
}
bool hasPurchasedFile(DLCManager::EDLCType type, const std::wstring& path);
};

View file

@ -7,166 +7,139 @@
#include "../../Minecraft.World/Player/Player.h"
#include "../../Minecraft.World/Util/StringHelpers.h"
DLCSkinFile::DLCSkinFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_Skin,path)
{
m_displayName = L"";
m_themeName = L"";
m_cape = L"";
m_bIsFree = false;
m_uiAnimOverrideBitmask=0L;
DLCSkinFile::DLCSkinFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Skin, path) {
m_displayName = L"";
m_themeName = L"";
m_cape = L"";
m_bIsFree = false;
m_uiAnimOverrideBitmask = 0L;
}
void DLCSkinFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
{
app.AddMemoryTextureFile(m_path,pbData,dataBytes);
void DLCSkinFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
app.AddMemoryTextureFile(m_path, pbData, dataBytes);
}
void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const std::wstring &value)
{
switch(type)
{
case DLCManager::e_DLCParamType_DisplayName:
{
// 4J Stu - In skin pack 2, the name for Zap is mis-spelt with two p's as Zapp
// dlcskin00000109.png
if( m_path.compare(L"dlcskin00000109.png") == 0)
{
m_displayName = L"Zap";
}
else
{
m_displayName = value;
}
}
break;
case DLCManager::e_DLCParamType_ThemeName:
m_themeName = value;
break;
case DLCManager::e_DLCParamType_Free: // If this parameter exists, then mark this as free
m_bIsFree = true;
break;
case DLCManager::e_DLCParamType_Credit: // If this parameter exists, then mark this as free
//add it to the DLC credits list
void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
const std::wstring& value) {
switch (type) {
case DLCManager::e_DLCParamType_DisplayName: {
// 4J Stu - In skin pack 2, the name for Zap is mis-spelt with two
// p's as Zapp dlcskin00000109.png
if (m_path.compare(L"dlcskin00000109.png") == 0) {
m_displayName = L"Zap";
} else {
m_displayName = value;
}
} break;
case DLCManager::e_DLCParamType_ThemeName:
m_themeName = value;
break;
case DLCManager::e_DLCParamType_Free: // If this parameter exists, then
// mark this as free
m_bIsFree = true;
break;
case DLCManager::e_DLCParamType_Credit: // If this parameter exists,
// then mark this as free
// add it to the DLC credits
// list
// we'll need to justify this text since we don't have a lot of room for lines of credits
{
if(app.AlreadySeenCreditText(value)) break;
// first add a blank string for spacing
app.AddCreditText(L"");
// we'll need to justify this text since we don't have a lot of room
// for lines of credits
{
if (app.AlreadySeenCreditText(value)) break;
// first add a blank string for spacing
app.AddCreditText(L"");
int maximumChars = 55;
int maximumChars = 55;
bool bIsSDMode=!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
bool bIsSDMode =
!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
if(bIsSDMode)
{
maximumChars = 45;
}
if (bIsSDMode) {
maximumChars = 45;
}
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
maximumChars = 35;
break;
default:
break;
}
std::wstring creditValue = value;
while (creditValue.length() > maximumChars)
{
unsigned int i = 1;
while (i < creditValue.length() && (i + 1) <= maximumChars)
{
i++;
}
int iLast=(int)creditValue.find_last_of(L" ",i);
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
iLast = maximumChars;
break;
default:
iLast=(int)creditValue.find_last_of(L" ",i);
break;
}
switch (XGetLanguage()) {
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
maximumChars = 35;
break;
default:
break;
}
std::wstring creditValue = value;
while (creditValue.length() > maximumChars) {
unsigned int i = 1;
while (i < creditValue.length() &&
(i + 1) <= maximumChars) {
i++;
}
int iLast = (int)creditValue.find_last_of(L" ", i);
switch (XGetLanguage()) {
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
iLast = maximumChars;
break;
default:
iLast = (int)creditValue.find_last_of(L" ", i);
break;
}
// if a space was found, include the space on this line
if(iLast!=i)
{
iLast++;
}
app.AddCreditText((creditValue.substr(0, iLast)).c_str());
creditValue = creditValue.substr(iLast);
}
app.AddCreditText(creditValue.c_str());
// if a space was found, include the space on this line
if (iLast != i) {
iLast++;
}
}
break;
case DLCManager::e_DLCParamType_Cape:
m_cape = value;
break;
case DLCManager::e_DLCParamType_Box:
{
WCHAR wchBodyPart[10];
SKIN_BOX *pSkinBox = new SKIN_BOX;
ZeroMemory(pSkinBox,sizeof(SKIN_BOX));
app.AddCreditText((creditValue.substr(0, iLast)).c_str());
creditValue = creditValue.substr(iLast);
}
app.AddCreditText(creditValue.c_str());
}
break;
case DLCManager::e_DLCParamType_Cape:
m_cape = value;
break;
case DLCManager::e_DLCParamType_Box: {
WCHAR wchBodyPart[10];
SKIN_BOX* pSkinBox = new SKIN_BOX;
ZeroMemory(pSkinBox, sizeof(SKIN_BOX));
// 4J Stu - The Xbox version used swscanf_s which isn't available in GCC.
swscanf(value.c_str(), L"%10ls%f%f%f%f%f%f%f%f", wchBodyPart,
&pSkinBox->fX,
&pSkinBox->fY,
&pSkinBox->fZ,
&pSkinBox->fW,
&pSkinBox->fH,
&pSkinBox->fD,
&pSkinBox->fU,
&pSkinBox->fV);
if(wcscmp(wchBodyPart,L"HEAD")==0)
{
pSkinBox->ePart=eBodyPart_Head;
}
else if(wcscmp(wchBodyPart,L"BODY")==0)
{
pSkinBox->ePart=eBodyPart_Body;
}
else if(wcscmp(wchBodyPart,L"ARM0")==0)
{
pSkinBox->ePart=eBodyPart_Arm0;
}
else if(wcscmp(wchBodyPart,L"ARM1")==0)
{
pSkinBox->ePart=eBodyPart_Arm1;
}
else if(wcscmp(wchBodyPart,L"LEG0")==0)
{
pSkinBox->ePart=eBodyPart_Leg0;
}
else if(wcscmp(wchBodyPart,L"LEG1")==0)
{
pSkinBox->ePart=eBodyPart_Leg1;
}
// 4J Stu - The Xbox version used swscanf_s which isn't available in
// GCC.
swscanf(value.c_str(), L"%10ls%f%f%f%f%f%f%f%f", wchBodyPart,
&pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW,
&pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV);
// add this to the skin's vector of parts
m_AdditionalBoxes.push_back(pSkinBox);
}
break;
case DLCManager::e_DLCParamType_Anim:
{
// 4J Stu - The Xbox version used swscanf_s which isn't available in GCC.
swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask);
std::uint32_t skinId = app.getSkinIdFromPath(m_path);
app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask);
}
break;
default:
break;
}
if (wcscmp(wchBodyPart, L"HEAD") == 0) {
pSkinBox->ePart = eBodyPart_Head;
} else if (wcscmp(wchBodyPart, L"BODY") == 0) {
pSkinBox->ePart = eBodyPart_Body;
} else if (wcscmp(wchBodyPart, L"ARM0") == 0) {
pSkinBox->ePart = eBodyPart_Arm0;
} else if (wcscmp(wchBodyPart, L"ARM1") == 0) {
pSkinBox->ePart = eBodyPart_Arm1;
} else if (wcscmp(wchBodyPart, L"LEG0") == 0) {
pSkinBox->ePart = eBodyPart_Leg0;
} else if (wcscmp(wchBodyPart, L"LEG1") == 0) {
pSkinBox->ePart = eBodyPart_Leg1;
}
// add this to the skin's vector of parts
m_AdditionalBoxes.push_back(pSkinBox);
} break;
case DLCManager::e_DLCParamType_Anim: {
// 4J Stu - The Xbox version used swscanf_s which isn't available in
// GCC.
swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask);
std::uint32_t skinId = app.getSkinIdFromPath(m_path);
app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask);
} break;
default:
break;
}
}
// std::vector<ModelPart *> *DLCSkinFile::getAdditionalModelParts()
@ -174,37 +147,32 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const std::ws
// return &m_AdditionalModelParts;
// }
int DLCSkinFile::getAdditionalBoxesCount()
{
return (int)m_AdditionalBoxes.size();
int DLCSkinFile::getAdditionalBoxesCount() {
return (int)m_AdditionalBoxes.size();
}
std::vector<SKIN_BOX *> *DLCSkinFile::getAdditionalBoxes()
{
return &m_AdditionalBoxes;
std::vector<SKIN_BOX*>* DLCSkinFile::getAdditionalBoxes() {
return &m_AdditionalBoxes;
}
std::wstring DLCSkinFile::getParameterAsString(DLCManager::EDLCParameterType type)
{
switch(type)
{
case DLCManager::e_DLCParamType_DisplayName:
return m_displayName;
case DLCManager::e_DLCParamType_ThemeName:
return m_themeName;
case DLCManager::e_DLCParamType_Cape:
return m_cape;
default:
return L"";
}
std::wstring DLCSkinFile::getParameterAsString(
DLCManager::EDLCParameterType type) {
switch (type) {
case DLCManager::e_DLCParamType_DisplayName:
return m_displayName;
case DLCManager::e_DLCParamType_ThemeName:
return m_themeName;
case DLCManager::e_DLCParamType_Cape:
return m_cape;
default:
return L"";
}
}
bool DLCSkinFile::getParameterAsBool(DLCManager::EDLCParameterType type)
{
switch(type)
{
case DLCManager::e_DLCParamType_Free:
return m_bIsFree;
default:
return false;
}
bool DLCSkinFile::getParameterAsBool(DLCManager::EDLCParameterType type) {
switch (type) {
case DLCManager::e_DLCParamType_Free:
return m_bIsFree;
default:
return false;
}
}

View file

@ -2,28 +2,27 @@
#include "DLCFile.h"
#include "../../Minecraft.Client/Rendering/Models/HumanoidModel.h"
class DLCSkinFile : public DLCFile
{
class DLCSkinFile : public DLCFile {
private:
std::wstring m_displayName;
std::wstring m_themeName;
std::wstring m_cape;
unsigned int m_uiAnimOverrideBitmask;
bool m_bIsFree;
std::vector<SKIN_BOX *> m_AdditionalBoxes;
std::wstring m_displayName;
std::wstring m_themeName;
std::wstring m_cape;
unsigned int m_uiAnimOverrideBitmask;
bool m_bIsFree;
std::vector<SKIN_BOX*> m_AdditionalBoxes;
public:
DLCSkinFile(const std::wstring& path);
DLCSkinFile(const std::wstring &path);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual void addParameter(DLCManager::EDLCParameterType type,
const std::wstring& value);
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes);
virtual void addParameter(DLCManager::EDLCParameterType type, const std::wstring &value);
virtual std::wstring getParameterAsString(DLCManager::EDLCParameterType type);
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
std::vector<SKIN_BOX *> *getAdditionalBoxes();
int getAdditionalBoxesCount();
unsigned int getAnimOverrideBitmask() { return m_uiAnimOverrideBitmask;}
bool isFree() {return m_bIsFree;}
virtual std::wstring getParameterAsString(
DLCManager::EDLCParameterType type);
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
std::vector<SKIN_BOX*>* getAdditionalBoxes();
int getAdditionalBoxesCount();
unsigned int getAnimOverrideBitmask() { return m_uiAnimOverrideBitmask; }
bool isFree() { return m_bIsFree; }
};

View file

@ -2,60 +2,54 @@
#include "DLCManager.h"
#include "DLCTextureFile.h"
DLCTextureFile::DLCTextureFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_Texture,path)
{
m_bIsAnim = false;
m_animString = L"";
m_pbData = NULL;
m_dataBytes = 0;
DLCTextureFile::DLCTextureFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Texture, path) {
m_bIsAnim = false;
m_animString = L"";
m_pbData = NULL;
m_dataBytes = 0;
}
void DLCTextureFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes)
{
//app.AddMemoryTextureFile(m_path,pbData,dwBytes);
m_pbData = pbData;
m_dataBytes = dataBytes;
void DLCTextureFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
// app.AddMemoryTextureFile(m_path,pbData,dwBytes);
m_pbData = pbData;
m_dataBytes = dataBytes;
}
std::uint8_t *DLCTextureFile::getData(std::uint32_t &dataBytes)
{
dataBytes = m_dataBytes;
return m_pbData;
std::uint8_t* DLCTextureFile::getData(std::uint32_t& dataBytes) {
dataBytes = m_dataBytes;
return m_pbData;
}
void DLCTextureFile::addParameter(DLCManager::EDLCParameterType type, const std::wstring &value)
{
switch(type)
{
case DLCManager::e_DLCParamType_Anim:
m_animString = value;
m_bIsAnim = true;
void DLCTextureFile::addParameter(DLCManager::EDLCParameterType type,
const std::wstring& value) {
switch (type) {
case DLCManager::e_DLCParamType_Anim:
m_animString = value;
m_bIsAnim = true;
break;
default:
break;
}
break;
default:
break;
}
}
std::wstring DLCTextureFile::getParameterAsString(DLCManager::EDLCParameterType type)
{
switch(type)
{
case DLCManager::e_DLCParamType_Anim:
return m_animString;
default:
return L"";
}
std::wstring DLCTextureFile::getParameterAsString(
DLCManager::EDLCParameterType type) {
switch (type) {
case DLCManager::e_DLCParamType_Anim:
return m_animString;
default:
return L"";
}
}
bool DLCTextureFile::getParameterAsBool(DLCManager::EDLCParameterType type)
{
switch(type)
{
case DLCManager::e_DLCParamType_Anim:
return m_bIsAnim;
default:
return false;
}
bool DLCTextureFile::getParameterAsBool(DLCManager::EDLCParameterType type) {
switch (type) {
case DLCManager::e_DLCParamType_Anim:
return m_bIsAnim;
default:
return false;
}
}

View file

@ -1,24 +1,24 @@
#pragma once
#include "DLCFile.h"
class DLCTextureFile : public DLCFile
{
class DLCTextureFile : public DLCFile {
private:
bool m_bIsAnim;
std::wstring m_animString;
bool m_bIsAnim;
std::wstring m_animString;
std::uint8_t *m_pbData;
std::uint32_t m_dataBytes;
std::uint8_t* m_pbData;
std::uint32_t m_dataBytes;
public:
DLCTextureFile(const std::wstring &path);
DLCTextureFile(const std::wstring& path);
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes);
virtual std::uint8_t *getData(std::uint32_t &dataBytes);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
virtual void addParameter(DLCManager::EDLCParameterType type, const std::wstring &value);
virtual void addParameter(DLCManager::EDLCParameterType type,
const std::wstring& value);
virtual std::wstring getParameterAsString(DLCManager::EDLCParameterType type);
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
virtual std::wstring getParameterAsString(
DLCManager::EDLCParameterType type);
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
};

View file

@ -2,31 +2,28 @@
#include "DLCManager.h"
#include "DLCUIDataFile.h"
DLCUIDataFile::DLCUIDataFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_UIData,path)
{
m_pbData = NULL;
m_dataBytes = 0;
m_canDeleteData = false;
DLCUIDataFile::DLCUIDataFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_UIData, path) {
m_pbData = NULL;
m_dataBytes = 0;
m_canDeleteData = false;
}
DLCUIDataFile::~DLCUIDataFile()
{
if(m_canDeleteData && m_pbData != NULL)
{
app.DebugPrintf("Deleting DLCUIDataFile data\n");
delete [] m_pbData;
}
DLCUIDataFile::~DLCUIDataFile() {
if (m_canDeleteData && m_pbData != NULL) {
app.DebugPrintf("Deleting DLCUIDataFile data\n");
delete[] m_pbData;
}
}
void DLCUIDataFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes,bool canDeleteData)
{
m_pbData = pbData;
m_dataBytes = dataBytes;
m_canDeleteData = canDeleteData;
void DLCUIDataFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes,
bool canDeleteData) {
m_pbData = pbData;
m_dataBytes = dataBytes;
m_canDeleteData = canDeleteData;
}
std::uint8_t *DLCUIDataFile::getData(std::uint32_t &dataBytes)
{
dataBytes = m_dataBytes;
return m_pbData;
std::uint8_t* DLCUIDataFile::getData(std::uint32_t& dataBytes) {
dataBytes = m_dataBytes;
return m_pbData;
}

View file

@ -1,20 +1,20 @@
#pragma once
#include "DLCFile.h"
class DLCUIDataFile : public DLCFile
{
class DLCUIDataFile : public DLCFile {
private:
std::uint8_t *m_pbData;
std::uint32_t m_dataBytes;
bool m_canDeleteData;
std::uint8_t* m_pbData;
std::uint32_t m_dataBytes;
bool m_canDeleteData;
public:
DLCUIDataFile(const std::wstring &path);
~DLCUIDataFile();
DLCUIDataFile(const std::wstring& path);
~DLCUIDataFile();
using DLCFile::addData;
using DLCFile::addParameter;
using DLCFile::addData;
using DLCFile::addParameter;
virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes,bool canDeleteData = false);
virtual std::uint8_t *getData(std::uint32_t &dataBytes);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes,
bool canDeleteData = false);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
};

View file

@ -6,6 +6,7 @@
#include "../../Minecraft.World/Util/ThreadName.h"
#include "../../Minecraft.World/Entities/Entity.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
#include "../../Minecraft.World/Recipes/FireworksRecipe.h"
#include "../../Minecraft.Client/Network/ClientConnection.h"
#include "../../Minecraft.Client/Minecraft.h"
#include "../../Minecraft.Client/Player/User.h"

View file

@ -8,6 +8,9 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.item.enchantment.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
#include "../../Minecraft.World/Util/JavaMath.h"
// 4J JEV - Images for each tab.
IUIScene_CreativeMenu::TabSpec** IUIScene_CreativeMenu::specs = NULL;

View file

@ -63,6 +63,7 @@ public:
unsigned int m_pages;
unsigned int m_staticPerPage;
unsigned int m_staticItems;
unsigned int m_debugItems;
public:
TabSpec(const wchar_t* icon, int descriptionId, int staticGroupsCount,
@ -96,13 +97,14 @@ public:
virtual void loopClick(int slotIndex, int buttonNum, bool quickKeyHeld,
std::shared_ptr<Player> player) {} // do nothing
}* itemPickerMenu;
protected:
// 4jcraft: changed these two from public to protected for the java UI
static std::vector<std::shared_ptr<ItemInstance> >
categoryGroups[eCreativeInventoryGroupsCount];
// 4J JEV - Tabs
static TabSpec** specs;
public:
bool m_bCarryingCreativeItem;
int m_creativeSlotX, m_creativeSlotY, m_inventorySlotX, m_inventorySlotY;

View file

@ -307,7 +307,7 @@ void UIComponent_Tooltips::_SetTooltip(unsigned int iToolTipId, UIString label,
value[0].type = IGGY_DATATYPE_number;
value[0].number = iToolTipId;
const std::u16string convLabel = convWstringToU16string(label);
const std::u16string convLabel = convWstringToU16string(label.getString());
value[1].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;

View file

@ -29,7 +29,7 @@ void UIControl_Base::tick() {
// app.DebugPrintf("Calling SetLabel - '%ls'\n", m_label.c_str());
m_bLabelChanged = false;
const std::u16string convLabel = convWstringToU16string(m_label);
const std::u16string convLabel = convWstringToU16string(m_label.getString());
IggyDataValue result;
IggyDataValue value[1];

View file

@ -19,7 +19,7 @@ void UIControl_Button::init(UIString label, int id) {
m_label = label;
m_id = id;
const std::u16string convLabel = convWstringToU16string(label);
const std::u16string convLabel = convWstringToU16string(label.getString());
IggyDataValue result;
IggyDataValue value[2];

View file

@ -19,12 +19,12 @@ bool UIControl_CheckBox::setupControl(UIScene* scene, IggyValuePath* parent,
return success;
}
void UIControl_CheckBox::init(const std::wstring& label, int id, bool checked) {
void UIControl_CheckBox::init(UIString label, int id, bool checked) {
m_label = label;
m_id = id;
m_bChecked = checked;
const std::u16string convLabel = convWstringToU16string(label);
const std::u16string convLabel = convWstringToU16string(label.getString());
IggyDataValue result;
IggyDataValue value[3];

View file

@ -30,7 +30,7 @@ void UIControl_Progress::init(UIString label, int id, int min, int max,
m_max = max;
m_current = current;
const std::u16string convLabel = convWstringToU16string(label);
const std::u16string convLabel = convWstringToU16string(label.getString());
IggyDataValue result;
IggyDataValue value[1];

View file

@ -29,7 +29,7 @@ void UIControl_Slider::init(UIString label, int id, int min, int max,
m_max = max;
m_current = current;
const std::u16string convLabel = convWstringToU16string(label);
const std::u16string convLabel = convWstringToU16string(label.getString());
IggyDataValue result;
IggyDataValue value[5];

View file

@ -1,6 +1,7 @@
#include "../../stdafx.h"
#include "UI.h"
#include "UIControl_TextInput.h"
#include "../../../Minecraft.World/Util/StringHelpers.h"
UIControl_TextInput::UIControl_TextInput() { m_bHasFocus = false; }
@ -21,7 +22,7 @@ void UIControl_TextInput::init(UIString label, int id) {
m_label = label;
m_id = id;
const std::u16string convLabel = convWstringToU16string(label);
const std::u16string convLabel = convWstringToU16string(label.getString());
IggyDataValue result;
IggyDataValue value[2];

View file

@ -230,13 +230,13 @@ void UIScene_AbstractContainerMenu::customDraw(
pMinecraft->localgameModes[m_iPad] == NULL)
return;
int slotId = parseSlotId(region->name);
std::shared_ptr<ItemInstance> item = nullptr;
if (std::char_traits<char16_t>::compare(region->name, u"pointerIcon", 11) ==
0) {
m_cacheSlotRenders = false;
item = pMinecraft->localplayers[m_iPad]->inventory->getCarried();
} else {
int slotId = parseSlotId(region->name);
if (slotId == -1) {
app.DebugPrintf("This is not the control we are looking for\n");
} else {

View file

@ -315,8 +315,7 @@ void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion* region) {
return;
std::shared_ptr<ItemInstance> item = nullptr;
int slotId = -1;
swscanf((wchar_t*)region->name, L"slot_%d", &slotId);
int slotId = parseSlotId(region->name);
if (slotId >= 0 && slotId >= m_menu->getSize()) {
int icon = slotId - m_menu->getSize();

View file

@ -429,7 +429,8 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion* region) {
float alpha = 1.0f;
bool decorations = true;
bool inventoryItem = false;
swscanf((wchar_t*)region->name, L"slot_%d", &slotId);
int slotId = parseSlotId(region->name);
if (slotId == -1) {
app.DebugPrintf("This is not the control we are looking for\n");
} else if (slotId >= CRAFTING_INVENTORY_SLOT_START &&