mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Fix fireworks crafting crash
This commit is contained in:
parent
e9dba1fa56
commit
2d6e11bb10
|
|
@ -961,7 +961,6 @@ int CGameNetworkManager::ServerThreadProc( void* lpParameter )
|
|||
Entity::useSmallIds();
|
||||
Level::enableLightingCache();
|
||||
Tile::CreateNewThreadStorage();
|
||||
FireworksRecipe::CreateNewThreadStorage();
|
||||
|
||||
MinecraftServer::main(seed, lpParameter); //saveData, app.GetGameHostOption(eGameHostOption_All));
|
||||
|
||||
|
|
|
|||
|
|
@ -2,47 +2,14 @@
|
|||
#include "net.minecraft.world.item.h"
|
||||
#include "FireworksRecipe.h"
|
||||
|
||||
DWORD FireworksRecipe::tlsIdx = 0;
|
||||
FireworksRecipe::ThreadStorage *FireworksRecipe::tlsDefault = nullptr;
|
||||
|
||||
FireworksRecipe::ThreadStorage::ThreadStorage()
|
||||
{
|
||||
resultItem = nullptr;
|
||||
}
|
||||
|
||||
void FireworksRecipe::CreateNewThreadStorage()
|
||||
{
|
||||
ThreadStorage *tls = new ThreadStorage();
|
||||
if(tlsDefault == nullptr )
|
||||
{
|
||||
tlsIdx = TlsAlloc();
|
||||
tlsDefault = tls;
|
||||
}
|
||||
TlsSetValue(tlsIdx, tls);
|
||||
}
|
||||
|
||||
void FireworksRecipe::UseDefaultThreadStorage()
|
||||
{
|
||||
TlsSetValue(tlsIdx, tlsDefault);
|
||||
}
|
||||
|
||||
void FireworksRecipe::ReleaseThreadStorage()
|
||||
{
|
||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
||||
if( tls == tlsDefault ) return;
|
||||
|
||||
delete tls;
|
||||
}
|
||||
|
||||
void FireworksRecipe::setResultItem(shared_ptr<ItemInstance> item)
|
||||
{
|
||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
||||
tls->resultItem = item;
|
||||
this->resultItem = item;
|
||||
}
|
||||
|
||||
FireworksRecipe::FireworksRecipe()
|
||||
{
|
||||
//resultItem = nullptr;
|
||||
resultItem = nullptr;
|
||||
}
|
||||
|
||||
bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *level)
|
||||
|
|
@ -268,9 +235,11 @@ bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *l
|
|||
|
||||
shared_ptr<ItemInstance> FireworksRecipe::assemble(shared_ptr<CraftingContainer> craftSlots)
|
||||
{
|
||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
||||
return tls->resultItem->copy();
|
||||
//return resultItem->copy();
|
||||
if (this->resultItem != nullptr)
|
||||
{
|
||||
return this->resultItem->copy();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int FireworksRecipe::size()
|
||||
|
|
@ -280,9 +249,7 @@ int FireworksRecipe::size()
|
|||
|
||||
const ItemInstance *FireworksRecipe::getResultItem()
|
||||
{
|
||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
||||
return tls->resultItem.get();
|
||||
//return resultItem.get();
|
||||
return this->resultItem.get();
|
||||
}
|
||||
|
||||
void FireworksRecipe::updatePossibleRecipes(shared_ptr<CraftingContainer> craftSlots, bool *firework, bool *charge, bool *fade)
|
||||
|
|
|
|||
|
|
@ -5,26 +5,9 @@
|
|||
class FireworksRecipe : public Recipy
|
||||
{
|
||||
private:
|
||||
//shared_ptr<ItemInstance> resultItem;
|
||||
|
||||
// 4J added so we can have separate contexts and rleBuf for different threads
|
||||
class ThreadStorage
|
||||
{
|
||||
public:
|
||||
shared_ptr<ItemInstance> resultItem;
|
||||
ThreadStorage();
|
||||
};
|
||||
static DWORD tlsIdx;
|
||||
static ThreadStorage *tlsDefault;
|
||||
shared_ptr<ItemInstance> resultItem;
|
||||
|
||||
void setResultItem(shared_ptr<ItemInstance> item);
|
||||
public:
|
||||
// Each new thread that needs to use Compression will need to call one of the following 2 functions, to either create its own
|
||||
// local storage, or share the default storage already allocated by the main thread
|
||||
static void CreateNewThreadStorage();
|
||||
static void UseDefaultThreadStorage();
|
||||
static void ReleaseThreadStorage();
|
||||
|
||||
public:
|
||||
FireworksRecipe();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue