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();
|
Entity::useSmallIds();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
Tile::CreateNewThreadStorage();
|
Tile::CreateNewThreadStorage();
|
||||||
FireworksRecipe::CreateNewThreadStorage();
|
|
||||||
|
|
||||||
MinecraftServer::main(seed, lpParameter); //saveData, app.GetGameHostOption(eGameHostOption_All));
|
MinecraftServer::main(seed, lpParameter); //saveData, app.GetGameHostOption(eGameHostOption_All));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,47 +2,14 @@
|
||||||
#include "net.minecraft.world.item.h"
|
#include "net.minecraft.world.item.h"
|
||||||
#include "FireworksRecipe.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)
|
void FireworksRecipe::setResultItem(shared_ptr<ItemInstance> item)
|
||||||
{
|
{
|
||||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
this->resultItem = item;
|
||||||
tls->resultItem = item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FireworksRecipe::FireworksRecipe()
|
FireworksRecipe::FireworksRecipe()
|
||||||
{
|
{
|
||||||
//resultItem = nullptr;
|
resultItem = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FireworksRecipe::matches(shared_ptr<CraftingContainer> craftSlots, Level *level)
|
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)
|
shared_ptr<ItemInstance> FireworksRecipe::assemble(shared_ptr<CraftingContainer> craftSlots)
|
||||||
{
|
{
|
||||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
if (this->resultItem != nullptr)
|
||||||
return tls->resultItem->copy();
|
{
|
||||||
//return resultItem->copy();
|
return this->resultItem->copy();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FireworksRecipe::size()
|
int FireworksRecipe::size()
|
||||||
|
|
@ -280,9 +249,7 @@ int FireworksRecipe::size()
|
||||||
|
|
||||||
const ItemInstance *FireworksRecipe::getResultItem()
|
const ItemInstance *FireworksRecipe::getResultItem()
|
||||||
{
|
{
|
||||||
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
|
return this->resultItem.get();
|
||||||
return tls->resultItem.get();
|
|
||||||
//return resultItem.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FireworksRecipe::updatePossibleRecipes(shared_ptr<CraftingContainer> craftSlots, bool *firework, bool *charge, bool *fade)
|
void FireworksRecipe::updatePossibleRecipes(shared_ptr<CraftingContainer> craftSlots, bool *firework, bool *charge, bool *fade)
|
||||||
|
|
|
||||||
|
|
@ -5,26 +5,9 @@
|
||||||
class FireworksRecipe : public Recipy
|
class FireworksRecipe : public Recipy
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
//shared_ptr<ItemInstance> resultItem;
|
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;
|
|
||||||
|
|
||||||
void setResultItem(shared_ptr<ItemInstance> item);
|
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:
|
public:
|
||||||
FireworksRecipe();
|
FireworksRecipe();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue