mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-13 12:17:13 +00:00
adjust naming scheme of private TLS members
This commit is contained in:
parent
9ff2fb4fef
commit
30170b8f9c
|
|
@ -20,18 +20,18 @@
|
|||
int Chunk::updates = 0;
|
||||
|
||||
#ifdef _LARGE_WORLDS
|
||||
thread_local uint8_t* Chunk::m_threadTileIds = nullptr;
|
||||
thread_local uint8_t* Chunk::m_tlsTileIds = nullptr;
|
||||
|
||||
void Chunk::CreateNewThreadStorage() {
|
||||
m_threadTileIds = new unsigned char[16 * 16 * Level::maxBuildHeight];
|
||||
m_tlsTileIds = new unsigned char[16 * 16 * Level::maxBuildHeight];
|
||||
}
|
||||
|
||||
void Chunk::ReleaseThreadStorage() {
|
||||
delete m_threadTileIds;
|
||||
delete m_tlsTileIds;
|
||||
}
|
||||
|
||||
uint8_t* Chunk::GetTileIdsStorage() {
|
||||
return m_threadTileIds;
|
||||
return m_tlsTileIds;
|
||||
}
|
||||
#else
|
||||
// 4J Stu - Don't want this when multi-threaded
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ private:
|
|||
#ifndef _LARGE_WORLDS
|
||||
static Tesselator* t;
|
||||
#else
|
||||
static thread_local uint8_t* m_threadTileIds;
|
||||
static thread_local uint8_t* m_tlsTileIds;
|
||||
|
||||
public:
|
||||
static void CreateNewThreadStorage();
|
||||
|
|
|
|||
|
|
@ -24,14 +24,14 @@ int normal;
|
|||
|
||||
|
||||
*/
|
||||
thread_local Tesselator* Tesselator::m_threadInstance = nullptr;
|
||||
thread_local Tesselator* Tesselator::m_tlsInstance = nullptr;
|
||||
|
||||
Tesselator* Tesselator::getInstance() {
|
||||
return m_threadInstance;
|
||||
return m_tlsInstance;
|
||||
}
|
||||
|
||||
void Tesselator::CreateNewThreadStorage(int bytes) {
|
||||
Tesselator::m_threadInstance = new Tesselator(bytes / 4);
|
||||
Tesselator::m_tlsInstance = new Tesselator(bytes / 4);
|
||||
}
|
||||
|
||||
// she tessalate my vertices till i render
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public:
|
|||
static void CreateNewThreadStorage(int bytes);
|
||||
|
||||
private:
|
||||
static thread_local Tesselator* m_threadInstance;
|
||||
static thread_local Tesselator* m_tlsInstance;
|
||||
|
||||
public:
|
||||
static Tesselator* getInstance();
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ void ButtonTile::checkPressed(Level* level, int x, int y, int z) {
|
|||
bool shouldBePressed;
|
||||
|
||||
updateShape(data);
|
||||
Tile::ThreadStorage* tls = m_threadShape;
|
||||
Tile::ThreadStorage* tls = m_tlsShape;
|
||||
std::vector<std::shared_ptr<Entity> >* entities = level->getEntitiesOfClass(
|
||||
typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0,
|
||||
x + tls->xx1, y + tls->yy1, z + tls->zz1));
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ void LiquidTile::animateTick(Level* level, int x, int y, int z,
|
|||
if (level->getMaterial(x, y + 1, z) == Material::air &&
|
||||
!level->isSolidRenderTile(x, y + 1, z)) {
|
||||
if (random->nextInt(100) == 0) {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
double xx = x + random->nextFloat();
|
||||
double yy = y + tls->yy1;
|
||||
double zz = z + random->nextFloat();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const std::wstring PistonBaseTile::INSIDE_TEX = L"piston_inner_top";
|
|||
|
||||
const float PistonBaseTile::PLATFORM_THICKNESS = 4.0f;
|
||||
|
||||
thread_local bool PistonBaseTile::m_threadIgnoreUpdate = false;
|
||||
thread_local bool PistonBaseTile::m_tlsIgnoreUpdate = false;
|
||||
|
||||
// 4J - NOTE - this ignoreUpdate stuff has been removed from the java version,
|
||||
// but I'm not currently sure how the java version does without it... there must
|
||||
|
|
@ -32,11 +32,11 @@ thread_local bool PistonBaseTile::m_threadIgnoreUpdate = false;
|
|||
// 4J - ignoreUpdate is a static in java, implementing as TLS here to make
|
||||
// thread safe
|
||||
bool PistonBaseTile::ignoreUpdate() {
|
||||
return m_threadIgnoreUpdate;
|
||||
return m_tlsIgnoreUpdate;
|
||||
}
|
||||
|
||||
void PistonBaseTile::ignoreUpdate(bool set) {
|
||||
m_threadIgnoreUpdate = set;
|
||||
m_tlsIgnoreUpdate = set;
|
||||
}
|
||||
|
||||
PistonBaseTile::PistonBaseTile(int id, bool isSticky)
|
||||
|
|
@ -72,7 +72,7 @@ Icon* PistonBaseTile::getTexture(int face, int data) {
|
|||
// when the piston is extended, either normally
|
||||
// or because a piston arm animation, the top
|
||||
// texture is the furnace bottom
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
if (isExtended(data) || tls->xx0 > 0 || tls->yy0 > 0 || tls->zz0 > 0 ||
|
||||
tls->xx1 < 1 || tls->yy1 < 1 || tls->zz1 < 1) {
|
||||
return iconInside;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ private:
|
|||
Icon* iconBack;
|
||||
Icon* iconPlatform;
|
||||
|
||||
static thread_local bool m_threadIgnoreUpdate;
|
||||
static thread_local bool m_tlsIgnoreUpdate;
|
||||
|
||||
static TlsKey tlsIdx;
|
||||
// 4J - was just a static but implemented with TLS for our version
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ void PistonMovingPiece::updateShape(
|
|||
progress = 1.0f - progress;
|
||||
}
|
||||
int facing = entity->getFacing();
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
tls->xx0 = tile->getShapeX0() - Facing::STEP_X[facing] * progress;
|
||||
tls->yy0 = tile->getShapeY0() - Facing::STEP_Y[facing] * progress;
|
||||
tls->zz0 = tile->getShapeZ0() - Facing::STEP_Z[facing] * progress;
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ void StemTile::updateShape(
|
|||
std::shared_ptr<TileEntity>
|
||||
forceEntity) // 4J added forceData, forceEntity param
|
||||
{
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
tls->yy1 = (level->getData(x, y, z) * 2 + 2) / 16.0f;
|
||||
float ss = 0.125f;
|
||||
setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float)tls->yy1, 0.5f + ss);
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@
|
|||
#include "../Headers/net.minecraft.world.h"
|
||||
#include <cstdint>
|
||||
|
||||
thread_local bool TheEndPortal::m_threadAllowAnywhere = false;
|
||||
thread_local bool TheEndPortal::m_tlsAllowAnywhere = false;
|
||||
|
||||
// 4J - allowAnywhere is a static in java, implementing as TLS here to make
|
||||
// thread safe
|
||||
bool TheEndPortal::allowAnywhere() {
|
||||
return m_threadAllowAnywhere;
|
||||
return m_tlsAllowAnywhere;
|
||||
}
|
||||
|
||||
void TheEndPortal::allowAnywhere(bool set) {
|
||||
m_threadAllowAnywhere = set;
|
||||
m_tlsAllowAnywhere = set;
|
||||
}
|
||||
|
||||
TheEndPortal::TheEndPortal(int id, Material* material)
|
||||
|
|
|
|||
|
|
@ -35,5 +35,5 @@ public:
|
|||
void registerIcons(IconRegister* iconRegister);
|
||||
|
||||
private:
|
||||
static thread_local bool m_threadAllowAnywhere;
|
||||
static thread_local bool m_tlsAllowAnywhere;
|
||||
};
|
||||
|
|
@ -222,7 +222,7 @@ Tile* Tile::woolCarpet = NULL;
|
|||
Tile* Tile::clayHardened = NULL;
|
||||
Tile* Tile::coalBlock = NULL;
|
||||
|
||||
thread_local Tile::ThreadStorage* Tile::m_threadShape = nullptr;
|
||||
thread_local Tile::ThreadStorage* Tile::m_tlsShape = nullptr;
|
||||
|
||||
Tile::ThreadStorage::ThreadStorage() {
|
||||
xx0 = yy0 = zz0 = xx1 = yy1 = zz1 = 0.0;
|
||||
|
|
@ -230,11 +230,11 @@ Tile::ThreadStorage::ThreadStorage() {
|
|||
}
|
||||
|
||||
void Tile::CreateNewThreadStorage() {
|
||||
m_threadShape = new ThreadStorage();
|
||||
m_tlsShape = new ThreadStorage();
|
||||
}
|
||||
|
||||
void Tile::ReleaseThreadStorage() {
|
||||
delete m_threadShape;
|
||||
delete m_tlsShape;
|
||||
}
|
||||
|
||||
void Tile::staticCtor() {
|
||||
|
|
@ -1868,7 +1868,7 @@ Tile* Tile::disableMipmap() {
|
|||
|
||||
void Tile::setShape(float x0, float y0, float z0, float x1, float y1,
|
||||
float z1) {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
tls->xx0 = x0;
|
||||
tls->yy0 = y0;
|
||||
tls->zz0 = z0;
|
||||
|
|
@ -1919,7 +1919,7 @@ bool Tile::isFaceVisible(Level* level, int x, int y, int z, int f) {
|
|||
|
||||
bool Tile::shouldRenderFace(LevelSource* level, int x, int y, int z, int face) {
|
||||
ThreadStorage* tls =
|
||||
m_threadShape;
|
||||
m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
if (face == 0 && tls->yy0 > 0) return true;
|
||||
|
|
@ -1936,7 +1936,7 @@ bool Tile::shouldRenderFace(LevelSource* level, int x, int y, int z, int face) {
|
|||
int Tile::getFaceFlags(LevelSource* level, int x, int y, int z) {
|
||||
int faceFlags = 0;
|
||||
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
|
||||
|
|
@ -2009,7 +2009,7 @@ Icon* Tile::getTexture(int face, int data) { return icon; }
|
|||
Icon* Tile::getTexture(int face) { return getTexture(face, 0); }
|
||||
|
||||
AABB* Tile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
|
||||
|
|
@ -2023,7 +2023,7 @@ void Tile::addAABBs(Level* level, int x, int y, int z, AABB* box,
|
|||
}
|
||||
|
||||
AABB* Tile::getAABB(Level* level, int x, int y, int z) {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
|
||||
|
|
@ -2128,7 +2128,7 @@ HitResult* Tile::clip(Level* level, int xt, int yt, int zt, Vec3* a, Vec3* b) {
|
|||
a = a->add(-xt, -yt, -zt);
|
||||
b = b->add(-xt, -yt, -zt);
|
||||
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
Vec3* xh0 = a->clipX(b, tls->xx0);
|
||||
Vec3* xh1 = a->clipX(b, tls->xx1);
|
||||
|
||||
|
|
@ -2176,7 +2176,7 @@ HitResult* Tile::clip(Level* level, int xt, int yt, int zt, Vec3* a, Vec3* b) {
|
|||
bool Tile::containsX(Vec3* v) {
|
||||
if (v == NULL) return false;
|
||||
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return v->y >= tls->yy0 && v->y <= tls->yy1 && v->z >= tls->zz0 &&
|
||||
|
|
@ -2186,7 +2186,7 @@ bool Tile::containsX(Vec3* v) {
|
|||
bool Tile::containsY(Vec3* v) {
|
||||
if (v == NULL) return false;
|
||||
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return v->x >= tls->xx0 && v->x <= tls->xx1 && v->z >= tls->zz0 &&
|
||||
|
|
@ -2196,7 +2196,7 @@ bool Tile::containsY(Vec3* v) {
|
|||
bool Tile::containsZ(Vec3* v) {
|
||||
if (v == NULL) return false;
|
||||
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return v->x >= tls->xx0 && v->x <= tls->xx1 && v->y >= tls->yy0 &&
|
||||
|
|
@ -2260,48 +2260,48 @@ void Tile::updateShape(
|
|||
std::shared_ptr<TileEntity>
|
||||
forceEntity) // 4J added forceData, forceEntity param
|
||||
{
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
}
|
||||
|
||||
double Tile::getShapeX0() {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return tls->xx0;
|
||||
}
|
||||
|
||||
double Tile::getShapeX1() {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return tls->xx1;
|
||||
}
|
||||
|
||||
double Tile::getShapeY0() {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return tls->yy0;
|
||||
}
|
||||
|
||||
double Tile::getShapeY1() {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return tls->yy1;
|
||||
}
|
||||
|
||||
double Tile::getShapeZ0() {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return tls->zz0;
|
||||
}
|
||||
|
||||
double Tile::getShapeZ1() {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return tls->zz1;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ protected:
|
|||
int tileId;
|
||||
ThreadStorage();
|
||||
};
|
||||
static thread_local ThreadStorage* m_threadShape;
|
||||
static thread_local ThreadStorage* m_tlsShape;
|
||||
public:
|
||||
// Each new thread that needs to use Vec3 pools will need to call one of the
|
||||
// following 2 functions, to either create its own local storage, or share
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ void TopSnowTile::registerIcons(IconRegister* iconRegister) {
|
|||
AABB* TopSnowTile::getAABB(Level* level, int x, int y, int z) {
|
||||
int height = level->getData(x, y, z) & HEIGHT_MASK;
|
||||
float offset = 2.0f / SharedConstants::WORLD_RESOLUTION;
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
|
||||
y + (height * offset), z + tls->zz1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ void TripWireTile::checkPressed(Level* level, int x, int y, int z) {
|
|||
bool wasPressed = (data & MASK_POWERED) == MASK_POWERED;
|
||||
bool shouldBePressed = false;
|
||||
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
std::vector<std::shared_ptr<Entity> >* entities = level->getEntities(
|
||||
nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0,
|
||||
x + tls->xx1, y + tls->yy1, z + tls->zz1));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ void WaterlilyTile::addAABBs(Level* level, int x, int y, int z, AABB* box,
|
|||
}
|
||||
|
||||
AABB* WaterlilyTile::getAABB(Level* level, int x, int y, int z) {
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Icon* WoolCarpetTile::getTexture(int face, int data) {
|
|||
AABB* WoolCarpetTile::getAABB(Level* level, int x, int y, int z) {
|
||||
int height = 0;
|
||||
float offset = 1.0f / SharedConstants::WORLD_RESOLUTION;
|
||||
ThreadStorage* tls = m_threadShape;
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include "../../Minecraft.Client/Level/ServerLevel.h"
|
||||
#include "../../Minecraft.Client/Network/PlayerList.h"
|
||||
|
||||
thread_local bool Entity::m_threadUseSmallIds = false;
|
||||
thread_local bool Entity::m_tlsUseSmallIds = false;
|
||||
|
||||
const std::wstring Entity::RIDING_TAG = L"Riding";
|
||||
int Entity::entityCounter =
|
||||
|
|
@ -54,7 +54,7 @@ int Entity::getSmallId() {
|
|||
// telling the client that the entity has been removed After we have already
|
||||
// re-used its Id and created a new entity. This ends up with newly created
|
||||
// client-side entities being removed by accident, causing invisible mobs.
|
||||
if (m_threadUseSmallIds) {
|
||||
if (m_tlsUseSmallIds) {
|
||||
MinecraftServer* server = MinecraftServer::getInstance();
|
||||
if (server) {
|
||||
// In some attempt to optimise this, flagEntitiesToBeRemoved most of
|
||||
|
|
@ -129,13 +129,13 @@ void Entity::countFlagsForPIX() {
|
|||
|
||||
void Entity::resetSmallId() {
|
||||
freeSmallId(entityId);
|
||||
if (m_threadUseSmallIds) {
|
||||
if (m_tlsUseSmallIds) {
|
||||
entityId = getSmallId();
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::freeSmallId(int index) {
|
||||
if (!m_threadUseSmallIds)
|
||||
if (!m_tlsUseSmallIds)
|
||||
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
|
||||
|
|
@ -148,7 +148,7 @@ void Entity::freeSmallId(int index) {
|
|||
entityIdWanderFlags[i] &= uiMask;
|
||||
}
|
||||
|
||||
void Entity::useSmallIds() { m_threadUseSmallIds = true; }
|
||||
void Entity::useSmallIds() { m_tlsUseSmallIds = true; }
|
||||
|
||||
// Things also added here to be able to manage the concept of a number of extra
|
||||
// "wandering" entities - normally path finding entities aren't allowed to
|
||||
|
|
@ -161,7 +161,7 @@ void Entity::useSmallIds() { m_threadUseSmallIds = true; }
|
|||
// Let the management system here know whether or not to consider this
|
||||
// particular entity for some extra wandering
|
||||
void Entity::considerForExtraWandering(bool enable) {
|
||||
if (!m_threadUseSmallIds)
|
||||
if (!m_tlsUseSmallIds)
|
||||
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
|
||||
|
|
@ -180,7 +180,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 (!m_threadUseSmallIds)
|
||||
if (!m_tlsUseSmallIds)
|
||||
return false; // Don't do anything with small ids if this isn't the
|
||||
// server thread
|
||||
if (entityId >= 2048)
|
||||
|
|
@ -247,7 +247,7 @@ void Entity::_init(bool useSmallId, Level* level) {
|
|||
// 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 && m_threadUseSmallIds) {
|
||||
if (useSmallId && m_tlsUseSmallIds) {
|
||||
entityId = getSmallId();
|
||||
} else {
|
||||
entityId = Entity::entityCounter++;
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ private:
|
|||
static int extraWanderCount;
|
||||
static int extraWanderTicks;
|
||||
|
||||
static thread_local bool m_threadUseSmallIds;
|
||||
static thread_local bool m_tlsUseSmallIds;
|
||||
public:
|
||||
static void tickExtraWandering();
|
||||
static void countFlagsForPIX();
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
#include "../../../Minecraft.Client/Platform/PS3/PS3Extras/EdgeZLib.h"
|
||||
#endif //__PS3__
|
||||
|
||||
thread_local Compression::ThreadStorage* Compression::m_threadCompression = nullptr;
|
||||
Compression::ThreadStorage* Compression::m_threadCompressionDefault = nullptr;
|
||||
thread_local Compression::ThreadStorage* Compression::m_tlsCompression = nullptr;
|
||||
Compression::ThreadStorage* Compression::m_tlsCompressionDefault = nullptr;
|
||||
|
||||
Compression::ThreadStorage::ThreadStorage() { compression = new Compression(); }
|
||||
|
||||
|
|
@ -26,24 +26,24 @@ Compression::ThreadStorage::~ThreadStorage() { delete compression; }
|
|||
|
||||
void Compression::CreateNewThreadStorage() {
|
||||
ThreadStorage* tls = new ThreadStorage();
|
||||
if (m_threadCompressionDefault == nullptr) {
|
||||
m_threadCompressionDefault = tls;
|
||||
if (m_tlsCompressionDefault == nullptr) {
|
||||
m_tlsCompressionDefault = tls;
|
||||
}
|
||||
m_threadCompression = tls;
|
||||
m_tlsCompression = tls;
|
||||
}
|
||||
|
||||
void Compression::UseDefaultThreadStorage() {
|
||||
m_threadCompression = m_threadCompressionDefault;
|
||||
m_tlsCompression = m_tlsCompressionDefault;
|
||||
}
|
||||
|
||||
void Compression::ReleaseThreadStorage() {
|
||||
if (m_threadCompression != m_threadCompressionDefault) {
|
||||
delete m_threadCompression;
|
||||
if (m_tlsCompression != m_tlsCompressionDefault) {
|
||||
delete m_tlsCompression;
|
||||
}
|
||||
}
|
||||
|
||||
Compression* Compression::getCompression() {
|
||||
return m_threadCompression->compression;
|
||||
return m_tlsCompression->compression;
|
||||
}
|
||||
|
||||
HRESULT Compression::CompressLZXRLE(void* pDestination, unsigned int* pDestSize,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ private:
|
|||
ThreadStorage();
|
||||
~ThreadStorage();
|
||||
};
|
||||
static thread_local ThreadStorage* m_threadCompression;
|
||||
static thread_local ThreadStorage* m_tlsCompression;
|
||||
static ThreadStorage* m_threadCompressionDefault;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -90,20 +90,20 @@
|
|||
// W - lighting value requires write
|
||||
#endif
|
||||
|
||||
thread_local bool Level::m_threadInstaTick = false;
|
||||
thread_local Level::lightCache_t* Level::m_threadLightCache = nullptr;
|
||||
thread_local bool Level::m_tlsInstaTick = false;
|
||||
thread_local Level::lightCache_t* Level::m_tlsLightCache = nullptr;
|
||||
|
||||
void Level::enableLightingCache() {
|
||||
// Allocate 16K (needs 32K for large worlds) for a 16x16x16x4 byte cache of
|
||||
// results, plus 128K required for toCheck array. Rounding up to 256 to keep
|
||||
// as multiple of alignement - aligning to 128K boundary for possible cache
|
||||
// locking.
|
||||
m_threadLightCache = (lightCache_t*)XPhysicalAlloc(
|
||||
m_tlsLightCache = (lightCache_t*)XPhysicalAlloc(
|
||||
256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES);
|
||||
}
|
||||
|
||||
void Level::destroyLightingCache() {
|
||||
delete m_threadLightCache;
|
||||
delete m_tlsLightCache;
|
||||
}
|
||||
|
||||
inline int GetIndex(int x, int y, int z) {
|
||||
|
|
@ -492,11 +492,11 @@ void Level::flushCache(lightCache_t* cache, uint64_t cacheUse,
|
|||
// 4J - added following 2 functions to move instaBuild flag from being a class
|
||||
// member, to TLS
|
||||
bool Level::getInstaTick() {
|
||||
return m_threadInstaTick;
|
||||
return m_tlsInstaTick;
|
||||
}
|
||||
|
||||
void Level::setInstaTick(bool enable) {
|
||||
m_threadInstaTick = enable;
|
||||
m_tlsInstaTick = enable;
|
||||
}
|
||||
|
||||
// 4J - added
|
||||
|
|
@ -3143,7 +3143,7 @@ int Level::getExpectedLight(lightCache_t* cache, int x, int y, int z,
|
|||
// this thread
|
||||
void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc,
|
||||
bool force, bool rootOnlyEmissive) {
|
||||
lightCache_t* cache = m_threadLightCache;
|
||||
lightCache_t* cache = m_tlsLightCache;
|
||||
uint64_t cacheUse = 0;
|
||||
|
||||
if (force) {
|
||||
|
|
|
|||
|
|
@ -93,8 +93,8 @@ public:
|
|||
|
||||
// 4J - added, making instaTick flag use TLS so we can set it in the chunk
|
||||
// rebuilding thread without upsetting the main game thread
|
||||
static thread_local bool m_threadInstaTick;
|
||||
static thread_local lightCache_t* m_threadLightCache;
|
||||
static thread_local bool m_tlsInstaTick;
|
||||
static thread_local lightCache_t* m_tlsLightCache;
|
||||
static void enableLightingCache();
|
||||
static void destroyLightingCache();
|
||||
static bool getCacheTestEnabled();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "../../IO/Files/FileHeader.h"
|
||||
#include "OldChunkStorage.h"
|
||||
|
||||
thread_local OldChunkStorage::ThreadStorage* OldChunkStorage::m_threadStorage =
|
||||
thread_local OldChunkStorage::ThreadStorage* OldChunkStorage::m_tlsStorage =
|
||||
nullptr;
|
||||
OldChunkStorage::ThreadStorage* OldChunkStorage::m_defaultThreadStorage =
|
||||
nullptr;
|
||||
|
|
@ -35,16 +35,16 @@ void OldChunkStorage::CreateNewThreadStorage() {
|
|||
m_defaultThreadStorage = tls;
|
||||
}
|
||||
|
||||
m_threadStorage = tls;
|
||||
m_tlsStorage = tls;
|
||||
}
|
||||
|
||||
void OldChunkStorage::UseDefaultThreadStorage() {
|
||||
m_threadStorage = m_defaultThreadStorage;
|
||||
m_tlsStorage = m_defaultThreadStorage;
|
||||
}
|
||||
|
||||
void OldChunkStorage::ReleaseThreadStorage() {
|
||||
if (m_threadStorage != m_defaultThreadStorage) {
|
||||
delete m_threadStorage;
|
||||
if (m_tlsStorage != m_defaultThreadStorage) {
|
||||
delete m_tlsStorage;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) {
|
|||
|
||||
// 4J Stu - As we now save on multiple threads, the static data has been
|
||||
// moved to TLS
|
||||
ThreadStorage* tls = m_threadStorage;
|
||||
ThreadStorage* tls = m_tlsStorage;
|
||||
|
||||
PIXBeginNamedEvent(0, "Getting block data");
|
||||
// static byteArray blockData = byteArray(32768);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ private:
|
|||
ThreadStorage();
|
||||
~ThreadStorage();
|
||||
};
|
||||
static thread_local ThreadStorage* m_threadStorage;
|
||||
static thread_local ThreadStorage* m_tlsStorage;
|
||||
static ThreadStorage* m_defaultThreadStorage;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "../Headers/net.minecraft.world.item.h"
|
||||
#include "FireworksRecipe.h"
|
||||
|
||||
thread_local FireworksRecipe::ThreadStorage* FireworksRecipe::m_threadStorage =
|
||||
thread_local FireworksRecipe::ThreadStorage* FireworksRecipe::m_tlsStorage =
|
||||
nullptr;
|
||||
FireworksRecipe::ThreadStorage* FireworksRecipe::m_defaultThreadStorage =
|
||||
nullptr;
|
||||
|
|
@ -16,21 +16,21 @@ void FireworksRecipe::CreateNewThreadStorage() {
|
|||
m_defaultThreadStorage = tls;
|
||||
}
|
||||
|
||||
m_threadStorage = tls;
|
||||
m_tlsStorage = tls;
|
||||
}
|
||||
|
||||
void FireworksRecipe::UseDefaultThreadStorage() {
|
||||
m_threadStorage = m_defaultThreadStorage;
|
||||
m_tlsStorage = m_defaultThreadStorage;
|
||||
}
|
||||
|
||||
void FireworksRecipe::ReleaseThreadStorage() {
|
||||
if (m_threadStorage != m_defaultThreadStorage) {
|
||||
delete m_threadStorage;
|
||||
if (m_tlsStorage != m_defaultThreadStorage) {
|
||||
delete m_tlsStorage;
|
||||
}
|
||||
}
|
||||
|
||||
void FireworksRecipe::setResultItem(std::shared_ptr<ItemInstance> item) {
|
||||
m_threadStorage->resultItem = item;
|
||||
m_tlsStorage->resultItem = item;
|
||||
}
|
||||
|
||||
FireworksRecipe::FireworksRecipe() {
|
||||
|
|
@ -216,14 +216,14 @@ bool FireworksRecipe::matches(std::shared_ptr<CraftingContainer> craftSlots,
|
|||
|
||||
std::shared_ptr<ItemInstance> FireworksRecipe::assemble(
|
||||
std::shared_ptr<CraftingContainer> craftSlots) {
|
||||
return m_threadStorage->resultItem->copy();
|
||||
return m_tlsStorage->resultItem->copy();
|
||||
// return resultItem->copy();
|
||||
}
|
||||
|
||||
int FireworksRecipe::size() { return 10; }
|
||||
|
||||
const ItemInstance* FireworksRecipe::getResultItem() {
|
||||
return m_threadStorage->resultItem.get();
|
||||
return m_tlsStorage->resultItem.get();
|
||||
// return resultItem.get();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ private:
|
|||
std::shared_ptr<ItemInstance> resultItem;
|
||||
ThreadStorage();
|
||||
};
|
||||
static thread_local ThreadStorage* m_threadStorage;
|
||||
static thread_local ThreadStorage* m_tlsStorage;
|
||||
static ThreadStorage* m_defaultThreadStorage;
|
||||
|
||||
void setResultItem(std::shared_ptr<ItemInstance> item);
|
||||
|
|
|
|||
Loading…
Reference in a new issue