Merge remote-tracking branch 'upstream/dev' into issue/51-phase-1-portable-win32-cleanup

# Conflicts:
#	Minecraft.Client/Platform/Common/DLC/DLCManager.cpp
#	Minecraft.Client/Rendering/Tesselator.cpp
This commit is contained in:
notmatthewbeshay 2026-03-13 15:16:43 +11:00
commit bcc765f3e7
117 changed files with 588 additions and 377 deletions

View file

@ -702,12 +702,12 @@ void MultiPlayerLevel::animateTickDoWork()
for( AUTO_VAR(it, chunksToAnimate.begin()); it != chunksToAnimate.end(); it++ ) for( AUTO_VAR(it, chunksToAnimate.begin()); it != chunksToAnimate.end(); it++ )
{ {
int packed = *it; int packed = *it;
int cx = ( packed << 8 ) >> 24; // 4jcraft changed the extraction logic to be safe
int cy = ( packed << 16 ) >> 24; // constantly shifting a signed integer
int cz = ( packed << 24 ) >> 24; int cx = (int8_t)(packed >> 16) * 8;
cx <<= 3; int cy = (int8_t)(packed >> 8) * 8;
cy <<= 3; int cz = (int8_t)packed * 8;
cz <<= 3;
int x = cx + random->nextInt(8); int x = cx + random->nextInt(8);
int y = cy + random->nextInt(8); int y = cy + random->nextInt(8);
int z = cz + random->nextInt(8); int z = cz + random->nextInt(8);

View file

@ -475,7 +475,8 @@ void ServerLevel::tickTiles()
// 4J - changes here brought forrward from 1.2.3 // 4J - changes here brought forrward from 1.2.3
if (random->nextInt(16) == 0) if (random->nextInt(16) == 0)
{ {
randValue = randValue * 3 + addend; //4jcraft added cast to unsigned
randValue = (unsigned)randValue * 3 + (unsigned)addend;
int val = (randValue >> 2); int val = (randValue >> 2);
int x = (val & 15); int x = (val & 15);
int z = ((val >> 8) & 15); int z = ((val >> 8) & 15);
@ -631,9 +632,10 @@ std::vector<TickNextTickData> *ServerLevel::fetchTicksInChunk(LevelChunk *chunk,
std::vector<TickNextTickData> *results = new std::vector<TickNextTickData>; std::vector<TickNextTickData> *results = new std::vector<TickNextTickData>;
ChunkPos *pos = chunk->getPos(); ChunkPos *pos = chunk->getPos();
int west = pos->x << 4; // 4jcraft added cast to unsigned
int west = (unsigned) pos->x << 4;
int east = west + 16; int east = west + 16;
int north = pos->z << 4; int north =(unsigned) pos->z << 4;
int south = north + 16; int south = north + 16;
delete pos; delete pos;
@ -1414,7 +1416,8 @@ int ServerLevel::runUpdate(void* lpParam)
for (int j = 0; j < 80; j++) for (int j = 0; j < 80; j++)
{ {
m_randValue[iLev] = m_randValue[iLev] * 3 + m_level[iLev]->addend; // 4jcraft added cast to unsigned
m_randValue[iLev] = (unsigned) m_randValue[iLev] * 3 + (unsigned) m_level[iLev]->addend;
int val = (m_randValue[iLev] >> 2); int val = (m_randValue[iLev] >> 2);
int x = (val & 15); int x = (val & 15);
if( ( x < minx ) || ( x > maxx ) ) continue; if( ( x < minx ) || ( x > maxx ) ) continue;
@ -1461,4 +1464,4 @@ void ServerLevel::flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFoun
{ {
chunkMap->flagEntitiesToBeRemoved(flags, removedFound); chunkMap->flagEntitiesToBeRemoved(flags, removedFound);
} }
} }

View file

@ -809,7 +809,8 @@ enum EControllerActions
ACTION_MENU_OK, ACTION_MENU_OK,
ACTION_MENU_CANCEL, ACTION_MENU_CANCEL,
ACTION_MAX_MENU = ACTION_MENU_CANCEL, // 4jcraft added, off by one
ACTION_MAX_MENU = ACTION_MENU_CANCEL + 1,
MINECRAFT_ACTION_JUMP, MINECRAFT_ACTION_JUMP,
MINECRAFT_ACTION_FORWARD, MINECRAFT_ACTION_FORWARD,
@ -911,4 +912,4 @@ enum eMCLang
eMCLang_elGR, eMCLang_elGR,
eMCLang_nnNO, eMCLang_nnNO,
eMCLang_skSK, eMCLang_skSK,
}; };

View file

@ -5861,7 +5861,21 @@ Random *CMinecraftApp::TipRandom = new Random();
int CMinecraftApp::TipsSortFunction(const void* a, const void* b) int CMinecraftApp::TipsSortFunction(const void* a, const void* b)
{ {
return ((TIPSTRUCT*)a)->iSortValue - ((TIPSTRUCT*)b)->iSortValue; // 4jcraft, scince the sortvalues can be negative, i changed it
// to a three way comparison,
// scince subtracting of signed integers can cause overflow.
int s1 = ((TIPSTRUCT*)a)->iSortValue;
int s2 = ((TIPSTRUCT*)b)->iSortValue;
if(s1 > s2) {
return 1;
} else if (s1 == s2) {
return 0;
}
return -1;
} }
void CMinecraftApp::InitialiseTips() void CMinecraftApp::InitialiseTips()

View file

@ -7,28 +7,54 @@
#include "../../Minecraft.World/Util/PortableFileIO.h" #include "../../Minecraft.World/Util/PortableFileIO.h"
#include "../../Minecraft.Client/Minecraft.h" #include "../../Minecraft.Client/Minecraft.h"
#include "../../Minecraft.Client/Textures/Packs/TexturePackRepository.h" #include "../../Minecraft.Client/Textures/Packs/TexturePackRepository.h"
#include <limits> #include <limits>
#include <cstddef>
#include <cstdint>
#ifdef __linux__ // 4jcraft, this is the size of wchar_t on disk
#include <stdint.h> // the DLC was created on windows, with wchar_t beeing 2 bytes and UTF-16
static const size_t DLC_WCHAR_BINARY = 2; static const std::size_t DLC_WCHAR_BIN_SIZE = 2;
static std::wstring dlc_read_wstring(const void *data)
#if WCHAR_MAX > 0xFFFF
// than sizeof(WCHAR) != DLC_WCHAR_BIN_SIZE
// e.g. Linux and all Posix/Unix systems with wchar_t beeing 4B/32bit
static_assert( sizeof(wchar_t) == 4, "wchar_t is not 4bytes but larger than 2bytes ???");
static inline std::wstring dlc_read_wstring(const void *data)
{ {
const std::uint16_t *p = (const std::uint16_t *)data; const std::uint16_t* p = static_cast<const std::uint16_t *>(data);
std::wstring s; // find the end (nullterminated)
while (*p) s += (wchar_t)*p++; const std::uint16_t* end = p;
return s; while(*end) {
++end;
}
std::size_t len = static_cast<std::size_t>(end - p);
// allocate wstring with length len
// it will be nullterminated internally, do not worry.
std::wstring out(len, 0);
// and copy them into thje string
for(std::size_t i = 0; i < len; ++i) {
out[i] = static_cast<wchar_t>(p[i]);
}
return out;
} }
#define DLC_WSTRING(ptr) dlc_read_wstring(ptr) #define DLC_WSTRING(ptr) dlc_read_wstring(ptr)
#define DLC_PARAM_ADV(n) (sizeof(C4JStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BINARY)
#define DLC_DETAIL_ADV(n) (sizeof(C4JStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BINARY)
#else #else
#define DLC_WSTRING(ptr) std::wstring((WCHAR *)(ptr)) // just in case.
#define DLC_PARAM_ADV(n) (sizeof(C4JStorage::DLC_FILE_PARAM) + sizeof(WCHAR) * (n)) static_assert( sizeof(wchar_t) == 2, "How did we get here? wide char smaller than 2 bytes");
#define DLC_DETAIL_ADV(n) (sizeof(C4JStorage::DLC_FILE_DETAILS) + sizeof(WCHAR) * (n)) // perfectly fine scince wchar_t will be 2 bytes (UCS-2/UTF-16)
#define DLC_WSTRING(ptr) std::wstring((wchar_t*)(ptr))
#endif #endif
#define DLC_PARAM_ADV(n) (sizeof(C4JStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BIN_SIZE)
#define DLC_DETAIL_ADV(n) (sizeof(C4JStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BIN_SIZE)
namespace namespace
{ {
std::wstring getMountedDlcReadPath(const std::string &path) std::wstring getMountedDlcReadPath(const std::string &path)
@ -421,14 +447,25 @@ bool DLCManager::readDLCDataFile(unsigned int &dwFilesProcessed, const std::stri
if(!readOwnedDlcFile(path, &pbData, &bytesRead)) if(!readOwnedDlcFile(path, &pbData, &bytesRead))
{ {
app.DebugPrintf("Failed to open DLC data file %s\n", path.c_str()); app.DebugPrintf("Failed to open DLC data file %s\n", path.c_str());
if( dwFilesProcessed == 0 ) removePack(pack); pack->SetIsCorrupt(true);
assert(false); SetNeedsCorruptCheck(true);
return false; return false;
} }
return processDLCDataFile(dwFilesProcessed, pbData, bytesRead, pack); return processDLCDataFile(dwFilesProcessed, pbData, bytesRead, pack);
} }
bool DLCManager::processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t *pbData, unsigned int dwLength, DLCPack *pack) bool DLCManager::processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t *pbData, unsigned int dwLength, DLCPack *pack)
// a bunch of makros to reduce memcpy and offset boilerplate
#define DLC_READ_UINT(out, buf, off) memcpy((out), (buf) + (off), sizeof(unsigned int))
#define DLC_READ_PARAM(out, buf, off) memcpy((out), (buf) + (off), sizeof(C4JStorage::DLC_FILE_PARAM))
#define DLC_READ_DETAIL(out, buf, off) memcpy((out), (buf) + (off), sizeof(C4JStorage::DLC_FILE_DETAILS))
// for details, read in the function below
#define DLC_PARAM_WSTR(buf, off) DLC_WSTRING((buf) + (off) + offsetof(C4JStorage::DLC_FILE_PARAM, wchData))
#define DLC_DETAIL_WSTR(buf, off) DLC_WSTRING((buf) + (off) + offsetof(C4JStorage::DLC_FILE_DETAILS, wchFile))
{ {
std::unordered_map<int, DLCManager::EDLCParameterType> parameterMapping; std::unordered_map<int, DLCManager::EDLCParameterType> parameterMapping;
unsigned int uiCurrentByte=0; unsigned int uiCurrentByte=0;
@ -444,7 +481,20 @@ bool DLCManager::processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t
// // unsigned long, p = number of parameters // // unsigned long, p = number of parameters
// // p * DLC_FILE_PARAM describing each parameter for this file // // p * DLC_FILE_PARAM describing each parameter for this file
// // ulFileSize bytes of data blob of the file added // // ulFileSize bytes of data blob of the file added
unsigned int uiVersion=*(unsigned int *)pbData;
// 4jcraft, some parts of this code changed, specifically:
// instead of casting a goddamn raw byte pointer and dereferencing it
// use memcpy, and access WSTRING with propper offset
// (scince bufferoffset after advancing by variable string length is not
// guaranteed to be properly aligned, so casting to a scalar/struct is UB)
// those casts coult be dangerous on e.g. ARM, because it doesnt handle
// missaligned loads, like x86/x64, so it would crash
// WHO TF USES HUNGARIAN NOTATION
unsigned int uiVersion;
DLC_READ_UINT(&uiVersion, pbData, uiCurrentByte);
uiCurrentByte+=sizeof(int); uiCurrentByte+=sizeof(int);
if(uiVersion < CURRENT_DLC_VERSION_NUM) if(uiVersion < CURRENT_DLC_VERSION_NUM)
@ -454,40 +504,47 @@ bool DLCManager::processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t
return false; return false;
} }
pack->SetDataPointer(pbData); pack->SetDataPointer(pbData);
unsigned int uiParameterCount=*(unsigned int *)&pbData[uiCurrentByte]; // safe, offset 4, aligned
unsigned int uiParameterCount;
DLC_READ_UINT(&uiParameterCount, pbData, uiCurrentByte);
uiCurrentByte+=sizeof(int); uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_PARAM *pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
C4JStorage::DLC_FILE_PARAM parBuf;
DLC_READ_PARAM(&parBuf, pbData, uiCurrentByte);
//DWORD dwwchCount=0; //DWORD dwwchCount=0;
for(unsigned int i=0;i<uiParameterCount;i++) for(unsigned int i=0;i<uiParameterCount;i++)
{ {
// Map DLC strings to application strings, then store the DLC index mapping to application index // Map DLC strings to application strings, then store the DLC index mapping to application index
std::wstring parameterName = DLC_WSTRING(pParams->wchData); std::wstring parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName);
if( type != DLCManager::e_DLCParamType_Invalid ) if( type != DLCManager::e_DLCParamType_Invalid )
{ {
parameterMapping[pParams->dwType] = type; parameterMapping[parBuf.dwType] = type;
} }
uiCurrentByte+= DLC_PARAM_ADV(pParams->dwWchCount); uiCurrentByte+= DLC_PARAM_ADV(parBuf.dwWchCount);
pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte]; DLC_READ_PARAM(&parBuf, pbData, uiCurrentByte);
} }
//ulCurrentByte+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM); //ulCurrentByte+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
unsigned int uiFileCount=*(unsigned int *)&pbData[uiCurrentByte]; unsigned int uiFileCount;
DLC_READ_UINT(&uiFileCount, pbData, uiCurrentByte);
uiCurrentByte+=sizeof(int); uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_DETAILS *pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
C4JStorage::DLC_FILE_DETAILS fileBuf;
DLC_READ_DETAIL(&fileBuf, pbData, uiCurrentByte);
unsigned int dwTemp=uiCurrentByte; unsigned int dwTemp=uiCurrentByte;
for(unsigned int i=0;i<uiFileCount;i++) for(unsigned int i=0;i<uiFileCount;i++)
{ {
dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount); dwTemp+=DLC_DETAIL_ADV(fileBuf.dwWchCount);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp]; DLC_READ_DETAIL(&fileBuf, pbData, dwTemp);
} }
std::uint8_t *pbTemp = reinterpret_cast<std::uint8_t *>(pFile);//+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount; std::uint8_t *pbTemp = &pbData[dwTemp];//+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount;
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; DLC_READ_DETAIL(&fileBuf, pbData, uiCurrentByte);
for(unsigned int i=0;i<uiFileCount;i++) for(unsigned int i=0;i<uiFileCount;i++)
{ {
DLCManager::EDLCType type = (DLCManager::EDLCType)pFile->dwType; DLCManager::EDLCType type = (DLCManager::EDLCType)fileBuf.dwType;
DLCFile *dlcFile = NULL; DLCFile *dlcFile = NULL;
DLCPack *dlcTexturePack = NULL; DLCPack *dlcTexturePack = NULL;
@ -498,40 +555,42 @@ bool DLCManager::processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t
} }
else if(type != e_DLCType_PackConfig) else if(type != e_DLCType_PackConfig)
{ {
dlcFile = pack->addFile(type, DLC_WSTRING(pFile->wchFile)); dlcFile = pack->addFile(type, DLC_DETAIL_WSTR(pbData, uiCurrentByte));
} }
// Params // Params
uiParameterCount=*(unsigned int *)pbTemp; unsigned int uiParamCount;
DLC_READ_UINT(&uiParamCount, pbTemp, 0);
pbTemp+=sizeof(int); pbTemp+=sizeof(int);
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
for(unsigned int j=0;j<uiParameterCount;j++) DLC_READ_PARAM(&parBuf, pbTemp, 0);
for(unsigned int j=0;j<uiParamCount;j++)
{ {
//DLCManager::EDLCParameterType paramType = DLCManager::e_DLCParamType_Invalid; //DLCManager::EDLCParameterType paramType = DLCManager::e_DLCParamType_Invalid;
AUTO_VAR(it, parameterMapping.find( pParams->dwType )); AUTO_VAR(it, parameterMapping.find( parBuf.dwType ));
if(it != parameterMapping.end() ) if(it != parameterMapping.end() )
{ {
if(type == e_DLCType_PackConfig) if(type == e_DLCType_PackConfig)
{ {
pack->addParameter(it->second, DLC_WSTRING(pParams->wchData)); pack->addParameter(it->second, DLC_PARAM_WSTR(pbTemp, 0));
} }
else else
{ {
if(dlcFile != NULL) dlcFile->addParameter(it->second, DLC_WSTRING(pParams->wchData)); if(dlcFile != NULL) dlcFile->addParameter(it->second, DLC_PARAM_WSTR(pbTemp, 0));
else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, DLC_WSTRING(pParams->wchData)); else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, DLC_PARAM_WSTR(pbTemp, 0));
} }
} }
pbTemp+=DLC_PARAM_ADV(pParams->dwWchCount); pbTemp+=DLC_PARAM_ADV(parBuf.dwWchCount);
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; DLC_READ_PARAM(&parBuf, pbTemp, 0);
} }
//pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM); //pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
if(dlcTexturePack != NULL) if(dlcTexturePack != NULL)
{ {
unsigned int texturePackFilesProcessed = 0; unsigned int texturePackFilesProcessed = 0;
bool validPack = processDLCDataFile(texturePackFilesProcessed,pbTemp,pFile->uiFileSize,dlcTexturePack); bool validPack = processDLCDataFile(texturePackFilesProcessed, pbTemp, fileBuf.uiFileSize, dlcTexturePack);
pack->SetDataPointer(NULL); // If it's a child pack, it doesn't own the data pack->SetDataPointer(NULL); // If it's a child pack, it doesn't own the data
if(!validPack || texturePackFilesProcessed == 0) if(!validPack || texturePackFilesProcessed == 0)
{ {
@ -552,13 +611,13 @@ bool DLCManager::processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t
else if(dlcFile != NULL) else if(dlcFile != NULL)
{ {
// Data // Data
dlcFile->addData(pbTemp,pFile->uiFileSize); dlcFile->addData(pbTemp,fileBuf.uiFileSize);
// TODO - 4J Stu Remove the need for this vSkinNames vector, or manage it differently // TODO - 4J Stu Remove the need for this vSkinNames vector, or manage it differently
switch(pFile->dwType) switch(fileBuf.dwType)
{ {
case DLCManager::e_DLCType_Skin: case DLCManager::e_DLCType_Skin:
app.vSkinNames.push_back(DLC_WSTRING(pFile->wchFile)); app.vSkinNames.push_back(DLC_DETAIL_WSTR(pbData, uiCurrentByte));
break; break;
} }
@ -566,10 +625,10 @@ bool DLCManager::processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t
} }
// Move the pointer to the start of the next files data; // Move the pointer to the start of the next files data;
pbTemp+=pFile->uiFileSize; pbTemp+=fileBuf.uiFileSize;
uiCurrentByte+=DLC_DETAIL_ADV(pFile->dwWchCount); uiCurrentByte+=DLC_DETAIL_ADV(fileBuf.dwWchCount);
pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; DLC_READ_DETAIL(&fileBuf, pbData, uiCurrentByte);
} }
if( pack->getDLCItemsCount(DLCManager::e_DLCType_GameRules) > 0 if( pack->getDLCItemsCount(DLCManager::e_DLCType_GameRules) > 0

View file

@ -109,13 +109,15 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
} }
// READ TAGS // // READ TAGS //
// 4jcraft, fixed cast of templated List to get the tag list
// and cast it to CompoundTag inside the loop
CompoundTag *tag = NbtIo::read(dis); CompoundTag *tag = NbtIo::read(dis);
ListTag<CompoundTag> *tileEntityTags = (ListTag<CompoundTag> *) tag->getList(L"TileEntities"); ListTag<Tag> *tileEntityTags = tag->getList(L"TileEntities");
if (tileEntityTags != NULL) if (tileEntityTags != NULL)
{ {
for (int i = 0; i < tileEntityTags->size(); i++) for (int i = 0; i < tileEntityTags->size(); i++)
{ {
CompoundTag *teTag = tileEntityTags->get(i); CompoundTag *teTag = (CompoundTag*) tileEntityTags->get(i);
std::shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag); std::shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
if(te == NULL) if(te == NULL)
@ -131,18 +133,23 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
} }
} }
} }
ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) tag->getList(L"Entities");
// 4jcraft, fixed cast of templated List to get the tag list
// and cast it to CompoundTag inside the loop
ListTag<Tag> *entityTags = tag->getList(L"Entities");
if (entityTags != NULL) if (entityTags != NULL)
{ {
for (int i = 0; i < entityTags->size(); i++) for (int i = 0; i < entityTags->size(); i++)
{ {
CompoundTag *eTag = entityTags->get(i); CompoundTag *eTag = (CompoundTag*) entityTags->get(i);
eINSTANCEOF type = EntityIO::getType(eTag->getString(L"id")); eINSTANCEOF type = EntityIO::getType(eTag->getString(L"id"));
ListTag<DoubleTag> *pos = (ListTag<DoubleTag> *) eTag->getList(L"Pos");
double x = pos->get(0)->data; // 4jcraft, same here
double y = pos->get(1)->data; ListTag<Tag> *pos = eTag->getList(L"Pos");
double z = pos->get(2)->data;
double x = ((DoubleTag*) pos->get(0))->data;
double y = ((DoubleTag*) pos->get(1))->data;
double z = ((DoubleTag*) pos->get(2))->data;
if( type == eTYPE_PAINTING || type == eTYPE_ITEM_FRAME ) if( type == eTYPE_PAINTING || type == eTYPE_ITEM_FRAME )
{ {
@ -187,14 +194,15 @@ void ConsoleSchematicFile::save_tags(DataOutputStream *dos)
__int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot)
{ {
int xStart = std::max(destinationBox->x0, (double)chunk->x*16); int xStart = std::max(destinationBox->x0, (double)chunk->x*16);
int xEnd = std::min(destinationBox->x1, (double)((xStart>>4)<<4) + 16); // 4jcraft changed from (xStart>>4)<<4 to (xStart & ~15)
int xEnd = std::min(destinationBox->x1, (double)((xStart & ~15) + 16));
int yStart = destinationBox->y0; int yStart = destinationBox->y0;
int yEnd = destinationBox->y1; int yEnd = destinationBox->y1;
if(yEnd > Level::maxBuildHeight) yEnd = Level::maxBuildHeight; if(yEnd > Level::maxBuildHeight) yEnd = Level::maxBuildHeight;
int zStart = std::max(destinationBox->z0, (double)chunk->z*16); int zStart = std::max(destinationBox->z0, (double)chunk->z*16);
int zEnd = std::min(destinationBox->z1, (double)((zStart>>4)<<4) + 16); int zEnd = std::min(destinationBox->z1, (double)(zStart & ~15) + 16);
#ifdef _DEBUG #ifdef _DEBUG
app.DebugPrintf("Range is (%d,%d,%d) to (%d,%d,%d)\n",xStart,yStart,zStart,xEnd-1,yEnd-1,zEnd-1); app.DebugPrintf("Range is (%d,%d,%d) to (%d,%d,%d)\n",xStart,yStart,zStart,xEnd-1,yEnd-1,zEnd-1);
@ -326,14 +334,15 @@ __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkB
__int64 ConsoleSchematicFile::applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) __int64 ConsoleSchematicFile::applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot)
{ {
int xStart = std::max(destinationBox->x0, (double)chunk->x*16); int xStart = std::max(destinationBox->x0, (double)chunk->x*16);
int xEnd = std::min(destinationBox->x1, (double)((xStart>>4)<<4) + 16); // 4jcraft changed >>4<<4 to & ~15
int xEnd = std::min(destinationBox->x1, (double)(xStart & ~15) + 16);
int yStart = destinationBox->y0; int yStart = destinationBox->y0;
int yEnd = destinationBox->y1; int yEnd = destinationBox->y1;
if(yEnd > Level::maxBuildHeight) yEnd = Level::maxBuildHeight; if(yEnd > Level::maxBuildHeight) yEnd = Level::maxBuildHeight;
int zStart = std::max(destinationBox->z0, (double)chunk->z*16); int zStart = std::max(destinationBox->z0, (double)chunk->z*16);
int zEnd = std::min(destinationBox->z1, (double)((zStart>>4)<<4) + 16); int zEnd = std::min(destinationBox->z1, (double)(zStart & ~15) + 16);
int rowBlocksIncluded = (yEnd-yStart)*(zEnd-zStart); int rowBlocksIncluded = (yEnd-yStart)*(zEnd-zStart);
int blocksIncluded = (xEnd-xStart)*rowBlocksIncluded; int blocksIncluded = (xEnd-xStart)*rowBlocksIncluded;

View file

@ -244,8 +244,9 @@ void LevelGenerationOptions::processSchematics(LevelChunk *chunk)
rule->processSchematic(chunkBox, chunk); rule->processSchematic(chunkBox, chunk);
} }
int cx = (chunk->x << 4); // 4jcraft added cast to unsigned
int cz = (chunk->z << 4); int cx = ((unsigned)chunk->x << 4);
int cz = ((unsigned)chunk->z << 4);
for( AUTO_VAR(it, m_structureRules.begin()); it != m_structureRules.end(); it++ ) for( AUTO_VAR(it, m_structureRules.begin()); it != m_structureRules.end(); it++ )
{ {

View file

@ -119,6 +119,8 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa
m_pGameNetworkManager = pGameNetworkManager; m_pGameNetworkManager = pGameNetworkManager;
m_flagIndexSize = flagIndexSize; m_flagIndexSize = flagIndexSize;
g_pPlatformNetworkManager = this; g_pPlatformNetworkManager = this;
// 4jcraft added this, as it was never called
m_pIQNet = new IQNet();
for( int i = 0; i < XUSER_MAX_COUNT; i++ ) for( int i = 0; i < XUSER_MAX_COUNT; i++ )
{ {
playerChangedCallback[ i ] = NULL; playerChangedCallback[ i ] = NULL;
@ -154,6 +156,7 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa
void CPlatformNetworkManagerStub::Terminate() void CPlatformNetworkManagerStub::Terminate()
{ {
//TODO: 4jcraft, no release of ressources
} }
int CPlatformNetworkManagerStub::GetJoiningReadyPercentage() int CPlatformNetworkManagerStub::GetJoiningReadyPercentage()

View file

@ -343,6 +343,9 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad )
m_bHasTickedOnce = false; m_bHasTickedOnce = false;
m_firstTickTime = 0; m_firstTickTime = 0;
// 4jcraft added, not initialized
m_bSceneIsSplitscreen = false;
m_lastMessage = NULL; m_lastMessage = NULL;
lastMessageTime = 0; lastMessageTime = 0;
@ -1258,7 +1261,7 @@ void Tutorial::tick()
else else
{ {
// if we've changed mode, we may need to change scene // if we've changed mode, we may need to change scene
if(m_bSceneIsSplitscreen!=(app.GetLocalPlayerCount()>1)) if(m_bSceneIsSplitscreen != (app.GetLocalPlayerCount() > 1))
{ {
#ifdef _XBOX #ifdef _XBOX
app.TutorialSceneNavigateBack(m_iPad); app.TutorialSceneNavigateBack(m_iPad);

View file

@ -23,6 +23,9 @@ UIComponent_TutorialPopup::UIComponent_TutorialPopup(int iPad, void *initData, U
m_bSplitscreenGamertagVisible = false; m_bSplitscreenGamertagVisible = false;
m_labelDescription.init(L""); m_labelDescription.init(L"");
// 4jcraft added
m_tutorial = NULL;
} }
std::wstring UIComponent_TutorialPopup::getMoviePath() std::wstring UIComponent_TutorialPopup::getMoviePath()
@ -69,6 +72,9 @@ void UIComponent_TutorialPopup::SetTutorialDescription(TutorialPopupInfo *info)
{ {
m_interactScene = info->interactScene; m_interactScene = info->interactScene;
// 4jcraft added
m_tutorial = info->tutorial;
std::wstring parsed = _SetIcon(info->icon, info->iAuxVal, info->isFoil, info->desc); std::wstring parsed = _SetIcon(info->icon, info->iAuxVal, info->isFoil, info->desc);
parsed = _SetImage( parsed ); parsed = _SetImage( parsed );
parsed = ParseDescription(m_iPad, parsed); parsed = ParseDescription(m_iPad, parsed);

View file

@ -10,6 +10,9 @@ UIGroup::UIGroup(EUIGroup group, int iPad)
m_bContainerMenuDisplayed = false; m_bContainerMenuDisplayed = false;
m_bIgnoreAutosaveMenuDisplayed = false; m_bIgnoreAutosaveMenuDisplayed = false;
m_bIgnorePlayerJoinMenuDisplayed = false; m_bIgnorePlayerJoinMenuDisplayed = false;
// 4jcraft, moved this to the top
// uninitialized memory was read.
m_viewportType = C4JRender::VIEWPORT_TYPE_FULLSCREEN;
m_updateFocusStateCountdown = 0; m_updateFocusStateCountdown = 0;
@ -39,8 +42,6 @@ UIGroup::UIGroup(EUIGroup group, int iPad)
m_pressStartToPlay = (UIComponent_PressStartToPlay *)m_layers[(int)eUILayer_Tooltips]->addComponent(0, eUIComponent_PressStartToPlay); m_pressStartToPlay = (UIComponent_PressStartToPlay *)m_layers[(int)eUILayer_Tooltips]->addComponent(0, eUIComponent_PressStartToPlay);
} }
m_viewportType = C4JRender::VIEWPORT_TYPE_FULLSCREEN;
// 4J Stu - Pre-allocate this for cached rendering in scenes. It's horribly slow to do dynamically, but we should only need one // 4J Stu - Pre-allocate this for cached rendering in scenes. It's horribly slow to do dynamically, but we should only need one
// per group as we will only be displaying one of these types of scenes at a time // per group as we will only be displaying one of these types of scenes at a time
m_commandBufferList = MemoryTracker::genLists(1); m_commandBufferList = MemoryTracker::genLists(1);

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
// 4J-PB - remove the inherits via dominance warnings // 4J-PB - remove the inherits via dominance warnings
#pragma warning( disable : 4250 )
//using namespace std; //using namespace std;
// A scene map directly to an Iggy movie (or more accurately a collection of different sized movies) // A scene map directly to an Iggy movie (or more accurately a collection of different sized movies)

View file

@ -460,7 +460,7 @@ public:
bool Suspended(); bool Suspended();
///////////////////////////////////////////////////////////////////////////// Unimplemented stubs ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// Unimplemented stubs /////////////////////////////////////////////////////////////////////////////////
#pragma warning(disable: 4100)
void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected) {} void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected) {}
bool GetSaveDeviceSelected(unsigned int iPad) { return true; } bool GetSaveDeviceSelected(unsigned int iPad) { return true; }
void ClearDLCOffers(); void ClearDLCOffers();

View file

@ -27,8 +27,8 @@ extern "C"
{ {
#endif #endif
#pragma warning(push)
#pragma warning(disable: 4200) // zero-sized array
typedef enum _XMEMCODEC_TYPE typedef enum _XMEMCODEC_TYPE
{ {
@ -244,7 +244,7 @@ typedef struct _XCOMPRESS_BLOCK_HEADER_LZXNATIVE
BYTE pCompressedData[0]; BYTE pCompressedData[0];
} XCOMPRESS_BLOCK_HEADER_LZXNATIVE; } XCOMPRESS_BLOCK_HEADER_LZXNATIVE;
#pragma warning(pop)
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -36,8 +36,8 @@ struct BoundingBox;
struct BoundingOrientedBox; struct BoundingOrientedBox;
struct BoundingFrustum; struct BoundingFrustum;
#pragma warning(push)
#pragma warning(disable:4324 4820)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Bounding sphere // Bounding sphere
@ -316,7 +316,7 @@ namespace TriangleTests
// Test a triangle against six planes at once (see BoundingFrustum::GetPlanes) // Test a triangle against six planes at once (see BoundingFrustum::GetPlanes)
}; };
#pragma warning(pop)
/**************************************************************************** /****************************************************************************
* *
@ -324,8 +324,8 @@ namespace TriangleTests
* *
****************************************************************************/ ****************************************************************************/
#pragma warning(push)
#pragma warning(disable : 4068 4616 6001)
#pragma prefast(push) #pragma prefast(push)
#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes") #pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes")
@ -333,7 +333,7 @@ namespace TriangleTests
#include "DirectXCollision.inl" #include "DirectXCollision.inl"
#pragma prefast(pop) #pragma prefast(pop)
#pragma warning(pop)
}; // namespace DirectX }; // namespace DirectX

View file

@ -49,12 +49,12 @@
#endif #endif
#endif // !_XM_ARM_NEON_INTRINSICS_ && !_XM_SSE_INTRINSICS_ && !_XM_VMX128_INTRINSICS_ && !_XM_NO_INTRINSICS_ #endif // !_XM_ARM_NEON_INTRINSICS_ && !_XM_SSE_INTRINSICS_ && !_XM_VMX128_INTRINSICS_ && !_XM_NO_INTRINSICS_
#pragma warning(push)
#pragma warning(disable:4514 4820 4985)
#include <cmath> #include <cmath>
#include <float.h> #include <float.h>
// MGH - #include <malloc.h> // MGH - #include <malloc.h>
#pragma warning(pop)
#if defined(_XM_SSE_INTRINSICS_) #if defined(_XM_SSE_INTRINSICS_)
@ -76,10 +76,10 @@
#include <assert.h> #include <assert.h>
#pragma warning(push)
#pragma warning(disable : 4005 4668)
#include <stdint.h> #include <stdint.h>
#pragma warning(pop)
namespace DirectX namespace DirectX
@ -184,8 +184,8 @@ inline bool XMComparisonAnyOutOfBounds(uint32_t CR) { return (((CR) & XM_CRMASK_
* *
****************************************************************************/ ****************************************************************************/
#pragma warning(push)
#pragma warning(disable:4068 4201 4365 4324 4820)
#pragma prefast(push) #pragma prefast(push)
#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes") #pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes")
@ -703,7 +703,7 @@ __declspec(align(16)) struct XMFLOAT4X4A : public XMFLOAT4X4
#endif #endif
#pragma prefast(pop) #pragma prefast(pop)
#pragma warning(pop)
/**************************************************************************** /****************************************************************************
* *
@ -1746,8 +1746,8 @@ XMGLOBALCONST XMVECTORF32 g_XMsrgbA1 = { 1.055f, 1.055f, 1.055f, 1.0f
* *
****************************************************************************/ ****************************************************************************/
#pragma warning(push)
#pragma warning(disable:4068 4214 4204 4365 4616 4640 6001)
#pragma prefast(push) #pragma prefast(push)
#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes") #pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes")
@ -1855,7 +1855,7 @@ inline XMVECTOR XMVectorSplatConstantInt(int32_t IntConstant)
#pragma prefast(pop) #pragma prefast(pop)
#pragma warning(pop)
}; // namespace DirectX }; // namespace DirectX

View file

@ -24,8 +24,8 @@
#if defined(_XM_NO_INTRINSICS_) || defined(_XM_SSE_INTRINSICS_) || defined(_XM_ARM_NEON_INTRINSICS_) #if defined(_XM_NO_INTRINSICS_) || defined(_XM_SSE_INTRINSICS_) || defined(_XM_ARM_NEON_INTRINSICS_)
// For VMX128, these routines are all defines in the main header // For VMX128, these routines are all defines in the main header
#pragma warning(push)
#pragma warning(disable:4701) // Prevent warnings about 'Result' potentially being used without having been initialized
inline XMVECTOR XMConvertVectorIntToFloat inline XMVECTOR XMConvertVectorIntToFloat
( (
@ -220,7 +220,7 @@ inline XMVECTOR XMConvertVectorFloatToUInt
#endif #endif
} }
#pragma warning(pop)
#endif // _XM_NO_INTRINSICS_ || _XM_SSE_INTRINSICS_ || _XM_ARM_NEON_INTRINSICS_ #endif // _XM_NO_INTRINSICS_ || _XM_SSE_INTRINSICS_ || _XM_ARM_NEON_INTRINSICS_

View file

@ -26,8 +26,8 @@ namespace PackedVector
#pragma bitfield_order(lsb_to_msb) #pragma bitfield_order(lsb_to_msb)
#endif #endif
#pragma warning(push)
#pragma warning(disable:4201 4365 4324)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// ARGB Color; 8-8-8-8 bit unsigned normalized integer components packed into // ARGB Color; 8-8-8-8 bit unsigned normalized integer components packed into
@ -865,7 +865,7 @@ struct XMU555
}; };
#pragma warning(pop)
#ifdef _XM_BIGENDIAN_ #ifdef _XM_BIGENDIAN_
#pragma bitfield_order(pop) #pragma bitfield_order(pop)
@ -977,8 +977,8 @@ void XMStoreU555(_Out_ XMU555* pDestination, _In_ FXMVECTOR V);
* *
****************************************************************************/ ****************************************************************************/
#pragma warning(push)
#pragma warning(disable:4068 4214 4204 4365 4616 6001)
#pragma prefast(push) #pragma prefast(push)
#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes") #pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes")
@ -986,7 +986,7 @@ void XMStoreU555(_Out_ XMU555* pDestination, _In_ FXMVECTOR V);
#include "DirectXPackedVector.inl" #include "DirectXPackedVector.inl"
#pragma prefast(pop) #pragma prefast(pop)
#pragma warning(pop)
}; // namespace PackedVector }; // namespace PackedVector

View file

@ -5,7 +5,7 @@
namespace Sentient namespace Sentient
{ {
#pragma warning(disable:4996)
__declspec(deprecated("This function is deprecated. See the function body for an example of using the new API.")) __declspec(deprecated("This function is deprecated. See the function body for an example of using the new API."))
__inline HRESULT SenBoxArtDownloadExtraInfo( __inline HRESULT SenBoxArtDownloadExtraInfo(
@ -40,5 +40,5 @@ namespace Sentient
return SenBoxArtXMLGetDescription(senXML, bufferLengthMax, out_bufferLength, out_buffer); return SenBoxArtXMLGetDescription(senXML, bufferLengthMax, out_bufferLength, out_buffer);
} }
#pragma warning(default:4996)
} }

View file

@ -63,9 +63,9 @@ namespace Sentient
{ {
SenUGCMetaData() SenUGCMetaData()
{ {
#pragma warning ( disable : 4996 ) // @TODO - Removed once Int16 Descriptors are deprecated
memset(descriptors, 0, sizeof(SenUGCDescriptor) * NrUgcDescriptors); memset(descriptors, 0, sizeof(SenUGCDescriptor) * NrUgcDescriptors);
#pragma warning ( default : 4996 )
memset(descriptors2, 0, sizeof(__int64) * NrUgcDescriptors); memset(descriptors2, 0, sizeof(__int64) * NrUgcDescriptors);
} }

View file

@ -45,6 +45,9 @@ ServerPlayer::ServerPlayer(MinecraftServer *server, Level *level, const std::wst
m_enteredEndExitPortal = false; m_enteredEndExitPortal = false;
lastCarried = ItemInstanceArray(5); lastCarried = ItemInstanceArray(5);
viewDistance = 10; viewDistance = 10;
// 4jcraft added (0 initialized)
m_lastDamageSource = eTelemetryChallenges_Unknown;
// gameMode->player = this; // 4J - removed to avoid use of shared_from_this in ctor, now set up externally // gameMode->player = this; // 4J - removed to avoid use of shared_from_this in ctor, now set up externally
this->gameMode = gameMode; this->gameMode = gameMode;
@ -540,7 +543,7 @@ void ServerPlayer::doTickB(bool ignorePortal)
if (getHealth() != lastSentHealth || lastSentFood != foodData.getFoodLevel() || ((foodData.getSaturationLevel() == 0) != lastFoodSaturationZero)) if (getHealth() != lastSentHealth || lastSentFood != foodData.getFoodLevel() || ((foodData.getSaturationLevel() == 0) != lastFoodSaturationZero))
{ {
// 4J Stu - Added m_lastDamageSource for telemetry // 4J Stu - Added m_lastDamageSource for telemetry //4jcraft, nice but you never initialized it
connection->send( std::shared_ptr<SetHealthPacket>( new SetHealthPacket(getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel(), m_lastDamageSource) ) ); connection->send( std::shared_ptr<SetHealthPacket>( new SetHealthPacket(getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel(), m_lastDamageSource) ) );
lastSentHealth = getHealth(); lastSentHealth = getHealth();
lastSentFood = foodData.getFoodLevel(); lastSentFood = foodData.getFoodLevel();

View file

@ -341,9 +341,11 @@ void ItemRenderer::renderGuiItem(Font *font, Textures *textures, std::shared_ptr
Tile *tile = Tile::tiles[itemId]; Tile *tile = Tile::tiles[itemId];
glPushMatrix(); glPushMatrix();
// 4J - original code left here for reference // 4J - original code left here for reference
#if 0 // 4jcraft: re-enable said original code to fix hotbar block rendering
#if 1
glTranslatef((float)(x), (float)(y), 0.0f); glTranslatef((float)(x), (float)(y), 0.0f);
glScalef(fScale, fScale, fScale); //glScalef(fScale, fScale, fScale);
glScalef(fScaleX, fScaleY, 1.0f); // 4jcraft: tweaked to use the new variables
glTranslatef(-2.0f,3.0f, -3.0f + blitOffset); glTranslatef(-2.0f,3.0f, -3.0f + blitOffset);
glScalef(10.0f, 10.0f, 10.0f); glScalef(10.0f, 10.0f, 10.0f);
glTranslatef(1.0f, 0.5f, 8.0f); glTranslatef(1.0f, 0.5f, 8.0f);

View file

@ -17,8 +17,9 @@ void MinecartRenderer::render(std::shared_ptr<Entity> _cart, double x, double y,
glPushMatrix(); glPushMatrix();
__int64 seed = cart->entityId * 493286711l; // 4jcraft added a bunch of casts to prever overflow
seed = seed * seed * 4392167121l + seed * 98761; int64_t seed = (int64_t)((uint64_t)cart->entityId * 493286711ULL);
seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 4392167121ULL) + ((uint64_t)seed * 98761ULL));
float xo = ((((seed >> 16) & 0x7) + 0.5f) / 8.0f - 0.5f) * 0.004f; float xo = ((((seed >> 16) & 0x7) + 0.5f) / 8.0f - 0.5f) * 0.004f;
float yo = ((((seed >> 20) & 0x7) + 0.5f) / 8.0f - 0.5f) * 0.004f; float yo = ((((seed >> 20) & 0x7) + 0.5f) / 8.0f - 0.5f) * 0.004f;
@ -103,4 +104,4 @@ void MinecartRenderer::render(std::shared_ptr<Entity> _cart, double x, double y,
model->render(cart, 0, 0, -0.1f, 0, 0, 1 / 16.0f, true); model->render(cart, 0, 0, -0.1f, 0, 0, 1 / 16.0f, true);
glPopMatrix(); glPopMatrix();
} }

View file

@ -3582,9 +3582,10 @@ bool TileRenderer::tesselateCrossInWorld( Tile* tt, int x, int y, int z )
if (tt == Tile::tallgrass) if (tt == Tile::tallgrass)
{ {
__int64 seed = (x * 3129871) ^ (z * 116129781l) ^ (y); // 4jcraft add a bunch of casts to prevent overflow (i pray to god)
seed = seed * seed * 42317861 + seed * 11; int64_t seed = ((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) + ((uint64_t)seed * 11ULL));
xt += ((((seed >> 16) & 0xf) / 15.0f) - 0.5f) * 0.5f; xt += ((((seed >> 16) & 0xf) / 15.0f) - 0.5f) * 0.5f;
yt += ((((seed >> 20) & 0xf) / 15.0f) - 1.0f) * 0.2f; yt += ((((seed >> 20) & 0xf) / 15.0f) - 1.0f) * 0.2f;
zt += ((((seed >> 24) & 0xf) / 15.0f) - 0.5f) * 0.5f; zt += ((((seed >> 24) & 0xf) / 15.0f) - 0.5f) * 0.5f;
@ -3821,9 +3822,9 @@ bool TileRenderer::tesselateLilypadInWorld(Tile *tt, int x, int y, int z)
float u1 = tex->getU1(true); float u1 = tex->getU1(true);
float v1 = tex->getV1(true); float v1 = tex->getV1(true);
__int64 seed = (x * 3129871) ^ (z * 116129781l) ^ (y); // 4jcraft add a bunch of casts to prevent overflow (i pray to god)
seed = seed * seed * 42317861 + seed * 11; int64_t seed = ((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) + ((uint64_t)seed * 11ULL));
int dir = (int) ((seed >> 16) & 0x3); int dir = (int) ((seed >> 16) & 0x3);

View file

@ -1332,6 +1332,10 @@ void GameRenderer::renderLevel(float a, __int64 until)
setupFog(-1, a); setupFog(-1, a);
levelRenderer->renderSky(a); levelRenderer->renderSky(a);
if(mc->skins->getSelected()->getId() == 1026 ) levelRenderer->renderHaloRing(a); if(mc->skins->getSelected()->getId() == 1026 ) levelRenderer->renderHaloRing(a);
} else {
// 4jcraft: needs to be enabled for proper transparent texturing on low render dists
// this was done in renderSky() for the far and normal dists but was missing here,
glEnable(GL_ALPHA_TEST);
} }
glEnable(GL_FOG); glEnable(GL_FOG);
setupFog(1, a); setupFog(1, a);

View file

@ -1049,9 +1049,10 @@ void Tesselator::normal(float x, float y, float z)
std::int8_t zz = (std::int8_t) (z * 127); std::int8_t zz = (std::int8_t) (z * 127);
_normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16);
#else #else
std::uint8_t xx = (std::uint8_t) (x * 127); // 4jcraft copied the PSVITA branch, read comment above
std::uint8_t yy = (std::uint8_t) (y * 127); std::int8_t xx = (std::int8_t) (x * 127);
std::uint8_t zz = (std::uint8_t) (z * 127); std::int8_t yy = (std::int8_t) (y * 127);
std::int8_t zz = (std::int8_t) (z * 127);
_normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16);
#endif #endif
} }

View file

@ -660,10 +660,11 @@ void Texture::transferFromImage(BufferedImage *image)
int c3 = data[level - 1]->getInt(((x * 2 + 0) + (y * 2 + 1) * ow) * 4); int c3 = data[level - 1]->getInt(((x * 2 + 0) + (y * 2 + 1) * ow) * 4);
#ifndef _XBOX #ifndef _XBOX
// 4J - convert our RGBA texels to ARGB that crispBlend is expecting // 4J - convert our RGBA texels to ARGB that crispBlend is expecting
c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( c0 << 24 ); // 4jcraft, added uint cast to pervent shift of neg int
c1 = ( ( c1 >> 8 ) & 0x00ffffff ) | ( c1 << 24 ); c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c0 << 24 );
c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( c2 << 24 ); c1 = ( ( c1 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c1 << 24 );
c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( c3 << 24 ); c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c2 << 24 );
c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c3 << 24 );
#endif #endif
int col = crispBlend(crispBlend(c0, c1), crispBlend(c2, c3)); int col = crispBlend(crispBlend(c0, c1), crispBlend(c2, c3));
// 4J - and back from ARGB -> RGBA // 4J - and back from ARGB -> RGBA

View file

@ -626,15 +626,16 @@ void Textures::loadTexture(BufferedImage *img, int id, bool blur, bool clamp)
int c3 = pixels->getInt(((x * 2 + 0) + (y * 2 + 1) * ow) * 4); int c3 = pixels->getInt(((x * 2 + 0) + (y * 2 + 1) * ow) * 4);
#ifndef _XBOX #ifndef _XBOX
// 4J - convert our RGBA texels to ARGB that crispBlend is expecting // 4J - convert our RGBA texels to ARGB that crispBlend is expecting
c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( c0 << 24 ); // 4jcraft, added uint cast to pervent shift of neg int
c1 = ( ( c1 >> 8 ) & 0x00ffffff ) | ( c1 << 24 ); c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c0 << 24 );
c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( c2 << 24 ); c1 = ( ( c1 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c1 << 24 );
c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( c3 << 24 ); c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c2 << 24 );
c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( (unsigned int) c3 << 24 );
#endif #endif
int col = Texture::crispBlend(Texture::crispBlend(c0, c1), Texture::crispBlend(c2, c3)); int col = Texture::crispBlend(Texture::crispBlend(c0, c1), Texture::crispBlend(c2, c3));
#ifndef _XBOX #ifndef _XBOX
// 4J - and back from ARGB -> RGBA // 4J - and back from ARGB -> RGBA
col = ( col << 8 ) | (( col >> 24 ) & 0xff); col = ( (unsigned int) col << 8 ) | (( col >> 24 ) & 0xff);
#endif #endif
tempData[x + y * ww] = col; tempData[x + y * ww] = col;
} }

View file

@ -258,7 +258,8 @@ void Font::draw(const std::wstring& str, int x, int y, int color, bool dropShado
// if not set // if not set
if (dropShadow) // divide RGB by 4, preserve alpha if (dropShadow) // divide RGB by 4, preserve alpha
color = (color & 0xfcfcfc) >> 2 | (color & (-1 << 24)); // 4jcraft changed -1 << 24 to the value of 1 (0xFF FF FF FF)
color = (color & 0xfcfcfc) >> 2 | (color & (0xFFFFFFFF << 24));
glColor4f((color >> 16 & 255) / 255.0F, (color >> 8 & 255) / 255.0F, (color & 255) / 255.0F, (color >> 24 & 255) / 255.0F); glColor4f((color >> 16 & 255) / 255.0F, (color >> 8 & 255) / 255.0F, (color & 255) / 255.0F, (color >> 24 & 255) / 255.0F);

View file

@ -30,7 +30,8 @@ hash(createHash(x, y, z))
int Node::createHash(const int x, const int y, const int z) int Node::createHash(const int x, const int y, const int z)
{ {
return (y & 0xff) | ((x & 0x7fff) << 8) | ((z & 0x7fff) << 24) | ((x < 0) ? 0x0080000000 : 0) | ((z < 0) ? 0x0000008000 : 0); // 4jcraft added cast to higher value to be representable after shift
return (y & 0xff) | (((int64_t)x & 0x7fff) << 8) | (((int64_t)z & 0x7fff) << 24) | ((x < 0) ? 0x0080000000 : 0) | ((z < 0) ? 0x0000008000 : 0);
} }
float Node::distanceTo(Node *to) float Node::distanceTo(Node *to)
@ -72,4 +73,4 @@ bool Node::inOpenSet()
std::wstring Node::toString() std::wstring Node::toString()
{ {
return _toString<int>(x) + L", " + _toString<int>(y) + L", " + _toString<int>(z); return _toString<int>(x) + L", " + _toString<int>(y) + L", " + _toString<int>(z);
} }

View file

@ -17,7 +17,7 @@ std::wstring AnvilTile::TEXTURE_DAMAGE_NAMES[ANVIL_NAMES_LENGTH] = {
L"anvil_top", L"anvil_top_damaged_1", L"anvil_top_damaged_2" L"anvil_top", L"anvil_top_damaged_1", L"anvil_top_damaged_2"
}; };
AnvilTile::AnvilTile(int id) : HeavyTile(id, Material::heavyMetal, isSolidRender() ) AnvilTile::AnvilTile(int id) : HeavyTile(id, Material::heavyMetal, false)
{ {
part = PART_BASE; part = PART_BASE;
setLightBlock(0); setLightBlock(0);
@ -114,4 +114,4 @@ void AnvilTile::onLand(Level *level, int xt, int yt, int zt, int data)
bool AnvilTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) bool AnvilTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{ {
return true; return true;
} }

View file

@ -12,7 +12,7 @@ int BedTile::HEAD_DIRECTION_OFFSETS[4][2] =
{ 0, 1 }, { -1, 0 }, { 0, -1 }, { 1, 0 } { 0, 1 }, { -1, 0 }, { 0, -1 }, { 1, 0 }
}; };
BedTile::BedTile(int id) : DirectionalTile(id, Material::cloth, isSolidRender()) BedTile::BedTile(int id) : DirectionalTile(id, Material::cloth, false)
{ {
setShape(); setShape();
@ -329,4 +329,4 @@ int BedTile::getPistonPushReaction()
int BedTile::cloneTileId(Level *level, int x, int y, int z) int BedTile::cloneTileId(Level *level, int x, int y, int z)
{ {
return Item::bed_Id; return Item::bed_Id;
} }

View file

@ -8,7 +8,7 @@
const std::wstring BrewingStandTile::TEXTURE_BASE = L"brewingStand_base"; const std::wstring BrewingStandTile::TEXTURE_BASE = L"brewingStand_base";
BrewingStandTile::BrewingStandTile(int id) : EntityTile(id, Material::metal, isSolidRender()) BrewingStandTile::BrewingStandTile(int id) : EntityTile(id, Material::metal, false)
{ {
random = new Random(); random = new Random();
iconBase = NULL; iconBase = NULL;
@ -133,4 +133,4 @@ void BrewingStandTile::registerIcons(IconRegister *iconRegister)
Icon *BrewingStandTile::getBaseTexture() Icon *BrewingStandTile::getBaseTexture()
{ {
return iconBase; return iconBase;
} }

View file

@ -6,7 +6,7 @@
#include "ButtonTile.h" #include "ButtonTile.h"
#include "../Util/SoundTypes.h" #include "../Util/SoundTypes.h"
ButtonTile::ButtonTile(int id, bool sensitive) : Tile(id, Material::decoration,isSolidRender()) ButtonTile::ButtonTile(int id, bool sensitive) : Tile(id, Material::decoration, false)
{ {
this->setTicking(true); this->setTicking(true);
this->sensitive = sensitive; this->sensitive = sensitive;

View file

@ -8,7 +8,7 @@
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
#include "CactusTile.h" #include "CactusTile.h"
CactusTile::CactusTile(int id) : Tile(id, Material::cactus,isSolidRender()) CactusTile::CactusTile(int id) : Tile(id, Material::cactus, false)
{ {
setTicking(true); setTicking(true);
iconTop = NULL; iconTop = NULL;

View file

@ -9,7 +9,7 @@
#include "CakeTile.h" #include "CakeTile.h"
CakeTile::CakeTile(int id) : Tile(id, Material::cake,isSolidRender()) CakeTile::CakeTile(int id) : Tile(id, Material::cake, false)
{ {
setTicking(true); setTicking(true);
@ -148,4 +148,4 @@ int CakeTile::getResource(int data, Random *random, int playerBonusLevel)
int CakeTile::cloneTileId(Level *level, int x, int y, int z) int CakeTile::cloneTileId(Level *level, int x, int y, int z)
{ {
return Item::cake_Id; return Item::cake_Id;
} }

View file

@ -11,7 +11,7 @@
const std::wstring CauldronTile::TEXTURE_INSIDE = L"cauldron_inner"; const std::wstring CauldronTile::TEXTURE_INSIDE = L"cauldron_inner";
const std::wstring CauldronTile::TEXTURE_BOTTOM = L"cauldron_bottom"; const std::wstring CauldronTile::TEXTURE_BOTTOM = L"cauldron_bottom";
CauldronTile::CauldronTile(int id) : Tile(id, Material::metal, isSolidRender()) CauldronTile::CauldronTile(int id) : Tile(id, Material::metal, false)
{ {
iconInner = NULL; iconInner = NULL;
iconTop = NULL; iconTop = NULL;
@ -174,4 +174,4 @@ int CauldronTile::getResource(int data, Random *random, int playerBonusLevel)
int CauldronTile::cloneTileId(Level *level, int x, int y, int z) int CauldronTile::cloneTileId(Level *level, int x, int y, int z)
{ {
return Item::cauldron_Id; return Item::cauldron_Id;
} }

View file

@ -10,7 +10,7 @@
#include "../Util/Facing.h" #include "../Util/Facing.h"
#include "../Entities/Mobs/Ocelot.h" #include "../Entities/Mobs/Ocelot.h"
ChestTile::ChestTile(int id) : EntityTile(id, Material::wood, isSolidRender() ) ChestTile::ChestTile(int id) : EntityTile(id, Material::wood, false)
{ {
random = new Random(); random = new Random();

View file

@ -8,7 +8,7 @@
const std::wstring CocoaTile::TEXTURE_AGES[] = { L"cocoa_0", L"cocoa_1", L"cocoa_2"}; const std::wstring CocoaTile::TEXTURE_AGES[] = { L"cocoa_0", L"cocoa_1", L"cocoa_2"};
CocoaTile::CocoaTile(int id) : DirectionalTile(id, Material::plant, isSolidRender() ) CocoaTile::CocoaTile(int id) : DirectionalTile(id, Material::plant, false)
{ {
setTicking(true); setTicking(true);
} }
@ -173,4 +173,4 @@ void CocoaTile::registerIcons(IconRegister *iconRegister)
{ {
icons[i] = iconRegister->registerIcon(TEXTURE_AGES[i]); icons[i] = iconRegister->registerIcon(TEXTURE_AGES[i]);
} }
} }

View file

@ -9,7 +9,7 @@
const double DiodeTile::DELAY_RENDER_OFFSETS[4] = { -1.0f / 16.0f, 1.0f / 16.0f, 3.0f / 16.0f, 5.0f / 16.0f }; const double DiodeTile::DELAY_RENDER_OFFSETS[4] = { -1.0f / 16.0f, 1.0f / 16.0f, 3.0f / 16.0f, 5.0f / 16.0f };
const int DiodeTile::DELAYS[4] = { 1, 2, 3, 4 }; const int DiodeTile::DELAYS[4] = { 1, 2, 3, 4 };
DiodeTile::DiodeTile(int id, bool on) : DirectionalTile(id, Material::decoration,isSolidRender()) DiodeTile::DiodeTile(int id, bool on) : DirectionalTile(id, Material::decoration, false)
{ {
this->on = on; this->on = on;
updateDefaultShape(); updateDefaultShape();

View file

@ -10,7 +10,7 @@
const std::wstring DoorTile::TEXTURES[] = { L"doorWood_lower", L"doorWood_upper", L"doorIron_lower", L"doorIron_upper" }; const std::wstring DoorTile::TEXTURES[] = { L"doorWood_lower", L"doorWood_upper", L"doorIron_lower", L"doorIron_upper" };
DoorTile::DoorTile(int id, Material *material) : Tile(id, material,isSolidRender()) DoorTile::DoorTile(int id, Material *material) : Tile(id, material, false)
{ {
icons = NULL; icons = NULL;

View file

@ -4,7 +4,7 @@
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "../Headers/net.minecraft.world.entity.item.h" #include "../Headers/net.minecraft.world.entity.item.h"
EggTile::EggTile(int id) : Tile(id, Material::egg, isSolidRender()) EggTile::EggTile(int id) : Tile(id, Material::egg, false)
{ {
} }
@ -170,4 +170,4 @@ void EggTile::generateTeleportParticles(Level *level,int xt,int yt, int zt,int d
bool EggTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) bool EggTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{ {
return true; return true;
} }

View file

@ -9,7 +9,7 @@ const std::wstring EnchantmentTableTile::TEXTURE_SIDE = L"enchantment_side";
const std::wstring EnchantmentTableTile::TEXTURE_TOP = L"enchantment_top"; const std::wstring EnchantmentTableTile::TEXTURE_TOP = L"enchantment_top";
const std::wstring EnchantmentTableTile::TEXTURE_BOTTOM = L"enchantment_bottom"; const std::wstring EnchantmentTableTile::TEXTURE_BOTTOM = L"enchantment_bottom";
EnchantmentTableTile::EnchantmentTableTile(int id) : EntityTile(id, Material::stone, isSolidRender()) EnchantmentTableTile::EnchantmentTableTile(int id) : EntityTile(id, Material::stone, false)
{ {
updateDefaultShape(); updateDefaultShape();
setLightBlock(0); setLightBlock(0);

View file

@ -7,7 +7,7 @@
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "EnderChestTile.h" #include "EnderChestTile.h"
EnderChestTile::EnderChestTile(int id) : EntityTile(id, Material::stone, isSolidRender()) EnderChestTile::EnderChestTile(int id) : EntityTile(id, Material::stone, false)
{ {
updateDefaultShape(); updateDefaultShape();
} }

View file

@ -6,7 +6,7 @@
#include "FarmTile.h" #include "FarmTile.h"
FarmTile::FarmTile(int id) : Tile(id, Material::dirt,isSolidRender()) FarmTile::FarmTile(int id) : Tile(id, Material::dirt, false)
{ {
iconWet = NULL; iconWet = NULL;
iconDry = NULL; iconDry = NULL;

View file

@ -5,7 +5,7 @@
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "../Level/Events/LevelEvent.h" #include "../Level/Events/LevelEvent.h"
FenceGateTile::FenceGateTile(int id) : DirectionalTile(id, Material::wood, isSolidRender() ) FenceGateTile::FenceGateTile(int id) : DirectionalTile(id, Material::wood, false)
{ {
} }
@ -144,4 +144,4 @@ void FenceGateTile::registerIcons(IconRegister *iconRegister)
bool FenceGateTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) bool FenceGateTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{ {
return true; return true;
} }

View file

@ -4,7 +4,7 @@
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
#include "FenceTile.h" #include "FenceTile.h"
FenceTile::FenceTile(int id, const std::wstring &texture, Material *material) : Tile( id, material, isSolidRender()) FenceTile::FenceTile(int id, const std::wstring &texture, Material *material) : Tile( id, material, false)
{ {
this->texture = texture; this->texture = texture;
} }
@ -129,4 +129,4 @@ void FenceTile::registerIcons(IconRegister *iconRegister)
bool FenceTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) bool FenceTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{ {
return true; return true;
} }

View file

@ -16,7 +16,7 @@
const std::wstring FireTile::TEXTURE_FIRST = L"fire_0"; const std::wstring FireTile::TEXTURE_FIRST = L"fire_0";
const std::wstring FireTile::TEXTURE_SECOND = L"fire_1"; const std::wstring FireTile::TEXTURE_SECOND = L"fire_1";
FireTile::FireTile(int id) : Tile(id, Material::fire,isSolidRender()) FireTile::FireTile(int id) : Tile(id, Material::fire, false)
{ {
flameOdds = new int[256]; flameOdds = new int[256];
memset( flameOdds,0,sizeof(int)*256); memset( flameOdds,0,sizeof(int)*256);

View file

@ -5,7 +5,7 @@
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "FlowerPotTile.h" #include "FlowerPotTile.h"
FlowerPotTile::FlowerPotTile(int id) : Tile(id, Material::decoration, isSolidRender() ) FlowerPotTile::FlowerPotTile(int id) : Tile(id, Material::decoration, false)
{ {
updateDefaultShape(); updateDefaultShape();
sendTileData(); sendTileData();
@ -189,4 +189,4 @@ int FlowerPotTile::getTypeFromItem(std::shared_ptr<ItemInstance> item)
} }
return 0; return 0;
} }

View file

@ -3,7 +3,7 @@
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
#include "HalfTransparentTile.h" #include "HalfTransparentTile.h"
HalfTransparentTile::HalfTransparentTile(int id, const std::wstring &tex, Material *material, bool allowSame) : Tile(id,material,isSolidRender()) HalfTransparentTile::HalfTransparentTile(int id, const std::wstring &tex, Material *material, bool allowSame) : Tile(id,material, false)
{ {
this->allowSame = allowSame; this->allowSame = allowSame;
this->texture = tex; this->texture = tex;
@ -29,4 +29,4 @@ bool HalfTransparentTile::blocksLight()
void HalfTransparentTile::registerIcons(IconRegister *iconRegister) void HalfTransparentTile::registerIcons(IconRegister *iconRegister)
{ {
icon = iconRegister->registerIcon(texture); icon = iconRegister->registerIcon(texture);
} }

View file

@ -3,7 +3,7 @@
#include "LadderTile.h" #include "LadderTile.h"
LadderTile::LadderTile(int id) : Tile(id, Material::decoration,isSolidRender()) LadderTile::LadderTile(int id) : Tile(id, Material::decoration, false)
{ {
} }
@ -109,4 +109,4 @@ void LadderTile::neighborChanged(Level *level, int x, int y, int z, int type)
int LadderTile::getResourceCount(Random* random) int LadderTile::getResourceCount(Random* random)
{ {
return 1; return 1;
} }

View file

@ -15,7 +15,11 @@ const unsigned int LeafTile::LEAF_NAMES[LEAF_NAMES_LENGTH] = { IDS_TILE_LEAVES_O
const std::wstring LeafTile::TEXTURES[2][4] = { {L"leaves", L"leaves_spruce", L"leaves", L"leaves_jungle"}, {L"leaves_opaque", L"leaves_spruce_opaque", L"leaves_opaque", L"leaves_jungle_opaque"},}; const std::wstring LeafTile::TEXTURES[2][4] = { {L"leaves", L"leaves_spruce", L"leaves", L"leaves_jungle"}, {L"leaves_opaque", L"leaves_spruce_opaque", L"leaves_opaque", L"leaves_jungle_opaque"},};
LeafTile::LeafTile(int id) : TransparentTile(id, Material::leaves, false, isSolidRender()) // 4jcraft, this is the unitinialized vpointer fiassco of isSolidRender()
// isSolidRender() returns !allowSame if !isServerLevel, else true
// scince allowSame for TransparentTile right here is set to false
// setting isSolidRender to true by default totally correct.
LeafTile::LeafTile(int id) : TransparentTile(id, Material::leaves, false, true)
{ {
checkBuffer = NULL; checkBuffer = NULL;
fancyTextureSet = 0; fancyTextureSet = 0;

View file

@ -4,7 +4,7 @@
#include "LeverTile.h" #include "LeverTile.h"
#include "../Util/SoundTypes.h" #include "../Util/SoundTypes.h"
LeverTile::LeverTile(int id) : Tile(id, Material::decoration,isSolidRender()) LeverTile::LeverTile(int id) : Tile(id, Material::decoration, false)
{ {
} }

View file

@ -12,7 +12,7 @@ const std::wstring LiquidTile::TEXTURE_WATER_STILL = L"water";
const std::wstring LiquidTile::TEXTURE_WATER_FLOW = L"water_flow"; const std::wstring LiquidTile::TEXTURE_WATER_FLOW = L"water_flow";
const std::wstring LiquidTile::TEXTURE_LAVA_FLOW = L"lava_flow"; const std::wstring LiquidTile::TEXTURE_LAVA_FLOW = L"lava_flow";
LiquidTile::LiquidTile(int id, Material *material) : Tile(id, material,isSolidRender()) LiquidTile::LiquidTile(int id, Material *material) : Tile(id, material, false)
{ {
float yo = 0; float yo = 0;
float e = 0; float e = 0;

View file

@ -3,7 +3,7 @@
#include "../Headers/net.minecraft.world.level.tile.entity.h" #include "../Headers/net.minecraft.world.level.tile.entity.h"
#include "MobSpawnerTile.h" #include "MobSpawnerTile.h"
MobSpawnerTile::MobSpawnerTile(int id) : EntityTile(id, Material::stone, isSolidRender() ) MobSpawnerTile::MobSpawnerTile(int id) : EntityTile(id, Material::stone, false)
{ {
} }
@ -46,4 +46,4 @@ void MobSpawnerTile::spawnResources(Level *level, int x, int y, int z, int data,
int MobSpawnerTile::cloneTileId(Level *level, int x, int y, int z) int MobSpawnerTile::cloneTileId(Level *level, int x, int y, int z)
{ {
return 0; return 0;
} }

View file

@ -73,7 +73,7 @@ void PistonBaseTile::ignoreUpdate(bool set)
PistonTlsSetValue(tlsIdx, reinterpret_cast<void *>(static_cast<intptr_t>(set ? 1 : 0))); PistonTlsSetValue(tlsIdx, reinterpret_cast<void *>(static_cast<intptr_t>(set ? 1 : 0)));
} }
PistonBaseTile::PistonBaseTile(int id, bool isSticky) : Tile(id, Material::piston, isSolidRender() ) PistonBaseTile::PistonBaseTile(int id, bool isSticky) : Tile(id, Material::piston, false)
{ {
// 4J - added initialiser // 4J - added initialiser
ignoreUpdate(false); ignoreUpdate(false);

View file

@ -4,7 +4,7 @@
#include "../Util/Facing.h" #include "../Util/Facing.h"
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
PistonExtensionTile::PistonExtensionTile(int id) : Tile(id, Material::piston,isSolidRender() ) PistonExtensionTile::PistonExtensionTile(int id) : Tile(id, Material::piston, false)
{ {
// 4J added initialiser // 4J added initialiser
overrideTopTexture = NULL; overrideTopTexture = NULL;
@ -207,4 +207,4 @@ int PistonExtensionTile::getFacing(int data)
int PistonExtensionTile::cloneTileId(Level *level, int x, int y, int z) int PistonExtensionTile::cloneTileId(Level *level, int x, int y, int z)
{ {
return 0; return 0;
} }

View file

@ -6,7 +6,7 @@
#include "../Util/Facing.h" #include "../Util/Facing.h"
#include "../Util/AABB.h" #include "../Util/AABB.h"
PistonMovingPiece::PistonMovingPiece(int id) : EntityTile(id, Material::piston, isSolidRender() ) PistonMovingPiece::PistonMovingPiece(int id) : EntityTile(id, Material::piston, false )
{ {
setDestroyTime(INDESTRUCTIBLE_DESTROY_TIME); setDestroyTime(INDESTRUCTIBLE_DESTROY_TIME);
} }

View file

@ -9,12 +9,12 @@ void Bush::_init()
updateDefaultShape(); updateDefaultShape();
} }
Bush::Bush(int id, Material *material) : Tile(id, material, isSolidRender()) Bush::Bush(int id, Material *material) : Tile(id, material, false)
{ {
_init(); _init();
} }
Bush::Bush(int id) : Tile(id, Material::plant, isSolidRender()) Bush::Bush(int id) : Tile(id, Material::plant, false)
{ {
_init(); _init();
} }

View file

@ -7,7 +7,7 @@
#include "PressurePlateTile.h" #include "PressurePlateTile.h"
#include "../Util/SoundTypes.h" #include "../Util/SoundTypes.h"
PressurePlateTile::PressurePlateTile(int id, const std::wstring &tex, Material *material, Sensitivity sensitivity) : Tile(id, material, isSolidRender()) PressurePlateTile::PressurePlateTile(int id, const std::wstring &tex, Material *material, Sensitivity sensitivity) : Tile(id, material, false)
{ {
this->sensitivity = sensitivity; this->sensitivity = sensitivity;
this->setTicking(true); this->setTicking(true);
@ -208,4 +208,4 @@ int PressurePlateTile::getPistonPushReaction()
void PressurePlateTile::registerIcons(IconRegister *iconRegister) void PressurePlateTile::registerIcons(IconRegister *iconRegister)
{ {
icon = iconRegister->registerIcon(texture); icon = iconRegister->registerIcon(texture);
} }

View file

@ -363,7 +363,9 @@ bool RailTile::isRail(int id)
return id == Tile::rail_Id || id == Tile::goldenRail_Id || id == Tile::detectorRail_Id; return id == Tile::rail_Id || id == Tile::goldenRail_Id || id == Tile::detectorRail_Id;
} }
RailTile::RailTile(int id, bool usesDataBit) : Tile(id, Material::decoration, isSolidRender()) // 4jcraft, changed from isSolidRender() to false, _init was changed by 4jstudios
// to take in a bool to avoid calling isSolidRender before the vptr is set,
RailTile::RailTile(int id, bool usesDataBit) : Tile(id, Material::decoration, false)
{ {
this->usesDataBit = usesDataBit; this->usesDataBit = usesDataBit;
this->setShape(0, 0, 0, 1, 2 / 16.0f, 1); this->setShape(0, 0, 0, 1, 2 / 16.0f, 1);
@ -673,4 +675,4 @@ void RailTile::registerIcons(IconRegister *iconRegister)
{ {
iconTurn = iconRegister->registerIcon(L"rail_turn"); iconTurn = iconRegister->registerIcon(L"rail_turn");
} }
} }

View file

@ -16,7 +16,7 @@ const std::wstring RedStoneDustTile::TEXTURE_LINE = L"redstoneDust_line";
const std::wstring RedStoneDustTile::TEXTURE_CROSS_OVERLAY = L"redstoneDust_cross_overlay"; const std::wstring RedStoneDustTile::TEXTURE_CROSS_OVERLAY = L"redstoneDust_cross_overlay";
const std::wstring RedStoneDustTile::TEXTURE_LINE_OVERLAY = L"redstoneDust_line_overlay"; const std::wstring RedStoneDustTile::TEXTURE_LINE_OVERLAY = L"redstoneDust_line_overlay";
RedStoneDustTile::RedStoneDustTile(int id) : Tile(id, Material::decoration,isSolidRender()) RedStoneDustTile::RedStoneDustTile(int id) : Tile(id, Material::decoration, false)
{ {
shouldSignal = true; shouldSignal = true;

View file

@ -6,7 +6,7 @@
#include "../Headers/net.minecraft.world.phys.h" #include "../Headers/net.minecraft.world.phys.h"
#include "ReedTile.h" #include "ReedTile.h"
ReedTile::ReedTile(int id) : Tile( id, Material::plant,isSolidRender() ) ReedTile::ReedTile(int id) : Tile( id, Material::plant, false)
{ {
this->updateDefaultShape(); this->updateDefaultShape();
this->setTicking(true); this->setTicking(true);

View file

@ -5,7 +5,7 @@
#include "TileEntities/SignTileEntity.h" #include "TileEntities/SignTileEntity.h"
#include "SignTile.h" #include "SignTile.h"
SignTile::SignTile(int id, eINSTANCEOF clas, bool onGround) : EntityTile(id, Material::wood, isSolidRender()) SignTile::SignTile(int id, eINSTANCEOF clas, bool onGround) : EntityTile(id, Material::wood, false)
{ {
this->onGround = onGround; this->onGround = onGround;
this->clas = clas; this->clas = clas;
@ -126,4 +126,4 @@ int SignTile::cloneTileId(Level *level, int x, int y, int z)
void SignTile::registerIcons(IconRegister *iconRegister) void SignTile::registerIcons(IconRegister *iconRegister)
{ {
// None // None
} }

View file

@ -5,7 +5,7 @@
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "SkullTile.h" #include "SkullTile.h"
SkullTile::SkullTile(int id) : EntityTile(id, Material::decoration, isSolidRender() ) SkullTile::SkullTile(int id) : EntityTile(id, Material::decoration, false)
{ {
setShape(4.0f / 16.0f, 0, 4.0f / 16.0f, 12.0f / 16.0f, .5f, 12.0f / 16.0f); setShape(4.0f / 16.0f, 0, 4.0f / 16.0f, 12.0f / 16.0f, .5f, 12.0f / 16.0f);
} }
@ -267,4 +267,4 @@ std::wstring SkullTile::getTileItemIconName()
{ {
return L""; return L"";
//return SkullItem::ICON_NAMES[0]; //return SkullItem::ICON_NAMES[0];
} }

View file

@ -10,7 +10,7 @@ int StairTile::DEAD_SPACES[8][2] = {
{0, 4}, {1, 5}, {0, 1}, {4, 5} {0, 4}, {1, 5}, {0, 1}, {4, 5}
}; };
StairTile::StairTile(int id, Tile *base,int basedata) : Tile(id, base->material, isSolidRender()) StairTile::StairTile(int id, Tile *base,int basedata) : Tile(id, base->material, false)
{ {
this->base = base; this->base = base;
this->basedata = basedata; this->basedata = basedata;

View file

@ -6,7 +6,7 @@
const std::wstring TheEndPortalFrameTile::TEXTURE_EYE = L"endframe_eye"; const std::wstring TheEndPortalFrameTile::TEXTURE_EYE = L"endframe_eye";
TheEndPortalFrameTile::TheEndPortalFrameTile(int id) : Tile(id, Material::glass, isSolidRender() ) TheEndPortalFrameTile::TheEndPortalFrameTile(int id) : Tile(id, Material::glass, false )
{ {
iconTop = NULL; iconTop = NULL;
iconEye = NULL; iconEye = NULL;

View file

@ -58,7 +58,7 @@ void TheEndPortal::allowAnywhere(bool set)
TheEndPortalTlsSetValue(tlsIdx, reinterpret_cast<void *>(static_cast<intptr_t>(set ? 1 : 0))); TheEndPortalTlsSetValue(tlsIdx, reinterpret_cast<void *>(static_cast<intptr_t>(set ? 1 : 0)));
} }
TheEndPortal::TheEndPortal(int id, Material *material) : EntityTile(id, material, isSolidRender()) TheEndPortal::TheEndPortal(int id, Material *material) : EntityTile(id, material, false)
{ {
this->setLightEmission(1.0f); this->setLightEmission(1.0f);
} }

View file

@ -3,7 +3,7 @@
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
ThinFenceTile::ThinFenceTile(int id, const std::wstring &tex, const std::wstring &edgeTex, Material *material, bool dropsResources) : Tile(id, material,isSolidRender()) ThinFenceTile::ThinFenceTile(int id, const std::wstring &tex, const std::wstring &edgeTex, Material *material, bool dropsResources) : Tile(id, material, false)
{ {
iconSide = NULL; iconSide = NULL;
edgeTexture = edgeTex; edgeTexture = edgeTex;

View file

@ -283,12 +283,13 @@ void BrewingStandTileEntity::load(CompoundTag *base)
{ {
TileEntity::load(base); TileEntity::load(base);
ListTag<CompoundTag> *inventoryList = (ListTag<CompoundTag> *) base->getList(L"Items"); ListTag<Tag> *inventoryList = base->getList(L"Items");
delete [] items.data;
delete [] items.data;
items = ItemInstanceArray(getContainerSize()); items = ItemInstanceArray(getContainerSize());
for (int i = 0; i < inventoryList->size(); i++) for (int i = 0; i < inventoryList->size(); i++)
{ {
CompoundTag *tag = inventoryList->get(i); CompoundTag *tag = (CompoundTag*) inventoryList->get(i);
int slot = tag->getByte(L"Slot"); int slot = tag->getByte(L"Slot");
if (slot >= 0 && slot < items.length) items[slot] = ItemInstance::fromTag(tag); if (slot >= 0 && slot < items.length) items[slot] = ItemInstance::fromTag(tag);
} }
@ -430,4 +431,4 @@ std::shared_ptr<TileEntity> BrewingStandTileEntity::clone()
} }
} }
return result; return result;
} }

View file

@ -95,7 +95,11 @@ int ChestTileEntity::getName()
void ChestTileEntity::load(CompoundTag *base) void ChestTileEntity::load(CompoundTag *base)
{ {
TileEntity::load(base); TileEntity::load(base);
ListTag<CompoundTag> *inventoryList = (ListTag<CompoundTag> *) base->getList(L"Items");
// 4jcraft, fixed cast of templated List to get the tag list
// and cast it to CompoundTag inside the loop
ListTag<Tag> *inventoryList = base->getList(L"Items");
if( items ) if( items )
{ {
delete [] items->data; delete [] items->data;
@ -104,7 +108,7 @@ void ChestTileEntity::load(CompoundTag *base)
items = new ItemInstanceArray(getContainerSize()); items = new ItemInstanceArray(getContainerSize());
for (int i = 0; i < inventoryList->size(); i++) for (int i = 0; i < inventoryList->size(); i++)
{ {
CompoundTag *tag = inventoryList->get(i); CompoundTag *tag = (CompoundTag*) inventoryList->get(i);
unsigned int slot = tag->getByte(L"Slot") & 0xff; unsigned int slot = tag->getByte(L"Slot") & 0xff;
if (slot >= 0 && slot < items->length) (*items)[slot] = ItemInstance::fromTag(tag); if (slot >= 0 && slot < items->length) (*items)[slot] = ItemInstance::fromTag(tag);
} }
@ -286,4 +290,4 @@ std::shared_ptr<TileEntity> ChestTileEntity::clone()
} }
} }
return result; return result;
} }

View file

@ -100,11 +100,14 @@ int FurnaceTileEntity::getName()
void FurnaceTileEntity::load(CompoundTag *base) void FurnaceTileEntity::load(CompoundTag *base)
{ {
TileEntity::load(base); TileEntity::load(base);
ListTag<CompoundTag> *inventoryList = (ListTag<CompoundTag> *) base->getList(L"Items"); // 4jcraft, fixed cast of templated List to get the tag list
// and cast it to CompoundTag inside the loop
ListTag<Tag> *inventoryList = base->getList(L"Items");
items = new ItemInstanceArray(getContainerSize()); items = new ItemInstanceArray(getContainerSize());
for (int i = 0; i < inventoryList->size(); i++) for (int i = 0; i < inventoryList->size(); i++)
{ {
CompoundTag *tag = inventoryList->get(i); CompoundTag *tag = (CompoundTag*) inventoryList->get(i);
unsigned int slot = tag->getByte(L"Slot"); unsigned int slot = tag->getByte(L"Slot");
if (slot >= 0 && slot < items->length) (*items)[slot] = ItemInstance::fromTag(tag); if (slot >= 0 && slot < items->length) (*items)[slot] = ItemInstance::fromTag(tag);
} }
@ -347,4 +350,4 @@ std::shared_ptr<TileEntity> FurnaceTileEntity::clone()
} }
} }
return result; return result;
} }

View file

@ -13,7 +13,7 @@ const int TopSnowTile::MAX_HEIGHT = 6;
const int TopSnowTile::HEIGHT_MASK = 7; // max 8 steps const int TopSnowTile::HEIGHT_MASK = 7; // max 8 steps
TopSnowTile::TopSnowTile(int id) : Tile(id, Material::topSnow,isSolidRender()) TopSnowTile::TopSnowTile(int id) : Tile(id, Material::topSnow, false)
{ {
setShape(0, 0, 0, 1, 2 / 16.0f, 1); setShape(0, 0, 0, 1, 2 / 16.0f, 1);
setTicking(true); setTicking(true);

View file

@ -4,7 +4,7 @@
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "TorchTile.h" #include "TorchTile.h"
TorchTile::TorchTile(int id) : Tile(id, Material::decoration,isSolidRender()) TorchTile::TorchTile(int id) : Tile(id, Material::decoration, false)
{ {
this->setTicking(true); this->setTicking(true);
} }

View file

@ -6,7 +6,7 @@
#include "TrapDoorTile.h" #include "TrapDoorTile.h"
TrapDoorTile::TrapDoorTile(int id, Material *material) : Tile(id, material,isSolidRender()) TrapDoorTile::TrapDoorTile(int id, Material *material) : Tile(id, material, false)
{ {
float r = 0.5f; float r = 0.5f;
float h = 1.0f; float h = 1.0f;
@ -206,4 +206,4 @@ bool TrapDoorTile::attachesTo(int id)
Tile *tile = Tile::tiles[id]; Tile *tile = Tile::tiles[id];
return tile != NULL && (tile->material->isSolidBlocking() && tile->isCubeShaped()) || tile == Tile::lightGem || (dynamic_cast<HalfSlabTile *>(tile) != NULL) || (dynamic_cast<StairTile *>(tile) != NULL); return tile != NULL && (tile->material->isSolidBlocking() && tile->isCubeShaped()) || tile == Tile::lightGem || (dynamic_cast<HalfSlabTile *>(tile) != NULL) || (dynamic_cast<StairTile *>(tile) != NULL);
} }

View file

@ -4,7 +4,7 @@
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "TripWireSourceTile.h" #include "TripWireSourceTile.h"
TripWireSourceTile::TripWireSourceTile(int id) : Tile(id, Material::decoration, isSolidRender()) TripWireSourceTile::TripWireSourceTile(int id) : Tile(id, Material::decoration, false)
{ {
this->setTicking(true); this->setTicking(true);
} }

View file

@ -5,7 +5,7 @@
#include "../Headers/net.minecraft.world.phys.h" #include "../Headers/net.minecraft.world.phys.h"
#include "TripWireTile.h" #include "TripWireTile.h"
TripWireTile::TripWireTile(int id) : Tile(id, Material::decoration, isSolidRender()) TripWireTile::TripWireTile(int id) : Tile(id, Material::decoration, false)
{ {
setShape(0, 0, 0, 1, 2.5f / 16.0f, 1); setShape(0, 0, 0, 1, 2.5f / 16.0f, 1);
this->setTicking(true); this->setTicking(true);

View file

@ -8,7 +8,7 @@
#include "../Headers/net.minecraft.stats.h" #include "../Headers/net.minecraft.stats.h"
#include "../Headers/net.minecraft.world.level.biome.h" #include "../Headers/net.minecraft.world.level.biome.h"
VineTile::VineTile(int id) : Tile(id, Material::replaceable_plant, isSolidRender() ) VineTile::VineTile(int id) : Tile(id, Material::replaceable_plant, false)
{ {
setTicking(true); setTicking(true);
} }

View file

@ -15,7 +15,7 @@ const unsigned int WallTile::COBBLE_NAMES[2] = { IDS_TILE_COBBLESTONE_WALL,
IDS_TILE_COBBLESTONE_WALL_MOSSY, IDS_TILE_COBBLESTONE_WALL_MOSSY,
}; };
WallTile::WallTile(int id, Tile *baseTile) : Tile(id, baseTile->material, isSolidRender()) WallTile::WallTile(int id, Tile *baseTile) : Tile(id, baseTile->material, false)
{ {
setDestroyTime(baseTile->destroySpeed); setDestroyTime(baseTile->destroySpeed);
setExplodeable(baseTile->explosionResistance / 3); setExplodeable(baseTile->explosionResistance / 3);

View file

@ -4,7 +4,7 @@
#include "../Util/SharedConstants.h" #include "../Util/SharedConstants.h"
#include "WoolCarpetTile.h" #include "WoolCarpetTile.h"
WoolCarpetTile::WoolCarpetTile(int id) : Tile(id, Material::clothDecoration, isSolidRender() ) WoolCarpetTile::WoolCarpetTile(int id) : Tile(id, Material::clothDecoration, false)
{ {
setShape(0, 0, 0, 1, 1 / 16.0f, 1); setShape(0, 0, 0, 1, 1 / 16.0f, 1);
setTicking(true); setTicking(true);

View file

@ -135,11 +135,11 @@ MerchantRecipeList *MerchantRecipeList::createFromStream(DataInputStream *stream
void MerchantRecipeList::load(CompoundTag *tag) void MerchantRecipeList::load(CompoundTag *tag)
{ {
ListTag<CompoundTag> *list = (ListTag<CompoundTag> *) tag->getList(L"Recipes"); ListTag<Tag> *list = tag->getList(L"Recipes");
for (int i = 0; i < list->size(); i++) for (int i = 0; i < list->size(); i++)
{ {
CompoundTag *recipeTag = list->get(i); CompoundTag *recipeTag = (CompoundTag*) list->get(i);
m_recipes.push_back(new MerchantRecipe(recipeTag)); m_recipes.push_back(new MerchantRecipe(recipeTag));
} }
} }
@ -192,4 +192,4 @@ size_t MerchantRecipeList::size()
bool MerchantRecipeList::empty() bool MerchantRecipeList::empty()
{ {
return m_recipes.empty(); return m_recipes.empty();
} }

View file

@ -1375,13 +1375,15 @@ void Entity::saveWithoutId(CompoundTag *entityTag)
void Entity::load(CompoundTag *tag) void Entity::load(CompoundTag *tag)
{ {
ListTag<DoubleTag> *pos = (ListTag<DoubleTag> *) tag->getList(L"Pos"); // 4jcraft changed c style cast of templated class
ListTag<DoubleTag> *motion = (ListTag<DoubleTag> *) tag->getList(L"Motion"); // to getting the actual type and casting when needed
ListTag<FloatTag> *rotation = (ListTag<FloatTag> *) tag->getList(L"Rotation"); ListTag<Tag> *pos = tag->getList(L"Pos");
ListTag<Tag> *motion = tag->getList(L"Motion");
ListTag<Tag> *rotation = tag->getList(L"Rotation");
xd = motion->get(0)->data; xd = ((DoubleTag*)motion->get(0))->data;
yd = motion->get(1)->data; yd = ((DoubleTag*)motion->get(1))->data;
zd = motion->get(2)->data; zd = ((DoubleTag*)motion->get(2))->data;
if (abs(xd) > 10.0) if (abs(xd) > 10.0)
{ {
@ -1396,12 +1398,12 @@ void Entity::load(CompoundTag *tag)
zd = 0; zd = 0;
} }
xo = xOld = x = pos->get(0)->data; xo = xOld = x = ((DoubleTag*)pos->get(0))->data;
yo = yOld = y = pos->get(1)->data; yo = yOld = y = ((DoubleTag*)pos->get(1))->data;
zo = zOld = z = pos->get(2)->data; zo = zOld = z = ((DoubleTag*)pos->get(2))->data;
yRotO = yRot = rotation->get(0)->data; yRotO = yRot = ((FloatTag*)rotation->get(0))->data;
xRotO = xRot = rotation->get(1)->data; xRotO = xRot = ((FloatTag*)rotation->get(1))->data;
fallDistance = tag->getFloat(L"FallDistance"); fallDistance = tag->getFloat(L"FallDistance");
onFire = tag->getShort(L"Fire"); onFire = tag->getShort(L"Fire");

View file

@ -802,6 +802,15 @@ bool ConsoleSaveFileSplit::zeroFile(FileEntry *file, unsigned int nNumberOfBytes
return false; return false;
} }
// 4jcraft added: memset(NULL + 0, 0, 0); was called
// no bytes need to be written, hence there you go
if(nNumberOfBytesToWrite == 0) {
if(lpNumberOfBytesWritten) {
*lpNumberOfBytesWritten = 0;
}
return 1;
}
LockSaveAccess(); LockSaveAccess();
if( file->isRegionFile() ) if( file->isRegionFile() )
@ -1229,7 +1238,8 @@ bool ConsoleSaveFileSplit::GetNumericIdentifierFromName(const std::wstring &file
swscanf_s(body, L"%d.%d.mcr", &x, &z ); swscanf_s(body, L"%d.%d.mcr", &x, &z );
// Pack full id // Pack full id
id |= ( ( x << 8 ) & 0x0000ff00 ); // 4jcraft added cast to unsigned
id |= ( ( (unsigned int) x << 8 ) & 0x0000ff00 );
id |= ( z & 0x000000ff ); id |= ( z & 0x000000ff );
*idOut = id; *idOut = id;

View file

@ -194,8 +194,11 @@ public:
ListTag<Tag> *getList(const wchar_t * name) ListTag<Tag> *getList(const wchar_t * name)
{ {
if (tags.find(name) == tags.end()) return new ListTag<Tag>(name); // 4jcraft changed this function to not do a c style cast
return (ListTag<Tag> *) tags[name]; // of a templated class
auto it = tags.find(name);
if(it == tags.end()) return new ListTag<Tag>(name);
return dynamic_cast<ListTag<Tag>*>(it->second);
} }
bool getBoolean(const wchar_t *string) bool getBoolean(const wchar_t *string)

View file

@ -3266,7 +3266,7 @@ void Level::tickClientSideTiles(int xo, int zo, LevelChunk *lc)
if (delayUntilNextMoodSound == 0) if (delayUntilNextMoodSound == 0)
{ {
randValue = randValue * 3 + addend; randValue = (unsigned) randValue * 3 + (unsigned) addend;
int val = (randValue >> 2); int val = (randValue >> 2);
int x = (val & 15); int x = (val & 15);
int z = ((val >> 8) & 15); int z = ((val >> 8) & 15);

View file

@ -459,7 +459,7 @@ bool LevelChunk::isAt(int x, int z)
int LevelChunk::getHeightmap(int x, int z) int LevelChunk::getHeightmap(int x, int z)
{ {
return heightmap[z << 4 | x] & 0xff; return heightmap[(unsigned) z << 4 | x] & 0xff;
} }
int LevelChunk::getHighestSectionPosition() int LevelChunk::getHighestSectionPosition()
@ -492,12 +492,12 @@ void LevelChunk::recalcHeightmapOnly()
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++) for (int z = 0; z < 16; z++)
{ {
rainHeights[x + (z << 4)] = 255; // 4J - changed from int to unsigned char & this special value changed from -999 to 255 rainHeights[x + ((unsigned) z << 4)] = 255; // 4J - changed from int to unsigned char & this special value changed from -999 to 255
int y = Level::maxBuildHeight - 1; int y = Level::maxBuildHeight - 1;
// int p = x << level->depthBitsPlusFour | z << level->depthBits; // 4J - removed // int p = x << level->depthBitsPlusFour | z << level->depthBits; // 4J - removed
#ifdef __PSVITA__ #ifdef __PSVITA__
int Index = ( x << 11 ) + ( z << 7 ); int Index = ( (unsigned) x << 11 ) + ( (unsigned) z << 7 );
int offset = Level::COMPRESSED_CHUNK_SECTION_TILES; int offset = Level::COMPRESSED_CHUNK_SECTION_TILES;
y = 127; y = 127;
while (y > 0 && Tile::lightBlock[blockData[Index + offset + (y - 1)]] == 0) // 4J - was blocks->get() was blocks[p + y - 1] while (y > 0 && Tile::lightBlock[blockData[Index + offset + (y - 1)]] == 0) // 4J - was blocks->get() was blocks[p + y - 1]
@ -525,7 +525,7 @@ void LevelChunk::recalcHeightmapOnly()
blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks; blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks;
} }
#endif #endif
heightmap[z << 4 | x] = (uint8_t) y; heightmap[(unsigned) z << 4 | x] = (uint8_t) y;
if (y < min) min = y; if (y < min) min = y;
} }
@ -553,7 +553,7 @@ void LevelChunk::recalcHeightmap()
// int p = x << level->depthBitsPlusFour | z << level->depthBits; // 4J - removed // int p = x << level->depthBitsPlusFour | z << level->depthBits; // 4J - removed
#ifdef __PSVITA__ #ifdef __PSVITA__
int Index = ( x << 11 ) + ( z << 7 ); int Index = ( (unsigned) x << 11 ) + ( (unsigned) z << 7 );
int offset = Level::COMPRESSED_CHUNK_SECTION_TILES; int offset = Level::COMPRESSED_CHUNK_SECTION_TILES;
y = 127; y = 127;
while (y > 0 && Tile::lightBlock[blockData[Index + offset + (y - 1)]] == 0) // 4J - was blocks->get() was blocks[p + y - 1] while (y > 0 && Tile::lightBlock[blockData[Index + offset + (y - 1)]] == 0) // 4J - was blocks->get() was blocks[p + y - 1]
@ -581,7 +581,7 @@ void LevelChunk::recalcHeightmap()
blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks; blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks;
} }
#endif #endif
heightmap[z << 4 | x] = (uint8_t) y; heightmap[(unsigned) z << 4 | x] = (uint8_t) y;
if (y < min) min = y; if (y < min) min = y;
if (!level->dimension->hasCeiling) if (!level->dimension->hasCeiling)
@ -788,7 +788,7 @@ void LevelChunk::lightGap(int x, int z, int y1, int y2)
void LevelChunk::recalcHeight(int x, int yStart, int z) void LevelChunk::recalcHeight(int x, int yStart, int z)
{ {
int yOld = heightmap[z << 4 | x] & 0xff; int yOld = heightmap[(unsigned) z << 4 | x] & 0xff;
int y = yOld; int y = yOld;
if (yStart > yOld) y = yStart; if (yStart > yOld) y = yStart;
@ -803,7 +803,7 @@ void LevelChunk::recalcHeight(int x, int yStart, int z)
if (y == yOld) return; if (y == yOld) return;
// level->lightColumnChanged(x, z, y, yOld); // 4J - this call moved below & corrected - see comment further down // level->lightColumnChanged(x, z, y, yOld); // 4J - this call moved below & corrected - see comment further down
heightmap[z << 4 | x] = (uint8_t) y; heightmap[(unsigned) z << 4 | x] = (uint8_t) y;
if (y < minHeight) if (y < minHeight)
{ {
@ -815,7 +815,7 @@ void LevelChunk::recalcHeight(int x, int yStart, int z)
for (int _x = 0; _x < 16; _x++) for (int _x = 0; _x < 16; _x++)
for (int _z = 0; _z < 16; _z++) for (int _z = 0; _z < 16; _z++)
{ {
if ((heightmap[_z << 4 | _x] & 0xff) < min) min = (heightmap[_z << 4 | _x] & 0xff); if ((heightmap[(unsigned) _z << 4 | _x] & 0xff) < min) min = (heightmap[(unsigned) _z << 4 | _x] & 0xff);
} }
this->minHeight = min; this->minHeight = min;
} }
@ -865,7 +865,7 @@ void LevelChunk::recalcHeight(int x, int yStart, int z)
level->lightColumnChanged(xOffs, zOffs, y, yOld); level->lightColumnChanged(xOffs, zOffs, y, yOld);
// 4J - lighting changes brought forward from 1.8.2 // 4J - lighting changes brought forward from 1.8.2
int height = heightmap[z << 4 | x]; int height = heightmap[(unsigned) z << 4 | x];
int y1 = yOld; int y1 = yOld;
int y2 = height; int y2 = height;
if (y2 < y1) if (y2 < y1)
@ -913,7 +913,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
uint8_t tile = (uint8_t) _tile; uint8_t tile = (uint8_t) _tile;
// Optimisation brought forward from 1.8.2, change from int to unsigned char & this special value changed from -999 to 255 // Optimisation brought forward from 1.8.2, change from int to unsigned char & this special value changed from -999 to 255
int slot = z << 4 | x; int slot = (unsigned) z << 4 | x;
if (y >= ((int)rainHeights[slot]) - 1) if (y >= ((int)rainHeights[slot]) - 1)
{ {
@ -1246,7 +1246,7 @@ void LevelChunk::removeEntity(std::shared_ptr<Entity> e, int yc)
bool LevelChunk::isSkyLit(int x, int y, int z) bool LevelChunk::isSkyLit(int x, int y, int z)
{ {
return y >= (heightmap[z << 4 | x] & 0xff); return y >= (heightmap[(unsigned) z << 4 | x] & 0xff);
} }
void LevelChunk::skyBrightnessChanged() void LevelChunk::skyBrightnessChanged()
@ -1979,12 +1979,13 @@ bool LevelChunk::isYSpaceEmpty(int y1, int y2)
Biome *LevelChunk::getBiome(int x, int z, BiomeSource *biomeSource) Biome *LevelChunk::getBiome(int x, int z, BiomeSource *biomeSource)
{ {
int value = biomes[(z << 4) | x] & 0xff; int value = biomes[((unsigned) z << 4) | x] & 0xff;
if (value == 0xff) if (value == 0xff)
{ {
Biome *biome = biomeSource->getBiome((this->x << 4) + x, (this->z << 4) + z); // 4jcraft added casts to u
Biome *biome = biomeSource->getBiome(((unsigned) this->x << 4) + x, ((unsigned) this->z << 4) + z);
value = biome->id; value = biome->id;
biomes[(z << 4) | x] = (uint8_t) (value & 0xff); biomes[((unsigned) z << 4) | x] = (uint8_t) (value & 0xff);
} }
if (Biome::biomes[value] == NULL) if (Biome::biomes[value] == NULL)
{ {
@ -2007,7 +2008,7 @@ void LevelChunk::setBiomes(byteArray biomes)
// 4J - optimisation brought forward from 1.8.2 // 4J - optimisation brought forward from 1.8.2
int LevelChunk::getTopRainBlock(int x, int z) int LevelChunk::getTopRainBlock(int x, int z)
{ {
int slot = x | (z << 4); int slot = x | ((unsigned) z << 4);
int h = rainHeights[slot]; int h = rainHeights[slot];
if (h == 255) if (h == 255)

View file

@ -144,7 +144,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
for (int x = 0; x < CHUNK_WIDTH; x++) for (int x = 0; x < CHUNK_WIDTH; x++)
{ {
int offs = (x + xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | (0 + zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y); int offs = (unsigned) (x + (unsigned) xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | ((unsigned) zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y);
int step = 1 << Level::genDepthBits; int step = 1 << Level::genDepthBits;
offs -= step; offs -= step;
double zStep = 1 / (double) CHUNK_WIDTH; double zStep = 1 / (double) CHUNK_WIDTH;
@ -654,7 +654,8 @@ void RandomLevelSource::postProcess(ChunkSource *parent, int xt, int zt)
pprandom->setSeed(level->getSeed()); pprandom->setSeed(level->getSeed());
__int64 xScale = pprandom->nextLong() / 2 * 2 + 1; __int64 xScale = pprandom->nextLong() / 2 * 2 + 1;
__int64 zScale = pprandom->nextLong() / 2 * 2 + 1; __int64 zScale = pprandom->nextLong() / 2 * 2 + 1;
pprandom->setSeed(((xt * xScale) + (zt * zScale)) ^ level->getSeed()); // 4jcraft added casts to a higher int and unsigned
pprandom->setSeed((((uint64_t)xt * (uint64_t)xScale) + ((uint64_t)zt * (uint64_t)zScale)) ^ level->getSeed());
bool hasVillage = false; bool hasVillage = false;

View file

@ -78,7 +78,9 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
// If we can't find the chunk in the save file, then we should remove any entities we might have for that chunk // If we can't find the chunk in the save file, then we should remove any entities we might have for that chunk
if(regionChunkInputStream == NULL) if(regionChunkInputStream == NULL)
{ {
__int64 index = ((__int64)(x) << 32) | (((__int64)(z))&0x00000000FFFFFFFF); // 4jcraft fixed cast from int to int64 and taking the mask of the upper bits
// and cast to unsigned
uint64_t index = ((uint64_t)(uint32_t)(x) << 32) | (((uint64_t)(uint32_t)(z)));
AUTO_VAR(it, m_entityData.find(index)); AUTO_VAR(it, m_entityData.find(index));
if(it != m_entityData.end()) if(it != m_entityData.end())
@ -235,7 +237,8 @@ void McRegionChunkStorage::saveEntities(Level *level, LevelChunk *levelChunk)
{ {
#ifdef SPLIT_SAVES #ifdef SPLIT_SAVES
PIXBeginNamedEvent(0,"Saving entities"); PIXBeginNamedEvent(0,"Saving entities");
__int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF); // 4j added cast to unsigned and changed index to u
uint64_t index = ((uint64_t)(uint32_t)(levelChunk->x) << 32) | (((uint64_t)(uint32_t)(levelChunk->z)));
delete m_entityData[index].data; delete m_entityData[index].data;

View file

@ -39,9 +39,9 @@ SparseDataStorage::SparseDataStorage()
XMemSet(data, 0, 128 * 127); XMemSet(data, 0, 128 * 127);
// Data and count packs together the pointer to our data and the count of planes allocated - 127 planes allocated in this case // Data and count packs together the pointer to our data and the count of planes allocated - 127 planes allocated in this case
#pragma warning ( disable : 4826 )
dataAndCount = 0x007F000000000000L | (( (__int64) planeIndices ) & 0x0000ffffffffffffL); dataAndCount = 0x007F000000000000L | (( (__int64) planeIndices ) & 0x0000ffffffffffffL);
#pragma warning ( default : 4826 )
#ifdef DATA_COMPRESSION_STATS #ifdef DATA_COMPRESSION_STATS
count = 128; count = 128;
#endif #endif
@ -58,9 +58,9 @@ SparseDataStorage::SparseDataStorage(bool isUpper)
} }
// Data and count packs together the pointer to our data and the count of planes allocated - 127 planes allocated in this case // Data and count packs together the pointer to our data and the count of planes allocated - 127 planes allocated in this case
#pragma warning ( disable : 4826 )
dataAndCount = 0x0000000000000000L | (( (__int64) planeIndices ) & 0x0000ffffffffffffL); dataAndCount = 0x0000000000000000L | (( (__int64) planeIndices ) & 0x0000ffffffffffffL);
#pragma warning ( default : 4826 )
#ifdef DATA_COMPRESSION_STATS #ifdef DATA_COMPRESSION_STATS
count = 128; count = 128;
#endif #endif
@ -96,9 +96,9 @@ SparseDataStorage::SparseDataStorage(SparseDataStorage *copyFrom)
// AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called. // AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called.
// This should never happen and this isn't a proper solution but fixes it for now. // This should never happen and this isn't a proper solution but fixes it for now.
#pragma warning ( disable : 4826 )
dataAndCount = ( sourceDataAndCount & 0xffff000000000000L ) | ( ((__int64) destIndicesAndData ) & 0x0000ffffffffffffL ); dataAndCount = ( sourceDataAndCount & 0xffff000000000000L ) | ( ((__int64) destIndicesAndData ) & 0x0000ffffffffffffL );
#pragma warning ( default : 4826 )
XMemCpy( destIndicesAndData, sourceIndicesAndData, sourceCount * 128 + 128 ); XMemCpy( destIndicesAndData, sourceIndicesAndData, sourceCount * 128 + 128 );
@ -175,9 +175,9 @@ void SparseDataStorage::setData(byteArray dataIn, unsigned int inOffset)
} }
// Get new data and count packed info // Get new data and count packed info
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ((__int64) planeIndices) & 0x0000ffffffffffffL; __int64 newDataAndCount = ((__int64) planeIndices) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= ((__int64)allocatedPlaneCount) << 48; newDataAndCount |= ((__int64)allocatedPlaneCount) << 48;
updateDataAndCount( newDataAndCount ); updateDataAndCount( newDataAndCount );
@ -400,9 +400,9 @@ void SparseDataStorage::addNewPlane(int y)
dataPointer[y] = lastLinesUsed; dataPointer[y] = lastLinesUsed;
// Get new data and count packed info // Get new data and count packed info
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL; __int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= ((__int64)linesUsed) << 48; newDataAndCount |= ((__int64)linesUsed) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at // Attempt to update the data & count atomically. This command will Only succeed if the data stored at
@ -557,9 +557,9 @@ int SparseDataStorage::compress()
} }
// Get new data and count packed info // Get new data and count packed info
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ((__int64) newIndicesAndData) & 0x0000ffffffffffffL; __int64 newDataAndCount = ((__int64) newIndicesAndData) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= ((__int64)planesToAlloc) << 48; newDataAndCount |= ((__int64)planesToAlloc) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at // Attempt to update the data & count atomically. This command will Only succeed if the data stored at
@ -616,9 +616,9 @@ void SparseDataStorage::read(DataInputStream *dis)
byteArray wrapper(dataPointer, count * 128 + 128); byteArray wrapper(dataPointer, count * 128 + 128);
dis->readFully(wrapper); dis->readFully(wrapper);
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL; __int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= ((__int64)count) << 48; newDataAndCount |= ((__int64)count) << 48;
updateDataAndCount(newDataAndCount); updateDataAndCount(newDataAndCount);

View file

@ -39,9 +39,9 @@ SparseLightStorage::SparseLightStorage(bool sky)
XMemSet(data, 0, 128 * 127); XMemSet(data, 0, 128 * 127);
// Data and count packs together the pointer to our data and the count of planes allocated - 127 planes allocated in this case // Data and count packs together the pointer to our data and the count of planes allocated - 127 planes allocated in this case
#pragma warning ( disable : 4826 )
dataAndCount = 0x007F000000000000L | (( (__int64) planeIndices ) & 0x0000ffffffffffffL); dataAndCount = 0x007F000000000000L | (( (__int64) planeIndices ) & 0x0000ffffffffffffL);
#pragma warning ( default : 4826 )
#ifdef LIGHT_COMPRESSION_STATS #ifdef LIGHT_COMPRESSION_STATS
count = 127; count = 127;
#endif #endif
@ -58,9 +58,9 @@ SparseLightStorage::SparseLightStorage(bool sky, bool isUpper)
} }
// Data and count packs together the pointer to our data and the count of planes allocated - 0 planes allocated in this case // Data and count packs together the pointer to our data and the count of planes allocated - 0 planes allocated in this case
#pragma warning ( disable : 4826 )
dataAndCount = 0x0000000000000000L | (( (__int64) planeIndices ) & 0x0000ffffffffffffL); dataAndCount = 0x0000000000000000L | (( (__int64) planeIndices ) & 0x0000ffffffffffffL);
#pragma warning ( default : 4826 )
#ifdef LIGHT_COMPRESSION_STATS #ifdef LIGHT_COMPRESSION_STATS
count = 0; count = 0;
#endif #endif
@ -96,9 +96,9 @@ SparseLightStorage::SparseLightStorage(SparseLightStorage *copyFrom)
// AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called. // AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called.
// This should never happen and this isn't a proper solution but fixes it for now. // This should never happen and this isn't a proper solution but fixes it for now.
#pragma warning ( disable : 4826 )
dataAndCount = ( sourceDataAndCount & 0xffff000000000000L ) | ( ((__int64) destIndicesAndData ) & 0x0000ffffffffffffL ); dataAndCount = ( sourceDataAndCount & 0xffff000000000000L ) | ( ((__int64) destIndicesAndData ) & 0x0000ffffffffffffL );
#pragma warning ( default : 4826 )
XMemCpy( destIndicesAndData, sourceIndicesAndData, sourceCount * 128 + 128 ); XMemCpy( destIndicesAndData, sourceIndicesAndData, sourceCount * 128 + 128 );
@ -179,9 +179,9 @@ void SparseLightStorage::setData(byteArray dataIn, unsigned int inOffset)
} }
// Get new data and count packed info // Get new data and count packed info
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ((__int64) planeIndices) & 0x0000ffffffffffffL; __int64 newDataAndCount = ((__int64) planeIndices) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= ((__int64)allocatedPlaneCount) << 48; newDataAndCount |= ((__int64)allocatedPlaneCount) << 48;
updateDataAndCount( newDataAndCount ); updateDataAndCount( newDataAndCount );
@ -311,9 +311,9 @@ void SparseLightStorage::setAllBright()
planeIndices[i] = ALL_15_INDEX; planeIndices[i] = ALL_15_INDEX;
} }
// Data and count packs together the pointer to our data and the count of planes allocated, which is currently zero // Data and count packs together the pointer to our data and the count of planes allocated, which is currently zero
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ( (__int64) planeIndices ) & 0x0000ffffffffffffL; __int64 newDataAndCount = ( (__int64) planeIndices ) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
updateDataAndCount( newDataAndCount ); updateDataAndCount( newDataAndCount );
} }
@ -406,9 +406,9 @@ void SparseLightStorage::addNewPlane(int y)
dataPointer[y] = lastLinesUsed; dataPointer[y] = lastLinesUsed;
// Get new data and count packed info // Get new data and count packed info
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL; __int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= ((__int64)linesUsed) << 48; newDataAndCount |= ((__int64)linesUsed) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at // Attempt to update the data & count atomically. This command will Only succeed if the data stored at
@ -574,9 +574,9 @@ int SparseLightStorage::compress()
} }
// Get new data and count packed info // Get new data and count packed info
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ((__int64) newIndicesAndData) & 0x0000ffffffffffffL; __int64 newDataAndCount = ((__int64) newIndicesAndData) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= ((__int64)planesToAlloc) << 48; newDataAndCount |= ((__int64)planesToAlloc) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at // Attempt to update the data & count atomically. This command will Only succeed if the data stored at
@ -633,9 +633,9 @@ void SparseLightStorage::read(DataInputStream *dis)
byteArray wrapper(dataPointer, count * 128 + 128); byteArray wrapper(dataPointer, count * 128 + 128);
dis->readFully(wrapper); dis->readFully(wrapper);
#pragma warning ( disable : 4826 )
__int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL; __int64 newDataAndCount = ((__int64) dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= ((__int64)count) << 48; newDataAndCount |= ((__int64)count) << 48;
updateDataAndCount( newDataAndCount ); updateDataAndCount( newDataAndCount );

View file

@ -30,7 +30,8 @@ bool TickNextTickData::equals(const void *o) const
int TickNextTickData::hashCode() const int TickNextTickData::hashCode() const
{ {
return (((x * 1024 * 1024) + (z * 1024) + y) * 256) + tileId; // 4jcraft added cast to unsigned
return ((((unsigned) x * 1024 * 1024) + ((unsigned) z * 1024) + (unsigned) y) * 256) + tileId;
} }
TickNextTickData *TickNextTickData::delay(__int64 l) TickNextTickData *TickNextTickData::delay(__int64 l)
@ -66,4 +67,4 @@ int TickNextTickData::hash_fnct(const TickNextTickData &k)
bool TickNextTickData::eq_test(const TickNextTickData &x, const TickNextTickData &y) bool TickNextTickData::eq_test(const TickNextTickData &x, const TickNextTickData &y)
{ {
return ( x.x == y.x ) && ( x.y == y.y ) && ( x.z == y.z ) && ( x.tileId == y.tileId ); return ( x.x == y.x ) && ( x.y == y.y ) && ( x.z == y.z ) && ( x.tileId == y.tileId );
} }

View file

@ -54,8 +54,9 @@ void ChunkTilesUpdatePacket::read(DataInputStream *dis) //throws IOException
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
xc = dis->readShort(); xc = dis->readShort();
zc = dis->readShort(); zc = dis->readShort();
xc = ( xc << 16 ) >> 16; // 4jcraft changed shift back and forth to a down cast
zc = ( zc << 16 ) >> 16; xc = (int16_t) xc;
zc = (int16_t) zc;
#else #else
xc = dis->read(); xc = dis->read();
zc = dis->read(); zc = dis->read();

View file

@ -1217,4 +1217,4 @@ void Recipes::buildRecipeIngredientsArray(void)
Recipy::INGREDIENTS_REQUIRED *Recipes::getRecipeIngredientsArray(void) Recipy::INGREDIENTS_REQUIRED *Recipes::getRecipeIngredientsArray(void)
{ {
return m_pRecipeIngredientsRequired; return m_pRecipeIngredientsRequired;
} }

View file

@ -141,11 +141,14 @@ void ShapedRecipy::requires(INGREDIENTS_REQUIRED *pIngReq)
TempIngReq.iIngC=0; TempIngReq.iIngC=0;
TempIngReq.iType = ((width>2) ||(height>2))?RECIPE_TYPE_3x3:RECIPE_TYPE_2x2; // 3x3 TempIngReq.iType = ((width>2) ||(height>2))?RECIPE_TYPE_3x3:RECIPE_TYPE_2x2; // 3x3
// 3x3 // 3x3
// 4jcraft, genuinly what is this garbage code
TempIngReq.uiGridA = new unsigned int [9]; TempIngReq.uiGridA = new unsigned int [9];
TempIngReq.iIngIDA= new int [9]; TempIngReq.iIngIDA= new int [9];
TempIngReq.iIngValA = new int [9]; TempIngReq.iIngValA = new int [9];
TempIngReq.iIngAuxValA = new int [9]; TempIngReq.iIngAuxValA = new int [9];
// 4jcraft,yes, yes!!
// use winapi and inbetween use a cstd function u could have used!
ZeroMemory(TempIngReq.iIngIDA,sizeof(int)*9); ZeroMemory(TempIngReq.iIngIDA,sizeof(int)*9);
ZeroMemory(TempIngReq.iIngValA,sizeof(int)*9); ZeroMemory(TempIngReq.iIngValA,sizeof(int)*9);
memset(TempIngReq.iIngAuxValA,Recipes::ANY_AUX_VALUE,sizeof(int)*9); memset(TempIngReq.iIngAuxValA,Recipes::ANY_AUX_VALUE,sizeof(int)*9);
@ -162,7 +165,8 @@ void ShapedRecipy::requires(INGREDIENTS_REQUIRED *pIngReq)
if (expected!=NULL) if (expected!=NULL)
{ {
int iAuxVal = expected->getAuxValue(); int iAuxVal = expected->getAuxValue();
TempIngReq.uiGridA[x+y*3]=expected->id | iAuxVal<<24; //4jcraft, added cast to uint (shift of negativ num, undefined)
TempIngReq.uiGridA[x+y*3]=expected->id | (unsigned int) iAuxVal<<24;
bFound=false; bFound=false;
for(j=0;j<TempIngReq.iIngC;j++) for(j=0;j<TempIngReq.iIngC;j++)
@ -227,4 +231,4 @@ ShapedRecipy *ShapedRecipy::keepTag()
{ {
_keepTag = true; _keepTag = true;
return this; return this;
} }

View file

@ -128,7 +128,8 @@ void ShapelessRecipy::requires(INGREDIENTS_REQUIRED *pIngReq)
if (expected!=NULL) if (expected!=NULL)
{ {
int iAuxVal = (*ingredient)->getAuxValue(); int iAuxVal = (*ingredient)->getAuxValue();
TempIngReq.uiGridA[iCount++]=expected->id | iAuxVal<<24; //4jcraft, added cast to uint, shift of negative int is undefined
TempIngReq.uiGridA[iCount++]=expected->id | (unsigned int) iAuxVal<<24;
// 4J-PB - put the ingredients in boxes 1,2,4,5 so we can see them in a 2x2 crafting screen // 4J-PB - put the ingredients in boxes 1,2,4,5 so we can see them in a 2x2 crafting screen
if(iCount==2) iCount=3; if(iCount==2) iCount=3;
bFound=false; bFound=false;
@ -179,4 +180,4 @@ void ShapelessRecipy::requires(INGREDIENTS_REQUIRED *pIngReq)
delete [] TempIngReq.iIngValA; delete [] TempIngReq.iIngValA;
delete [] TempIngReq.iIngAuxValA; delete [] TempIngReq.iIngAuxValA;
delete [] TempIngReq.uiGridA; delete [] TempIngReq.uiGridA;
} }

View file

@ -3,7 +3,8 @@
#include "I18n.h" #include "I18n.h"
Language *I18n::lang = Language::getInstance(); Language *I18n::lang = Language::getInstance();
std::wstring I18n::get(const std::wstring& id, ...) // 4jcraft const & into va_start is ub
std::wstring I18n::get(std::wstring id, ...)
{ {
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway #ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L""; return L"";

View file

@ -10,6 +10,6 @@ private:
static Language *lang; static Language *lang;
public: public:
static std::wstring get(const std::wstring& id, ...); static std::wstring get(std::wstring id, ...);
static std::wstring get(const std::wstring& id, va_list args); static std::wstring get(const std::wstring& id, va_list args);
}; };

View file

@ -9,11 +9,12 @@ struct IntKeyHash
{ {
int operator() (const int &k) const int operator() (const int &k) const
{ {
int h = k; // 4jcraft added h to be unsigned, to not cast it later
unsigned int h = k;
h += ~(h << 9); h += ~(h << 9);
h ^= (((unsigned int)h) >> 14); h ^= (h >> 14);
h += (h << 4); h += (h << 4);
h ^= (((unsigned int)h) >> 10); h ^= (h >> 10);
return h; return h;
} }
}; };

View file

@ -36,7 +36,20 @@ double Math::random()
//the value of the argument rounded to the nearest long value. //the value of the argument rounded to the nearest long value.
__int64 Math::round( double d ) __int64 Math::round( double d )
{ {
return (__int64)floor( d + 0.5 ); // 4jcraft fixes the fact that if double is a huge
// number than the cast of d to int64_t overflows
d = floor( d + 0.5 );
// if smaller or bigger than representable int64 than return the max
if(d >= (double)INT64_MAX) {
return INT64_MAX;
} else if (d <= (double)INT64_MIN) {
return INT64_MIN;
}
return (int64_t) d;
} }
int Math::_max(int a, int b) int Math::_max(int a, int b)
@ -73,4 +86,4 @@ double Math::wrapDegrees(double input)
if (input >= 180.0) input -= 360.0; if (input >= 180.0) input -= 360.0;
if (input < -180.0) input += 360.0; if (input < -180.0) input += 360.0;
return input; return input;
} }

View file

@ -3,7 +3,7 @@
// 4J - TODO - properly implement // 4J - TODO - properly implement
Language *Language::singleton = new Language(); Language *Language::singleton = nullptr;
Language::Language() Language::Language()
{ {
@ -11,6 +11,11 @@ Language::Language()
Language *Language::getInstance() Language *Language::getInstance()
{ {
// 4jcraft, fixes static init fiassco in I18n.cpp
if(singleton == nullptr) {
singleton = new Language();
}
return singleton; return singleton;
} }
@ -20,7 +25,8 @@ std::wstring Language::getElement(const std::wstring& elementId)
return elementId; return elementId;
} */ } */
std::wstring Language::getElement(const std::wstring& elementId, ...) // 4jcraft changed, again const reference into va_start, std forbids
std::wstring Language::getElement(std::wstring elementId, ...)
{ {
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway #ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
return L""; return L"";
@ -45,4 +51,4 @@ std::wstring Language::getElementName(const std::wstring& elementId)
std::wstring Language::getElementDescription(const std::wstring& elementId) std::wstring Language::getElementDescription(const std::wstring& elementId)
{ {
return elementId; return elementId;
} }

Some files were not shown because too many files have changed in this diff Show more