refactor: remove dead code and fix thread safety in console_helpers

This commit is contained in:
MatthewBeshay
2026-04-03 19:00:40 +11:00
parent 5bbb045e86
commit 116cf4887d
26 changed files with 93 additions and 597 deletions
@@ -7,7 +7,6 @@
#include <unordered_set>
#include <vector>
#include "console_helpers/HashExtension.h"
#include "java/JavaIntHash.h"
#include "minecraft/world/entity/Entity.h"
@@ -202,7 +202,6 @@ GameRenderer::GameRenderer(Minecraft* mc) {
m_updateEvents->set(eUpdateEventIsFinished);
m_updateThread = new C4JThread(runUpdate, nullptr, "Chunk update");
m_updateThread->setProcessor(CPU_CORE_CHUNK_UPDATE);
m_updateThread->run();
#endif
}
@@ -4029,14 +4029,6 @@ void LevelRenderer::staticCtor() {
s_activationEventA[i] = new C4JThread::Event();
// Threads 1,3 and 5 are generally idle so use them
if ((i % 3) == 0)
rebuildThreads[i]->setProcessor(CPU_CORE_CHUNK_REBUILD_A);
else if ((i % 3) == 1) {
rebuildThreads[i]->setProcessor(CPU_CORE_CHUNK_REBUILD_B);
} else if ((i % 3) == 2)
rebuildThreads[i]->setProcessor(CPU_CORE_CHUNK_REBUILD_C);
// ResumeThread( saveThreads[j] );
rebuildThreads[i]->run();
}
@@ -1228,13 +1228,10 @@ BufferedImage* Textures::readImage(
name, false, isTu,
drive); // new BufferedImage(name,false,isTu,drive);
} else {
const char* pchName = wstringtofilename(name);
{
drive = skins->getDefault()->getPath(isTu);
}
const char* pchDrive = wstringtofilename(drive);
if (IsOriginalImage(texId, name) || isTu) {
img = skins->getDefault()->getImageResource(
name, false, isTu,
@@ -160,9 +160,10 @@ std::wstring AbstractTexturePack::getAnimationString(
BufferedImage* AbstractTexturePack::getImageResource(
const std::wstring& File, bool filenameHasExtension /*= false*/,
bool bTitleUpdateTexture /*=false*/, const std::wstring& drive /*=L""*/) {
const char* pchTexture = wstringtofilename(File);
std::string pchTexture = wstringtofilename(File);
std::string pchDrive = wstringtofilename(drive);
app.DebugPrintf("AbstractTexturePack::getImageResource - %s, drive is %s\n",
pchTexture, wstringtofilename(drive));
pchTexture.c_str(), pchDrive.c_str());
return new BufferedImage(TexturePack::getResource(L"/" + File),
filenameHasExtension, bTitleUpdateTexture, drive);
+3 -6
View File
@@ -116,19 +116,16 @@ Connection::Connection(Socket* socket, const std::wstring& id,
m_hWakeReadThread = new C4JThread::Event;
m_hWakeWriteThread = new C4JThread::Event;
const char* szId = wstringtofilename(id);
std::string szId = wstringtofilename(id);
char readThreadName[256];
char writeThreadName[256];
sprintf(readThreadName, "%s read\n", szId);
sprintf(writeThreadName, "%s write\n", szId);
sprintf(readThreadName, "%s read\n", szId.c_str());
sprintf(writeThreadName, "%s write\n", szId.c_str());
readThread =
new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE);
writeThread =
new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE);
readThread->setProcessor(CPU_CORE_CONNECTIONS);
writeThread->setProcessor(CPU_CORE_CONNECTIONS);
readThread->run();
writeThread->run();
@@ -4,7 +4,6 @@
#include <unordered_map>
#include <unordered_set>
#include "console_helpers/HashExtension.h"
#include "java/JavaIntHash.h"
class Entity;
@@ -91,7 +91,6 @@ void ServerLevel::staticCtor() {
m_updateTrigger = new C4JThread::EventArray(3);
m_updateThread = new C4JThread(runUpdate, nullptr, "Tile update");
m_updateThread->setProcessor(CPU_CORE_TILE_UPDATE);
m_updateThread->run();
RANDOM_BONUS_ITEMS = std::vector<WeighedTreasure*>(20);
@@ -1200,7 +1200,7 @@ int CompressedTileStorage::getHighestNonEmptyY() {
void CompressedTileStorage::write(DataOutputStream* dos) {
dos->writeInt(allocatedSize);
if (indicesAndData) {
if (LOCALSYTEM_ENDIAN == BIGENDIAN) {
if (LOCALSYSTEM_ENDIAN == BIGENDIAN) {
// The first 1024 bytes are an array of shorts, so we need to
// reverse the endianness
std::vector<uint8_t> indicesCopy(1024);
@@ -1236,7 +1236,7 @@ void CompressedTileStorage::read(DataInputStream* dis) {
std::vector<uint8_t> wrapper(allocatedSize);
dis->readFully(wrapper);
memcpy(indicesAndData, wrapper.data(), allocatedSize);
if (LOCALSYTEM_ENDIAN == BIGENDIAN) {
if (LOCALSYSTEM_ENDIAN == BIGENDIAN) {
reverseIndices(indicesAndData);
}
@@ -12,7 +12,6 @@
#include "app/common/src/Console_Debug_enum.h"
#include "app/linux/Linux_App.h"
#include "console_helpers/C4JThread.h"
#include "console_helpers/ThreadName.h"
#include "console_helpers/compression.h"
#include "java/InputOutputStream/BufferedOutputStream.h"
#include "java/InputOutputStream/ByteArrayInputStream.h"
@@ -324,7 +323,7 @@ void McRegionChunkStorage::staticCtor() {
for (unsigned int i = 0; i < 3; ++i) {
char threadName[256];
sprintf(threadName, "McRegion Save thread %d\n", i);
SetThreadName(0, threadName);
C4JThread::setThreadName(0, threadName);
// saveThreads[j] =
// CreateThread(nullptr,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]);
@@ -333,14 +332,6 @@ void McRegionChunkStorage::staticCtor() {
// app.DebugPrintf("Created new thread: %s\n",threadName);
// Threads 1,3 and 5 are generally idle so use them
if (i == 0)
s_saveThreads[i]->setProcessor(CPU_CORE_SAVE_THREAD_A);
else if (i == 1) {
s_saveThreads[i]->setProcessor(CPU_CORE_SAVE_THREAD_B);
} else if (i == 2)
s_saveThreads[i]->setProcessor(CPU_CORE_SAVE_THREAD_C);
// ResumeThread( saveThreads[j] );
s_saveThreads[i]->run();
}
@@ -4,7 +4,6 @@
#include <string>
#include <unordered_map>
#include "console_helpers/HashExtension.h"
#include "java/Class.h"
#include "java/JavaIntHash.h"