Compare commits
1
Commits
main
...
lcemp-networking
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21e2add09a |
@@ -552,12 +552,13 @@ bool AbstractContainerMenu::isPauseScreen()
|
|||||||
|
|
||||||
void AbstractContainerMenu::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
|
void AbstractContainerMenu::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
|
||||||
{
|
{
|
||||||
|
if (slot >= slots->size()) return;
|
||||||
getSlot(slot)->set(item);
|
getSlot(slot)->set(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractContainerMenu::setAll(ItemInstanceArray *items)
|
void AbstractContainerMenu::setAll(ItemInstanceArray *items)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < items->length; i++)
|
for (unsigned int i = 0; i < items->length && i < slots->size(); i++)
|
||||||
{
|
{
|
||||||
getSlot(i)->set( (*items)[i] );
|
getSlot(i)->set( (*items)[i] );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void AwardStatPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
|
|
||||||
// Read parameter blob.
|
// Read parameter blob.
|
||||||
int length = dis->readInt();
|
int length = dis->readInt();
|
||||||
if(length > 0)
|
if(length > 0 && length <= 65536)
|
||||||
{
|
{
|
||||||
m_paramData = byteArray(length);
|
m_paramData = byteArray(length);
|
||||||
dis->readFully(m_paramData);
|
dis->readFully(m_paramData);
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ void BlockRegionUpdatePacket::read(DataInputStream *dis) //throws IOException
|
|||||||
levelIdx = ( size >> 30 ) & 3;
|
levelIdx = ( size >> 30 ) & 3;
|
||||||
size &= 0x3fffffff;
|
size &= 0x3fffffff;
|
||||||
|
|
||||||
|
const int MAX_COMPRESSED_CHUNK_SIZE = 5 * 1024 * 1024;
|
||||||
|
if(size < 0 || size > MAX_COMPRESSED_CHUNK_SIZE)
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(size == 0)
|
if(size == 0)
|
||||||
{
|
{
|
||||||
buffer = byteArray();
|
buffer = byteArray();
|
||||||
@@ -131,7 +137,10 @@ void BlockRegionUpdatePacket::read(DataInputStream *dis) //throws IOException
|
|||||||
|
|
||||||
|
|
||||||
delete [] compressedBuffer.data;
|
delete [] compressedBuffer.data;
|
||||||
assert(buffer.length == outputSize);
|
if(buffer.length != outputSize)
|
||||||
|
{
|
||||||
|
app.DebugPrintf("BlockRegionUpdatePacket: decompressed size mismatch (expected %d, got %d)\n", buffer.length, outputSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,16 @@
|
|||||||
//offset - the offset in the buffer of the first byte to read.
|
//offset - the offset in the buffer of the first byte to read.
|
||||||
//length - the maximum number of bytes to read from the buffer.
|
//length - the maximum number of bytes to read from the buffer.
|
||||||
ByteArrayInputStream::ByteArrayInputStream(byteArray buf, unsigned int offset, unsigned int length)
|
ByteArrayInputStream::ByteArrayInputStream(byteArray buf, unsigned int offset, unsigned int length)
|
||||||
: pos( offset ), count( min( offset+length, buf.length ) ), mark( offset )
|
: pos( offset ), mark( offset )
|
||||||
{
|
{
|
||||||
|
if( offset > buf.length )
|
||||||
|
count = buf.length;
|
||||||
|
else if( length > buf.length - offset )
|
||||||
|
count = buf.length;
|
||||||
|
else
|
||||||
|
count = offset + length;
|
||||||
this->buf = buf;
|
this->buf = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Creates a ByteArrayInputStream so that it uses buf as its buffer array. The buffer array is not copied.
|
//Creates a ByteArrayInputStream so that it uses buf as its buffer array. The buffer array is not copied.
|
||||||
//The initial value of pos is 0 and the initial value of count is the length of buf.
|
//The initial value of pos is 0 and the initial value of count is the length of buf.
|
||||||
//Parameters:
|
//Parameters:
|
||||||
|
|||||||
@@ -51,14 +51,23 @@ void ByteArrayOutputStream::write(byteArray b)
|
|||||||
//len - the number of bytes to write.
|
//len - the number of bytes to write.
|
||||||
void ByteArrayOutputStream::write(byteArray b, unsigned int offset, unsigned int length)
|
void ByteArrayOutputStream::write(byteArray b, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
assert( b.length >= offset + length );
|
|
||||||
|
if (offset > b.length || length > b.length - offset)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (length > 0xFFFFFFFF - count)
|
||||||
|
return;
|
||||||
|
|
||||||
// If we will fill the buffer we need to make it bigger
|
// If we will fill the buffer we need to make it bigger
|
||||||
if( count + length >= buf.length )
|
if( count + length >= buf.length )
|
||||||
buf.resize( max( count + length + 1, buf.length * 2 ) );
|
{
|
||||||
|
unsigned int newSize = (std::max)( count + length + 1, buf.length * 2 );
|
||||||
|
if( newSize <= buf.length )
|
||||||
|
return;
|
||||||
|
buf.resize( newSize );
|
||||||
|
}
|
||||||
|
|
||||||
XMemCpy( &buf[count], &b[offset], length );
|
XMemCpy( &buf[count], &b[offset], length );
|
||||||
//std::copy( b->data+offset, b->data+offset+length, buf->data + count ); // Or this instead?
|
|
||||||
|
|
||||||
count += length;
|
count += length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ public:
|
|||||||
dos->write(data);
|
dos->write(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(DataInput *dis, int tagDepth)
|
void load(DataInput *dis)
|
||||||
{
|
{
|
||||||
int length = dis->readInt();
|
int length = dis->readInt();
|
||||||
|
if (length < 0 || length > 2 * 1024 * 1024) length = 0;
|
||||||
|
|
||||||
if ( data.data ) delete[] data.data;
|
if ( data.data ) delete[] data.data;
|
||||||
data = byteArray(length);
|
data = byteArray(length);
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ C4JThread::C4JThread( C4JThreadStartFunc* startFunc, void* param, const char* th
|
|||||||
m_threadID = sceKernelCreateThread(m_threadName, entryPoint, g_DefaultPriority, m_stackSize, 0, CPU, NULL);
|
m_threadID = sceKernelCreateThread(m_threadName, entryPoint, g_DefaultPriority, m_stackSize, 0, CPU, NULL);
|
||||||
app.DebugPrintf("***************************** start thread %s **************************\n", m_threadName);
|
app.DebugPrintf("***************************** start thread %s **************************\n", m_threadName);
|
||||||
#else
|
#else
|
||||||
|
m_completionFlag = new Event(Event::e_modeManualClear);
|
||||||
m_threadID = 0;
|
m_threadID = 0;
|
||||||
m_threadHandle = 0;
|
m_threadHandle = 0;
|
||||||
m_threadHandle = CreateThread(NULL, m_stackSize, entryPoint, this, CREATE_SUSPENDED, &m_threadID);
|
m_threadHandle = CreateThread(NULL, m_stackSize, entryPoint, this, CREATE_SUSPENDED, &m_threadID);
|
||||||
@@ -160,6 +161,7 @@ C4JThread::C4JThread( const char* mainThreadName)
|
|||||||
// sceKernelChangeThreadPriority(m_threadID, g_DefaultPriority + 1);
|
// sceKernelChangeThreadPriority(m_threadID, g_DefaultPriority + 1);
|
||||||
g_DefaultCPU = SCE_KERNEL_CPU_MASK_USER_ALL;//sceKernelGetThreadCpuAffinityMask(m_threadID);
|
g_DefaultCPU = SCE_KERNEL_CPU_MASK_USER_ALL;//sceKernelGetThreadCpuAffinityMask(m_threadID);
|
||||||
#else
|
#else
|
||||||
|
m_completionFlag = new Event(Event::e_modeManualClear);
|
||||||
m_threadID = GetCurrentThreadId();
|
m_threadID = GetCurrentThreadId();
|
||||||
m_threadHandle = GetCurrentThread();
|
m_threadHandle = GetCurrentThread();
|
||||||
#endif
|
#endif
|
||||||
@@ -173,9 +175,7 @@ C4JThread::C4JThread( const char* mainThreadName)
|
|||||||
|
|
||||||
C4JThread::~C4JThread()
|
C4JThread::~C4JThread()
|
||||||
{
|
{
|
||||||
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
|
||||||
delete m_completionFlag;
|
delete m_completionFlag;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined __ORBIS__
|
#if defined __ORBIS__
|
||||||
scePthreadJoin(m_threadID, NULL);
|
scePthreadJoin(m_threadID, NULL);
|
||||||
@@ -243,6 +243,7 @@ DWORD WINAPI C4JThread::entryPoint(LPVOID lpParam)
|
|||||||
C4JThread* pThread = (C4JThread*)lpParam;
|
C4JThread* pThread = (C4JThread*)lpParam;
|
||||||
SetThreadName(-1, pThread->m_threadName);
|
SetThreadName(-1, pThread->m_threadName);
|
||||||
pThread->m_exitCode = (*pThread->m_startFunc)(pThread->m_threadParam);
|
pThread->m_exitCode = (*pThread->m_startFunc)(pThread->m_threadParam);
|
||||||
|
pThread->m_completionFlag->Set();
|
||||||
pThread->m_isRunning = false;
|
pThread->m_isRunning = false;
|
||||||
return pThread->m_exitCode;
|
return pThread->m_exitCode;
|
||||||
}
|
}
|
||||||
@@ -388,7 +389,7 @@ DWORD C4JThread::WaitForCompletion( int timeoutMs )
|
|||||||
|
|
||||||
// return m_exitCode;
|
// return m_exitCode;
|
||||||
#else
|
#else
|
||||||
return WaitForSingleObject(m_threadHandle, timeoutMs);
|
return m_completionFlag->WaitForSignal(timeoutMs);
|
||||||
#endif // __PS3__
|
#endif // __PS3__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ void ComplexItemDataPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
itemType = dis->readShort();
|
itemType = dis->readShort();
|
||||||
itemId = dis->readShort();
|
itemId = dis->readShort();
|
||||||
|
|
||||||
data = charArray(dis->readUnsignedShort() & 0xffff);
|
int dataLength = dis->readShort() & 0xffff;
|
||||||
|
if(dataLength > 32767) dataLength = 0;
|
||||||
|
data = charArray(dataLength);
|
||||||
dis->readFully(data);
|
dis->readFully(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ void Connection::_init()
|
|||||||
running = true;
|
running = true;
|
||||||
quitting = false;
|
quitting = false;
|
||||||
disconnected = false;
|
disconnected = false;
|
||||||
|
m_closeState = 0;
|
||||||
disconnectReason = DisconnectPacket::eDisconnect_None;
|
disconnectReason = DisconnectPacket::eDisconnect_None;
|
||||||
noInputTicks = 0;
|
noInputTicks = 0;
|
||||||
estimatedRemaining = 0;
|
estimatedRemaining = 0;
|
||||||
@@ -45,12 +46,19 @@ void Connection::_init()
|
|||||||
// 4J Jev, need to delete the critical section.
|
// 4J Jev, need to delete the critical section.
|
||||||
Connection::~Connection()
|
Connection::~Connection()
|
||||||
{
|
{
|
||||||
// 4J Stu - Just to be sure, make sure the read and write threads terminate themselves before the connection object is destroyed
|
LONG closeState = InterlockedCompareExchange(&m_closeState, 1, 0);
|
||||||
running = false;
|
if (closeState == 0)
|
||||||
if( dis ) dis->close(); // The input stream needs closed before the readThread, or the readThread
|
{
|
||||||
// may get stuck whilst blocking waiting on a read
|
shutdownConnectionResources();
|
||||||
readThread->WaitForCompletion(INFINITE);
|
InterlockedExchange(&m_closeState, 2);
|
||||||
writeThread->WaitForCompletion(INFINITE);
|
}
|
||||||
|
else if (closeState == 1)
|
||||||
|
{
|
||||||
|
while (InterlockedCompareExchange(&m_closeState, 2, 2) != 2)
|
||||||
|
{
|
||||||
|
Sleep(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DeleteCriticalSection(&writeLock);
|
DeleteCriticalSection(&writeLock);
|
||||||
DeleteCriticalSection(&threadCounterLock);
|
DeleteCriticalSection(&threadCounterLock);
|
||||||
@@ -74,6 +82,37 @@ Connection::~Connection()
|
|||||||
dis = NULL;
|
dis = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Connection::shutdownConnectionResources()
|
||||||
|
{
|
||||||
|
running = false;
|
||||||
|
if( dis ) dis->close();
|
||||||
|
|
||||||
|
if( readThread ) readThread->WaitForCompletion(INFINITE);
|
||||||
|
if( writeThread ) writeThread->WaitForCompletion(INFINITE);
|
||||||
|
|
||||||
|
delete dis;
|
||||||
|
dis = NULL;
|
||||||
|
if( bufferedDos )
|
||||||
|
{
|
||||||
|
bufferedDos->close();
|
||||||
|
bufferedDos->deleteChildStream();
|
||||||
|
delete bufferedDos;
|
||||||
|
bufferedDos = NULL;
|
||||||
|
}
|
||||||
|
if( byteArrayDos )
|
||||||
|
{
|
||||||
|
byteArrayDos->close();
|
||||||
|
delete byteArrayDos;
|
||||||
|
byteArrayDos = NULL;
|
||||||
|
}
|
||||||
|
if( socket )
|
||||||
|
{
|
||||||
|
socket->close(packetListener != NULL ? packetListener->isServerPacketListener() : false);
|
||||||
|
socket = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Connection::Connection(Socket *socket, const wstring& id, PacketListener *packetListener) // throws IOException
|
Connection::Connection(Socket *socket, const wstring& id, PacketListener *packetListener) // throws IOException
|
||||||
{
|
{
|
||||||
_init();
|
_init();
|
||||||
@@ -108,8 +147,8 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet
|
|||||||
const char *szId = wstringtofilename(id);
|
const char *szId = wstringtofilename(id);
|
||||||
char readThreadName[256];
|
char readThreadName[256];
|
||||||
char writeThreadName[256];
|
char writeThreadName[256];
|
||||||
sprintf(readThreadName,"%s read\n",szId);
|
sprintf_s(readThreadName, sizeof(readThreadName), "%.240s read\n", szId);
|
||||||
sprintf(writeThreadName,"%s write\n",szId);
|
sprintf_s(writeThreadName, sizeof(writeThreadName), "%.240s write\n", szId);
|
||||||
|
|
||||||
readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE);
|
readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE);
|
||||||
writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE);
|
writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE);
|
||||||
@@ -367,31 +406,16 @@ close("disconnect.genericReason", "Internal exception: " + e.toString());
|
|||||||
void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
|
void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
|
||||||
{
|
{
|
||||||
// printf("Con:0x%x close\n",this);
|
// printf("Con:0x%x close\n",this);
|
||||||
if (!running) return;
|
if (InterlockedCompareExchange(&m_closeState, 1, 0) != 0) return;
|
||||||
// printf("Con:0x%x close doing something\n",this);
|
// printf("Con:0x%x close doing something\n",this);
|
||||||
disconnected = true;
|
disconnected = true;
|
||||||
|
|
||||||
va_list input;
|
va_list input;
|
||||||
va_start( input, reason );
|
va_start( input, reason );
|
||||||
|
|
||||||
disconnectReason = reason;//va_arg( input, const wstring );
|
disconnectReason = reason;
|
||||||
|
disconnectReasonObjects = NULL;
|
||||||
vector<void *> objs = vector<void *>();
|
va_end(input);
|
||||||
void *i = NULL;
|
|
||||||
while (i != NULL)
|
|
||||||
{
|
|
||||||
i = va_arg( input, void* );
|
|
||||||
objs.push_back(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( objs.size() )
|
|
||||||
{
|
|
||||||
disconnectReasonObjects = &objs[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
disconnectReasonObjects = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int count = 0, sum = 0, i = first;
|
// int count = 0, sum = 0, i = first;
|
||||||
// va_list marker;
|
// va_list marker;
|
||||||
@@ -409,35 +433,8 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
|
|||||||
|
|
||||||
// CreateThread(NULL, 0, runClose, this, 0, &closeThreadID);
|
// CreateThread(NULL, 0, runClose, this, 0, &closeThreadID);
|
||||||
|
|
||||||
running = false;
|
shutdownConnectionResources();
|
||||||
|
InterlockedExchange(&m_closeState, 2);
|
||||||
if( dis ) dis->close(); // The input stream needs closed before the readThread, or the readThread
|
|
||||||
// may get stuck whilst blocking waiting on a read
|
|
||||||
|
|
||||||
// Make sure that the read & write threads are dead before we go and kill the streams that they depend on
|
|
||||||
readThread->WaitForCompletion(INFINITE);
|
|
||||||
writeThread->WaitForCompletion(INFINITE);
|
|
||||||
|
|
||||||
delete dis;
|
|
||||||
dis = NULL;
|
|
||||||
if( bufferedDos )
|
|
||||||
{
|
|
||||||
bufferedDos->close();
|
|
||||||
bufferedDos->deleteChildStream();
|
|
||||||
delete bufferedDos;
|
|
||||||
bufferedDos = NULL;
|
|
||||||
}
|
|
||||||
if( byteArrayDos )
|
|
||||||
{
|
|
||||||
byteArrayDos->close();
|
|
||||||
delete byteArrayDos;
|
|
||||||
byteArrayDos = NULL;
|
|
||||||
}
|
|
||||||
if( socket )
|
|
||||||
{
|
|
||||||
socket->close(packetListener->isServerPacketListener());
|
|
||||||
socket = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::tick()
|
void Connection::tick()
|
||||||
@@ -500,6 +497,11 @@ void Connection::tick()
|
|||||||
// MGH - moved the packet handling outside of the incoming_cs block, as it was locking up sometimes when disconnecting
|
// MGH - moved the packet handling outside of the incoming_cs block, as it was locking up sometimes when disconnecting
|
||||||
for(int i=0; i<packetsToHandle.size();i++)
|
for(int i=0; i<packetsToHandle.size();i++)
|
||||||
{
|
{
|
||||||
|
// if a packet handler disconnected this connection, drop any remaining queued packets
|
||||||
|
if (disconnected || quitting || packetListener == NULL)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
PIXBeginNamedEvent(0,"Handling packet %d\n",packetsToHandle[i]->getId());
|
PIXBeginNamedEvent(0,"Handling packet %d\n",packetsToHandle[i]->getId());
|
||||||
packetsToHandle[i]->handle(packetListener);
|
packetsToHandle[i]->handle(packetListener);
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ private:
|
|||||||
DataOutputStream *byteArrayDos; // 4J This dos allows us to write individual packets to the socket
|
DataOutputStream *byteArrayDos; // 4J This dos allows us to write individual packets to the socket
|
||||||
ByteArrayOutputStream *baos;
|
ByteArrayOutputStream *baos;
|
||||||
Socket::SocketOutputStream *sos;
|
Socket::SocketOutputStream *sos;
|
||||||
|
volatile LONG m_closeState;
|
||||||
|
|
||||||
bool running;
|
bool running;
|
||||||
|
|
||||||
@@ -87,6 +88,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _init();
|
void _init();
|
||||||
|
void shutdownConnectionResources();
|
||||||
|
|
||||||
// 4J Jev, these might be better of as private
|
// 4J Jev, these might be better of as private
|
||||||
CRITICAL_SECTION threadCounterLock;
|
CRITICAL_SECTION threadCounterLock;
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ ConsoleSaveFileOriginal::~ConsoleSaveFileOriginal()
|
|||||||
VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT );
|
VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT );
|
||||||
pagesCommitted = 0;
|
pagesCommitted = 0;
|
||||||
// Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway
|
// Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway
|
||||||
#if defined _XBOX
|
#if defined _XBOX || defined _WINDOWS64
|
||||||
app.GetSaveThumbnail(NULL,NULL);
|
app.GetSaveThumbnail(NULL,NULL);
|
||||||
#elif defined __PS3__
|
#elif defined __PS3__
|
||||||
app.GetSaveThumbnail(NULL,NULL, NULL,NULL);
|
app.GetSaveThumbnail(NULL,NULL, NULL,NULL);
|
||||||
@@ -749,7 +749,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
|
|||||||
PBYTE pbDataSaveImage=NULL;
|
PBYTE pbDataSaveImage=NULL;
|
||||||
DWORD dwDataSizeSaveImage=0;
|
DWORD dwDataSizeSaveImage=0;
|
||||||
|
|
||||||
#if ( defined _XBOX || defined _DURANGO )
|
#if ( defined _XBOX || defined _DURANGO || defined _WINDOWS64 )
|
||||||
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize);
|
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize);
|
||||||
#elif ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ )
|
#elif ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ )
|
||||||
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage);
|
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage);
|
||||||
@@ -819,7 +819,8 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
|
|||||||
|
|
||||||
int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
|
int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
|
||||||
{
|
{
|
||||||
ConsoleSaveFile *pClass=(ConsoleSaveFile *)lpParam;
|
(void)lpParam;
|
||||||
|
(void)bRes;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -586,7 +586,7 @@ ConsoleSaveFileSplit::~ConsoleSaveFileSplit()
|
|||||||
VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT );
|
VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT );
|
||||||
pagesCommitted = 0;
|
pagesCommitted = 0;
|
||||||
// Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway
|
// Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway
|
||||||
#if defined _XBOX
|
#if defined _XBOX || defined _WINDOWS64
|
||||||
app.GetSaveThumbnail(NULL,NULL);
|
app.GetSaveThumbnail(NULL,NULL);
|
||||||
#elif defined __PS3__
|
#elif defined __PS3__
|
||||||
app.GetSaveThumbnail(NULL,NULL, NULL,NULL);
|
app.GetSaveThumbnail(NULL,NULL, NULL,NULL);
|
||||||
@@ -1412,7 +1412,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
|
|||||||
PBYTE pbDataSaveImage=NULL;
|
PBYTE pbDataSaveImage=NULL;
|
||||||
DWORD dwDataSizeSaveImage=0;
|
DWORD dwDataSizeSaveImage=0;
|
||||||
|
|
||||||
#if ( defined _XBOX || defined _DURANGO )
|
#if ( defined _XBOX || defined _DURANGO || defined _WINDOWS64 )
|
||||||
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize);
|
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize);
|
||||||
#elif ( defined __PS3__ || defined __ORBIS__ )
|
#elif ( defined __PS3__ || defined __ORBIS__ )
|
||||||
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage);
|
app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage);
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ void ContainerSetContentPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
{
|
{
|
||||||
containerId = dis->readByte();
|
containerId = dis->readByte();
|
||||||
int count = dis->readShort();
|
int count = dis->readShort();
|
||||||
|
|
||||||
|
if(count < 0 || count > 256) count = 0;
|
||||||
|
|
||||||
items = ItemInstanceArray(count);
|
items = ItemInstanceArray(count);
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void ContainerSetSlotPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
// 4J Stu - TU-1 hotfix
|
// 4J Stu - TU-1 hotfix
|
||||||
// Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts
|
// Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts
|
||||||
BYTE byteId = dis->readByte();
|
BYTE byteId = dis->readByte();
|
||||||
containerId = *(char *)&byteId;
|
containerId = (char)(signed char)byteId;
|
||||||
slot = dis->readShort();
|
slot = dis->readShort();
|
||||||
item = readItem(dis);
|
item = readItem(dis);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void CustomPayloadPacket::read(DataInputStream *dis)
|
|||||||
identifier = readUtf(dis, 20);
|
identifier = readUtf(dis, 20);
|
||||||
length = dis->readShort();
|
length = dis->readShort();
|
||||||
|
|
||||||
if (length > 0 && length < Short::MAX_VALUE)
|
if (length > 0 && length <= Short::MAX_VALUE)
|
||||||
{
|
{
|
||||||
if(data.data != NULL)
|
if(data.data != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -303,6 +303,10 @@ wstring DataInputStream::readUTF()
|
|||||||
int b = stream->read();
|
int b = stream->read();
|
||||||
unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff));
|
unsigned short UTFLength = (unsigned short) (((a & 0xff) << 8) | (b & 0xff));
|
||||||
|
|
||||||
|
const unsigned short MAX_UTF_LENGTH = 32767;
|
||||||
|
if( UTFLength > MAX_UTF_LENGTH )
|
||||||
|
return outputString;
|
||||||
|
|
||||||
//// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format
|
//// 4J Stu - I decided while writing DataOutputStream that we didn't need to bother using the UTF8 format
|
||||||
//// used in the java libs, and just write in/out as wchar_t all the time
|
//// used in the java libs, and just write in/out as wchar_t all the time
|
||||||
|
|
||||||
|
|||||||
@@ -432,6 +432,27 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
|
|||||||
CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player)
|
CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player)
|
||||||
{
|
{
|
||||||
CompoundTag *tag = loadPlayerDataTag( player->getXuid() );
|
CompoundTag *tag = loadPlayerDataTag( player->getXuid() );
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
if (tag == NULL)
|
||||||
|
{
|
||||||
|
const PlayerUID WIN64_XUID_BASE = (PlayerUID)0xe000d45248242f2e;
|
||||||
|
for (int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; i++)
|
||||||
|
{
|
||||||
|
PlayerUID oldXuid = WIN64_XUID_BASE + i;
|
||||||
|
tag = loadPlayerDataTag(oldXuid);
|
||||||
|
if (tag != NULL)
|
||||||
|
{
|
||||||
|
ConsoleSavePath oldFile = ConsoleSavePath(playerDir.getName() + _toString(oldXuid) + L".dat");
|
||||||
|
if (m_saveFile->doesFileExist(oldFile))
|
||||||
|
{
|
||||||
|
m_saveFile->deleteFile(m_saveFile->createFile(oldFile));
|
||||||
|
}
|
||||||
|
app.DebugPrintf("Migrated player data from old XUID %llu to new XUID %llu\n", oldXuid, player->getXuid());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (tag != NULL)
|
if (tag != NULL)
|
||||||
{
|
{
|
||||||
player->load(tag);
|
player->load(tag);
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ public:
|
|||||||
#ifdef _XBOX_ONE
|
#ifdef _XBOX_ONE
|
||||||
eDisconnect_ExitedGame,
|
eDisconnect_ExitedGame,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
eDisconnect_NotWhitelisted = 100,
|
||||||
|
eDisconnect_ServerBanned,
|
||||||
|
eDisconnect_IPBanned,
|
||||||
|
eDisconnect_InvalidUsername,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 4J Stu - The reason was a string, but we need to send a non-locale specific reason
|
// 4J Stu - The reason was a string, but we need to send a non-locale specific reason
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ void EnchantmentMenu::slotsChanged() // 4J used to take a shared_ptr<Container>
|
|||||||
|
|
||||||
bool EnchantmentMenu::clickMenuButton(shared_ptr<Player> player, int i)
|
bool EnchantmentMenu::clickMenuButton(shared_ptr<Player> player, int i)
|
||||||
{
|
{
|
||||||
|
if (i < 0 || i >= 3) return false;
|
||||||
shared_ptr<ItemInstance> item = enchantSlots->getItem(0);
|
shared_ptr<ItemInstance> item = enchantSlots->getItem(0);
|
||||||
if (costs[i] > 0 && item != NULL && (player->experienceLevel >= costs[i] || player->abilities.instabuild) )
|
if (costs[i] > 0 && item != NULL && (player->experienceLevel >= costs[i] || player->abilities.instabuild) )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ void ExplodePacket::read(DataInputStream *dis) //throws IOException
|
|||||||
r = dis->readFloat();
|
r = dis->readFloat();
|
||||||
int count = dis->readInt();
|
int count = dis->readInt();
|
||||||
|
|
||||||
|
if(count < 0 || count > 32768) count = 0;
|
||||||
|
|
||||||
int xp = (int)x;
|
int xp = (int)x;
|
||||||
int yp = (int)y;
|
int yp = (int)y;
|
||||||
int zp = (int)z;
|
int zp = (int)z;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void GameCommandPacket::read(DataInputStream *dis)
|
|||||||
command = (EGameCommand)dis->readInt();
|
command = (EGameCommand)dis->readInt();
|
||||||
length = dis->readShort();
|
length = dis->readShort();
|
||||||
|
|
||||||
if (length > 0 && length < Short::MAX_VALUE)
|
if (length > 0 && length <= Short::MAX_VALUE)
|
||||||
{
|
{
|
||||||
if(data.data != NULL)
|
if(data.data != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <xhash>
|
#include <xhash>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include "Hasher.h"
|
#include "Hasher.h"
|
||||||
|
|
||||||
@@ -19,7 +20,11 @@ wstring Hasher::getHash(wstring &name)
|
|||||||
//return new BigInteger(1, m.digest()).toString(16);
|
//return new BigInteger(1, m.digest()).toString(16);
|
||||||
|
|
||||||
// TODO 4J Stu - Will this hash us with the same distribution as the MD5?
|
// TODO 4J Stu - Will this hash us with the same distribution as the MD5?
|
||||||
return _toString( hash_value( s ) );
|
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
|
return _toString( std::hash<wstring>{}( s ) );
|
||||||
|
#else
|
||||||
|
return _toString( stdext::hash_value( s ) );
|
||||||
|
#endif
|
||||||
//}
|
//}
|
||||||
//catch (NoSuchAlgorithmException e)
|
//catch (NoSuchAlgorithmException e)
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ wstring I18n::get(const wstring& id, ...)
|
|||||||
{
|
{
|
||||||
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
|
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
|
||||||
return L"";
|
return L"";
|
||||||
|
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
|
||||||
|
return id;
|
||||||
#else
|
#else
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, id);
|
va_start(va, id);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public:
|
|||||||
void load(DataInput *dis, int tagDepth)
|
void load(DataInput *dis, int tagDepth)
|
||||||
{
|
{
|
||||||
int length = dis->readInt();
|
int length = dis->readInt();
|
||||||
|
if (length < 0 || length > 65536) length = 0;
|
||||||
|
|
||||||
if ( data.data ) delete[] data.data;
|
if ( data.data ) delete[] data.data;
|
||||||
data = intArray(length);
|
data = intArray(length);
|
||||||
|
|||||||
@@ -143,9 +143,6 @@ void Inventory::grabTexture(int id, int data, bool checkData, bool mayReplace)
|
|||||||
|
|
||||||
void Inventory::swapPaint(int wheel)
|
void Inventory::swapPaint(int wheel)
|
||||||
{
|
{
|
||||||
if (wheel > 0) wheel = 1;
|
|
||||||
if (wheel < 0) wheel = -1;
|
|
||||||
|
|
||||||
selected -= wheel;
|
selected -= wheel;
|
||||||
|
|
||||||
while (selected < 0)
|
while (selected < 0)
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ wstring Language::getElement(const wstring& elementId, ...)
|
|||||||
{
|
{
|
||||||
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
|
#ifdef __PSVITA__ // 4J - vita doesn't like having a reference type as the last parameter passed to va_start - we shouldn't need this method anyway
|
||||||
return L"";
|
return L"";
|
||||||
|
#elif _MSC_VER >= 1930 // VS2022+ also disallows va_start with reference types
|
||||||
|
return elementId;
|
||||||
#else
|
#else
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, elementId);
|
va_start(args, elementId);
|
||||||
|
|||||||
@@ -1951,7 +1951,8 @@ AABBList *Level::getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities/
|
|||||||
// 4J - now add in collision for any blocks which have actually been removed, but haven't had their render data updated to reflect this yet. This is to stop the player
|
// 4J - now add in collision for any blocks which have actually been removed, but haven't had their render data updated to reflect this yet. This is to stop the player
|
||||||
// being able to move the view position inside a tile which is (visually) still there, and see out of the world. This is particularly a problem when moving upwards in
|
// being able to move the view position inside a tile which is (visually) still there, and see out of the world. This is particularly a problem when moving upwards in
|
||||||
// creative mode as the player can get very close to the edge of tiles whilst looking upwards and can therefore very quickly move inside one.
|
// creative mode as the player can get very close to the edge of tiles whilst looking upwards and can therefore very quickly move inside one.
|
||||||
Minecraft::GetInstance()->levelRenderer->destroyedTileManager->addAABBs( this, box, &boxes);
|
if(Minecraft::GetInstance()->levelRenderer != NULL)
|
||||||
|
Minecraft::GetInstance()->levelRenderer->destroyedTileManager->addAABBs( this, box, &boxes);
|
||||||
|
|
||||||
// 4J - added
|
// 4J - added
|
||||||
if( noEntities ) return &boxes;
|
if( noEntities ) return &boxes;
|
||||||
|
|||||||
@@ -37,11 +37,13 @@ public:
|
|||||||
}
|
}
|
||||||
type = dis->readByte();
|
type = dis->readByte();
|
||||||
int size = dis->readInt();
|
int size = dis->readInt();
|
||||||
|
if (size < 0 || size > 10000) size = 0;
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
Tag *tag = Tag::newTag(type, L"");
|
Tag *tag = Tag::newTag(type, L"");
|
||||||
|
if (tag == NULL) break;
|
||||||
tag->load(dis, tagDepth);
|
tag->load(dis, tagDepth);
|
||||||
list.push_back(tag);
|
list.push_back(tag);
|
||||||
}
|
}
|
||||||
@@ -58,7 +60,7 @@ public:
|
|||||||
|
|
||||||
void print(char *prefix, ostream out)
|
void print(char *prefix, ostream out)
|
||||||
{
|
{
|
||||||
Tag::print(prefix, out);
|
Tag::print(out);
|
||||||
|
|
||||||
out << prefix << "{" << endl;
|
out << prefix << "{" << endl;
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ public:
|
|||||||
strcat( newPrefix, " ");
|
strcat( newPrefix, " ");
|
||||||
AUTO_VAR(itEnd, list.end());
|
AUTO_VAR(itEnd, list.end());
|
||||||
for (AUTO_VAR(it, list.begin()); it != itEnd; it++)
|
for (AUTO_VAR(it, list.begin()); it != itEnd; it++)
|
||||||
(*it)->print(newPrefix, out);
|
(*it)->print(out);
|
||||||
delete[] newPrefix;
|
delete[] newPrefix;
|
||||||
out << prefix << "}" << endl;
|
out << prefix << "}" << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ C4JThread *McRegionChunkStorage::s_saveThreads[3];
|
|||||||
McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstring &prefix) : m_prefix( prefix )
|
McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstring &prefix) : m_prefix( prefix )
|
||||||
{
|
{
|
||||||
m_saveFile = saveFile;
|
m_saveFile = saveFile;
|
||||||
|
InitializeCriticalSectionAndSpinCount(&m_csEntityData, 4000);
|
||||||
|
|
||||||
// Make sure that if there are any files for regions to be created, that they are created in the order that suits us for making the initial level save work fast
|
// Make sure that if there are any files for regions to be created, that they are created in the order that suits us for making the initial level save work fast
|
||||||
if( prefix == L"" )
|
if( prefix == L"" )
|
||||||
@@ -68,6 +69,7 @@ McRegionChunkStorage::~McRegionChunkStorage()
|
|||||||
{
|
{
|
||||||
delete it->second.data;
|
delete it->second.data;
|
||||||
}
|
}
|
||||||
|
DeleteCriticalSection(&m_csEntityData);
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
|
LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
|
||||||
@@ -80,12 +82,14 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
|
|||||||
{
|
{
|
||||||
__int64 index = ((__int64)(x) << 32) | (((__int64)(z))&0x00000000FFFFFFFF);
|
__int64 index = ((__int64)(x) << 32) | (((__int64)(z))&0x00000000FFFFFFFF);
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_csEntityData);
|
||||||
AUTO_VAR(it, m_entityData.find(index));
|
AUTO_VAR(it, m_entityData.find(index));
|
||||||
if(it != m_entityData.end())
|
if(it != m_entityData.end())
|
||||||
{
|
{
|
||||||
delete it->second.data;
|
delete it->second.data;
|
||||||
m_entityData.erase(it);
|
m_entityData.erase(it);
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csEntityData);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -244,11 +248,12 @@ void McRegionChunkStorage::saveEntities(Level *level, LevelChunk *levelChunk)
|
|||||||
PIXBeginNamedEvent(0,"Saving entities");
|
PIXBeginNamedEvent(0,"Saving entities");
|
||||||
__int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF);
|
__int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF);
|
||||||
|
|
||||||
delete m_entityData[index].data;
|
|
||||||
|
|
||||||
CompoundTag *newTag = new CompoundTag();
|
CompoundTag *newTag = new CompoundTag();
|
||||||
bool savedEntities = OldChunkStorage::saveEntities(levelChunk, level, newTag);
|
bool savedEntities = OldChunkStorage::saveEntities(levelChunk, level, newTag);
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_csEntityData);
|
||||||
|
delete m_entityData[index].data;
|
||||||
|
|
||||||
if(savedEntities)
|
if(savedEntities)
|
||||||
{
|
{
|
||||||
ByteArrayOutputStream bos;
|
ByteArrayOutputStream bos;
|
||||||
@@ -268,6 +273,7 @@ void McRegionChunkStorage::saveEntities(Level *level, LevelChunk *levelChunk)
|
|||||||
m_entityData.erase(it);
|
m_entityData.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csEntityData);
|
||||||
delete newTag;
|
delete newTag;
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
#endif
|
#endif
|
||||||
@@ -278,16 +284,22 @@ void McRegionChunkStorage::loadEntities(Level *level, LevelChunk *levelChunk)
|
|||||||
#ifdef SPLIT_SAVES
|
#ifdef SPLIT_SAVES
|
||||||
__int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF);
|
__int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF);
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_csEntityData);
|
||||||
AUTO_VAR(it, m_entityData.find(index));
|
AUTO_VAR(it, m_entityData.find(index));
|
||||||
if(it != m_entityData.end())
|
if(it != m_entityData.end())
|
||||||
{
|
{
|
||||||
ByteArrayInputStream bais(it->second);
|
ByteArrayInputStream bais(it->second);
|
||||||
DataInputStream dis(&bais);
|
DataInputStream dis(&bais);
|
||||||
CompoundTag *tag = NbtIo::read(&dis);
|
CompoundTag *tag = NbtIo::read(&dis);
|
||||||
|
LeaveCriticalSection(&m_csEntityData);
|
||||||
OldChunkStorage::loadEntities(levelChunk, level, tag);
|
OldChunkStorage::loadEntities(levelChunk, level, tag);
|
||||||
bais.reset();
|
bais.reset();
|
||||||
delete tag;
|
delete tag;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&m_csEntityData);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,6 +318,7 @@ void McRegionChunkStorage::flush()
|
|||||||
DataOutputStream dos(&bos);
|
DataOutputStream dos(&bos);
|
||||||
|
|
||||||
PIXBeginNamedEvent(0,"Writing to stream");
|
PIXBeginNamedEvent(0,"Writing to stream");
|
||||||
|
EnterCriticalSection(&m_csEntityData);
|
||||||
dos.writeInt(m_entityData.size());
|
dos.writeInt(m_entityData.size());
|
||||||
|
|
||||||
for(AUTO_VAR(it,m_entityData.begin()); it != m_entityData.end(); ++it)
|
for(AUTO_VAR(it,m_entityData.begin()); it != m_entityData.end(); ++it)
|
||||||
@@ -313,6 +326,7 @@ void McRegionChunkStorage::flush()
|
|||||||
dos.writeLong(it->first);
|
dos.writeLong(it->first);
|
||||||
dos.write(it->second,0,it->second.length);
|
dos.write(it->second,0,it->second.length);
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csEntityData);
|
||||||
bos.flush();
|
bos.flush();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ private:
|
|||||||
static CRITICAL_SECTION cs_memory;
|
static CRITICAL_SECTION cs_memory;
|
||||||
|
|
||||||
unordered_map<__int64, byteArray> m_entityData;
|
unordered_map<__int64, byteArray> m_entityData;
|
||||||
|
CRITICAL_SECTION m_csEntityData;
|
||||||
|
|
||||||
static std::deque<DataOutputStream *> s_chunkDataQueue;
|
static std::deque<DataOutputStream *> s_chunkDataQueue;
|
||||||
static int s_runningThreadCount;
|
static int s_runningThreadCount;
|
||||||
|
|||||||
@@ -32,13 +32,6 @@ TilePos MobSpawner::getRandomPosWithin(Level *level, int cx, int cz)
|
|||||||
return TilePos(x, y, z);
|
return TilePos(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __PSVITA__
|
|
||||||
// AP - See CustomMap.h for an explanation of this
|
|
||||||
CustomMap MobSpawner::chunksToPoll;
|
|
||||||
#else
|
|
||||||
unordered_map<ChunkPos,bool,ChunkPosKeyHash,ChunkPosKeyEq> MobSpawner::chunksToPoll;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent)
|
const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent)
|
||||||
{
|
{
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
@@ -99,7 +92,12 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
MemSect(20);
|
MemSect(20);
|
||||||
chunksToPoll.clear();
|
#ifdef __PSVITA__
|
||||||
|
// AP - See CustomMap.h for an explanation of this
|
||||||
|
CustomMap MobSpawner::chunksToPoll;
|
||||||
|
#else
|
||||||
|
unordered_map<ChunkPos,bool,ChunkPosKeyHash,ChunkPosKeyEq> chunksToPoll;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
AUTO_VAR(itEnd, level->players.end());
|
AUTO_VAR(itEnd, level->players.end());
|
||||||
|
|||||||
@@ -17,14 +17,6 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
static TilePos getRandomPosWithin(Level *level, int cx, int cz);
|
static TilePos getRandomPosWithin(Level *level, int cx, int cz);
|
||||||
|
|
||||||
private:
|
|
||||||
#ifdef __PSVITA__
|
|
||||||
// AP - See CustomMap.h for an explanation of this
|
|
||||||
static CustomMap chunksToPoll;
|
|
||||||
#else
|
|
||||||
static unordered_map<ChunkPos,bool,ChunkPosKeyHash,ChunkPosKeyEq> chunksToPoll;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int tick(ServerLevel *level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent);
|
static const int tick(ServerLevel *level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent);
|
||||||
static bool isSpawnPositionOk(MobCategory *category, Level *level, int x, int y, int z);
|
static bool isSpawnPositionOk(MobCategory *category, Level *level, int x, int y, int z);
|
||||||
|
|||||||
@@ -476,29 +476,28 @@ LevelChunk *OldChunkStorage::load(Level *level, DataInputStream *dis)
|
|||||||
|
|
||||||
CompoundTag *tag = NbtIo::read(dis);
|
CompoundTag *tag = NbtIo::read(dis);
|
||||||
|
|
||||||
loadEntities(levelChunk, level, tag);
|
if (tag != NULL)
|
||||||
|
|
||||||
if (tag->contains(L"TileTicks"))
|
|
||||||
{
|
{
|
||||||
PIXBeginNamedEvent(0,"Loading TileTicks");
|
loadEntities(levelChunk, level, tag);
|
||||||
ListTag<CompoundTag> *tileTicks = (ListTag<CompoundTag> *) tag->getList(L"TileTicks");
|
|
||||||
|
|
||||||
if (tileTicks != NULL)
|
if (tag->contains(L"TileTicks"))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < tileTicks->size(); i++)
|
ListTag<CompoundTag> *tileTicks = (ListTag<CompoundTag> *) tag->getList(L"TileTicks");
|
||||||
{
|
|
||||||
CompoundTag *teTag = tileTicks->get(i);
|
|
||||||
|
|
||||||
level->forceAddTileTick(teTag->getInt(L"x"), teTag->getInt(L"y"), teTag->getInt(L"z"), teTag->getInt(L"i"), teTag->getInt(L"t"), teTag->getInt(L"p"));
|
if (tileTicks != NULL)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < tileTicks->size(); i++)
|
||||||
|
{
|
||||||
|
CompoundTag *teTag = tileTicks->get(i);
|
||||||
|
|
||||||
|
level->forceAddTileTick(teTag->getInt(L"x"), teTag->getInt(L"y"), teTag->getInt(L"z"), teTag->getInt(L"i"), teTag->getInt(L"t"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PIXEndNamedEvent();
|
|
||||||
|
delete tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete tag;
|
|
||||||
|
|
||||||
PIXEndNamedEvent();
|
|
||||||
|
|
||||||
return levelChunk;
|
return levelChunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -267,8 +267,9 @@ void Packet::updatePacketStatsPIX()
|
|||||||
|
|
||||||
shared_ptr<Packet> Packet::getPacket(int id)
|
shared_ptr<Packet> Packet::getPacket(int id)
|
||||||
{
|
{
|
||||||
// 4J: Removed try/catch
|
auto it = idToCreateMap.find(id);
|
||||||
return idToCreateMap[id]();
|
if (it == idToCreateMap.end()) return nullptr;
|
||||||
|
return it->second();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Packet::writeBytes(DataOutputStream *dataoutputstream, byteArray bytes)
|
void Packet::writeBytes(DataOutputStream *dataoutputstream, byteArray bytes)
|
||||||
|
|||||||
@@ -2711,9 +2711,11 @@ int Player::hash_fnct(const shared_ptr<Player> k)
|
|||||||
// TODO 4J Stu - Should we just be using the pointers and hashing them?
|
// TODO 4J Stu - Should we just be using the pointers and hashing them?
|
||||||
#ifdef __PS3__
|
#ifdef __PS3__
|
||||||
return (int)boost::hash_value( k->name ); // 4J Stu - Names are completely unique?
|
return (int)boost::hash_value( k->name ); // 4J Stu - Names are completely unique?
|
||||||
|
#elif !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||||
|
return (int)std::hash<wstring>{}( k->name ); // 4J Stu - Names are completely unique?
|
||||||
#else
|
#else
|
||||||
return (int)std::hash_value( k->name ); // 4J Stu - Names are completely unique?
|
return (int)stdext::hash_value( k->name ); // 4J Stu - Names are completely unique?
|
||||||
#endif //__PS3__
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::eq_test(const shared_ptr<Player> x, const shared_ptr<Player> y)
|
bool Player::eq_test(const shared_ptr<Player> x, const shared_ptr<Player> y)
|
||||||
|
|||||||
@@ -180,11 +180,39 @@ int PotionBrewing::getAppearanceValue(int brew)
|
|||||||
return valueOf(brew, 5, 4, 3, 2, 1);
|
return valueOf(brew, 5, 4, 3, 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int GetFallbackPotionColour(eMinecraftColour id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case eMinecraftColour_Potion_BaseColour: return 0x385DC6;
|
||||||
|
case eMinecraftColour_Effect_MovementSpeed: return 0x7CAFC6;
|
||||||
|
case eMinecraftColour_Effect_MovementSlowDown: return 0x5A6C81;
|
||||||
|
case eMinecraftColour_Effect_DigSpeed: return 0xD9C043;
|
||||||
|
case eMinecraftColour_Effect_DigSlowdown: return 0x4A4217;
|
||||||
|
case eMinecraftColour_Effect_DamageBoost: return 0x932423;
|
||||||
|
case eMinecraftColour_Effect_Heal: return 0xF82423;
|
||||||
|
case eMinecraftColour_Effect_Harm: return 0x430A09;
|
||||||
|
case eMinecraftColour_Effect_Jump: return 0x786297;
|
||||||
|
case eMinecraftColour_Effect_Confusion: return 0x551D4A;
|
||||||
|
case eMinecraftColour_Effect_Regeneration: return 0xCD5CAB;
|
||||||
|
case eMinecraftColour_Effect_DamageResistance: return 0x99453A;
|
||||||
|
case eMinecraftColour_Effect_FireResistance: return 0xE49A3A;
|
||||||
|
case eMinecraftColour_Effect_WaterBreathing: return 0x2E5299;
|
||||||
|
case eMinecraftColour_Effect_Invisiblity: return 0x7F8392;
|
||||||
|
case eMinecraftColour_Effect_Blindness: return 0x1F1F23;
|
||||||
|
case eMinecraftColour_Effect_NightVision: return 0x1F1FA1;
|
||||||
|
case eMinecraftColour_Effect_Hunger: return 0x587653;
|
||||||
|
case eMinecraftColour_Effect_Weakness: return 0x484D48;
|
||||||
|
case eMinecraftColour_Effect_Poison: return 0x4E9331;
|
||||||
|
default: return 0xFFFFFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
|
int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
|
||||||
{
|
{
|
||||||
ColourTable *colourTable = Minecraft::GetInstance()->getColourTable();
|
ColourTable *colourTable = Minecraft::GetInstance()->getColourTable();
|
||||||
|
|
||||||
int baseColor = colourTable->getColor( eMinecraftColour_Potion_BaseColour );
|
int baseColor = colourTable != NULL ? colourTable->getColor(eMinecraftColour_Potion_BaseColour) : GetFallbackPotionColour(eMinecraftColour_Potion_BaseColour);
|
||||||
|
|
||||||
if (effects == NULL || effects->empty())
|
if (effects == NULL || effects->empty())
|
||||||
{
|
{
|
||||||
@@ -200,7 +228,8 @@ int PotionBrewing::getColorValue(vector<MobEffectInstance *> *effects)
|
|||||||
for(AUTO_VAR(it, effects->begin()); it != effects->end(); ++it)
|
for(AUTO_VAR(it, effects->begin()); it != effects->end(); ++it)
|
||||||
{
|
{
|
||||||
MobEffectInstance *effect = *it;
|
MobEffectInstance *effect = *it;
|
||||||
int potionColor = colourTable->getColor( MobEffect::effects[effect->getId()]->getColor() );
|
eMinecraftColour effectColorId = MobEffect::effects[effect->getId()]->getColor();
|
||||||
|
int potionColor = colourTable != NULL ? colourTable->getColor(effectColorId) : GetFallbackPotionColour(effectColorId);
|
||||||
|
|
||||||
for (int potency = 0; potency <= effect->getAmplifier(); potency++)
|
for (int potency = 0; potency <= effect->getAmplifier(); potency++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
m_friendsOnlyBits = dis->readByte();
|
m_friendsOnlyBits = dis->readByte();
|
||||||
m_ugcPlayersVersion = dis->readInt();
|
m_ugcPlayersVersion = dis->readInt();
|
||||||
m_dwPlayerCount = dis->readByte();
|
m_dwPlayerCount = dis->readByte();
|
||||||
|
if( m_dwPlayerCount > MINECRAFT_NET_MAX_PLAYERS ) m_dwPlayerCount = MINECRAFT_NET_MAX_PLAYERS;
|
||||||
if( m_dwPlayerCount > 0 )
|
if( m_dwPlayerCount > 0 )
|
||||||
{
|
{
|
||||||
m_playerXuids = new PlayerUID[m_dwPlayerCount];
|
m_playerXuids = new PlayerUID[m_dwPlayerCount];
|
||||||
@@ -74,6 +75,7 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
{
|
{
|
||||||
m_szUniqueSaveName[i]=dis->readByte();
|
m_szUniqueSaveName[i]=dis->readByte();
|
||||||
}
|
}
|
||||||
|
m_szUniqueSaveName[m_iSaveNameLen - 1] = 0;
|
||||||
m_serverSettings = dis->readInt();
|
m_serverSettings = dis->readInt();
|
||||||
m_hostIndex = dis->readByte();
|
m_hostIndex = dis->readByte();
|
||||||
|
|
||||||
|
|||||||
@@ -778,7 +778,7 @@ void RandomLevelSource::postProcess(ChunkSource *parent, int xt, int zt)
|
|||||||
mineShaftFeature->postProcess(level, pprandom, xt, zt);
|
mineShaftFeature->postProcess(level, pprandom, xt, zt);
|
||||||
hasVillage = villageFeature->postProcess(level, pprandom, xt, zt);
|
hasVillage = villageFeature->postProcess(level, pprandom, xt, zt);
|
||||||
strongholdFeature->postProcess(level, pprandom, xt, zt);
|
strongholdFeature->postProcess(level, pprandom, xt, zt);
|
||||||
scatteredFeature->postProcess(level, random, xt, zt);
|
scatteredFeature->postProcess(level, pprandom, xt, zt);
|
||||||
}
|
}
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
|
|
||||||
|
|||||||
@@ -1099,7 +1099,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case L'c':
|
case L'c':
|
||||||
wchFrom=va_arg(vl,wchar_t);
|
wchFrom=(wchar_t)va_arg(vl,int);
|
||||||
break;
|
break;
|
||||||
case L'z':
|
case L'z':
|
||||||
pItemInstance=va_arg(vl,ItemInstance *);
|
pItemInstance=va_arg(vl,ItemInstance *);
|
||||||
@@ -1116,7 +1116,7 @@ ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
|
|||||||
mappings->insert(myMap::value_type(wchFrom,pItemInstance));
|
mappings->insert(myMap::value_type(wchFrom,pItemInstance));
|
||||||
break;
|
break;
|
||||||
case L'g':
|
case L'g':
|
||||||
wchFrom=va_arg(vl,wchar_t);
|
wchFrom=(wchar_t)va_arg(vl,int);
|
||||||
switch(wchFrom)
|
switch(wchFrom)
|
||||||
{
|
{
|
||||||
// case L'W':
|
// case L'W':
|
||||||
@@ -1214,7 +1214,7 @@ void Recipes::addShapelessRecipy(ItemInstance *result,... )
|
|||||||
ingredients->push_back(new ItemInstance(pTile));
|
ingredients->push_back(new ItemInstance(pTile));
|
||||||
break;
|
break;
|
||||||
case L'g':
|
case L'g':
|
||||||
wchFrom=va_arg(vl,wchar_t);
|
wchFrom=(wchar_t)va_arg(vl,int);
|
||||||
switch(wchFrom)
|
switch(wchFrom)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ byteArray RegionFile::emptySector(SECTOR_BYTES);
|
|||||||
|
|
||||||
RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
|
RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
|
||||||
{
|
{
|
||||||
|
InitializeCriticalSectionAndSpinCount(&m_cs, 4000);
|
||||||
_lastModified = 0;
|
_lastModified = 0;
|
||||||
|
|
||||||
m_saveFile = saveFile;
|
m_saveFile = saveFile;
|
||||||
@@ -38,7 +39,12 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fileEntry = m_saveFile->createFile( fileName->getName() );
|
wstring saveName = fileName->getPath();
|
||||||
|
for (size_t i = 0; i < saveName.size(); i++)
|
||||||
|
{
|
||||||
|
if (saveName[i] == L'\\') saveName[i] = L'/';
|
||||||
|
}
|
||||||
|
fileEntry = m_saveFile->createFile( ConsoleSavePath(saveName) );
|
||||||
m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END );
|
m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END );
|
||||||
|
|
||||||
if ( fileEntry->getFileSize() < SECTOR_BYTES)
|
if ( fileEntry->getFileSize() < SECTOR_BYTES)
|
||||||
@@ -135,6 +141,8 @@ void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile conversi
|
|||||||
{
|
{
|
||||||
if(m_bIsEmpty == false)
|
if(m_bIsEmpty == false)
|
||||||
{
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
// save all the offsets and timestamps
|
// save all the offsets and timestamps
|
||||||
m_saveFile->LockSaveAccess();
|
m_saveFile->LockSaveAccess();
|
||||||
|
|
||||||
@@ -147,6 +155,7 @@ void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile conversi
|
|||||||
m_saveFile->writeFile(fileEntry, chunkTimestamps, SECTOR_BYTES, &numberOfBytesWritten);
|
m_saveFile->writeFile(fileEntry, chunkTimestamps, SECTOR_BYTES, &numberOfBytesWritten);
|
||||||
|
|
||||||
m_saveFile->ReleaseSaveAccess();
|
m_saveFile->ReleaseSaveAccess();
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -156,6 +165,7 @@ RegionFile::~RegionFile()
|
|||||||
delete[] chunkTimestamps;
|
delete[] chunkTimestamps;
|
||||||
delete sectorFree;
|
delete sectorFree;
|
||||||
m_saveFile->closeHandle( fileEntry );
|
m_saveFile->closeHandle( fileEntry );
|
||||||
|
DeleteCriticalSection(&m_cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 RegionFile::lastModified()
|
__int64 RegionFile::lastModified()
|
||||||
@@ -165,8 +175,10 @@ __int64 RegionFile::lastModified()
|
|||||||
|
|
||||||
int RegionFile::getSizeDelta() // TODO - was synchronized
|
int RegionFile::getSizeDelta() // TODO - was synchronized
|
||||||
{
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
int ret = sizeDelta;
|
int ret = sizeDelta;
|
||||||
sizeDelta = 0;
|
sizeDelta = 0;
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,12 +190,14 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
// 4J - removed try/catch
|
// 4J - removed try/catch
|
||||||
// try {
|
// try {
|
||||||
int offset = getOffset(x, z);
|
int offset = getOffset(x, z);
|
||||||
if (offset == 0)
|
if (offset == 0)
|
||||||
{
|
{
|
||||||
// debugln("READ", x, z, "miss");
|
// debugln("READ", x, z, "miss");
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +206,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
|
|||||||
|
|
||||||
if (sectorNumber + numSectors > sectorFree->size())
|
if (sectorNumber + numSectors > sectorFree->size())
|
||||||
{
|
{
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
// debugln("READ", x, z, "invalid sector");
|
// debugln("READ", x, z, "invalid sector");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -227,7 +242,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
|
|||||||
if (length > SECTOR_BYTES * numSectors)
|
if (length > SECTOR_BYTES * numSectors)
|
||||||
{
|
{
|
||||||
// debugln("READ", x, z, "invalid length: " + length + " > 4096 * " + numSectors);
|
// debugln("READ", x, z, "invalid length: " + length + " > 4096 * " + numSectors);
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
m_saveFile->ReleaseSaveAccess();
|
m_saveFile->ReleaseSaveAccess();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -240,6 +255,7 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
|
|||||||
m_saveFile->readFile(fileEntry,data,length,&numberOfBytesRead);
|
m_saveFile->readFile(fileEntry,data,length,&numberOfBytesRead);
|
||||||
|
|
||||||
m_saveFile->ReleaseSaveAccess();
|
m_saveFile->ReleaseSaveAccess();
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
|
||||||
Compression::getCompression()->SetDecompressionType(m_saveFile->getSavePlatform()); // if this save is from another platform, set the correct decompression type
|
Compression::getCompression()->SetDecompressionType(m_saveFile->getSavePlatform()); // if this save is from another platform, set the correct decompression type
|
||||||
|
|
||||||
@@ -290,6 +306,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
m_saveFile->LockSaveAccess();
|
m_saveFile->LockSaveAccess();
|
||||||
{
|
{
|
||||||
int offset = getOffset(x, z);
|
int offset = getOffset(x, z);
|
||||||
@@ -396,6 +413,7 @@ void RegionFile::write(int x, int z, byte *data, int length) // TODO - was sync
|
|||||||
setTimestamp(x, z, (int) (System::currentTimeMillis() / 1000L));
|
setTimestamp(x, z, (int) (System::currentTimeMillis() / 1000L));
|
||||||
}
|
}
|
||||||
m_saveFile->ReleaseSaveAccess();
|
m_saveFile->ReleaseSaveAccess();
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
|
||||||
// } catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ private:
|
|||||||
int sizeDelta;
|
int sizeDelta;
|
||||||
__int64 _lastModified;
|
__int64 _lastModified;
|
||||||
bool m_bIsEmpty; // 4J added
|
bool m_bIsEmpty; // 4J added
|
||||||
|
CRITICAL_SECTION m_cs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RegionFile(ConsoleSaveFile *saveFile, File *path);
|
RegionFile(ConsoleSaveFile *saveFile, File *path);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
|
|||||||
}
|
}
|
||||||
MemSect(0);
|
MemSect(0);
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
RegionFile *ref = NULL;
|
RegionFile *ref = NULL;
|
||||||
AUTO_VAR(it, cache.find(file));
|
AUTO_VAR(it, cache.find(file));
|
||||||
if( it != cache.end() )
|
if( it != cache.end() )
|
||||||
@@ -46,6 +47,7 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
|
|||||||
// 4J Jev, put back in.
|
// 4J Jev, put back in.
|
||||||
if (ref != NULL)
|
if (ref != NULL)
|
||||||
{
|
{
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +65,7 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
|
|||||||
|
|
||||||
RegionFile *reg = new RegionFile(saveFile, &file);
|
RegionFile *reg = new RegionFile(saveFile, &file);
|
||||||
cache[file] = reg; // 4J - this was originally a softReferenc
|
cache[file] = reg; // 4J - this was originally a softReferenc
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
return reg;
|
return reg;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -85,6 +88,7 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
cache.clear();
|
cache.clear();
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RegionFileCache::_getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ)
|
int RegionFileCache::_getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ)
|
||||||
|
|||||||
@@ -10,13 +10,14 @@ private:
|
|||||||
static const int MAX_CACHE_SIZE = 256;
|
static const int MAX_CACHE_SIZE = 256;
|
||||||
|
|
||||||
unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> cache;
|
unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> cache;
|
||||||
|
CRITICAL_SECTION m_cs;
|
||||||
|
|
||||||
static RegionFileCache s_defaultCache;
|
static RegionFileCache s_defaultCache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Made public and non-static so we can have a cache for input and output files
|
// Made public and non-static so we can have a cache for input and output files
|
||||||
RegionFileCache() {}
|
RegionFileCache() { InitializeCriticalSectionAndSpinCount(&m_cs, 4000); }
|
||||||
~RegionFileCache();
|
~RegionFileCache() { DeleteCriticalSection(&m_cs); }
|
||||||
|
|
||||||
RegionFile *_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); // 4J - TODO was synchronized
|
RegionFile *_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); // 4J - TODO was synchronized
|
||||||
void _clear(); // 4J - TODO was synchronized
|
void _clear(); // 4J - TODO was synchronized
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ RemoveEntitiesPacket::~RemoveEntitiesPacket()
|
|||||||
|
|
||||||
void RemoveEntitiesPacket::read(DataInputStream *dis) //throws IOException
|
void RemoveEntitiesPacket::read(DataInputStream *dis) //throws IOException
|
||||||
{
|
{
|
||||||
ids = intArray(dis->readByte());
|
int count = dis->readByte();
|
||||||
|
if(count < 0) count = 0;
|
||||||
|
ids = intArray(count);
|
||||||
for(unsigned int i = 0; i < ids.length; ++i)
|
for(unsigned int i = 0; i < ids.length; ++i)
|
||||||
{
|
{
|
||||||
ids[i] = dis->readInt();
|
ids[i] = dis->readInt();
|
||||||
|
|||||||
@@ -138,6 +138,11 @@ void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHos
|
|||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&m_queueLockNetwork[queueIdx]);
|
EnterCriticalSection(&m_queueLockNetwork[queueIdx]);
|
||||||
|
if(m_queueNetwork[queueIdx].size() + dwDataSize > 2 * 1024 * 1024)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&m_queueLockNetwork[queueIdx]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
for( unsigned int i = 0; i < dwDataSize; i++ )
|
for( unsigned int i = 0; i < dwDataSize; i++ )
|
||||||
{
|
{
|
||||||
m_queueNetwork[queueIdx].push(*pbData++);
|
m_queueNetwork[queueIdx].push(*pbData++);
|
||||||
|
|||||||
@@ -602,9 +602,10 @@ bool SparseDataStorage::isCompressed()
|
|||||||
|
|
||||||
void SparseDataStorage::write(DataOutputStream *dos)
|
void SparseDataStorage::write(DataOutputStream *dos)
|
||||||
{
|
{
|
||||||
int count = ( dataAndCount >> 48 ) & 0xffff;
|
__int64 snapshot = dataAndCount;
|
||||||
|
int count = ( snapshot >> 48 ) & 0xffff;
|
||||||
dos->writeInt(count);
|
dos->writeInt(count);
|
||||||
unsigned char *dataPointer = (unsigned char *)(dataAndCount & 0x0000ffffffffffff);
|
unsigned char *dataPointer = (unsigned char *)(snapshot & 0x0000ffffffffffff);
|
||||||
byteArray wrapper(dataPointer, count * 128 + 128);
|
byteArray wrapper(dataPointer, count * 128 + 128);
|
||||||
dos->write(wrapper);
|
dos->write(wrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -619,9 +619,10 @@ bool SparseLightStorage::isCompressed()
|
|||||||
|
|
||||||
void SparseLightStorage::write(DataOutputStream *dos)
|
void SparseLightStorage::write(DataOutputStream *dos)
|
||||||
{
|
{
|
||||||
int count = ( dataAndCount >> 48 ) & 0xffff;
|
__int64 snapshot = dataAndCount;
|
||||||
|
int count = ( snapshot >> 48 ) & 0xffff;
|
||||||
dos->writeInt(count);
|
dos->writeInt(count);
|
||||||
unsigned char *dataPointer = (unsigned char *)(dataAndCount & 0x0000ffffffffffff);
|
unsigned char *dataPointer = (unsigned char *)(snapshot & 0x0000ffffffffffff);
|
||||||
byteArray wrapper(dataPointer, count * 128 + 128);
|
byteArray wrapper(dataPointer, count * 128 + 128);
|
||||||
dos->write(wrapper);
|
dos->write(wrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
StructureFeature::StructureFeature()
|
StructureFeature::StructureFeature()
|
||||||
{
|
{
|
||||||
|
InitializeCriticalSectionAndSpinCount(&m_csCachedStructures, 4000);
|
||||||
#ifdef ENABLE_STRUCTURE_SAVING
|
#ifdef ENABLE_STRUCTURE_SAVING
|
||||||
savedData = nullptr;
|
savedData = nullptr;
|
||||||
#endif
|
#endif
|
||||||
@@ -16,10 +17,13 @@ StructureFeature::StructureFeature()
|
|||||||
|
|
||||||
StructureFeature::~StructureFeature()
|
StructureFeature::~StructureFeature()
|
||||||
{
|
{
|
||||||
|
EnterCriticalSection(&m_csCachedStructures);
|
||||||
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
|
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
|
||||||
{
|
{
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
|
DeleteCriticalSection(&m_csCachedStructures);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOffs, byteArray blocks)
|
void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOffs, byteArray blocks)
|
||||||
@@ -30,10 +34,13 @@ void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOf
|
|||||||
|
|
||||||
restoreSavedData(level);
|
restoreSavedData(level);
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_csCachedStructures);
|
||||||
if (cachedStructures.find(ChunkPos::hashCode(x, z)) != cachedStructures.end())
|
if (cachedStructures.find(ChunkPos::hashCode(x, z)) != cachedStructures.end())
|
||||||
{
|
{
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
|
|
||||||
// clear random key
|
// clear random key
|
||||||
random->nextInt();
|
random->nextInt();
|
||||||
@@ -41,8 +48,10 @@ void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOf
|
|||||||
if (isFeatureChunk(x, z,level->getLevelData()->getGenerator() == LevelType::lvl_flat))
|
if (isFeatureChunk(x, z,level->getLevelData()->getGenerator() == LevelType::lvl_flat))
|
||||||
{
|
{
|
||||||
StructureStart *start = createStructureStart(x, z);
|
StructureStart *start = createStructureStart(x, z);
|
||||||
|
EnterCriticalSection(&m_csCachedStructures);
|
||||||
cachedStructures[ChunkPos::hashCode(x, z)] = start;
|
cachedStructures[ChunkPos::hashCode(x, z)] = start;
|
||||||
saveFeature(x, z, start);
|
saveFeature(x, z, start);
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +67,7 @@ bool StructureFeature::postProcess(Level *level, Random *random, int chunkX, int
|
|||||||
int cz = (chunkZ << 4); // + 8;
|
int cz = (chunkZ << 4); // + 8;
|
||||||
|
|
||||||
bool intersection = false;
|
bool intersection = false;
|
||||||
|
EnterCriticalSection(&m_csCachedStructures);
|
||||||
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
|
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
|
||||||
{
|
{
|
||||||
StructureStart *structureStart = it->second;
|
StructureStart *structureStart = it->second;
|
||||||
@@ -76,6 +86,7 @@ bool StructureFeature::postProcess(Level *level, Random *random, int chunkX, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
|
|
||||||
return intersection;
|
return intersection;
|
||||||
}
|
}
|
||||||
@@ -84,6 +95,7 @@ bool StructureFeature::isIntersection(int cellX, int cellZ)
|
|||||||
{
|
{
|
||||||
restoreSavedData(level);
|
restoreSavedData(level);
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_csCachedStructures);
|
||||||
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
|
for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ )
|
||||||
{
|
{
|
||||||
StructureStart *structureStart = it->second;
|
StructureStart *structureStart = it->second;
|
||||||
@@ -97,12 +109,14 @@ bool StructureFeature::isIntersection(int cellX, int cellZ)
|
|||||||
StructurePiece *next = *it2++;
|
StructurePiece *next = *it2++;
|
||||||
if (next->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ))
|
if (next->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ))
|
||||||
{
|
{
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +129,7 @@ bool StructureFeature::isInsideFeature(int cellX, int cellY, int cellZ)
|
|||||||
StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ)
|
StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ)
|
||||||
{
|
{
|
||||||
//for (StructureStart structureStart : cachedStructures.values())
|
//for (StructureStart structureStart : cachedStructures.values())
|
||||||
|
EnterCriticalSection(&m_csCachedStructures);
|
||||||
for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it)
|
for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it)
|
||||||
{
|
{
|
||||||
StructureStart *pStructureStart = it->second;
|
StructureStart *pStructureStart = it->second;
|
||||||
@@ -138,12 +153,14 @@ StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ
|
|||||||
StructurePiece* piece = *it2;
|
StructurePiece* piece = *it2;
|
||||||
if ( piece->getBoundingBox()->isInside(cellX, cellY, cellZ) )
|
if ( piece->getBoundingBox()->isInside(cellX, cellY, cellZ) )
|
||||||
{
|
{
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
return pStructureStart;
|
return pStructureStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +199,7 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i
|
|||||||
double minDistance = DBL_MAX;
|
double minDistance = DBL_MAX;
|
||||||
TilePos *selected = NULL;
|
TilePos *selected = NULL;
|
||||||
|
|
||||||
|
EnterCriticalSection(&m_csCachedStructures);
|
||||||
for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it)
|
for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it)
|
||||||
{
|
{
|
||||||
StructureStart *pStructureStart = it->second;
|
StructureStart *pStructureStart = it->second;
|
||||||
@@ -205,6 +223,7 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&m_csCachedStructures);
|
||||||
if (selected != NULL)
|
if (selected != NULL)
|
||||||
{
|
{
|
||||||
return selected;
|
return selected;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
unordered_map<__int64, StructureStart *> cachedStructures;
|
unordered_map<__int64, StructureStart *> cachedStructures;
|
||||||
|
CRITICAL_SECTION m_csCachedStructures;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StructureFeature();
|
StructureFeature();
|
||||||
|
|||||||
@@ -343,8 +343,10 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
|
|||||||
vector<shared_ptr<DataItem> > *result = NULL;
|
vector<shared_ptr<DataItem> > *result = NULL;
|
||||||
|
|
||||||
int currentHeader = input->readByte();
|
int currentHeader = input->readByte();
|
||||||
|
int itemCount = 0;
|
||||||
|
const int MAX_ENTITY_DATA_ITEMS = 256;
|
||||||
|
|
||||||
while (currentHeader != EOF_MARKER)
|
while (currentHeader != EOF_MARKER && itemCount < MAX_ENTITY_DATA_ITEMS)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
@@ -399,6 +401,7 @@ vector<shared_ptr<SynchedEntityData::DataItem> > *SynchedEntityData::unpack(Data
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result->push_back(item);
|
result->push_back(item);
|
||||||
|
itemCount++;
|
||||||
|
|
||||||
currentHeader = input->readByte();
|
currentHeader = input->readByte();
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-17
@@ -79,32 +79,44 @@ Tag *Tag::setName(const wstring& name)
|
|||||||
|
|
||||||
Tag *Tag::readNamedTag(DataInput *dis)
|
Tag *Tag::readNamedTag(DataInput *dis)
|
||||||
{
|
{
|
||||||
return readNamedTag(dis,0);
|
static __declspec(thread) int depth = 0;
|
||||||
}
|
static __declspec(thread) int totalTagCount = 0;
|
||||||
|
|
||||||
Tag *Tag::readNamedTag(DataInput *dis, int tagDepth)
|
if (depth == 0)
|
||||||
{
|
totalTagCount = 0;
|
||||||
byte type = dis->readByte();
|
|
||||||
if (type == 0) return new EndTag();
|
|
||||||
|
|
||||||
// 4J Stu - readByte can return -1, so if it's that then also mark as the end tag
|
depth++;
|
||||||
if(type == 255)
|
|
||||||
|
if (depth > 256)
|
||||||
{
|
{
|
||||||
app.DebugPrintf("readNamedTag read a type of 255\n");
|
depth--;
|
||||||
#ifndef _CONTENT_PACKAGE
|
|
||||||
__debugbreak();
|
|
||||||
#endif
|
|
||||||
return new EndTag();
|
return new EndTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring name = dis->readUTF();//new String(bytes, "UTF-8");
|
totalTagCount++;
|
||||||
|
const int MAX_TOTAL_TAGS = 32768;
|
||||||
|
if (totalTagCount > MAX_TOTAL_TAGS)
|
||||||
|
{
|
||||||
|
depth--;
|
||||||
|
return new EndTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte type = dis->readByte();
|
||||||
|
if (type == 0) { depth--; return new EndTag(); }
|
||||||
|
|
||||||
|
if(type == 255)
|
||||||
|
{
|
||||||
|
depth--;
|
||||||
|
return new EndTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
wstring name = dis->readUTF();
|
||||||
|
|
||||||
Tag *tag = newTag(type, name);
|
Tag *tag = newTag(type, name);
|
||||||
// short length = dis.readShort();
|
if (tag == NULL) { depth--; return new EndTag(); }
|
||||||
// byte[] bytes = new byte[length];
|
|
||||||
// dis.readFully(bytes);
|
|
||||||
|
|
||||||
tag->load(dis, tagDepth);
|
tag->load(dis);
|
||||||
|
depth--;
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,17 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
{
|
{
|
||||||
textureName = dis->readUTF();
|
textureName = dis->readUTF();
|
||||||
dwSkinID = (DWORD)dis->readInt();
|
dwSkinID = (DWORD)dis->readInt();
|
||||||
dwTextureBytes = (DWORD)dis->readShort();
|
|
||||||
|
short rawTextureBytes = dis->readShort();
|
||||||
|
if(rawTextureBytes <= 0)
|
||||||
|
{
|
||||||
|
dwTextureBytes = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dwTextureBytes = (DWORD)(unsigned short)rawTextureBytes;
|
||||||
|
if(dwTextureBytes > 65536) dwTextureBytes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(dwTextureBytes>0)
|
if(dwTextureBytes>0)
|
||||||
{
|
{
|
||||||
@@ -136,7 +146,16 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
|
|||||||
}
|
}
|
||||||
uiAnimOverrideBitmask = dis->readInt();
|
uiAnimOverrideBitmask = dis->readInt();
|
||||||
|
|
||||||
dwBoxC = (DWORD)dis->readShort();
|
short rawBoxC = dis->readShort();
|
||||||
|
if(rawBoxC <= 0)
|
||||||
|
{
|
||||||
|
dwBoxC = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dwBoxC = (DWORD)(unsigned short)rawBoxC;
|
||||||
|
if(dwBoxC > 256) dwBoxC = 0; // sane limit for skin boxes
|
||||||
|
}
|
||||||
|
|
||||||
if(dwBoxC>0)
|
if(dwBoxC>0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,9 +37,19 @@ void TexturePacket::handle(PacketListener *listener)
|
|||||||
void TexturePacket::read(DataInputStream *dis) //throws IOException
|
void TexturePacket::read(DataInputStream *dis) //throws IOException
|
||||||
{
|
{
|
||||||
textureName = dis->readUTF();
|
textureName = dis->readUTF();
|
||||||
dwBytes = (DWORD)dis->readShort();
|
short rawBytes = dis->readShort();
|
||||||
|
if(rawBytes <= 0)
|
||||||
|
{
|
||||||
|
dwBytes = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dwBytes = (DWORD)(unsigned short)rawBytes;
|
||||||
|
if(dwBytes > 65536)
|
||||||
|
{
|
||||||
|
dwBytes = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(dwBytes>0)
|
|
||||||
{
|
{
|
||||||
this->pbData= new BYTE [dwBytes];
|
this->pbData= new BYTE [dwBytes];
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName )
|
|||||||
#if ( defined _WINDOWS64 | defined _DURANGO )
|
#if ( defined _WINDOWS64 | defined _DURANGO )
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR *)&info );
|
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR *)&info );
|
||||||
}
|
}
|
||||||
__except( GetExceptionCode()==0x406D1388 ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_EXECUTE_HANDLER )
|
__except( EXCEPTION_EXECUTE_HANDLER )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void UpdateGameRuleProgressPacket::read(DataInputStream *dis) //throws IOExcepti
|
|||||||
m_dataTag = dis->readInt();
|
m_dataTag = dis->readInt();
|
||||||
int dataLength = dis->readInt();
|
int dataLength = dis->readInt();
|
||||||
|
|
||||||
if(dataLength > 0)
|
if(dataLength > 0 && dataLength <= 65536)
|
||||||
{
|
{
|
||||||
m_data = byteArray(dataLength);
|
m_data = byteArray(dataLength);
|
||||||
dis->readFully(m_data);
|
dis->readFully(m_data);
|
||||||
|
|||||||
@@ -196,9 +196,20 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
|
|||||||
unsigned int rleSize = staticRleSize;
|
unsigned int rleSize = staticRleSize;
|
||||||
unsigned char *dynamicRleBuf = NULL;
|
unsigned char *dynamicRleBuf = NULL;
|
||||||
|
|
||||||
if(*pDestSize > rleSize)
|
|
||||||
|
unsigned int safeRleSize = max(rleSize, *pDestSize);
|
||||||
|
|
||||||
|
const unsigned int MAX_RLE_ALLOC = 16 * 1024 * 1024; // 16 MB
|
||||||
|
if(safeRleSize > MAX_RLE_ALLOC)
|
||||||
{
|
{
|
||||||
rleSize = *pDestSize;
|
LeaveCriticalSection(&rleDecompressLock);
|
||||||
|
*pDestSize = 0;
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(safeRleSize > staticRleSize)
|
||||||
|
{
|
||||||
|
rleSize = safeRleSize;
|
||||||
dynamicRleBuf = new unsigned char[rleSize];
|
dynamicRleBuf = new unsigned char[rleSize];
|
||||||
Decompress(dynamicRleBuf, &rleSize, pSource, SrcSize);
|
Decompress(dynamicRleBuf, &rleSize, pSource, SrcSize);
|
||||||
pucIn = (unsigned char *)dynamicRleBuf;
|
pucIn = (unsigned char *)dynamicRleBuf;
|
||||||
@@ -212,16 +223,19 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
|
|||||||
//unsigned char *pucIn = (unsigned char *)rleDecompressBuf;
|
//unsigned char *pucIn = (unsigned char *)rleDecompressBuf;
|
||||||
unsigned char *pucEnd = pucIn + rleSize;
|
unsigned char *pucEnd = pucIn + rleSize;
|
||||||
unsigned char *pucOut = (unsigned char *)pDestination;
|
unsigned char *pucOut = (unsigned char *)pDestination;
|
||||||
|
unsigned char *pucOutEnd = pucOut + *pDestSize;
|
||||||
|
|
||||||
while( pucIn != pucEnd )
|
while( pucIn != pucEnd )
|
||||||
{
|
{
|
||||||
unsigned char thisOne = *pucIn++;
|
unsigned char thisOne = *pucIn++;
|
||||||
if( thisOne == 255 )
|
if( thisOne == 255 )
|
||||||
{
|
{
|
||||||
|
if( pucIn >= pucEnd ) break;
|
||||||
unsigned int count = *pucIn++;
|
unsigned int count = *pucIn++;
|
||||||
if( count < 3 )
|
if( count < 3 )
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; }
|
||||||
for( unsigned int i = 0; i < count; i++ )
|
for( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
*pucOut++ = 255;
|
*pucOut++ = 255;
|
||||||
@@ -230,7 +244,9 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
if( pucIn >= pucEnd ) break;
|
||||||
unsigned char data = *pucIn++;
|
unsigned char data = *pucIn++;
|
||||||
|
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; }
|
||||||
for( unsigned int i = 0; i < count; i++ )
|
for( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
*pucOut++ = data;
|
*pucOut++ = data;
|
||||||
@@ -239,6 +255,7 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if( pucOut >= pucOutEnd ) break;
|
||||||
*pucOut++ = thisOne;
|
*pucOut++ = thisOne;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,16 +277,19 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
|
|||||||
unsigned char *pucIn = (unsigned char *)pSource;
|
unsigned char *pucIn = (unsigned char *)pSource;
|
||||||
unsigned char *pucEnd = pucIn + SrcSize;
|
unsigned char *pucEnd = pucIn + SrcSize;
|
||||||
unsigned char *pucOut = (unsigned char *)pDestination;
|
unsigned char *pucOut = (unsigned char *)pDestination;
|
||||||
|
unsigned char *pucOutEnd = pucOut + *pDestSize;
|
||||||
|
|
||||||
while( pucIn != pucEnd )
|
while( pucIn != pucEnd )
|
||||||
{
|
{
|
||||||
unsigned char thisOne = *pucIn++;
|
unsigned char thisOne = *pucIn++;
|
||||||
if( thisOne == 255 )
|
if( thisOne == 255 )
|
||||||
{
|
{
|
||||||
|
if( pucIn >= pucEnd ) break;
|
||||||
unsigned int count = *pucIn++;
|
unsigned int count = *pucIn++;
|
||||||
if( count < 3 )
|
if( count < 3 )
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; }
|
||||||
for( unsigned int i = 0; i < count; i++ )
|
for( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
*pucOut++ = 255;
|
*pucOut++ = 255;
|
||||||
@@ -278,7 +298,9 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
if( pucIn >= pucEnd ) break;
|
||||||
unsigned char data = *pucIn++;
|
unsigned char data = *pucIn++;
|
||||||
|
if( pucOut + count > pucOutEnd ) { pucOut = pucOutEnd; break; }
|
||||||
for( unsigned int i = 0; i < count; i++ )
|
for( unsigned int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
*pucOut++ = data;
|
*pucOut++ = data;
|
||||||
@@ -287,6 +309,7 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if( pucOut >= pucOutEnd ) break;
|
||||||
*pucOut++ = thisOne;
|
*pucOut++ = thisOne;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,14 @@ void System::arraycopy(arrayWithLength<int> src, unsigned int srcPos, arrayWithL
|
|||||||
//The current value of the system timer, in nanoseconds.
|
//The current value of the system timer, in nanoseconds.
|
||||||
__int64 System::nanoTime()
|
__int64 System::nanoTime()
|
||||||
{
|
{
|
||||||
return GetTickCount() * 1000000LL;
|
static LARGE_INTEGER s_frequency = { 0 };
|
||||||
|
if (s_frequency.QuadPart == 0)
|
||||||
|
QueryPerformanceFrequency(&s_frequency);
|
||||||
|
|
||||||
|
LARGE_INTEGER counter;
|
||||||
|
QueryPerformanceCounter(&counter);
|
||||||
|
|
||||||
|
return (__int64)((double)counter.QuadPart * 1000000000.0 / (double)s_frequency.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond,
|
//Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond,
|
||||||
|
|||||||
@@ -13,16 +13,28 @@
|
|||||||
|
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
|
|
||||||
|
#ifndef XUSER_INDEX_ANY
|
||||||
const int XUSER_INDEX_ANY = 255;
|
const int XUSER_INDEX_ANY = 255;
|
||||||
|
#endif
|
||||||
|
#ifndef XUSER_INDEX_FOCUS
|
||||||
const int XUSER_INDEX_FOCUS = 254;
|
const int XUSER_INDEX_FOCUS = 254;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
|
#ifndef XUSER_MAX_COUNT
|
||||||
const int XUSER_MAX_COUNT = 1;
|
const int XUSER_MAX_COUNT = 1;
|
||||||
|
#endif
|
||||||
const int MINECRAFT_NET_MAX_PLAYERS = 4;
|
const int MINECRAFT_NET_MAX_PLAYERS = 4;
|
||||||
#else
|
#else
|
||||||
|
#ifndef XUSER_MAX_COUNT
|
||||||
const int XUSER_MAX_COUNT = 4;
|
const int XUSER_MAX_COUNT = 4;
|
||||||
|
#endif
|
||||||
|
#if defined(_DEDICATED_SERVER) || defined(_WINDOWS64)
|
||||||
|
const int MINECRAFT_NET_MAX_PLAYERS = 255;
|
||||||
|
#else
|
||||||
const int MINECRAFT_NET_MAX_PLAYERS = 8;
|
const int MINECRAFT_NET_MAX_PLAYERS = 8;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -215,10 +227,19 @@ public:
|
|||||||
int GetUserIndex();
|
int GetUserIndex();
|
||||||
void SetCustomDataValue(ULONG_PTR ulpCustomDataValue);
|
void SetCustomDataValue(ULONG_PTR ulpCustomDataValue);
|
||||||
ULONG_PTR GetCustomDataValue();
|
ULONG_PTR GetCustomDataValue();
|
||||||
|
|
||||||
|
BYTE m_smallId;
|
||||||
|
bool m_isRemote;
|
||||||
|
bool m_isHostPlayer;
|
||||||
|
wchar_t m_gamertag[32];
|
||||||
private:
|
private:
|
||||||
ULONG_PTR m_customData;
|
ULONG_PTR m_customData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal);
|
||||||
|
PlayerUID Win64_UsernameToXuid(const char* username);
|
||||||
|
PlayerUID Win64_UsernameToXuid(const wchar_t* username);
|
||||||
|
|
||||||
const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0;
|
const int QNET_GETSENDQUEUESIZE_SECONDARY_TYPE = 0;
|
||||||
const int QNET_GETSENDQUEUESIZE_MESSAGES = 0;
|
const int QNET_GETSENDQUEUESIZE_MESSAGES = 0;
|
||||||
const int QNET_GETSENDQUEUESIZE_BYTES = 0;
|
const int QNET_GETSENDQUEUESIZE_BYTES = 0;
|
||||||
@@ -309,9 +330,15 @@ public:
|
|||||||
bool IsHost();
|
bool IsHost();
|
||||||
HRESULT JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo);
|
HRESULT JoinGameFromInviteInfo(DWORD dwUserIndex, DWORD dwUserMask, const INVITE_INFO *pInviteInfo);
|
||||||
void HostGame();
|
void HostGame();
|
||||||
|
void ClientJoinGame();
|
||||||
void EndGame();
|
void EndGame();
|
||||||
|
static void SetPlayerCapacity(DWORD capacity);
|
||||||
|
static DWORD GetPlayerCapacity();
|
||||||
|
|
||||||
static IQNetPlayer m_player[4];
|
static IQNetPlayer *m_player;
|
||||||
|
static DWORD s_playerCapacity;
|
||||||
|
static DWORD s_playerCount;
|
||||||
|
static bool s_isHosting;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _DURANGO
|
#ifdef _DURANGO
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "extraX64.h"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "extraX64.h"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "extraX64.h"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "extraX64.h"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "extraX64.h"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "extraX64.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user