nuke memory tracking

This commit is contained in:
Tropical 2026-03-30 21:58:19 -05:00
parent e00c95e7ab
commit f9e89c2be6
64 changed files with 0 additions and 685 deletions

View file

@ -327,14 +327,12 @@ void Socket::SocketOutputStreamLocal::write(const std::vector<uint8_t>& b, unsig
if (m_streamOpen != true) {
return;
}
// MemSect(12);
{
std::lock_guard<std::mutex> lock(s_hostQueueLock[m_queueIdx]);
for (unsigned int i = 0; i < length; i++) {
s_hostQueue[m_queueIdx].push(b[offset + i]);
}
}
// MemSect(0);
}
void Socket::SocketOutputStreamLocal::close() {

View file

@ -341,9 +341,7 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer* renderer, double x,
if (ws > 1) ws = 1;
MemSect(31);
bindTexture(m_customTextureUrl, m_backupTexture);
MemSect(0);
glEnable(GL_ALPHA_TEST);
// model->prepareMobModel(mob, wp, ws, a);
@ -458,9 +456,7 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer* renderer, double x,
glPopMatrix();
MemSect(31);
// renderName(mob, x, y, z);
MemSect(0);
// Reset the model values to stop the changes we made here affecting
// anything in game (like the player hand render)

View file

@ -140,4 +140,3 @@ using namespace DirectX;
#define OutputDebugStringW BREAKTHECOMPILE
#endif
void MemSect(int sect);

View file

@ -405,16 +405,6 @@ void DefineActions(void) {
_360_JOY_BUTTON_DPAD_DOWN);
}
// #define MEMORY_TRACKING
#if defined(MEMORY_TRACKING)
void ResetMem();
void DumpMem();
void MemPixStuff();
#else
void MemSect(int sect) {}
#endif
#if !defined(__linux__)
HINSTANCE g_hInst = nullptr;
HWND g_hWnd = nullptr;
@ -690,14 +680,6 @@ int main(int argc, const char* argv[]) {
static bool bTrialTimerDisplayed = true;
#if defined(MEMORY_TRACKING)
ResetMem();
MEMORYSTATUS memStat;
GlobalMemoryStatus(&memStat);
printf("RESETMEM start: Avail. phys %d\n",
memStat.dwAvailPhys / (1024 * 1024));
#endif
RenderManager.Initialise();
// Read the file containing the product codes
@ -797,9 +779,7 @@ int main(int argc, const char* argv[]) {
// Tick sentient.
PIXBeginNamedEvent(0, "Sentient tick");
MemSect(37);
// SentientManager.Tick();
MemSect(0);
PIXEndNamedEvent();
PIXBeginNamedEvent(0, "Network manager do work #1");
@ -823,9 +803,7 @@ int main(int argc, const char* argv[]) {
g_NetworkManager.GetPlayerCount() == 1 &&
ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()));
} else {
MemSect(28);
pMinecraft->soundEngine->tick(nullptr, 0.0f);
MemSect(0);
pMinecraft->textures->tick(true, false);
if (app.GetReallyChangingSessionType()) {
pMinecraft
@ -842,31 +820,6 @@ int main(int argc, const char* argv[]) {
g_NetworkManager.Initialise();
}
#if defined(MEMORY_TRACKING)
static bool bResetMemTrack = false;
static bool bDumpMemTrack = false;
MemPixStuff();
if (bResetMemTrack) {
ResetMem();
MEMORYSTATUS memStat;
GlobalMemoryStatus(&memStat);
printf("RESETMEM: Avail. phys %d\n",
memStat.dwAvailPhys / (1024 * 1024));
bResetMemTrack = false;
}
if (bDumpMemTrack) {
DumpMem();
bDumpMemTrack = false;
MEMORYSTATUS memStat;
GlobalMemoryStatus(&memStat);
printf("DUMPMEM: Avail. phys %d\n",
memStat.dwAvailPhys / (1024 * 1024));
printf("Renderer used: %d\n", RenderManager.CBuffSize(-1));
}
#endif
ui.tick();
ui.render();
@ -1031,172 +984,3 @@ void FreeRichPresenceStrings() {
}
vRichPresenceStrings.clear();
}
#if 0 // #ifdef MEMORY_TRACKING
int totalAllocGen = 0;
std::unordered_map<int, int> allocCounts;
bool trackEnable = false;
bool trackStarted = false;
volatile size_t sizeCheckMin = 1160;
volatile size_t sizeCheckMax = 1160;
volatile int sectCheck = 48;
std::mutex memCS;
uint32_t tlsIdx;
void* XMemAlloc(size_t dwSize, uint32_t dwAllocAttributes) {
if (!trackStarted) {
void* p = XMemAllocDefault(dwSize, dwAllocAttributes);
size_t realSize = XMemSizeDefault(p, dwAllocAttributes);
totalAllocGen += realSize;
return p;
}
void* p;
{
std::lock_guard<std::mutex> lock(memCS);
p = XMemAllocDefault(dwSize + 16, dwAllocAttributes);
size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16;
if (trackEnable) {
int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f;
*(((unsigned char*)p) + realSize) = sect;
if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) &&
((sect == sectCheck) || (sectCheck == -1))) {
app.DebugPrintf("Found one\n");
}
if (p) {
totalAllocGen += realSize;
trackEnable = false;
int key = (sect << 26) | realSize;
int oldCount = allocCounts[key];
allocCounts[key] = oldCount + 1;
trackEnable = true;
}
}
}
return p;
}
void* operator new(size_t size) {
return (unsigned char*)XMemAlloc(
size, MAKE_XALLOC_ATTRIBUTES(
0, false, true, false, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
XALLOC_MEMPROTECT_READWRITE, false, XALLOC_MEMTYPE_HEAP));
}
void operator delete(void* p) {
XMemFree(p, MAKE_XALLOC_ATTRIBUTES(
0, false, true, false, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
XALLOC_MEMPROTECT_READWRITE, false, XALLOC_MEMTYPE_HEAP));
}
void WINAPI XMemFree(void* pAddress, uint32_t dwAllocAttributes) {
bool special = false;
if (dwAllocAttributes == 0) {
dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(
0, false, true, false, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
XALLOC_MEMPROTECT_READWRITE, false, XALLOC_MEMTYPE_HEAP);
special = true;
}
if (!trackStarted) {
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes);
XMemFreeDefault(pAddress, dwAllocAttributes);
totalAllocGen -= realSize;
return;
}
{
std::lock_guard<std::mutex> lock(memCS);
if (pAddress) {
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
if (trackEnable) {
int sect = *(((unsigned char*)pAddress) + realSize);
totalAllocGen -= realSize;
trackEnable = false;
int key = (sect << 26) | realSize;
int oldCount = allocCounts[key];
allocCounts[key] = oldCount - 1;
trackEnable = true;
}
XMemFreeDefault(pAddress, dwAllocAttributes);
}
}
}
size_t WINAPI XMemSize(void* pAddress, uint32_t dwAllocAttributes) {
if (trackStarted) {
return XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
} else {
return XMemSizeDefault(pAddress, dwAllocAttributes);
}
}
void DumpMem() {
int totalLeak = 0;
for (auto it = allocCounts.begin(); it != allocCounts.end(); it++) {
if (it->second > 0) {
app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f,
it->first & 0x03ffffff, it->second,
(it->first & 0x03ffffff) * it->second);
totalLeak += (it->first & 0x03ffffff) * it->second;
}
}
app.DebugPrintf("Total %d\n", totalLeak);
}
void ResetMem() {
if (!trackStarted) {
trackEnable = true;
trackStarted = true;
totalAllocGen = 0;
tlsIdx = TlsAlloc();
}
{
std::lock_guard<std::mutex> lock(memCS);
trackEnable = false;
allocCounts.clear();
trackEnable = true;
}
}
void MemSect(int section) {
unsigned int value = (unsigned int)TlsGetValue(tlsIdx);
if (section == 0) // pop
{
value = (value >> 6) & 0x03ffffff;
} else {
value = (value << 6) | section;
}
TlsSetValue(tlsIdx, (void*)value);
}
void MemPixStuff() {
const int MAX_SECT = 46;
int totals[MAX_SECT] = {0};
for (auto it = allocCounts.begin(); it != allocCounts.end(); it++) {
if (it->second > 0) {
int sect = (it->first >> 26) & 0x3f;
int bytes = it->first & 0x03ffffff;
totals[sect] += bytes * it->second;
}
}
unsigned int allSectsTotal = 0;
for (int i = 0; i < MAX_SECT; i++) {
allSectsTotal += totals[i];
PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i);
}
PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f),
"MemSect total pages");
}
#endif

