* Rename screen related fields in Minecraft class

This commit is contained in:
iProgramInCpp 2023-08-05 16:26:02 +03:00
parent 0ceef907c0
commit 9d88bfb962
6 changed files with 55 additions and 57 deletions

View file

@ -91,38 +91,36 @@ void Minecraft::grabMouse()
void Minecraft::setScreen(Screen* pScreen)
{
if (field_DB0)
if (m_bUsingScreen)
{
field_DB1 = 1;
m_pScreen = pScreen; //@BUG: potential memory leak?
m_bHasQueuedScreen = true;
m_pQueuedScreen = pScreen;
return;
}
else if (!pScreen || !pScreen->isErrorScreen())
if (pScreen && pScreen->isErrorScreen())
{
if (field_D14)
{
field_D14->removed();
delete field_D14;
}
// not in original
delete pScreen;
return;
}
field_D14 = pScreen;
if (pScreen)
{
releaseMouse();
pScreen->init(this, int(width * Gui::InvGuiScale), int(height * Gui::InvGuiScale));
}
else
{
grabMouse();
}
if (m_pScreen)
{
m_pScreen->removed();
delete m_pScreen;
}
m_pScreen = pScreen;
if (pScreen)
{
releaseMouse();
pScreen->init(this, int(width * Gui::InvGuiScale), int(height * Gui::InvGuiScale));
}
//@BUG: memory leak?
#ifndef ORIGINAL_CODE
else
{
// @NOTE: Added this to not leak screens. A good idea unless you use the screen instance after calling setScreen()
delete pScreen;
grabMouse();
}
#endif
}
void Minecraft::onGraphicsReset()
@ -301,18 +299,19 @@ label_3:
void Minecraft::tickInput()
{
if (field_D14)
if (m_pScreen)
{
if (!field_D14->field_10)
if (!m_pScreen->field_10)
{
field_DB0 = true;
field_D14->updateEvents();
field_DB0 = false;
if (field_DB1)
m_bUsingScreen = true;
m_pScreen->updateEvents();
m_bUsingScreen = false;
if (m_bHasQueuedScreen)
{
setScreen(m_pScreen);
m_pScreen = NULL;
field_DB1 = false;
setScreen(m_pQueuedScreen);
m_pQueuedScreen = nullptr;
m_bHasQueuedScreen = false;
}
return;
}
@ -452,7 +451,7 @@ void Minecraft::tickInput()
goto label_12;
}
if (!field_D14 && (field_DA8 - field_DAC) >= (m_timer.field_10 * 0.25f))
if (!m_pScreen && (field_DA8 - field_DAC) >= (m_timer.field_10 * 0.25f))
{
handleMouseClick(1);
field_DAC = field_DA8;
@ -488,8 +487,8 @@ void Minecraft::tickMouse()
void Minecraft::handleCharInput(char chr)
{
if (field_D14)
field_D14->charInput(chr);
if (m_pScreen)
m_pScreen->charInput(chr);
}
void Minecraft::_levelGenerated()
@ -552,8 +551,8 @@ void Minecraft::tick()
}
if (field_D14)
field_D14->tick();
if (m_pScreen)
m_pScreen->tick();
}
}
@ -801,7 +800,7 @@ void* Minecraft::prepareLevel_tspawn(void* ptr)
void Minecraft::pauseGame()
{
if (field_D14) return;
if (m_pScreen) return;
m_pLevel->savePlayerData();
setScreen(new PauseScreen);
}

View file

@ -101,7 +101,7 @@ public:
Gui m_gui;
int field_D0C = 0;
CThread* m_pPrepThread = nullptr;
Screen* field_D14 = nullptr;
Screen* m_pScreen = nullptr;
int field_D18 = 10;
ITurnInput* m_pTurnInput = nullptr;
float field_D20 = 0.0f;
@ -118,9 +118,9 @@ public:
int field_DA4 = 0;
int field_DA8 = 0;
int field_DAC = 0;
bool field_DB0 = 0;
bool field_DB1 = 0;
Screen* m_pScreen = nullptr;
bool m_bUsingScreen = false;
bool m_bHasQueuedScreen = false;
Screen* m_pQueuedScreen = nullptr;
int m_licenseID = -2;
ItemInstance m_CurrItemInstance;
};

View file

@ -25,17 +25,17 @@ bool NinecraftApp::handleBack(bool b)
if (!m_pLevel)
{
if (!field_D14)
if (!m_pScreen)
return false;
return field_D14->handleBackEvent(b);
return m_pScreen->handleBackEvent(b);
}
if (b)
return 1;
if (!field_D14) return false;
if (!m_pScreen) return false;
if (field_D14->handleBackEvent(b))
if (m_pScreen->handleBackEvent(b))
return true;
setScreen(nullptr);

View file

@ -254,11 +254,10 @@ void EnableOpenGL(HWND hwnd, HDC* hDC, HGLRC* hRC)
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.cDepthBits = 8;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat(*hDC, &pfd);

View file

@ -55,14 +55,14 @@ void SavingWorldScreen::tick()
m_pMinecraft->m_pLevel = nullptr;
}
m_pMinecraft->field_DB0 = true;
m_pMinecraft->m_bUsingScreen = true;
if (m_bCopyMapAtEnd)
m_pMinecraft->setScreen(new RenameMPLevelScreen("_LastJoinedServer"));
else
m_pMinecraft->setScreen(new StartMenuScreen);
m_pMinecraft->field_DB0 = false;
m_pMinecraft->m_bUsingScreen = false;
m_pMinecraft->field_288 = false;
}

View file

@ -549,11 +549,11 @@ void GameRenderer::render(float f)
renderLevel(f);
if (m_pMinecraft->m_options.field_23C)
{
if (!m_pMinecraft->field_D14)
if (!m_pMinecraft->m_pScreen)
return;
}
m_pMinecraft->m_gui.render(f, m_pMinecraft->field_D14 != nullptr, int(Mouse::_x * Gui::InvGuiScale), int(Mouse::_y * Gui::InvGuiScale));
m_pMinecraft->m_gui.render(f, m_pMinecraft->m_pScreen != nullptr, int(Mouse::_x * Gui::InvGuiScale), int(Mouse::_y * Gui::InvGuiScale));
}
}
else
@ -566,12 +566,12 @@ void GameRenderer::render(float f)
setupGuiScreen();
}
if (m_pMinecraft->field_D14)
if (m_pMinecraft->m_pScreen)
{
glClear(GL_ACCUM);
m_pMinecraft->field_D14->render(int(Mouse::_x * Gui::InvGuiScale), int(Mouse::_y * Gui::InvGuiScale), f);
m_pMinecraft->m_pScreen->render(int(Mouse::_x * Gui::InvGuiScale), int(Mouse::_y * Gui::InvGuiScale), f);
if (m_pMinecraft->field_D14 && !m_pMinecraft->field_D14->isInGameScreen())
if (m_pMinecraft->m_pScreen && !m_pMinecraft->m_pScreen->isInGameScreen())
{
#ifdef ORIGINAL_CODE
sleepMs(15);