diff --git a/Minecraft.World/Recipes/Recipes.cpp b/Minecraft.World/Recipes/Recipes.cpp index 206b62ef3..66eab96cd 100644 --- a/Minecraft.World/Recipes/Recipes.cpp +++ b/Minecraft.World/Recipes/Recipes.cpp @@ -1217,4 +1217,4 @@ void Recipes::buildRecipeIngredientsArray(void) Recipy::INGREDIENTS_REQUIRED *Recipes::getRecipeIngredientsArray(void) { return m_pRecipeIngredientsRequired; -} \ No newline at end of file +} diff --git a/Minecraft.World/Recipes/ShapedRecipy.cpp b/Minecraft.World/Recipes/ShapedRecipy.cpp index 65a1c7d68..b33d10153 100644 --- a/Minecraft.World/Recipes/ShapedRecipy.cpp +++ b/Minecraft.World/Recipes/ShapedRecipy.cpp @@ -141,11 +141,14 @@ void ShapedRecipy::requires(INGREDIENTS_REQUIRED *pIngReq) TempIngReq.iIngC=0; TempIngReq.iType = ((width>2) ||(height>2))?RECIPE_TYPE_3x3:RECIPE_TYPE_2x2; // 3x3 // 3x3 + // 4jcraft, genuinly what is this garbage code TempIngReq.uiGridA = new unsigned int [9]; TempIngReq.iIngIDA= new int [9]; TempIngReq.iIngValA = 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.iIngValA,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) { 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; for(j=0;jgetAuxValue(); - 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 if(iCount==2) iCount=3; bFound=false; @@ -179,4 +180,4 @@ void ShapelessRecipy::requires(INGREDIENTS_REQUIRED *pIngReq) delete [] TempIngReq.iIngValA; delete [] TempIngReq.iIngAuxValA; delete [] TempIngReq.uiGridA; -} \ No newline at end of file +} diff --git a/Minecraft.World/Util/Random.cpp b/Minecraft.World/Util/Random.cpp index 5be1d53d3..00c4403aa 100644 --- a/Minecraft.World/Util/Random.cpp +++ b/Minecraft.World/Util/Random.cpp @@ -33,7 +33,9 @@ void Random::setSeed(__int64 s) int Random::next(int bits) { - seed = (seed * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1); + // 4jcraft, cast to uint64_t for modulo arithmethic + // overflow of int undefined, and its guaranteed here. + seed = ((uint64_t) seed * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1); return (int)(seed >> (48 - bits)); }