View file

@ -376,16 +376,6 @@ void DefineActions(void) {
_360_JOY_BUTTON_DPAD_DOWN);
}
// #define MEMORY_TRACKING
#if defined(MEMORY_TRACKING)
void ResetMem();
void DumpMem();
void MemPixStuff();
#else
void MemSect(int sect) {}
#endif
HINSTANCE g_hInst = nullptr;
HWND g_hWnd = nullptr;
D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
@ -717,14 +707,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
static bool bTrialTimerDisplayed = true;
#if defined(MEMORY_TRACKING)
ResetMem();
MEMORYSTATUS memStat;
GlobalMemoryStatus(&memStat);
printf("RESETMEM start: Avail. phys %d\n",
memStat.dwAvailPhys / (1024 * 1024));
#endif
app.loadMediaArchive();
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
@ -828,9 +810,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// Tick sentient.
PIXBeginNamedEvent(0, "Sentient tick");
MemSect(37);
// SentientManager.Tick();
MemSect(0);
PIXEndNamedEvent();
PIXBeginNamedEvent(0, "Network manager do work #1");
@ -846,9 +826,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
g_NetworkManager.GetPlayerCount() == 1 &&
ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()));
} else {
MemSect(28);
pMinecraft->soundEngine->tick(nullptr, 0.0f);
MemSect(0);
pMinecraft->textures->tick(true, false);
if (app.GetReallyChangingSessionType()) {
pMinecraft
@ -860,31 +838,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
pMinecraft->soundEngine->playMusicTick();
#if defined(MEMORY_TRACKING)
static bool bResetMemTrack = false;
static bool bDumpMemTrack = false;
MemPixStuff();
if (bResetMemTrack) {
ResetMem();
MEMORYSTATUS memStat;
GlobalMemoryStatus(&memStat);
printf("RESETMEM: Avail. phys %d\n",
memStat.dwAvailPhys / (1024 * 1024));
bResetMemTrack = false;
}
if (bDumpMemTrack) {
DumpMem();
bDumpMemTrack = false;
MEMORYSTATUS memStat;
GlobalMemoryStatus(&memStat);
printf("DUMPMEM: Avail. phys %d\n",
memStat.dwAvailPhys / (1024 * 1024));
printf("Renderer used: %d\n", RenderManager.CBuffSize(-1));
}
#endif
ui.tick();
ui.render();
// Present the frame.
@ -921,172 +874,3 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// app.Uninit();
g_pd3dDevice->Release();
}
#if defined(MEMORY_TRACKING)
int totalAllocGen = 0;
std::unordered_map<int, int> allocCounts;
bool trackEnable = false;
bool trackStarted = false;
volatile size_t sizeCheckMin = 1160;
volatile size_t sizeCheckMax = 1160;
volatile int sectCheck = 48;
std::mutex memCS;
uint32_t tlsIdx;
void* XMemAlloc(size_t dwSize, uint32_t dwAllocAttributes) {
if (!trackStarted) {
void* p = XMemAllocDefault(dwSize, dwAllocAttributes);
size_t realSize = XMemSizeDefault(p, dwAllocAttributes);
totalAllocGen += realSize;
return p;
}
void* p;
{
std::lock_guard<std::mutex> lock(memCS);
p = XMemAllocDefault(dwSize + 16, dwAllocAttributes);
size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16;
if (trackEnable) {
int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f;
*(((unsigned char*)p) + realSize) = sect;
if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) &&
((sect == sectCheck) || (sectCheck == -1))) {
app.DebugPrintf("Found one\n");
}
if (p) {
totalAllocGen += realSize;
trackEnable = false;
int key = (sect << 26) | realSize;
int oldCount = allocCounts[key];
allocCounts[key] = oldCount + 1;
trackEnable = true;
}
}
}
return p;
}
void* operator new(size_t size) {
return (unsigned char*)XMemAlloc(
size, MAKE_XALLOC_ATTRIBUTES(
0, false, true, false, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
XALLOC_MEMPROTECT_READWRITE, false, XALLOC_MEMTYPE_HEAP));
}
void operator delete(void* p) {
XMemFree(p, MAKE_XALLOC_ATTRIBUTES(
0, false, true, false, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
XALLOC_MEMPROTECT_READWRITE, false, XALLOC_MEMTYPE_HEAP));
}
void WINAPI XMemFree(void* pAddress, uint32_t dwAllocAttributes) {
bool special = false;
if (dwAllocAttributes == 0) {
dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(
0, false, true, false, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,
XALLOC_MEMPROTECT_READWRITE, false, XALLOC_MEMTYPE_HEAP);
special = true;
}
if (!trackStarted) {
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes);
XMemFreeDefault(pAddress, dwAllocAttributes);
totalAllocGen -= realSize;
return;
}
{
std::lock_guard<std::mutex> lock(memCS);
if (pAddress) {
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
if (trackEnable) {
int sect = *(((unsigned char*)pAddress) + realSize);
totalAllocGen -= realSize;
trackEnable = false;
int key = (sect << 26) | realSize;
int oldCount = allocCounts[key];
allocCounts[key] = oldCount - 1;
trackEnable = true;
}
XMemFreeDefault(pAddress, dwAllocAttributes);
}
}
}
size_t WINAPI XMemSize(void* pAddress, uint32_t dwAllocAttributes) {
if (trackStarted) {
return XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
} else {
return XMemSizeDefault(pAddress, dwAllocAttributes);
}
}
void DumpMem() {
int totalLeak = 0;
for (auto it = allocCounts.begin(); it != allocCounts.end(); it++) {
if (it->second > 0) {
app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f,
it->first & 0x03ffffff, it->second,
(it->first & 0x03ffffff) * it->second);
totalLeak += (it->first & 0x03ffffff) * it->second;
}
}
app.DebugPrintf("Total %d\n", totalLeak);
}
void ResetMem() {
if (!trackStarted) {
trackEnable = true;
trackStarted = true;
totalAllocGen = 0;
tlsIdx = TlsAlloc();
}
{
std::lock_guard<std::mutex> lock(memCS);
trackEnable = false;
allocCounts.clear();
trackEnable = true;
}
}
void MemSect(int section) {
unsigned int value = (unsigned int)TlsGetValue(tlsIdx);
if (section == 0) // pop
{
value = (value >> 6) & 0x03ffffff;
} else {
value = (value << 6) | section;
}
TlsSetValue(tlsIdx, (void*)value);
}
void MemPixStuff() {
const int MAX_SECT = 46;
int totals[MAX_SECT] = {0};
for (auto it = allocCounts.begin(); it != allocCounts.end(); it++) {
if (it->second > 0) {
int sect = (it->first >> 26) & 0x3f;
int bytes = it->first & 0x03ffffff;
totals[sect] += bytes * it->second;
}
}
unsigned int allSectsTotal = 0;
for (int i = 0; i < MAX_SECT; i++) {
allSectsTotal += totals[i];
PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i);
}
PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f),
"MemSect total pages");
}
#endif

View file

