From 365f6ad5eb3079770d3cb111cc44c5421e97d319 Mon Sep 17 00:00:00 2001 From: Mohamed Ashraf Date: Tue, 3 Mar 2026 00:41:40 +0400 Subject: [PATCH] fix(TLS): tls shit --- Minecraft.Client/Textures.h | 2 +- Minecraft.World/Entity.cpp | 10 +++++----- Minecraft.World/Entity.h | 2 +- Minecraft.World/EntityIO.cpp | 1 + Minecraft.World/Mob.cpp | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Minecraft.Client/Textures.h b/Minecraft.Client/Textures.h index eb0799e2c..730b09f01 100644 --- a/Minecraft.Client/Textures.h +++ b/Minecraft.Client/Textures.h @@ -1,5 +1,5 @@ #pragma once -#include "..\Minecraft.World\ArrayWithLength.h" +#include "../Minecraft.World/ArrayWithLength.h" class DynamicTexture; class BufferedImage; diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index 5ce051ebe..853ac888f 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -133,7 +133,7 @@ void Entity::countFlagsForPIX() void Entity::resetSmallId() { freeSmallId(entityId); - if( ((size_t)TlsGetValue(tlsIdx) != 0 ) ) + if( ((size_t)pthread_getspecific(tlsIdx) != 0 ) ) { entityId = getSmallId(); } @@ -141,7 +141,7 @@ void Entity::resetSmallId() void Entity::freeSmallId(int index) { - if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread + if( ( (size_t)pthread_getspecific(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread if( index >= 2048 ) return; // Don't do anything if this isn't a short id unsigned int i = index / 32; @@ -164,7 +164,7 @@ void Entity::useSmallIds() // Let the management system here know whether or not to consider this particular entity for some extra wandering void Entity::considerForExtraWandering(bool enable) { - if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread + if( ( (size_t)pthread_getspecific(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread if( entityId >= 2048 ) return; // Don't do anything if this isn't a short id unsigned int i = entityId / 32; @@ -184,7 +184,7 @@ void Entity::considerForExtraWandering(bool enable) // Should this entity do wandering in addition to what the java code would have done? bool Entity::isExtraWanderingEnabled() { - if( ( (size_t)TlsGetValue(tlsIdx) ) == 0 ) return false; // Don't do anything with small ids if this isn't the server thread + if( ( (size_t)pthread_getspecific(tlsIdx) ) == 0 ) return false; // Don't do anything with small ids if this isn't the server thread if( entityId >= 2048 ) return false; // Don't do anything if this isn't a short id for( int i = 0; i < extraWanderCount; i++ ) @@ -247,7 +247,7 @@ void Entity::_init(bool useSmallId) // 4J - changed to assign two different types of ids. A range from 0-2047 is used for things that we'll be wanting to identify over the network, // so we should only need 11 bits rather than 32 to uniquely identify them. The rest of the range is used for anything we don't need to track like this, // currently particles. We only ever want to allocate this type of id from the server thread, so using thread local storage to isolate this. - if( useSmallId && ((size_t)TlsGetValue(tlsIdx) != 0 ) ) + if( useSmallId && ((size_t)pthread_getspecific(tlsIdx) != 0 ) ) { entityId = getSmallId(); } diff --git a/Minecraft.World/Entity.h b/Minecraft.World/Entity.h index 2248ed9ec..94873f899 100644 --- a/Minecraft.World/Entity.h +++ b/Minecraft.World/Entity.h @@ -369,7 +369,7 @@ private: #if defined(_WIN32) static DWORD tlsIdx; #else - static pthread_key_t tlsKey; + static pthread_key_t tlsIdx; #endif public: static void tickExtraWandering(); diff --git a/Minecraft.World/EntityIO.cpp b/Minecraft.World/EntityIO.cpp index d0677d38e..e4bf95f44 100644 --- a/Minecraft.World/EntityIO.cpp +++ b/Minecraft.World/EntityIO.cpp @@ -13,6 +13,7 @@ #include "net.minecraft.world.level.h" #include "com.mojang.nbt.h" #include "EntityIO.h" +#include "../Minecraft.Client/Windows64Media/strings.h" unordered_map *EntityIO::idCreateMap = new unordered_map; unordered_map *EntityIO::classIdMap = new unordered_map; diff --git a/Minecraft.World/Mob.cpp b/Minecraft.World/Mob.cpp index d2dcddfbf..5311b56c9 100644 --- a/Minecraft.World/Mob.cpp +++ b/Minecraft.World/Mob.cpp @@ -18,7 +18,7 @@ #include "net.minecraft.world.item.enchantment.h" #include "com.mojang.nbt.h" #include "Mob.h" -#include "..\Minecraft.Client\Textures.h" +#include "../Minecraft.Client/Textures.h" #include "SoundTypes.h" #include "BasicTypeContainers.h" #include "ParticleTypes.h"