Project modernization (#630)

* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
This commit is contained in:
ModMaker101
2026-03-07 21:56:03 -05:00
committed by GitHub
parent 1be5faaea7
commit a9be52c41a
1373 changed files with 19903 additions and 19449 deletions

View File

@@ -28,6 +28,7 @@
#include "..\Minecraft.World\net.minecraft.world.h"
#include "..\Minecraft.World\LevelChunk.h"
#include "..\Minecraft.World\Biome.h"
#include <Common/UI/UI.h>
ResourceLocation Gui::PUMPKIN_BLUR_LOCATION = ResourceLocation(TN__BLUR__MISC_PUMPKINBLUR);
@@ -87,7 +88,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
int quickSelectHeight=22;
float fScaleFactorWidth=1.0f,fScaleFactorHeight=1.0f;
bool bTwoPlayerSplitscreen=false;
currentGuiScaleFactor = (float) guiScale; // Keep static copy of scale so we know how gui coordinates map to physical pixels - this is also affected by the viewport
currentGuiScaleFactor = static_cast<float>(guiScale); // Keep static copy of scale so we know how gui coordinates map to physical pixels - this is also affected by the viewport
switch(guiScale)
{
@@ -117,7 +118,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
iSafezoneYHalf = splitYOffset;
iSafezoneTopYHalf = screenHeight/10;
fScaleFactorWidth=0.5f;
iWidthOffset=(int)((float)screenWidth*(1.0f - fScaleFactorWidth));
iWidthOffset=static_cast<int>((float)screenWidth * (1.0f - fScaleFactorWidth));
iTooltipsYOffset=44;
bTwoPlayerSplitscreen=true;
currentGuiScaleFactor *= 0.5f;
@@ -127,7 +128,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
iSafezoneYHalf = splitYOffset + screenHeight/10;// 5% (need to treat the whole screen is 2x this screen)
iSafezoneTopYHalf = 0;
fScaleFactorWidth=0.5f;
iWidthOffset=(int)((float)screenWidth*(1.0f - fScaleFactorWidth));
iWidthOffset=static_cast<int>((float)screenWidth * (1.0f - fScaleFactorWidth));
iTooltipsYOffset=44;
bTwoPlayerSplitscreen=true;
currentGuiScaleFactor *= 0.5f;
@@ -697,7 +698,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
#endif
glPushMatrix();
glTranslatef((float)xo, (float)yo, 50);
glTranslatef(static_cast<float>(xo), static_cast<float>(yo), 50);
float ss = 12;
glScalef(-ss, ss, ss);
glRotatef(180, 0, 0, 1);
@@ -806,14 +807,14 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
int timer = minecraft->player->getSleepTimer();
float amount = (float) timer / (float) Player::SLEEP_DURATION;
float amount = static_cast<float>(timer) / static_cast<float>(Player::SLEEP_DURATION);
if (amount > 1)
{
// waking up
amount = 1.0f - ((float) (timer - Player::SLEEP_DURATION) / (float) Player::WAKE_UP_DURATION);
amount = 1.0f - (static_cast<float>(timer - Player::SLEEP_DURATION) / static_cast<float>(Player::WAKE_UP_DURATION));
}
int color = (int) (220.0f * amount) << 24 | (0x101020);
int color = static_cast<int>(220.0f * amount) << 24 | (0x101020);
fill(0, 0, screenWidth/fScaleFactorWidth, screenHeight/fScaleFactorHeight, color);
glEnable(GL_ALPHA_TEST);
glEnable(GL_DEPTH_TEST);
@@ -825,9 +826,9 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
int timer = minecraft->player->getDeathFadeTimer();
float amount = (float) timer / (float) Player::DEATHFADE_DURATION;
float amount = static_cast<float>(timer) / static_cast<float>(Player::DEATHFADE_DURATION);
int color = (int) (220.0f * amount) << 24 | (0x200000);
int color = static_cast<int>(220.0f * amount) << 24 | (0x200000);
fill(0, 0, screenWidth/fScaleFactorWidth, screenHeight/fScaleFactorHeight, color);
glEnable(GL_ALPHA_TEST);
glEnable(GL_DEPTH_TEST);
@@ -850,15 +851,15 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
const int debugTop = 1;
const float maxContentWidth = 1200.f;
const float maxContentHeight = 420.f;
float scale = (float)(screenWidth - debugLeft - 8) / maxContentWidth;
float scaleV = (float)(screenHeight - debugTop - 80) / maxContentHeight;
float scale = static_cast<float>(screenWidth - debugLeft - 8) / maxContentWidth;
float scaleV = static_cast<float>(screenHeight - debugTop - 80) / maxContentHeight;
if (scaleV < scale) scale = scaleV;
if (scale > 1.f) scale = 1.f;
if (scale < 0.5f) scale = 0.5f;
glPushMatrix();
glTranslatef((float)debugLeft, (float)debugTop, 0.f);
glTranslatef(static_cast<float>(debugLeft), static_cast<float>(debugTop), 0.f);
glScalef(scale, scale, 1.f);
glTranslatef((float)-debugLeft, (float)-debugTop, 0.f);
glTranslatef(static_cast<float>(-debugLeft), static_cast<float>(-debugTop), 0.f);
vector<wstring> lines;
@@ -984,11 +985,11 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
wfeature[eTerrainFeature_Village] = L"Village: ";
wfeature[eTerrainFeature_Ravine] = L"Ravine: ";
float maxW = (float)(screenWidth - debugLeft - 8) / scale;
float maxWForContent = maxW - (float)font->width(L"...");
float maxW = static_cast<float>(screenWidth - debugLeft - 8) / scale;
float maxWForContent = maxW - static_cast<float>(font->width(L"..."));
bool truncated[eTerrainFeature_Count] = {};
for (int i = 0; i < (int)app.m_vTerrainFeatures.size(); i++)
for (size_t i = 0; i < app.m_vTerrainFeatures.size(); i++)
{
FEATURE_DATA *pFeatureData = app.m_vTerrainFeatures[i];
int type = pFeatureData->eTerrainFeature;
@@ -1014,7 +1015,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
}
lines.push_back(L""); // Add a spacer line
for (int i = eTerrainFeature_Stronghold; i <= (int)eTerrainFeature_Ravine; i++)
for (int i = eTerrainFeature_Stronghold; i <= static_cast<int>(eTerrainFeature_Ravine); i++)
{
lines.push_back(wfeature[i]);
}
@@ -1241,10 +1242,10 @@ void Gui::renderPumpkin(int w, int h)
MemSect(0);
Tesselator *t = Tesselator::getInstance();
t->begin();
t->vertexUV((float)(0), (float)( h), (float)( -90), (float)( 0), (float)( 1));
t->vertexUV((float)(w), (float)( h), (float)( -90), (float)( 1), (float)( 1));
t->vertexUV((float)(w), (float)( 0), (float)( -90), (float)( 1), (float)( 0));
t->vertexUV((float)(0), (float)( 0), (float)( -90), (float)( 0), (float)( 0));
t->vertexUV(static_cast<float>(0), static_cast<float>(h), static_cast<float>(-90), static_cast<float>(0), static_cast<float>(1));
t->vertexUV(static_cast<float>(w), static_cast<float>(h), static_cast<float>(-90), static_cast<float>(1), static_cast<float>(1));
t->vertexUV(static_cast<float>(w), static_cast<float>(0), static_cast<float>(-90), static_cast<float>(1), static_cast<float>(0));
t->vertexUV(static_cast<float>(0), static_cast<float>(0), static_cast<float>(-90), static_cast<float>(0), static_cast<float>(0));
t->end();
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
@@ -1305,10 +1306,10 @@ void Gui::renderTp(float br, int w, int h)
float v1 = slot->getV1();
Tesselator *t = Tesselator::getInstance();
t->begin();
t->vertexUV((float)(0), (float)( h), (float)( -90), (float)( u0), (float)( v1));
t->vertexUV((float)(w), (float)( h), (float)( -90), (float)( u1), (float)( v1));
t->vertexUV((float)(w), (float)( 0), (float)( -90), (float)( u1), (float)( v0));
t->vertexUV((float)(0), (float)( 0), (float)( -90), (float)( u0), (float)( v0));
t->vertexUV(static_cast<float>(0), static_cast<float>(h), static_cast<float>(-90), (float)( u0), (float)( v1));
t->vertexUV(static_cast<float>(w), static_cast<float>(h), static_cast<float>(-90), (float)( u1), (float)( v1));
t->vertexUV(static_cast<float>(w), static_cast<float>(0), static_cast<float>(-90), (float)( u1), (float)( v0));
t->vertexUV(static_cast<float>(0), static_cast<float>(0), static_cast<float>(-90), (float)( u0), (float)( v0));
t->end();
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
@@ -1326,10 +1327,10 @@ void Gui::renderSlot(int slot, int x, int y, float a)
if (pop > 0)
{
glPushMatrix();
float squeeze = 1 + pop / (float) Inventory::POP_TIME_DURATION;
glTranslatef((float)(x + 8), (float)(y + 12), 0);
float squeeze = 1 + pop / static_cast<float>(Inventory::POP_TIME_DURATION);
glTranslatef(static_cast<float>(x + 8), static_cast<float>(y + 12), 0);
glScalef(1 / squeeze, (squeeze + 1) / 2, 1);
glTranslatef((float)-(x + 8), (float)-(y + 12), 0);
glTranslatef(static_cast<float>(-(x + 8)), static_cast<float>(-(y + 12)), 0);
}
itemRenderer->renderAndDecorateItem(minecraft->font, minecraft->textures, item, x, y);
@@ -1468,7 +1469,7 @@ void Gui::addMessage(const wstring& _string,int iPad,bool bIsDeathMessage)
{
i++;
}
int iLast=(int)string.find_last_of(L" ",i);
size_t iLast=string.find_last_of(L" ",i);
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
@@ -1477,7 +1478,7 @@ void Gui::addMessage(const wstring& _string,int iPad,bool bIsDeathMessage)
iLast = maximumChars;
break;
default:
iLast=(int)string.find_last_of(L" ",i);
iLast=string.find_last_of(L" ",i);
break;
}
@@ -1537,7 +1538,7 @@ float Gui::getOpacity(int iPad, DWORD index)
float Gui::getJukeboxOpacity(int iPad)
{
float t = overlayMessageTime - lastTickA;
int alpha = (int) (t * 256 / 20);
int alpha = static_cast<int>(t * 256 / 20);
if (alpha > 255) alpha = 255;
alpha /= 255;
@@ -1571,7 +1572,7 @@ void Gui::renderGraph(int dataLength, int dataPos, int64_t *dataA, float dataASc
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, (float)minecraft->width, (float)height, 0, 1000, 3000);
glOrtho(0, static_cast<float>(minecraft->width), static_cast<float>(height), 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
@@ -1602,8 +1603,8 @@ void Gui::renderGraph(int dataLength, int dataPos, int64_t *dataA, float dataASc
int64_t aVal = dataA[i] / dataAScale;
t->vertex((float)(xScale*i + 0.5f), (float)( height - aVal + 0.5f), (float)( 0));
t->vertex((float)(xScale*i + 0.5f), (float)( height + 0.5f), (float)( 0));
t->vertex((float)(xScale*i + 0.5f), (float)( height - aVal + 0.5f), static_cast<float>(0));
t->vertex((float)(xScale*i + 0.5f), (float)( height + 0.5f), static_cast<float>(0));
}
if( dataB != NULL )
@@ -1619,8 +1620,8 @@ void Gui::renderGraph(int dataLength, int dataPos, int64_t *dataA, float dataASc
int64_t bVal = dataB[i] / dataBScale;
t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height - bVal + 0.5f), (float)( 0));
t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height + 0.5f), (float)( 0));
t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height - bVal + 0.5f), static_cast<float>(0));
t->vertex((float)(xScale*i + (xScale - 1) + 0.5f), (float)( height + 0.5f), static_cast<float>(0));
}
}
t->end();
@@ -1635,7 +1636,7 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, int64
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, (float)minecraft->width, (float)height, 0, 1000, 3000);
glOrtho(0, static_cast<float>(minecraft->width), static_cast<float>(height), 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2000);
@@ -1664,15 +1665,15 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, int64
if( thisVal > 0 )
{
float vary = (float)source/dataSources;
float vary = static_cast<float>(source)/dataSources;
int fColour = floor(vary * 0xffffff);
int colour = 0xff000000 + fColour;
//printf("Colour is %x\n", colour);
t->color(colour);
t->vertex((float)(i + 0.5f), (float)( height - topVal - thisVal + 0.5f), (float)( 0));
t->vertex((float)(i + 0.5f), (float)( height - topVal + 0.5f), (float)( 0));
t->vertex((float)(i + 0.5f), (float)( height - topVal - thisVal + 0.5f), static_cast<float>(0));
t->vertex((float)(i + 0.5f), (float)( height - topVal + 0.5f), static_cast<float>(0));
topVal += thisVal;
}
@@ -1683,8 +1684,8 @@ void Gui::renderStackedGraph(int dataPos, int dataLength, int dataSources, int64
{
t->color(0xff000000);
t->vertex((float)(0 + 0.5f), (float)( height - (horiz*100) + 0.5f), (float)( 0));
t->vertex((float)(dataLength + 0.5f), (float)( height - (horiz*100) + 0.5f), (float)( 0));
t->vertex((float)(0 + 0.5f), (float)( height - (horiz*100) + 0.5f), static_cast<float>(0));
t->vertex((float)(dataLength + 0.5f), (float)( height - (horiz*100) + 0.5f), static_cast<float>(0));
}
}
t->end();