@ -282,9 +282,7 @@ void Minecraft::init() {
// Keyboard::create();
Mouse::create();
MemSect(31);
checkGlError(L"Pre startup");
MemSect(0);
// width = Display.getDisplayMode().getWidth();
// height = Display.getDisplayMode().getHeight();
@ -301,9 +299,7 @@ void Minecraft::init() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
MemSect(31);
checkGlError(L"Startup");
MemSect(0);
// openGLCapabilities = new OpenGLCapabilities(); // 4J - removed
@ -323,9 +319,7 @@ void Minecraft::init() {
// } catch (Exception e) {
// }
MemSect(31);
checkGlError(L"Post startup");
MemSect(0);
gui = new Gui(this);
if (connectToIp != L"") // 4J - was nullptr comparison
@ -1560,9 +1554,7 @@ void Minecraft::run_middle() {
// // 4J added
}
// int64_t tickDuraction = System::nanoTime() - beforeTickTime;
MemSect(31);
checkGlError(L"Pre render");
MemSect(0);
TileRenderer::fancy = options->fancyGraphics;
@ -1719,9 +1711,7 @@ void Minecraft::run_middle() {
}
}
*/
MemSect(31);
checkGlError(L"Post render");
MemSect(0);
frames++;
// pause = !isClientSide() && screen != nullptr &&
// screen->isPauseScreen();
@ -1735,11 +1725,9 @@ void Minecraft::run_middle() {
#if !defined(_CONTENT_PACKAGE)
while (System::nanoTime() >= lastTime + 1000000000) {
MemSect(31);
fpsString = _toString<int>(frames) + L" fps, " +
_toString<int>(Chunk::updates) +
L" chunk updates";
MemSect(0);
Chunk::updates = 0;
lastTime += 1000000000;
frames = 0;
@ -1978,10 +1966,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
// soundEngine.playMusicTick();
if (!pause && level != nullptr) gameMode->tick();
MemSect(31);
glBindTexture(GL_TEXTURE_2D,
textures->loadTexture(TN_TERRAIN)); // L"/terrain.png"));
MemSect(0);
if (bFirst) {
PIXBeginNamedEvent(0, "Texture tick");
if (!pause) textures->tick(bUpdateTextures);

View file

@ -342,10 +342,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
// the crosshair
/////////////////////////////////////////////////////////////////////////////////////
if (bDisplayGui) {
MemSect(31);
minecraft->textures->bindTexture(
&GUI_GUI_LOCATION); // 4J was L"/gui/gui.png"
MemSect(0);
std::shared_ptr<Inventory> inventory = minecraft->player->inventory;
if (bTwoPlayerSplitscreen) {
@ -380,10 +378,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
0, 22, 24, 22);
}
MemSect(31);
minecraft->textures->bindTexture(
&GUI_ICONS_LOCATION); // L"/gui/icons.png"));
MemSect(0);
glEnable(GL_BLEND);
RenderManager.StateSetBlendFactor(0xffffff |
(((unsigned int)fVal) << 24));
@ -923,7 +919,6 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
// }
#if !defined(_FINAL_BUILD)
MemSect(31);
if (minecraft->options->renderDebug) {
glPushMatrix();
if (Minecraft::warezTime > 0) glTranslatef(0, 32, 0);
@ -1032,7 +1027,6 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth
glPopMatrix();
}
MemSect(0);
#endif
lastTickA = a;
@ -1191,9 +1185,7 @@ void Gui::renderPumpkin(int w, int h) {
glColor4f(1, 1, 1, 1);
glDisable(GL_ALPHA_TEST);
MemSect(31);
minecraft->textures->bindTexture(&PUMPKIN_BLUR_LOCATION);
MemSect(0);
Tesselator* t = Tesselator::getInstance();
t->begin();
t->vertexUV((float)(0), (float)(h), (float)(-90), (float)(0), (float)(1));
@ -1250,10 +1242,8 @@ void Gui::renderTp(float br, int w, int h) {
glDepthMask(false);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1, 1, 1, br);
MemSect(31);
minecraft->textures->bindTexture(
&TextureAtlas::LOCATION_BLOCKS); // L"/terrain.png"));
MemSect(0);
Icon* slot = Tile::portalTile->getTexture(Facing::UP);
float u0 = slot->getU0();

View file

@ -197,10 +197,8 @@ void ClientConnection::handleLogin(std::shared_ptr<LoginPacket> packet) {
minecraft->gameMode =
new TrialMode(ProfileManager.GetPrimaryPad(), minecraft, this);
} else {
MemSect(13);
minecraft->gameMode = new ConsoleGameMode(
ProfileManager.GetPrimaryPad(), minecraft, this);
MemSect(0);
}
Level* dimensionLevel = minecraft->getLevel(packet->dimension);

View file

@ -701,9 +701,7 @@ void MultiPlayerLevel::animateTickDoWork() {
// be based on the current player.
Minecraft::GetInstance()->animateTickLevel = this;
MemSect(31);
Random* animateRandom = new Random();
MemSect(0);
for (int i = 0; i < ticksPerChunk; i++) {
for (auto it = chunksToAnimate.begin(); it != chunksToAnimate.end();

View file

@ -110,14 +110,12 @@ void ParticleEngine::render(std::shared_ptr<Entity> player, float a, int list) {
break;
}
MemSect(31);
if (tt == MISC_TEXTURE || tt == DRAGON_BREATH_TEXTURE)
textures->bindTexture(&PARTICLES_LOCATION);
if (tt == TERRAIN_TEXTURE)
textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS);
if (tt == ITEM_TEXTURE)
textures->bindTexture(&TextureAtlas::LOCATION_ITEMS);
MemSect(0);
Tesselator* t = Tesselator::getInstance();
glColor4f(1.0f, 1.0f, 1.0f, 1);

View file

@ -463,9 +463,7 @@ void Chunk::rebuild() {
if (!started) {
started = true;
MemSect(31);
glNewList(lists + currentLayer, GL_COMPILE);
MemSect(0);
glDepthMask(true); // 4J added
t->useCompactVertices(true); // 4J added
t->begin();

View file

@ -253,9 +253,7 @@ void GameRenderer::pick(float a) {
double range = mc->gameMode->getPickRange();
delete mc->hitResult;
MemSect(31);
mc->hitResult = mc->cameraTargetPlayer->pick(range, a);
MemSect(0);
// 4J - added - stop blocks right at the edge of the world from being
// pickable so we shouldn't be able to directly destroy or create anything
@ -1253,11 +1251,9 @@ void GameRenderer::renderLevel(float a, int64_t until) {
}
PIXBeginNamedEvent(0, "Culling");
MemSect(31);
// Culler *frustum = new FrustumCuller();
FrustumCuller frustObj;
Culler* frustum = &frustObj;
MemSect(0);
frustum->prepare(xOff, yOff, zOff);
{
@ -1300,10 +1296,8 @@ void GameRenderer::renderLevel(float a, int64_t until) {
setupFog(0, a);
glEnable(GL_FOG);
MemSect(31);
mc->textures->bindTexture(
&TextureAtlas::LOCATION_BLOCKS); // 4J was L"/terrain.png"
MemSect(0);
Lighting::turnOff();
PIXBeginNamedEvent(0, "Level render");
levelRenderer->render(cameraEntity, 0, a, updateChunks);
@ -1372,10 +1366,8 @@ void GameRenderer::renderLevel(float a, int64_t until) {
setupFog(0, a);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
MemSect(31);
mc->textures->bindTexture(
&TextureAtlas::LOCATION_BLOCKS); // 4J was L"/terrain.png"
MemSect(0);
// 4J - have changed this fancy rendering option to work with our
// command buffers. The original used to use frame buffer flags to
// disable writing to colour when doing the z-only pass, but that value
@ -1573,7 +1565,6 @@ void GameRenderer::tickRain() {
if (rainPosSamples > 0 && random->nextInt(3) < rainSoundTime++) {
rainSoundTime = 0;
MemSect(24);
if (rainPosY > player->y + 1 &&
level->getTopRainBlock(Mth::floor(player->x),
Mth::floor(player->z)) >
@ -1586,7 +1577,6 @@ void GameRenderer::tickRain() {
eSoundType_AMBIENT_WEATHER_RAIN, 0.2f,
1.0f);
}
MemSect(0);
}
}
@ -1629,10 +1619,8 @@ void GameRenderer::renderSnowAndRain(float a) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0.01f);
MemSect(31);
mc->textures->bindTexture(
&SNOW_LOCATION); // 4J was L"/environment/snow.png"
MemSect(0);
double xo = player->xOld + (player->x - player->xOld) * a;
double yo = player->yOld + (player->y - player->yOld) * a;

View file

@ -244,10 +244,8 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<LivingEntity> mob,
Tile* tile = Tile::tiles[item->id];
if (item->getIconType() == Icon::TYPE_TERRAIN && tile != nullptr &&
TileRenderer::canRender(tile->getRenderShape())) {
MemSect(31);
minecraft->textures->bindTexture(
minecraft->textures->getTextureLocation(Icon::TYPE_TERRAIN));
MemSect(0);
tileRenderer->renderTile(
Tile::tiles[item->id], item->getAuxValue(),
SharedConstants::TEXTURE_LIGHTING
@ -255,11 +253,9 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<LivingEntity> mob,
: mob->getBrightness(
1)); // 4J - change brought forward from 1.8.2
} else {
MemSect(31);
Icon* icon = mob->getItemInHandIcon(item, layer);
if (icon == nullptr) {
glPopMatrix();
MemSect(0);
return;
}
@ -267,7 +263,6 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<LivingEntity> mob,
minecraft->textures->bindTexture(
minecraft->textures->getTextureLocation(item->getIconType()));
MemSect(0);
Tesselator* t = Tesselator::getInstance();
// Consider forcing the mipmap LOD level to use, if this is to be
@ -555,10 +550,8 @@ void ItemInHandRenderer::render(float a) {
float s = 2 / 128.0f;
glScalef(s, s, s);
MemSect(31);
minecraft->textures->bindTexture(
&MAP_BACKGROUND_LOCATION); // 4J was L"/misc/mapbg.png"
MemSect(0);
Tesselator* t = Tesselator::getInstance();
// glNormal3f(0, 0, -1); // 4J - changed to use tesselator
@ -725,11 +718,9 @@ void ItemInHandRenderer::render(float a) {
// minecraft->textures->loadHttpTexture(minecraft->player->customTextureUrl,
// minecraft->player->getTexture()));
MemSect(31);
glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadMemTexture(
minecraft->player->customTextureUrl,
minecraft->player->getTexture()));
MemSect(0);
minecraft->textures->clearLastBoundId();
glTranslatef(-1.0f, +3.6f, +3.5f);
glRotatef(120, 0, 0, 1);
@ -743,7 +734,6 @@ void ItemInHandRenderer::render(float a) {
PlayerRenderer* playerRenderer = (PlayerRenderer*)er;
float ss = 1;
glScalef(ss, ss, ss);
MemSect(31);
// Can't turn off the hand if the player is holding a map
std::shared_ptr<ItemInstance> itemInstance =
player->inventory->getSelected();
@ -753,7 +743,6 @@ void ItemInHandRenderer::render(float a) {
eGameSetting_DisplayHand) != 0) {
playerRenderer->renderHand();
}
MemSect(0);
glPopMatrix();
}
@ -798,10 +787,8 @@ void ItemInHandRenderer::renderScreenEffect(float a) {
}
if (minecraft->player->isUnderLiquid(Material::water)) {
MemSect(31);
minecraft->textures->bindTexture(
&UNDERWATER_LOCATION); // 4J was L"/misc/water.png"
MemSect(0);
renderWater(a);
}
glEnable(GL_ALPHA_TEST);

View file

@ -989,9 +989,7 @@ void LevelRenderer::renderSky(float alpha) {
glRotatef(level[playerIndex]->getTimeOfDay(alpha) * 360, 1, 0, 0);
float ss = 30;
MemSect(31);
textures->bindTexture(&SUN_LOCATION);
MemSect(0);
t->begin();
t->vertexUV((float)(-ss), (float)(100), (float)(-ss), (float)(0),
(float)(0));
@ -1441,10 +1439,8 @@ void LevelRenderer::renderAdvancedClouds(float alpha) {
glEnable(GL_CULL_FACE);
}
MemSect(31);
textures->bindTexture(
&CLOUDS_LOCATION); // 4J was L"/environment/clouds.png"
MemSect(0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

View file

@ -662,7 +662,6 @@ void Textures::loadTexture(BufferedImage* img, int id, bool blur, bool clamp) {
// printf("Textures::loadTexture BufferedImage with blur and clamp
//%d\n",id);
int iMipLevels = 1;
MemSect(33);
glBindTexture(GL_TEXTURE_2D, id);
if (MIPMAP) {
@ -802,7 +801,6 @@ void Textures::loadTexture(BufferedImage* img, int id, bool blur, bool clamp) {
* GL_RGBA, GL_UNSIGNED_BYTE, pixels); } else { }
*/
delete pixels; // 4J - now creating this dynamically
MemSect(0);
}
std::vector<int> Textures::anaglyph(std::vector<int>& rawPixels) {
@ -1122,7 +1120,6 @@ void Textures::tick(
bool updateTextures,
bool tickDynamics) // 4J added updateTextures parameter & tickDynamics
{
MemSect(22);
if (tickDynamics) {
// 4J - added - if we aren't updating the final renderer textures, just
// tick each of the dynamic textures instead. This is used so that in
@ -1130,7 +1127,6 @@ void Textures::tick(
// that we don't lock the renderer textures twice needlessly and force
// the CPU to sync with the GPU.
if (!updateTextures) {
MemSect(0);
return;
}
@ -1159,7 +1155,6 @@ void Textures::tick(
it++;
}
}
MemSect(0);
}
void Textures::reloadAll() {
@ -1208,7 +1203,6 @@ BufferedImage* Textures::readImage(
TEXTURE_NAME texId, const std::wstring& name) // 4J was InputStream *in
{
BufferedImage* img = nullptr;
MemSect(32);
// is this image one of the Title Update ones?
bool isTu = IsTUImage(texId, name);
std::wstring drive = L"";
@ -1239,7 +1233,6 @@ BufferedImage* Textures::readImage(
}
}
MemSect(0);
return img;
}

View file

@ -82,9 +82,7 @@ void EntityRenderer::renderFlame(std::shared_ptr<Entity> e, double x, double y,
float s = e->bbWidth * 1.4f;
glScalef(s, s, s);
MemSect(31);
bindTexture(&TextureAtlas::LOCATION_BLOCKS);
MemSect(0);
Tesselator* t = Tesselator::getInstance();
float r = 0.5f;
@ -142,9 +140,7 @@ void EntityRenderer::renderShadow(std::shared_ptr<Entity> e, double x, double y,
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
MemSect(31);
entityRenderDispatcher->textures->bindTexture(&SHADOW_LOCATION);
MemSect(0);
Level* level = getLevel();

View file

@ -25,9 +25,7 @@ void FireballRenderer::render(std::shared_ptr<Entity> _fireball, double x,
glScalef(s / 1.0f, s / 1.0f, s / 1.0f);
Icon* icon = Item::fireball->getIcon(
fireball->GetType() == eTYPE_DRAGON_FIREBALL ? 1 : 0); // 14 + 2 * 16;
MemSect(31);
bindTexture(fireball);
MemSect(0);
Tesselator* t = Tesselator::getInstance();
float u0 = icon->getU0();
@ -68,9 +66,7 @@ void FireballRenderer::renderFlame(std::shared_ptr<Entity> e, double x,
float s = e->bbWidth * 1.4f;
glScalef(s, s, s);
MemSect(31);
bindTexture(&TextureAtlas::LOCATION_BLOCKS);
MemSect(0);
Tesselator* t = Tesselator::getInstance();
float r = 1.0f;

View file

@ -342,9 +342,7 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
if (item->getIconType() == Icon::TYPE_TERRAIN &&
TileRenderer::canRender(Tile::tiles[itemId]->getRenderShape())) {
PIXBeginNamedEvent(0, "3D gui item render %d\n", itemId);
MemSect(31);
textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS);
MemSect(0);
Tile* tile = Tile::tiles[itemId];
glPushMatrix();
@ -397,7 +395,6 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
} else {
PIXBeginNamedEvent(0, "2D gui item render %d\n", itemIcon);
glDisable(GL_LIGHTING);
MemSect(31);
if (item->getIconType() == Icon::TYPE_TERRAIN) {
textures->bindTexture(
&TextureAtlas::LOCATION_BLOCKS); // L"/terrain.png"));
@ -405,7 +402,6 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
textures->bindTexture(
&TextureAtlas::LOCATION_ITEMS); // L"/gui/items.png"));
}
MemSect(0);
if (itemIcon == nullptr) {
itemIcon = textures->getMissingIcon(item->getIconType());
@ -583,7 +579,6 @@ void ItemRenderer::renderGuiItemDecorations(Font* font, Textures* textures,
if (item->count > 1 || !countText.empty() ||
item->GetForceNumberDisplay()) {
MemSect(31);
std::wstring amount = countText;
if (amount.empty()) {
int count = item->count;
@ -593,7 +588,6 @@ void ItemRenderer::renderGuiItemDecorations(Font* font, Textures* textures,
amount = _toString<int>(item->count);
}
}
MemSect(0);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
font->drawShadow(amount, x + 19 - 2 - font->width(amount), y + 6 + 3,

View file

@ -219,9 +219,7 @@ void LivingEntityRenderer::render(std::shared_ptr<Entity> _mob, double x,
glPopMatrix();
MemSect(31);
renderName(mob, x, y, z);
MemSect(0);
}
void LivingEntityRenderer::renderModel(std::shared_ptr<LivingEntity> mob,

View file

@ -17,9 +17,7 @@ int PigRenderer::prepareArmor(std::shared_ptr<LivingEntity> _pig, int layer,
std::shared_ptr<Pig> pig = std::dynamic_pointer_cast<Pig>(_pig);
if (layer == 0 && pig->hasSaddle()) {
MemSect(31);
bindTexture(&SADDLE_LOCATION);
MemSect(0);
return 1;
}

View file

@ -24,9 +24,7 @@ int SheepRenderer::prepareArmor(std::shared_ptr<LivingEntity> _sheep, int layer,
->player)) // 4J-JEV: Todo, merge with java fix (for invisible
// sheep armour) in '1.7.5'.
{
MemSect(31);
bindTexture(&SHEEP_FUR_LOCATION);
MemSect(0);
if (sheep->hasCustomName() &&
sheep->getCustomName().compare(L"jeb_") == 0) {

View file

@ -23,9 +23,7 @@ int SpiderRenderer::prepareArmor(std::shared_ptr<LivingEntity> _spider,
std::shared_ptr<Spider> spider = std::dynamic_pointer_cast<Spider>(_spider);
if (layer != 0) return -1;
MemSect(31);
bindTexture(&SPIDER_EYES_LOCATION);
MemSect(0);
// 4J - changes brought forward from 1.8.2
float br = 1.0f; // was (1-spider->getBrightness(1))*0.5f;
glEnable(GL_BLEND);

View file

@ -88,7 +88,6 @@ void PreStitchedTextureMap::stitch() {
int minFilter = Texture::TFLT_NEAREST;
int magFilter = Texture::TFLT_NEAREST;
MemSect(32);
std::wstring drive = L"";
// 4J-PB - need to check for BD patched files
@ -104,7 +103,6 @@ void PreStitchedTextureMap::stitch() {
// //ImageIO::read(texturePack->getResource(L"/" + filename));
BufferedImage* image =
texturePack->getImageResource(filename, false, true, drive);
MemSect(0);
int height = image->getHeight();
int width = image->getWidth();
@ -130,13 +128,11 @@ void PreStitchedTextureMap::stitch() {
preStitched->init(stitchResult, nullptr, x, y, width, height, false);
}
MemSect(52);
for (auto it = texturesByName.begin(); it != texturesByName.end(); ++it) {
StitchedTexture* preStitched = (StitchedTexture*)(it->second);
makeTextureAnimated(texturePack, preStitched);
}
MemSect(0);
// missingPosition = (StitchedTexture
// *)texturesByName.find(NAME_MISSING_TEXTURE)->second;

View file

@ -381,9 +381,7 @@ void Texture::transferFromImage(BufferedImage* image) {
}
}
MemSect(51);
data[0] = ByteBuffer::allocateDirect(tempBytes.size());
MemSect(0);
data[0]->clear();
data[0]->put(tempBytes);
data[0]->limit(tempBytes.size());
@ -465,9 +463,7 @@ void Texture::transferFromImage(BufferedImage* image) {
}
}
MemSect(51);
data[level] = ByteBuffer::allocateDirect(tempBytes.size());
MemSect(0);
data[level]->clear();
data[level]->put(tempBytes);
data[level]->limit(tempBytes.size());

View file

@ -81,7 +81,6 @@ std::vector<Texture*>* TextureManager::createTextures(
int minFilter = Texture::TFLT_NEAREST;
int magFilter = Texture::TFLT_NEAREST;
MemSect(32);
std::wstring drive = L"";
if (texturePack->hasFile(L"res/" + filename, false)) {
@ -99,7 +98,6 @@ std::vector<Texture*>* TextureManager::createTextures(
BufferedImage* image =
texturePack->getImageResource(filename, false, true, drive);
MemSect(0);
int height = image->getHeight();
int width = image->getWidth();

View file

@ -245,9 +245,7 @@ void PlayerList::placeNewPlayer(Connection* connection,
broadcastAll(std::shared_ptr<ChatPacket>(
new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame)));
MemSect(14);
add(player);
MemSect(0);
player->doTick(
true, true,

View file

@ -31,9 +31,7 @@ bool Settings::getBoolean(const std::wstring& key, bool defaultValue) {
properties[key] = _toString<bool>(defaultValue);
saveProperties();
}
MemSect(35);
bool retval = _fromString<bool>(properties[key]);
MemSect(0);
return retval;
}

View file

@ -315,18 +315,14 @@ void ServerLevel::tick() {
PIXEndNamedEvent();
PIXBeginNamedEvent(0, "Tick tiles");
MemSect(18);
tickTiles();
MemSect(0);
PIXEndNamedEvent();
chunkMap->tick();
PIXBeginNamedEvent(0, "Tick villages");
// MemSect(18);
villages->tick();
villageSiege->tick();
// MemSect(0);
PIXEndNamedEvent();
PIXBeginNamedEvent(0, "Tick portal forcer");
@ -577,7 +573,6 @@ void ServerLevel::addToTickNextTick(int x, int y, int z, int tileId,
void ServerLevel::addToTickNextTick(int x, int y, int z, int tileId,
int tickDelay, int priorityTilt) {
MemSect(27);
TickNextTickData td = TickNextTickData(x, y, z, tileId);
int r = 0;
if (getInstaTick() && tileId > 0) {
@ -590,7 +585,6 @@ void ServerLevel::addToTickNextTick(int x, int y, int z, int tileId,
Tile::tiles[id]->tick(this, td.x, td.y, td.z, random);
}
}
MemSect(0);
return;
} else {
tickDelay = 1;
@ -610,7 +604,6 @@ void ServerLevel::addToTickNextTick(int x, int y, int z, int tileId,
}
}
}
MemSect(0);
}
void ServerLevel::forceAddTileTick(int x, int y, int z, int tileId,

View file

@ -32,9 +32,7 @@ void ServerLevelListener::addParticle(ePARTICLE_TYPE name, double x, double y,
void ServerLevelListener::allChanged() {}
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity) {
MemSect(10);
level->getTracker()->addEntity(entity);
MemSect(0);
}
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity) {

View file

@ -65,7 +65,6 @@
#define OutputDebugStringW BREAKTHECOMPILE
#endif
void MemSect(int sect);
#ifdef _WINDOWS64
#include "Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Profile.h"

View file

@ -139,7 +139,6 @@ void Connection::setListener(PacketListener* packetListener) {
void Connection::send(std::shared_ptr<Packet> packet) {
if (quitting) return;
MemSect(15);
// 4J Jev, synchronized (&writeLock)
{
std::lock_guard<std::mutex> lock(writeLock);
@ -156,7 +155,6 @@ void Connection::send(std::shared_ptr<Packet> packet) {
}
// 4J Jev, end synchronized.
MemSect(0);
}
void Connection::queueSend(std::shared_ptr<Packet> packet) {
@ -549,7 +547,6 @@ int Connection::runRead(void* lpParam) {
// try {
MemSect(19);
while (
con->running && !con->quitting &&
ShutdownManager::ShouldRun(ShutdownManager::eConnectionReadThreads)) {
@ -561,7 +558,6 @@ int Connection::runRead(void* lpParam) {
// whether we should do that as well
con->m_hWakeReadThread->waitForSignal(100L);
}
MemSect(0);
/* 4J JEV, removed try/catch
} catch (InterruptedException e) {

View file

@ -78,9 +78,7 @@ void AddMobPacket::read(DataInputStream* dis) // throws IOException
xd = dis->readShort();
yd = dis->readShort();
zd = dis->readShort();
MemSect(1);
unpack = SynchedEntityData::unpack(dis);
MemSect(0);
}
void AddMobPacket::write(DataOutputStream* dos) // throws IOException

View file

@ -85,9 +85,7 @@ void AddPlayerPacket::read(DataInputStream* dis) // throws IOException
m_capeId = *(uint32_t*)&capeId;
int32_t privileges = dis->readInt();
m_uiGamePrivileges = *(unsigned int*)&privileges;
MemSect(1);
unpack = SynchedEntityData::unpack(dis);
MemSect(0);
}
void AddPlayerPacket::write(DataOutputStream* dos) // throws IOException

View file

@ -56,9 +56,7 @@ BlockRegionUpdatePacket::BlockRegionUpdatePacket(int x, int y, int z, int xs,
rawBuffer = lc->getReorderedBlocksAndData(x & 0xF, y, z & 0xF, xs,
this->ys, zs);
} else {
MemSect(50);
rawBuffer = level->getBlocksAndData(x, y, z, xs, ys, zs, false);
MemSect(0);
}
if (rawBuffer.size() == 0) {

View file

@ -99,9 +99,7 @@ void LivingEntity::_init() {
}
LivingEntity::LivingEntity(Level* level) : Entity(level) {
MemSect(56);
_init();
MemSect(0);
// 4J Stu - This will not call the correct derived function, so moving to
// each derived class
@ -775,7 +773,6 @@ bool LivingEntity::hurt(DamageSource* source, float dmg) {
}
}
MemSect(31);
if (getHealth() <= 0) {
if (sound)
playSound(getDeathSound(), getSoundVolume(), getVoicePitch());
@ -783,7 +780,6 @@ bool LivingEntity::hurt(DamageSource* source, float dmg) {
} else {
if (sound) playSound(getHurtSound(), getSoundVolume(), getVoicePitch());
}
MemSect(0);
return true;
}
@ -930,10 +926,8 @@ void LivingEntity::causeFallDamage(float distance) {
Mth::floor(z));
if (t > 0) {
const Tile::SoundType* soundType = Tile::tiles[t]->soundType;
MemSect(31);
playSound(soundType->getStepSound(), soundType->getVolume() * 0.5f,
soundType->getPitch() * 0.75f);
MemSect(0);
}
}
}
@ -1080,7 +1074,6 @@ void LivingEntity::handleEntityEvent(uint8_t id) {
hurtTime = hurtDuration = 10;
hurtDir = 0;
MemSect(31);
// 4J-PB -added because villagers have no sounds
int iHurtSound = getHurtSound();
if (iHurtSound != -1) {
@ -1088,10 +1081,8 @@ void LivingEntity::handleEntityEvent(uint8_t id) {
iHurtSound, getSoundVolume(),
(random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
}
MemSect(0);
hurt(DamageSource::genericSource, 0);
} else if (id == EntityEvent::DEATH) {
MemSect(31);
// 4J-PB -added because villagers have no sounds
int iDeathSound = getDeathSound();
if (iDeathSound != -1) {
@ -1099,7 +1090,6 @@ void LivingEntity::handleEntityEvent(uint8_t id) {
iDeathSound, getSoundVolume(),
(random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
}
MemSect(0);
setHealth(0);
die(DamageSource::genericSource);
} else {
@ -1539,7 +1529,6 @@ void LivingEntity::aiStep() {
yya = 0;
yRotA = 0;
} else {
MemSect(25);
if (isEffectiveAi()) {
if (useNewAi()) {
newServerAiStep();
@ -1548,7 +1537,6 @@ void LivingEntity::aiStep() {
yHeadRot = yRot;
}
}
MemSect(0);
}
if (jumping) {

View file

@ -59,15 +59,11 @@ void Mob::_init() {
}
Mob::Mob(Level* level) : LivingEntity(level) {
MemSect(57);
_init();
MemSect(0);
MemSect(58);
// 4J Stu - We call this again in the derived classes, but need to do it
// here for some internal members
registerAttributes();
MemSect(0);
lookControl = new LookControl(this);
moveControl = new MoveControl(this);
@ -133,12 +129,10 @@ void Mob::defineSynchedData() {
int Mob::getAmbientSoundInterval() { return 20 * 4; }
void Mob::playAmbientSound() {
MemSect(31);
int ambient = getAmbientSound();
if (ambient != -1) {
playSound(ambient, getSoundVolume(), getVoicePitch());
}
MemSect(0);
}
void Mob::baseTick() {
@ -406,7 +400,6 @@ void Mob::checkDespawn() {
void Mob::newServerAiStep() {
PIXBeginNamedEvent(0, "Tick target selector for %d", GetType());
MemSect(51);
noActionTime++;
PIXBeginNamedEvent(0, "Check despawn");
checkDespawn();
@ -442,7 +435,6 @@ void Mob::newServerAiStep() {
PIXBeginNamedEvent(0, "Consider extra wandering");
considerForExtraWandering(isDespawnProtected());
PIXEndNamedEvent();
MemSect(0);
PIXEndNamedEvent();
}

View file

@ -12,68 +12,56 @@ SynchedEntityData::SynchedEntityData() {
}
void SynchedEntityData::define(int id, int value) {
MemSect(17);
checkId(id);
int type = TYPE_INT;
std::shared_ptr<DataItem> dataItem =
std::shared_ptr<DataItem>(new DataItem(type, id, value));
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
}
void SynchedEntityData::define(int id, uint8_t value) {
MemSect(17);
checkId(id);
int type = TYPE_BYTE;
std::shared_ptr<DataItem> dataItem =
std::shared_ptr<DataItem>(new DataItem(type, id, value));
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
}
void SynchedEntityData::define(int id, short value) {
MemSect(17);
checkId(id);
int type = TYPE_SHORT;
std::shared_ptr<DataItem> dataItem =
std::shared_ptr<DataItem>(new DataItem(type, id, value));
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
}
void SynchedEntityData::define(int id, float value) {
MemSect(17);
checkId(id);
int type = TYPE_FLOAT;
std::shared_ptr<DataItem> dataItem =
std::shared_ptr<DataItem>(new DataItem(type, id, value));
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
}
void SynchedEntityData::define(int id, const std::wstring& value) {
MemSect(17);
checkId(id);
int type = TYPE_STRING;
std::shared_ptr<DataItem> dataItem =
std::shared_ptr<DataItem>(new DataItem(type, id, value));
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
}
void SynchedEntityData::defineNULL(int id, void* pVal) {
MemSect(17);
checkId(id);
int type = TYPE_ITEMINSTANCE;
std::shared_ptr<DataItem> dataItem = std::shared_ptr<DataItem>(
new DataItem(type, id, std::shared_ptr<ItemInstance>()));
itemsById[id] = dataItem;
MemSect(0);
m_isEmpty = false;
}

View file

@ -66,9 +66,7 @@ Path* PathNavigation::createPath(double x, double y, double z) {
bool PathNavigation::moveTo(double x, double y, double z,
double speedModifier) {
MemSect(52);
Path* newPath = createPath(Mth::floor(x), (int)y, Mth::floor(z));
MemSect(0);
// No need to delete newPath here as this will be copied into the member
// variable path and the class can assume responsibility for it
return moveTo(newPath, speedModifier);
@ -82,9 +80,7 @@ Path* PathNavigation::createPath(std::shared_ptr<Entity> target) {
bool PathNavigation::moveTo(std::shared_ptr<Entity> target,
double speedModifier) {
MemSect(53);
Path* newPath = createPath(target);
MemSect(0);
// No need to delete newPath here as this will be copied into the member
// variable path and the class can assume responsibility for it
if (newPath != nullptr)

View file

@ -82,10 +82,8 @@ void ItemEntity::tick() {
yd = 0.2f;
xd = (random->nextFloat() - random->nextFloat()) * 0.2f;
zd = (random->nextFloat() - random->nextFloat()) * 0.2f;
MemSect(31);
playSound(eSoundType_RANDOM_FIZZ, 0.4f,
2.0f + random->nextFloat() * 0.4f);
MemSect(0);
}
if (!level->isClientSide) {

View file

@ -115,9 +115,7 @@ Player::Player(Level* level, const std::wstring& name) : LivingEntity(level) {
this->name = name;
_init();
MemSect(11);
inventoryMenu = new InventoryMenu(inventory, !level->isClientSide, this);
MemSect(0);
containerMenu = inventoryMenu;

View file

@ -165,7 +165,6 @@ void Fireball::tick() {
flightTime++;
}
MemSect(41);
Vec3 from(x, y, z);
Vec3 to(x + xd, y + yd, z + zd);
HitResult* res = level->clip(&from, &to);
@ -204,7 +203,6 @@ void Fireball::tick() {
delete res;
res = new HitResult(hitEntity);
}
MemSect(0);
if (res != nullptr) {
onHit(res);

View file

@ -69,10 +69,8 @@ void InventoryMenu::slotsChanged() // 4J used to take a shared_ptr<Container>
// but wasn't using it, so removed to
// simplify things
{
MemSect(23);
resultSlots->setItem(
0, Recipes::getInstance()->getItemFor(craftSlots, owner->level));
MemSect(0);
}
void InventoryMenu::removed(std::shared_ptr<Player> player) {

View file

@ -42,10 +42,8 @@ std::shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum,
std::shared_ptr<MapItemSavedData> MapItem::getSavedData(
std::shared_ptr<ItemInstance> itemInstance, Level* level) {
MemSect(31);
std::wstring id =
std::wstring(L"map_") + _toString(itemInstance->getAuxValue());
MemSect(0);
std::shared_ptr<MapItemSavedData> mapItemSavedData =
std::dynamic_pointer_cast<MapItemSavedData>(
level->getSavedData(typeid(MapItemSavedData), id));

View file

@ -1611,18 +1611,12 @@ bool Level::addEntity(std::shared_ptr<Entity> e) {
updateSleepingPlayerList();
}
MemSect(42);
getChunk(xc, zc)->addEntity(e);
MemSect(0);
{
std::lock_guard<std::recursive_mutex> lock(m_entitiesCS);
MemSect(43);
entities.push_back(e);
MemSect(0);
}
MemSect(44);
entityAdded(e);
MemSect(0);
return true;
}
return false;
@ -2305,9 +2299,7 @@ void Level::tick(std::shared_ptr<Entity> e, bool actual) {
if (hasChunk(xcn, zcn)) {
e->inChunk = true;
MemSect(39);
getChunk(xcn, zcn)->addEntity(e);
MemSect(0);
} else {
e->inChunk = false;
// e.remove();
@ -3372,7 +3364,6 @@ std::vector<std::shared_ptr<Entity> >* Level::getEntities(
std::vector<std::shared_ptr<Entity> >* Level::getEntities(
std::shared_ptr<Entity> except, AABB* bb, const EntitySelector* selector) {
MemSect(40);
es.clear();
int xc0 = Mth::floor((bb->x0 - 2) / 16);
int xc1 = Mth::floor((bb->x1 + 2) / 16);
@ -3385,7 +3376,6 @@ std::vector<std::shared_ptr<Entity> >* Level::getEntities(
getChunk(xc, zc)->getEntities(except, bb, es, selector);
}
}
MemSect(0);
return &es;
}
@ -3694,7 +3684,6 @@ std::shared_ptr<Player> Level::getNearestPlayer(std::shared_ptr<Entity> source,
std::shared_ptr<Player> Level::getNearestPlayer(double x, double y, double z,
double maxDist,
double maxYDist /*= -1*/) {
MemSect(21);
double best = -1;
std::shared_ptr<Player> result = nullptr;
auto itEnd = players.end();
@ -3712,7 +3701,6 @@ std::shared_ptr<Player> Level::getNearestPlayer(double x, double y, double z,
result = p;
}
}
MemSect(0);
return result;
}

View file

@ -44,7 +44,6 @@ const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies,
if (!spawnEnemies && !spawnFriendlies && !spawnPersistent) {
return 0;
}
MemSect(20);
chunksToPoll.clear();
// 4J - rewritten to add chunks interleaved by player, and to add them from
@ -103,11 +102,8 @@ const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies,
}
delete[] xx;
delete[] zz;
MemSect(0);
int count = 0;
MemSect(31);
Pos* spawnPos = level->getSharedSpawnPos();
MemSect(0);
for (unsigned int i = 0; i < MobCategory::values.size(); i++) {
MobCategory* mobCategory = MobCategory::values[i];
@ -210,13 +206,11 @@ const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies,
// 4J - removed try/catch
// try
// {
MemSect(29);
// mob =
// type.mobClass.getConstructor(Level.class).newInstance(level);
mob = std::dynamic_pointer_cast<Mob>(
EntityIO::newByEnumType(currentMobType->mobClass,
level));
MemSect(0);
// }
// catch
//(exception e)

View file

@ -83,11 +83,9 @@ BiomeCache::Block* BiomeCache::getBlockAt(int x, int z) {
auto it = cached.find(slot);
Block* block = nullptr;
if (it == cached.end()) {
MemSect(48);
block = new Block(x, z, this);
cached[slot] = block;
all.push_back(block);
MemSect(0);
} else {
block = it->second;
}

View file

@ -138,9 +138,7 @@ void BiomeDecorator::decorate() {
int x = xo + random->nextInt(16) + 8;
int y = random->nextInt(Level::genDepth);
int z = zo + random->nextInt(16) + 8;
MemSect(50);
Feature* grassFeature = biome->getGrassFeature(random);
MemSect(0);
grassFeature->place(level, random, x, y, z);
delete grassFeature;
}

View file

@ -317,7 +317,6 @@ TilePos* BiomeSource::findBiome(int x, int z, int r,
int w = x1 - x0 + 1;
int h = z1 - z0 + 1;
MemSect(50);
std::vector<int> biomes = layer->getArea(x0, z0, w, h);
TilePos* res = nullptr;
int found = 0;
@ -333,7 +332,6 @@ TilePos* BiomeSource::findBiome(int x, int z, int r,
}
}
}
MemSect(0);
return res;
}

View file

@ -69,9 +69,7 @@ void FixedBiomeSource::getDownfallBlock(std::vector<double>& downfalls, int x, i
// arrays output if pointers are passed in (_temperatures, _downfalls)
void FixedBiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
int h, bool useCache) const {
MemSect(36);
biomes = std::vector<Biome*>(w * h);
MemSect(0);
Arrays::fill(biomes, 0, w * h, biome);
}
@ -80,9 +78,7 @@ void FixedBiomeSource::getBiomeBlock(std::vector<Biome*>& biomes, int x, int z,
// arrays output if pointers are passed in (_temperatures, _downfalls)
void FixedBiomeSource::getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, int x, int z,
int w, int h, bool useCache) const {
MemSect(36);
biomeIndices = std::vector<uint8_t>(w * h);
MemSect(0);
int biomeIndex = biome->id;
Arrays::fill(biomeIndices, 0, w * h, biomeIndex);
}
@ -92,9 +88,7 @@ void FixedBiomeSource::getBiomeIndexBlock(std::vector<uint8_t>& biomeIndices, in
// arrays output if pointers are passed in (_temperatures, _downfalls)
void FixedBiomeSource::getRawBiomeBlock(std::vector<Biome*>& biomes, int x, int z, int w,
int h) const {
MemSect(36);
biomes = std::vector<Biome*>(w * h);
MemSect(0);
Arrays::fill(biomes, 0, w * h, biome);
}

View file

@ -57,7 +57,6 @@ void LevelChunk::init(Level* level, int x, int z) {
this->level = level;
this->x = x;
this->z = z;
MemSect(1);
heightmap = std::vector<uint8_t>(16 * 16);
{
std::lock_guard<std::recursive_mutex> lock(m_csEntities);
@ -66,7 +65,6 @@ void LevelChunk::init(Level* level, int x, int z) {
}
}
MemSect(0);
lowestHeightmap = 256;
inhabitedTime = 0;
@ -251,7 +249,6 @@ void LevelChunk::stopSharingTilesAndData() {
return;
}
MemSect(47);
// Changed to used compressed storage - these CTORs make deep copies of
// the storage passed as a parameter
@ -281,7 +278,6 @@ void LevelChunk::stopSharingTilesAndData() {
*/
sharingTilesAndData = false;
MemSect(0);
}
#endif
}
@ -1176,9 +1172,7 @@ void LevelChunk::removeEntity(std::shared_ptr<Entity> e, int yc) {
entityBlocks[yc]->erase(it);
// 4J - we don't want storage creeping up here as thinkgs move round
// the world accumulating up spare space
MemSect(31);
entityBlocks[yc]->shrink_to_fit();
MemSect(0);
}
}
}

View file

@ -96,19 +96,15 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) {
if (m_saveFile->getOriginalSaveVersion() >=
SAVE_FILE_VERSION_COMPRESSED_CHUNK_STORAGE) {
if (regionChunkInputStream != nullptr) {
MemSect(9);
levelChunk = OldChunkStorage::load(level, regionChunkInputStream);
loadEntities(level, levelChunk);
MemSect(0);
regionChunkInputStream->deleteChildStream();
delete regionChunkInputStream;
}
} else {
CompoundTag* chunkData;
if (regionChunkInputStream != nullptr) {
MemSect(8);
chunkData = NbtIo::read((DataInput*)regionChunkInputStream);
MemSect(0);
} else {
return nullptr;
}
@ -134,10 +130,8 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) {
delete chunkData;
return nullptr;
}
MemSect(9);
levelChunk =
OldChunkStorage::load(level, chunkData->getCompound(L"Level"));
MemSect(0);
if (!levelChunk->isAt(x, z)) {
char buf[256];
sprintf(buf,
@ -153,9 +147,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) {
// can never reload from it
// chunkData->putInt(L"xPos", x);
// chunkData->putInt(L"zPos", z);
// MemSect(10);
// levelChunk = OldChunkStorage::load(level,
// chunkData->getCompound(L"Level")); MemSect(0);
}
#if defined(SPLIT_SAVES)
loadEntities(level, levelChunk);
@ -184,7 +176,6 @@ void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) {
// running saves on multiple threads these sections have a lot of
// contention. Better to let each thread have its turn at a higher level of
// granularity.
MemSect(30);
PIXBeginNamedEvent(0, "Getting output stream\n");
DataOutputStream* output = RegionFileCache::getChunkDataOutputStream(
m_saveFile, m_prefix, levelChunk->x, levelChunk->z);
@ -232,7 +223,6 @@ void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) {
}
PIXEndNamedEvent();
}
MemSect(0);
LevelData* levelInfo = level->getLevelData();

View file

@ -231,10 +231,8 @@ DataInputStream* RegionFile::getChunkDataInputStream(
return nullptr;
}
MemSect(50);
std::uint8_t* data = new std::uint8_t[length];
std::uint8_t* decomp = new std::uint8_t[decompLength];
MemSect(0);
readDecompLength = decompLength;
m_saveFile->readFile(fileEntry, data, length, &numberOfBytesRead);

View file

@ -27,7 +27,6 @@ RegionFile* RegionFileCache::_getRegionFile(
// File file(regionDir, wstring(L"r.") + _toString(chunkX>>5) + L"." +
// _toString(chunkZ>>5) + L".mcr" );
MemSect(31);
File file;
if (useSplitSaves(saveFile->getSavePlatform())) {
file = File(prefix + std::wstring(L"r.") + _toString(chunkX >> 4) +
@ -36,7 +35,6 @@ RegionFile* RegionFileCache::_getRegionFile(
file = File(prefix + std::wstring(L"r.") + _toString(chunkX >> 5) +
L"." + _toString(chunkZ >> 5) + L".mcr");
}
MemSect(0);
RegionFile* ref = nullptr;
auto it = cache.find(file);

View file

@ -8,9 +8,7 @@ void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs,
std::vector<uint8_t>& blocks, double xCave, double yCave,
double zCave, float thickness, float yRot,
float xRot, int step, int dist, double yScale) {
MemSect(49);
Random* random = new Random(seed);
MemSect(0);
double xMid = xOffs * 16 + 8;
double zMid = zOffs * 16 + 8;

View file

@ -92,9 +92,7 @@ StructurePiece* MineShaftPieces::generateAndAddPiece(
StructurePiece* newPiece = createRandomShaftPiece(
pieces, random, footX, footY, footZ, direction, depth + 1);
if (newPiece != nullptr) {
MemSect(50);
pieces->push_back(newPiece);
MemSect(0);
newPiece->addChildren(startPiece, pieces, random);
}
return newPiece;

View file

@ -10,13 +10,11 @@ PerlinNoise::PerlinNoise(int levels) {
PerlinNoise::PerlinNoise(Random* random, int levels) { init(random, levels); }
void PerlinNoise::init(Random* random, int levels) {
MemSect(2);
this->levels = levels;
noiseLevels = new ImprovedNoise*[levels];
for (int i = 0; i < levels; i++) {
noiseLevels[i] = new ImprovedNoise(random);
}
MemSect(0);
}
PerlinNoise::~PerlinNoise() {

View file

@ -12,13 +12,11 @@ PerlinSimplexNoise::PerlinSimplexNoise(Random* random, int levels) {
}
void PerlinSimplexNoise::init(Random* random, int levels) {
MemSect(3);
this->levels = levels;
noiseLevels = new SimplexNoise*[levels];
for (int i = 0; i < levels; i++) {
noiseLevels[i] = new SimplexNoise(random);
}
MemSect(0);
}
PerlinSimplexNoise::~PerlinSimplexNoise() {

View file

@ -190,9 +190,7 @@ Node* PathFinder::getNode(Entity* entity, int x, int y, int z, Node* size,
Node* node;
auto it = nodes.find(i);
if (it == nodes.end()) {
MemSect(54);
node = new Node(x, y, z);
MemSect(0);
nodes.insert(std::unordered_map<int, Node*>::value_type(i, node));
} else {
node = (*it).second;

View file

@ -414,12 +414,10 @@ void MapItemSavedData::tickCarriedBy(std::shared_ptr<Player> player,
}
#endif
MemSect(45);
decorations.push_back(new MapDecoration(
imgIndex, x, y, rot, decorationPlayer->entityId,
(decorationPlayer == hp->player ||
decorationPlayer->canShowOnMaps())));
MemSect(0);
}
}
}

View file

@ -93,9 +93,7 @@ ChunkStorage* McRegionLevelStorage::createChunkStorage(Dimension* dimension) {
void McRegionLevelStorage::saveLevelData(
LevelData* levelData, std::vector<std::shared_ptr<Player> >* players) {
levelData->setVersion(MCREGION_VERSION_ID);
MemSect(38);
DirectoryLevelStorage::saveLevelData(levelData, players);
MemSect(0);
}
void McRegionLevelStorage::closeAll() { RegionFileCache::clear(); }

View file

@ -41,7 +41,6 @@ void BaseRailTile::Rail::updateConnections(int direction) {
delete connections[i];
}
connections.clear();
MemSect(50);
if (direction == DIR_FLAT_Z) {
connections.push_back(new TilePos(x, y, z - 1));
connections.push_back(new TilePos(x, y, z + 1));
@ -73,7 +72,6 @@ void BaseRailTile::Rail::updateConnections(int direction) {
connections.push_back(new TilePos(x + 1, y, z));
connections.push_back(new TilePos(x, y, z - 1));
}
MemSect(0);
}
}
@ -87,9 +85,7 @@ void BaseRailTile::Rail::removeSoftConnections() {
i--;
} else {
delete connections[i];
MemSect(50);
connections[i] = new TilePos(rail->x, rail->y, rail->z);
MemSect(0);
}
delete rail;
}
@ -169,9 +165,7 @@ bool BaseRailTile::Rail::canConnectTo(Rail* rail) {
void BaseRailTile::Rail::connectTo(Rail* rail) {
if (m_bValidRail) {
MemSect(50);
connections.push_back(new TilePos(rail->x, rail->y, rail->z));
MemSect(0);
bool n = hasConnection(x, y, z - 1);
bool s = hasConnection(x, y, z + 1);

View file

@ -317,10 +317,8 @@ std::shared_ptr<Container> ChestTile::getContainer(Level* level, int x, int y,
}
std::shared_ptr<TileEntity> ChestTile::newTileEntity(Level* level) {
MemSect(50);
std::shared_ptr<TileEntity> retval =
std::shared_ptr<TileEntity>(new ChestTileEntity());
MemSect(0);
return retval;
}

View file

@ -352,12 +352,10 @@ void LiquidTile::updateLiquid(Level* level, int x, int y, int z) {
}
void LiquidTile::fizz(Level* level, int x, int y, int z) {
MemSect(31);
level->playSound(
x + 0.5f, y + 0.5f, z + 0.5f, eSoundType_RANDOM_FIZZ, 0.5f,
2.6f +
(level->random->nextFloat() - level->random->nextFloat()) * 0.8f);
MemSect(0);
for (int i = 0; i < 8; i++) {
level->addParticle(eParticleType_largesmoke, x + Math::random(),
y + 1.2, z + Math::random(), 0, 0, 0);

View file

@ -2,13 +2,11 @@
#include "nbt/NbtIo.h"
CompoundTag* NbtIo::readCompressed(InputStream* in) {
// MemSect(26);
// 4J - this was using a try/finally block
DataInputStream dis =
DataInputStream(in); // 4J - was new GZIPInputStream as well
CompoundTag* ret = NbtIo::read((DataInput*)&dis);
dis.close();
// MemSect(0);
return ret;
}