Add threadlock and universal fs functions

This commit is contained in:
murdle 2026-03-01 23:19:08 +02:00
parent 5b984ad854
commit f0632c2364
92 changed files with 618 additions and 281 deletions

View File

@ -46,7 +46,7 @@ Tesselator *Chunk::t = Tesselator::getInstance();
LevelRenderer *Chunk::levelRenderer; LevelRenderer *Chunk::levelRenderer;
// TODO - 4J see how input entity vector is set up and decide what way is best to pass this to the function // TODO - 4J see how input entity vector is set up and decide what way is best to pass this to the function
Chunk::Chunk(Level *level, LevelRenderer::rteMap &globalRenderableTileEntities, CRITICAL_SECTION& globalRenderableTileEntities_cs, int x, int y, int z, ClipChunk *clipChunk) Chunk::Chunk(Level *level, LevelRenderer::rteMap &globalRenderableTileEntities, ThreadLock& globalRenderableTileEntities_cs, int x, int y, int z, ClipChunk *clipChunk)
: globalRenderableTileEntities( &globalRenderableTileEntities ), globalRenderableTileEntities_cs(&globalRenderableTileEntities_cs) : globalRenderableTileEntities( &globalRenderableTileEntities ), globalRenderableTileEntities_cs(&globalRenderableTileEntities_cs)
{ {
clipChunk->visible = false; clipChunk->visible = false;

View File

@ -56,10 +56,10 @@ public:
private: private:
LevelRenderer::rteMap *globalRenderableTileEntities; LevelRenderer::rteMap *globalRenderableTileEntities;
CRITICAL_SECTION *globalRenderableTileEntities_cs; ThreadLock *globalRenderableTileEntities_cs;
bool assigned; bool assigned;
public: public:
Chunk(Level *level, LevelRenderer::rteMap &globalRenderableTileEntities, CRITICAL_SECTION &globalRenderableTileEntities_cs, int x, int y, int z, ClipChunk *clipChunk); Chunk(Level *level, LevelRenderer::rteMap &globalRenderableTileEntities, ThreadLock &globalRenderableTileEntities_cs, int x, int y, int z, ClipChunk *clipChunk);
Chunk(); Chunk();
void setPos(int x, int y, int z); void setPos(int x, int y, int z);

View File

@ -176,7 +176,7 @@ void AILCALL ErrorCallback(S64 i_Id, char const* i_Details)
// AP - this is the callback when the driver is about to mix. At this point the mutex is locked by Miles so we can now call all Miles functions without // AP - this is the callback when the driver is about to mix. At this point the mutex is locked by Miles so we can now call all Miles functions without
// the possibility of incurring a stall. // the possibility of incurring a stall.
static bool SoundEngine_Change = false; // has tick been called? static bool SoundEngine_Change = false; // has tick been called?
static CRITICAL_SECTION SoundEngine_MixerMutex; static ThreadLock SoundEngine_MixerMutex;
void AILCALL MilesMixerCB(HDIGDRIVER dig) void AILCALL MilesMixerCB(HDIGDRIVER dig)
{ {

View File

@ -28,7 +28,7 @@ class C4JMemoryPoolFixed : public C4JMemoryPool
uchar* m_memStart; // Beginning of memory pool uchar* m_memStart; // Beginning of memory pool
uchar* m_memEnd; // End of memory pool uchar* m_memEnd; // End of memory pool
uchar* m_next; // Num of next free block uchar* m_next; // Num of next free block
// CRITICAL_SECTION m_CS; // ThreadLock m_CS;
public: public:
C4JMemoryPoolFixed() C4JMemoryPoolFixed()
{ {

View File

@ -5325,8 +5325,8 @@ int CMinecraftApp::DLCMountedCallback(void* pParam,int iPad,unsigned long dwErr,
m_Time.qwAppTime.QuadPart += qwDeltaTime.QuadPart; m_Time.qwAppTime.QuadPart += qwDeltaTime.QuadPart;
m_Time.qwTime.QuadPart = qwNewTime.QuadPart; m_Time.qwTime.QuadPart = qwNewTime.QuadPart;
m_Time.fElapsedTime = m_Time.fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); m_Time.fElapsedTime = m_Time.fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
m_Time.fAppTime = m_Time.fSecsPerTick * ((FLOAT)(m_Time.qwAppTime.QuadPart)); m_Time.fAppTime = m_Time.fSecsPerTick * ((float)(m_Time.qwAppTime.QuadPart));
} }

View File

@ -373,8 +373,8 @@ private:
unordered_map<wstring, PMEMDATA> m_MEM_Files; unordered_map<wstring, PMEMDATA> m_MEM_Files;
// for storing texture pack data files // for storing texture pack data files
unordered_map<int, PMEMDATA> m_MEM_TPD; unordered_map<int, PMEMDATA> m_MEM_TPD;
CRITICAL_SECTION csMemFilesLock; // For locking access to the above map ThreadLock csMemFilesLock; // For locking access to the above map
CRITICAL_SECTION csMemTPDLock; // For locking access to the above map ThreadLock csMemTPDLock; // For locking access to the above map
VNOTIFICATIONS m_vNotifications; VNOTIFICATIONS m_vNotifications;
@ -780,7 +780,7 @@ public:
void EnterSaveNotificationSection(); void EnterSaveNotificationSection();
void LeaveSaveNotificationSection(); void LeaveSaveNotificationSection();
private: private:
CRITICAL_SECTION m_saveNotificationCriticalSection; ThreadLock m_saveNotificationCriticalSection;
int m_saveNotificationDepth; int m_saveNotificationDepth;
// Download Status // Download Status
@ -792,11 +792,11 @@ private:
bool m_bAllDLCContentRetrieved; bool m_bAllDLCContentRetrieved;
bool m_bAllTMSContentRetrieved; bool m_bAllTMSContentRetrieved;
bool m_bTickTMSDLCFiles; bool m_bTickTMSDLCFiles;
CRITICAL_SECTION csDLCDownloadQueue; ThreadLock csDLCDownloadQueue;
CRITICAL_SECTION csTMSPPDownloadQueue; ThreadLock csTMSPPDownloadQueue;
CRITICAL_SECTION csAdditionalModelParts; ThreadLock csAdditionalModelParts;
CRITICAL_SECTION csAdditionalSkinBoxes; ThreadLock csAdditionalSkinBoxes;
CRITICAL_SECTION csAnimOverrideBitmask; ThreadLock csAnimOverrideBitmask;
bool m_bCorruptSaveDeleted; bool m_bCorruptSaveDeleted;
unsigned long m_dwAdditionalModelParts[XUSER_MAX_COUNT]; unsigned long m_dwAdditionalModelParts[XUSER_MAX_COUNT];

View File

@ -229,8 +229,8 @@ protected:
}; };
std::queue<StateChangeInfo> m_stateChangeQueue; std::queue<StateChangeInfo> m_stateChangeQueue;
CRITICAL_SECTION m_csStateChangeQueue; ThreadLock m_csStateChangeQueue;
CRITICAL_SECTION m_csMatching; ThreadLock m_csMatching;
typedef enum typedef enum
{ {

View File

@ -98,6 +98,6 @@ class SQRNetworkPlayer
SQRNetworkManager *m_manager; // Pointer back to the manager that is managing this player SQRNetworkManager *m_manager; // Pointer back to the manager that is managing this player
wchar_t m_name[21]; wchar_t m_name[21];
uintptr_t m_customData; uintptr_t m_customData;
CRITICAL_SECTION m_csQueue; ThreadLock m_csQueue;
std::queue<QueuedSendBlock> m_sendQueue; std::queue<QueuedSendBlock> m_sendQueue;
}; };

View File

@ -1,7 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "SonyCommerce.h" #include "SonyCommerce.h"
#include "PS3Extras/ShutdownManager.h" #include "Common/Shutdown/ShutdownManager.h"
#include <sys/event.h> #include <sys/event.h>
@ -31,7 +31,7 @@ bool SonyCommerce::m_bUpgradingTrial = false;
SonyCommerce::CallbackFunc SonyCommerce::m_trialUpgradeCallbackFunc; SonyCommerce::CallbackFunc SonyCommerce::m_trialUpgradeCallbackFunc;
void* SonyCommerce::m_trialUpgradeCallbackParam; void* SonyCommerce::m_trialUpgradeCallbackParam;
CRITICAL_SECTION SonyCommerce::m_queueLock; ThreadLock SonyCommerce::m_queueLock;

View File

@ -0,0 +1,204 @@
#include "stdafx.h"
#include "ShutdownManager.h"
#include "..\..\Common\Leaderboards\LeaderboardManager.h"
#include "..\..\MinecraftServer.h"
#ifdef __PS3__
#include "C4JSpursJob.h"
bool ShutdownManager::s_threadShouldRun[ShutdownManager::eThreadIdCount];
int ShutdownManager::s_threadRunning[ShutdownManager::eThreadIdCount];
ThreadLock ShutdownManager::s_threadRunningCS;
C4JThread::EventArray *ShutdownManager::s_eventArray[eThreadIdCount];
#endif
// Initialises the shutdown manager - this needs to be called as soon as the game is started so it can respond as quickly as possible to shut down requests
void ShutdownManager::Initialise()
{
#ifdef __PS3__
cellSysutilRegisterCallback( 1, SysUtilCallback, NULL );
for( int i = 0; i < eThreadIdCount; i++ )
{
s_threadShouldRun[i] = true;
s_threadRunning[i] = 0;
s_eventArray[i] = NULL;
}
// Special case for storage manager, which we will manually set now to be considered as running - this will be unset by StorageManager.ExitRequest if required
s_threadRunning[eStorageManagerThreads] = true;
InitializeCriticalSection(&s_threadRunningCS);
#endif
}
// Called in response to a system request to exit the game. This just requests that the main thread should stop, and then the main thread is responsible for calling MainThreadHandleShutdown which
// starts the rest of the shut down process, then waits until it is complete.
void ShutdownManager::StartShutdown()
{
#ifdef __PS3__
s_threadShouldRun[ eMainThread ] = false;
#endif
}
// This should be called from the main thread after it has been requested to shut down (ShouldRun for main thread returns false), and before it returns control to the kernel. This is responsible for
// signalling to all other threads to stop, and wait until their completion before returning.
void ShutdownManager::MainThreadHandleShutdown()
{
#ifdef __PS3__
// Set flags for each thread which will be reset when they are complete
s_threadRunning[ eMainThread ] = false;
// Second wave of things we would like to shut down (after main)
LeaderboardManager::Instance()->CancelOperation();
RequestThreadToStop( eLeaderboardThread );
RequestThreadToStop( eCommerceThread );
RequestThreadToStop( ePostProcessThread );
RequestThreadToStop( eRunUpdateThread );
RequestThreadToStop( eRenderChunkUpdateThread );
RequestThreadToStop( eConnectionReadThreads );
RequestThreadToStop( eConnectionWriteThreads );
RequestThreadToStop( eEventQueueThreads );
app.DebugPrintf("Shutdown manager: waiting on first batch of threads requested to terminate...\n");
WaitForSignalledToComplete();
app.DebugPrintf("Shutdown manager: terminated.\n");
// Now shut down the server thread
MinecraftServer::HaltServer();
RequestThreadToStop( eServerThread );
app.DebugPrintf("Shutdown manager: waiting on server to terminate...\n");
WaitForSignalledToComplete();
app.DebugPrintf("Shutdown manager: terminated.\n");
//And shut down the storage manager
RequestThreadToStop( eStorageManagerThreads );
StorageManager.ExitRequest(&StorageManagerCompleteFn);
app.DebugPrintf("Shutdown manager: waiting on storage manager to terminate...\n");
WaitForSignalledToComplete();
app.DebugPrintf("Shutdown manager: terminated.\n");
// Audio system shutdown
app.DebugPrintf("Shutdown manager: Audio shutdown.\n");
AIL_shutdown();
// Trophy system shutdown
app.DebugPrintf("Shutdown manager: Trophy system shutdown.\n");
ProfileManager.Terminate();
// Network manager shutdown
app.DebugPrintf("Shutdown manager: Network manager shutdown.\n");
g_NetworkManager.Terminate();
// Finally shut down the spurs job queue - leaving until last so there should be nothing else dependent on this still running
app.DebugPrintf("Shutdown manager: SPURS shutdown.\n");
C4JSpursJobQueue::getMainJobQueue().shutdown();
app.DebugPrintf("Shutdown manager: Complete.\n");
#endif
}
void ShutdownManager::HasStarted(ShutdownManager::EThreadId threadId)
{
#ifdef __PS3__
EnterCriticalSection(&s_threadRunningCS);
s_threadRunning[threadId]++;
LeaveCriticalSection(&s_threadRunningCS);
#endif
}
void ShutdownManager::HasStarted(ShutdownManager::EThreadId threadId, C4JThread::EventArray *eventArray)
{
#ifdef __PS3__
EnterCriticalSection(&s_threadRunningCS);
s_threadRunning[threadId]++;
LeaveCriticalSection(&s_threadRunningCS);
s_eventArray[threadId] = eventArray;
#endif
}
bool ShutdownManager::ShouldRun(ShutdownManager::EThreadId threadId)
{
#ifdef __PS3__
return s_threadShouldRun[threadId];
#else
return true;
#endif
}
void ShutdownManager::HasFinished(ShutdownManager::EThreadId threadId)
{
#ifdef __PS3__
EnterCriticalSection(&s_threadRunningCS);
s_threadRunning[threadId]--;
LeaveCriticalSection(&s_threadRunningCS);
#endif
}
#ifdef __PS3__
void ShutdownManager::SysUtilCallback(uint64_t status, uint64_t param, void *userdata)
{
Minecraft *minecraft = Minecraft::GetInstance();
switch(status)
{
case CELL_SYSUTIL_REQUEST_EXITGAME:
app.DebugPrintf("CELL_SYSUTIL_REQUEST_EXITGAME\n");
StartShutdown();
break;
case CELL_SYSUTIL_SYSTEM_MENU_OPEN:
// Tell the game UI to stop processing
StorageManager.SetSystemUIDisplaying(true);
break;
case CELL_SYSUTIL_DRAWING_END:
StorageManager.SetSystemUIDisplaying(false);
break;
case CELL_SYSUTIL_DRAWING_BEGIN:
case CELL_SYSUTIL_SYSTEM_MENU_CLOSE:
break;
case CELL_SYSUTIL_BGMPLAYBACK_PLAY:
if( minecraft )
{
minecraft->soundEngine->updateSystemMusicPlaying(true);
}
app.DebugPrintf("BGM playing\n");
break;
case CELL_SYSUTIL_BGMPLAYBACK_STOP:
if( minecraft )
{
minecraft->soundEngine->updateSystemMusicPlaying(false);
}
app.DebugPrintf("BGM stopped\n");
break;
}
}
#endif
#ifdef __PS3__
void ShutdownManager::WaitForSignalledToComplete()
{
bool allComplete;
do
{
cellSysutilCheckCallback();
Sleep(10);
allComplete = true;
for( int i = 0; i < eThreadIdCount; i++ )
{
if( !s_threadShouldRun[i] )
{
if( s_threadRunning[i] != 0 ) allComplete = false;
}
}
} while( !allComplete);
}
void ShutdownManager::RequestThreadToStop(int i)
{
s_threadShouldRun[i] = false;
if( s_eventArray[i] )
{
s_eventArray[i]->Cancel();
}
}
void ShutdownManager::StorageManagerCompleteFn()
{
HasFinished(eStorageManagerThreads);
}
#endif

View File

@ -0,0 +1,47 @@
#pragma once
class ShutdownManager
{
public:
typedef enum
{
eMainThread,
eLeaderboardThread,
eCommerceThread,
ePostProcessThread,
eRunUpdateThread,
eRenderChunkUpdateThread,
eServerThread,
eStorageManagerThreads,
eConnectionReadThreads,
eConnectionWriteThreads,
eEventQueueThreads,
eThreadIdCount
} EThreadId;
static void Initialise();
static void StartShutdown();
static void MainThreadHandleShutdown();
#ifdef __PS3__
static void SysUtilCallback(uint64_t status, uint64_t param, void *userdata);
#endif
static void HasStarted(EThreadId threadId);
static void HasStarted(EThreadId threadId, C4JThread::EventArray *eventArray);
static bool ShouldRun(EThreadId threadId);
static void HasFinished(EThreadId threadId);
private:
#ifdef __PS3__
static bool s_threadShouldRun[eThreadIdCount];
static int s_threadRunning[eThreadIdCount];
static ThreadLock s_threadRunningCS;
static C4JThread::EventArray *s_eventArray[eThreadIdCount];
static void RequestThreadToStop(int i);
static void WaitForSignalledToComplete();
static void StorageManagerCompleteFn();
#endif
};

View File

@ -0,0 +1,33 @@
#include "ThreadLock.h"
ThreadLock::ThreadLock()
{
#ifdef _XBOX
InitializeCriticalSection(&m_cs);
#endif
}
ThreadLock::~ThreadLock()
{
#ifdef _XBOX
DeleteCriticalSection(&m_cs);
#endif
}
void ThreadLock::lock()
{
#ifdef _XBOX
EnterCriticalSection(&m_cs);
#else
m_mutex.lock();
#endif
}
void ThreadLock::unlock()
{
#ifdef _XBOX
LeaveCriticalSection(&m_cs);
#else
m_mutex.unlock();
#endif
}

View File

@ -0,0 +1,24 @@
#pragma once
#ifdef _XBOX
#include <Windows.h>
#else
#include <mutex>
#endif
class ThreadLock
{
public:
ThreadLock();
~ThreadLock();
void lock();
void unlock();
private:
#ifdef _XBOX
CRITICAL_SECTION m_cs;
#else
std::mutex m_mutex;
#endif
};

View File

@ -47,7 +47,7 @@
#endif #endif
CRITICAL_SECTION UIController::ms_reloadSkinCS; ThreadLock UIController::ms_reloadSkinCS;
bool UIController::ms_bReloadSkinCSInitialised = false; bool UIController::ms_bReloadSkinCSInitialised = false;
unsigned long UIController::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; unsigned long UIController::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME;

View File

@ -18,7 +18,7 @@ public:
static int64_t iggyAllocCount; static int64_t iggyAllocCount;
// MGH - added to prevent crash loading Iggy movies while the skins were being reloaded // MGH - added to prevent crash loading Iggy movies while the skins were being reloaded
static CRITICAL_SECTION ms_reloadSkinCS; static ThreadLock ms_reloadSkinCS;
static bool ms_bReloadSkinCSInitialised; static bool ms_bReloadSkinCSInitialised;
protected: protected:
@ -26,7 +26,7 @@ protected:
UIComponent_DebugUIMarketingGuide *m_uiDebugMarketingGuide; UIComponent_DebugUIMarketingGuide *m_uiDebugMarketingGuide;
private: private:
CRITICAL_SECTION m_navigationLock; ThreadLock m_navigationLock;
static const int UI_REPEAT_KEY_DELAY_MS = 300; // How long from press until the first repeat static const int UI_REPEAT_KEY_DELAY_MS = 300; // How long from press until the first repeat
static const int UI_REPEAT_KEY_REPEAT_RATE_MS = 100; // How long in between repeats static const int UI_REPEAT_KEY_REPEAT_RATE_MS = 100; // How long in between repeats
@ -140,7 +140,7 @@ private:
D3D11_RECT m_customRenderingClearRect; D3D11_RECT m_customRenderingClearRect;
unordered_map<size_t, UIScene *> m_registeredCallbackScenes; // A collection of scenes and unique id's that are used in async callbacks so we can safely handle when they get destroyed unordered_map<size_t, UIScene *> m_registeredCallbackScenes; // A collection of scenes and unique id's that are used in async callbacks so we can safely handle when they get destroyed
CRITICAL_SECTION m_registeredCallbackScenesCS;; ThreadLock m_registeredCallbackScenesCS;;
public: public:
UIController(); UIController();
@ -180,7 +180,7 @@ protected:
public: public:
CRITICAL_SECTION m_Allocatorlock; ThreadLock m_Allocatorlock;
void SetupFont(); void SetupFont();
public: public:
// TICKING // TICKING

View File

@ -263,7 +263,7 @@ bool UIScene::mapElementsAndNames()
return true; return true;
} }
extern CRITICAL_SECTION s_loadSkinCS; extern ThreadLock s_loadSkinCS;
void UIScene::loadMovie() void UIScene::loadMovie()
{ {
EnterCriticalSection(&UIController::ms_reloadSkinCS); // MGH - added to prevent crash loading Iggy movies while the skins were being reloaded EnterCriticalSection(&UIController::ms_reloadSkinCS); // MGH - added to prevent crash loading Iggy movies while the skins were being reloaded

View File

@ -184,6 +184,6 @@ private:
#endif #endif
#ifdef __PSVITA__ #ifdef __PSVITA__
CRITICAL_SECTION m_DLCInstallCS; // to prevent a race condition between the install and the mounted callback ThreadLock m_DLCInstallCS; // to prevent a race condition between the install and the mounted callback
#endif #endif
}; };

View File

@ -67,7 +67,7 @@ protected:
int OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, bool& bHandled ); int OnNotifySelChanged( HXUIOBJ hObjSource, XUINotifySelChanged* pNotifySelChangedData, bool& bHandled );
LISTITEMINFOARRAY m_vListData; LISTITEMINFOARRAY m_vListData;
CRITICAL_SECTION m_AccessListData; ThreadLock m_AccessListData;
private: private:
static bool AlphabeticSortFn(const void *a, const void *b); static bool AlphabeticSortFn(const void *a, const void *b);

View File

@ -111,7 +111,7 @@ public:
void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo); void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo);
void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs); void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs);
void SetDebugSequence( const char *chSequenceA,int( *Func)(void*),void* lpParam ); void SetDebugSequence( const char *chSequenceA,int( *Func)(void*),void* lpParam );
FLOAT GetIdleSeconds(int iPad); float GetIdleSeconds(int iPad);
unsigned int GetConnectedGamepadCount(); unsigned int GetConnectedGamepadCount();
bool IsPadConnected(int iPad); bool IsPadConnected(int iPad);
bool IsPadLocked(int iPad); bool IsPadLocked(int iPad);

View File

@ -31,7 +31,7 @@ unordered_map<uintptr_t, size_t> tracker;
static volatile bool memDump = false; static volatile bool memDump = false;
static volatile bool memReset = false; static volatile bool memReset = false;
static bool memDumpInit = false; static bool memDumpInit = false;
static CRITICAL_SECTION memTrackCS; static ThreadLock memTrackCS;
static volatile size_t memSizeComp = 0; static volatile size_t memSizeComp = 0;
static long long lastTrackTime = 0; static long long lastTrackTime = 0;
@ -275,7 +275,7 @@ void ApplicationView::OnSuspending(Platform::Object^ sender, SuspendingEventArgs
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); fElapsedTime = fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
app.DebugPrintf("Entire suspend process: Elapsed time %f\n", fElapsedTime); app.DebugPrintf("Entire suspend process: Elapsed time %f\n", fElapsedTime);
} }

View File

@ -990,7 +990,7 @@ bool trackStarted = false;
volatile size_t sizeCheckMin = 1160; volatile size_t sizeCheckMin = 1160;
volatile size_t sizeCheckMax = 1160; volatile size_t sizeCheckMax = 1160;
volatile int sectCheck = 48; volatile int sectCheck = 48;
CRITICAL_SECTION memCS; ThreadLock memCS;
unsigned long tlsIdx; unsigned long tlsIdx;
void* XMemAlloc(size_t dwSize, unsigned long dwAllocAttributes) void* XMemAlloc(size_t dwSize, unsigned long dwAllocAttributes)

View File

@ -28,7 +28,7 @@ protected:
private: private:
unsigned short m_openSessions; unsigned short m_openSessions;
CRITICAL_SECTION m_csStatsState; ThreadLock m_csStatsState;
EStatsState m_eStatsState; //State of the stats read EStatsState m_eStatsState; //State of the stats read
ReadScore *m_scores; ReadScore *m_scores;

View File

@ -86,7 +86,7 @@ private:
wstring m_score; wstring m_score;
} StatResult; } StatResult;
CRITICAL_SECTION m_retrievedStatsLock; ThreadLock m_retrievedStatsLock;
vector<StatResult> m_retrievedStats; vector<StatResult> m_retrievedStats;

View File

@ -52,7 +52,7 @@ public:
void EvaluateDevicesForUser(__in Windows::Xbox::System::IUser^ user ); void EvaluateDevicesForUser(__in Windows::Xbox::System::IUser^ user );
vector<AddedUser *> m_addedUsers; vector<AddedUser *> m_addedUsers;
CRITICAL_SECTION m_csAddedUsers; ThreadLock m_csAddedUsers;
private: private:
/// <summary> /// <summary>

View File

@ -327,13 +327,13 @@ protected:
}; };
std::queue<StateChangeInfo> m_stateChangeQueue; std::queue<StateChangeInfo> m_stateChangeQueue;
CRITICAL_SECTION m_csStateChangeQueue; ThreadLock m_csStateChangeQueue;
CRITICAL_SECTION m_csSendBytes; ThreadLock m_csSendBytes;
CRITICAL_SECTION m_csPartyViewVector; ThreadLock m_csPartyViewVector;
std::queue<RTS_Message> m_RTSMessageQueueIncoming; std::queue<RTS_Message> m_RTSMessageQueueIncoming;
CRITICAL_SECTION m_csRTSMessageQueueIncoming; ThreadLock m_csRTSMessageQueueIncoming;
std::queue<RTS_Message> m_RTSMessageQueueOutgoing; std::queue<RTS_Message> m_RTSMessageQueueOutgoing;
CRITICAL_SECTION m_csRTSMessageQueueOutgoing; ThreadLock m_csRTSMessageQueueOutgoing;
private: private:
void SetState(DQRNetworkManager::eDQRNetworkManagerInternalState state); void SetState(DQRNetworkManager::eDQRNetworkManagerInternalState state);
static const eDQRNetworkManagerState m_INTtoEXTStateMappings[DNM_INT_STATE_COUNT]; static const eDQRNetworkManagerState m_INTtoEXTStateMappings[DNM_INT_STATE_COUNT];
@ -359,7 +359,7 @@ private:
MXS::XboxLiveContext^ m_primaryUserXboxLiveContext; MXS::XboxLiveContext^ m_primaryUserXboxLiveContext;
WXN::SecureDeviceAssociationTemplate^ m_associationTemplate; WXN::SecureDeviceAssociationTemplate^ m_associationTemplate;
CRITICAL_SECTION m_csRoomSyncData; ThreadLock m_csRoomSyncData;
RoomSyncData m_roomSyncData; RoomSyncData m_roomSyncData;
DQRNetworkPlayer *m_players[MAX_ONLINE_PLAYER_COUNT]; DQRNetworkPlayer *m_players[MAX_ONLINE_PLAYER_COUNT];
@ -403,7 +403,7 @@ private:
DQRConnectionInfo m_connectionInfoClient; // For client DQRConnectionInfo m_connectionInfoClient; // For client
unsigned int m_hostSessionAddress; // For client unsigned int m_hostSessionAddress; // For client
CRITICAL_SECTION m_csHostGamertagResolveResults; ThreadLock m_csHostGamertagResolveResults;
queue<HostGamertagResolveDetails *> m_hostGamertagResolveResults; queue<HostGamertagResolveDetails *> m_hostGamertagResolveResults;
void AddPlayerFailed(Platform::String ^xuid); void AddPlayerFailed(Platform::String ^xuid);
@ -460,7 +460,7 @@ private:
static int _RTSDoWorkThread(void* lpParameter); static int _RTSDoWorkThread(void* lpParameter);
int RTSDoWorkThread(); int RTSDoWorkThread();
CRITICAL_SECTION m_csVecChatPlayers; ThreadLock m_csVecChatPlayers;
vector<int> m_vecChatPlayersJoined; vector<int> m_vecChatPlayersJoined;
public: public:
void HandleNewPartyFoundForPlayer(); void HandleNewPartyFoundForPlayer();

View File

@ -44,7 +44,7 @@
#include "HumanoidModel.h" #include "HumanoidModel.h"
#include "Item.h" #include "Item.h"
#include "compression.h" #include "compression.h"
#include "PS3\PS3Extras\ShutdownManager.h" #include "Common/Shutdown/ShutdownManager.h"
#include "TexturePackRepository.h" #include "TexturePackRepository.h"
#include "TexturePack.h" #include "TexturePack.h"
@ -62,7 +62,7 @@ vector<SparseLightStorage *> GameRenderer::m_deleteStackSparseLightStorage;
vector<CompressedTileStorage *> GameRenderer::m_deleteStackCompressedTileStorage; vector<CompressedTileStorage *> GameRenderer::m_deleteStackCompressedTileStorage;
vector<SparseDataStorage *> GameRenderer::m_deleteStackSparseDataStorage; vector<SparseDataStorage *> GameRenderer::m_deleteStackSparseDataStorage;
#endif #endif
CRITICAL_SECTION GameRenderer::m_csDeleteStack; ThreadLock GameRenderer::m_csDeleteStack;
GameRenderer::GameRenderer(Minecraft *mc) GameRenderer::GameRenderer(Minecraft *mc)
{ {

View File

@ -160,7 +160,7 @@ public:
static vector<SparseLightStorage *> m_deleteStackSparseLightStorage; static vector<SparseLightStorage *> m_deleteStackSparseLightStorage;
static vector<CompressedTileStorage *> m_deleteStackCompressedTileStorage; static vector<CompressedTileStorage *> m_deleteStackCompressedTileStorage;
static vector<SparseDataStorage *> m_deleteStackSparseDataStorage; static vector<SparseDataStorage *> m_deleteStackSparseDataStorage;
static CRITICAL_SECTION m_csDeleteStack; static ThreadLock m_csDeleteStack;
static void AddForDelete(byte *deleteThis); static void AddForDelete(byte *deleteThis);
static void AddForDelete(SparseLightStorage *deleteThis); static void AddForDelete(SparseLightStorage *deleteThis);
static void AddForDelete(CompressedTileStorage *deleteThis); static void AddForDelete(CompressedTileStorage *deleteThis);

View File

@ -126,7 +126,7 @@ private:
// 4J - this block of declarations was scattered round the code but have gathered everything into one place // 4J - this block of declarations was scattered round the code but have gathered everything into one place
rteMap renderableTileEntities; // 4J - changed - was vector<shared_ptr<TileEntity>, now hashed by chunk so we can find them rteMap renderableTileEntities; // 4J - changed - was vector<shared_ptr<TileEntity>, now hashed by chunk so we can find them
CRITICAL_SECTION m_csRenderableTileEntities; ThreadLock m_csRenderableTileEntities;
MultiPlayerLevel *level[4]; // 4J - now one per player MultiPlayerLevel *level[4]; // 4J - now one per player
Textures *textures; Textures *textures;
// vector<Chunk *> *sortedChunks[4]; // 4J - removed - not sorting our chunks anymore // vector<Chunk *> *sortedChunks[4]; // 4J - removed - not sorting our chunks anymore
@ -164,7 +164,7 @@ private:
public: public:
void fullyFlagRenderableTileEntitiesToBeRemoved(); // 4J added void fullyFlagRenderableTileEntitiesToBeRemoved(); // 4J added
CRITICAL_SECTION m_csDirtyChunks; ThreadLock m_csDirtyChunks;
bool m_nearDirtyChunk; bool m_nearDirtyChunk;
@ -186,7 +186,7 @@ public:
RecentTile(int x, int y, int z, Level *level); RecentTile(int x, int y, int z, Level *level);
~RecentTile(); ~RecentTile();
}; };
CRITICAL_SECTION m_csDestroyedTiles; ThreadLock m_csDestroyedTiles;
vector<RecentTile *> m_destroyedTiles; vector<RecentTile *> m_destroyedTiles;
public: public:
void destroyingTileAt( Level *level, int x, int y, int z ); // For game to let this manager know that a tile is about to be destroyed (must be called before it actually is) void destroyingTileAt( Level *level, int x, int y, int z ); // For game to let this manager know that a tile is about to be destroyed (must be called before it actually is)
@ -271,7 +271,7 @@ public:
static void staticCtor(); static void staticCtor();
static int rebuildChunkThreadProc(void* lpParam); static int rebuildChunkThreadProc(void* lpParam);
CRITICAL_SECTION m_csChunkFlags; ThreadLock m_csChunkFlags;
#endif #endif
void nonStackDirtyChunksAdded(); void nonStackDirtyChunksAdded();
}; };

View File

@ -310,7 +310,7 @@ public:
// 4J Stu // 4J Stu
void forceStatsSave(int idx); void forceStatsSave(int idx);
CRITICAL_SECTION m_setLevelCS; ThreadLock m_setLevelCS;
private: private:
// A bit field that store whether a particular quadrant is in the full tutorial or not // A bit field that store whether a particular quadrant is in the full tutorial or not
uint8_t m_inFullTutorialBits; uint8_t m_inFullTutorialBits;

View File

@ -43,7 +43,7 @@
#ifdef _XBOX #ifdef _XBOX
#include "Common/XUI\XUI_DebugSetCamera.h" #include "Common/XUI\XUI_DebugSetCamera.h"
#endif #endif
#include "PS3\PS3Extras\ShutdownManager.h" #include "Common/Shutdown/ShutdownManager.h"
#include "ServerCommandDispatcher.h" #include "ServerCommandDispatcher.h"
#include "BiomeSource.h" #include "BiomeSource.h"
#include "PlayerChunkMap.h" #include "PlayerChunkMap.h"
@ -842,7 +842,7 @@ void MinecraftServer::Suspend()
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); fElapsedTime = fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
// 4J-JEV: Flush stats and call PlayerSessionExit. // 4J-JEV: Flush stats and call PlayerSessionExit.
for (int iPad = 0; iPad < XUSER_MAX_COUNT; iPad++) for (int iPad = 0; iPad < XUSER_MAX_COUNT; iPad++)
@ -1233,7 +1233,7 @@ void MinecraftServer::run(int64_t seed, void *lpParameter)
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); fElapsedTime = fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
app.DebugPrintf("Autosave: Elapsed time %f\n", fElapsedTime); app.DebugPrintf("Autosave: Elapsed time %f\n", fElapsedTime);
} }
break; break;

View File

@ -205,7 +205,7 @@ private:
postProcessRequest(int x, int z, ChunkSource *chunkSource) : x(x), z(z), chunkSource(chunkSource) {} postProcessRequest(int x, int z, ChunkSource *chunkSource) : x(x), z(z), chunkSource(chunkSource) {}
}; };
vector<postProcessRequest> m_postProcessRequests; vector<postProcessRequest> m_postProcessRequests;
CRITICAL_SECTION m_postProcessCS; ThreadLock m_postProcessCS;
public: public:
void addPostProcessRequest(ChunkSource *chunkSource, int x, int z); void addPostProcessRequest(ChunkSource *chunkSource, int x, int z);

View File

@ -18,7 +18,7 @@ private:
LevelChunk **cache; LevelChunk **cache;
// 4J - added for multithreaded support // 4J - added for multithreaded support
CRITICAL_SECTION m_csLoadCreate; ThreadLock m_csLoadCreate;
// 4J - size of cache is defined by size of one side - must be even // 4J - size of cache is defined by size of one side - must be even
int XZSIZE; int XZSIZE;
int XZOFFSET; int XZOFFSET;

View File

@ -16,7 +16,7 @@ class PlayerConnection : public PacketListener, public ConsoleInputSource
public: public:
Connection *connection; Connection *connection;
bool done; bool done;
CRITICAL_SECTION done_cs; ThreadLock done_cs;
// 4J Stu - Added this so that we can manage UGC privileges // 4J Stu - Added this so that we can manage UGC privileges
PlayerUID m_offlineXUID, m_onlineXUID; PlayerUID m_offlineXUID, m_onlineXUID;

View File

@ -31,9 +31,9 @@ private:
// 4J Added // 4J Added
vector<PlayerUID> m_bannedXuids; vector<PlayerUID> m_bannedXuids;
deque<uint8_t> m_smallIdsToKick; deque<uint8_t> m_smallIdsToKick;
CRITICAL_SECTION m_kickPlayersCS; ThreadLock m_kickPlayersCS;
deque<uint8_t> m_smallIdsToClose; deque<uint8_t> m_smallIdsToClose;
CRITICAL_SECTION m_closePlayersCS; ThreadLock m_closePlayersCS;
/* 4J - removed /* 4J - removed
Set<String> bans = new HashSet<String>(); Set<String> bans = new HashSet<String>();
Set<String> ipBans = new HashSet<String>(); Set<String> ipBans = new HashSet<String>();

View File

@ -4,7 +4,7 @@
#include "ProgressRenderer.h" #include "ProgressRenderer.h"
#include "System.h" #include "System.h"
CRITICAL_SECTION ProgressRenderer::s_progress; ThreadLock ProgressRenderer::s_progress;
ProgressRenderer::ProgressRenderer(Minecraft *minecraft) ProgressRenderer::ProgressRenderer(Minecraft *minecraft)
{ {

View File

@ -10,7 +10,7 @@ public:
eProgressStringType_String, // 4J-PB added for updating the bytes read on a save transfer eProgressStringType_String, // 4J-PB added for updating the bytes read on a save transfer
}; };
static CRITICAL_SECTION s_progress; static ThreadLock s_progress;
int getCurrentPercent(); int getCurrentPercent();
int getCurrentTitle(); int getCurrentTitle();

View File

@ -165,7 +165,7 @@ void C_4JInput::SetDebugSequence(const char* chSequenceA, int(*Func)(void*), voi
{ {
} }
FLOAT C_4JInput::GetIdleSeconds(int iPad) float C_4JInput::GetIdleSeconds(int iPad)
{ {
return 0.0f; return 0.0f;
} }

View File

@ -45,16 +45,25 @@
#define TRIGGER_MAP_0 0 #define TRIGGER_MAP_0 0
#define TRIGGER_MAP_1 1 #define TRIGGER_MAP_1 1
enum EKeyboardResult
{
EKeyboard_Pending,
EKeyboard_Cancelled,
EKeyboard_ResultAccept,
EKeyboard_ResultDecline,
};
typedef struct _STRING_VERIFY_RESPONSE
{
uint16_t wNumStrings;
int *pStringResult;
}
STRING_VERIFY_RESPONSE;
class C_4JInput class C_4JInput
{ {
public: public:
enum EKeyboardResult
{
EKeyboard_Pending,
EKeyboard_Cancelled,
EKeyboard_ResultAccept,
EKeyboard_ResultDecline,
};
enum EKeyboardMode enum EKeyboardMode
{ {
@ -98,8 +107,10 @@ public:
void SetMenuDisplayed(int iPad, bool bVal); void SetMenuDisplayed(int iPad, bool bVal);
EKeyboardResult RequestKeyboard(unsigned int uiTitle, unsigned int uiText, unsigned int uiDesc, unsigned long dwPad, wchar_t *pwchResult, unsigned int uiResultSize,int( *Func)(void*,const bool),void* lpParam,EKeyboardMode eMode,CXuiStringTable *pStringTable=NULL); // EKeyboardResult RequestKeyboard(unsigned int uiTitle, unsigned int uiText, unsigned int uiDesc, unsigned long dwPad, wchar_t *pwchResult, unsigned int uiResultSize,int( *Func)(void*,const bool),void* lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
EKeyboardResult RequestKeyboard(unsigned int uiTitle, const wchar_t* pwchDefault, unsigned int uiDesc, unsigned long dwPad, wchar_t *pwchResult, unsigned int uiResultSize,int( *Func)(void*,const bool),void* lpParam, EKeyboardMode eMode,CXuiStringTable *pStringTable=NULL); // EKeyboardResult RequestKeyboard(unsigned int uiTitle, const wchar_t* pwchDefault, unsigned int uiDesc, unsigned long dwPad, wchar_t *pwchResult, unsigned int uiResultSize,int( *Func)(void*,const bool),void* lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
EKeyboardResult RequestKeyboard(const wchar_t* Title, const wchar_t* Text, unsigned long dwPad, unsigned int uiMaxChars, int( *Func)(void*,const bool),void* lpParam,C_4JInput::EKeyboardMode eMode);
void GetText(uint16_t *UTF16String);
// Online check strings against offensive list - TCR 92 // Online check strings against offensive list - TCR 92
// TCR # 092 CMTV Player Text String Verification // TCR # 092 CMTV Player Text String Verification
@ -115,11 +126,10 @@ public:
// Exemption It is not required to use the Xbox LIVE service to verify real-time text communication. An example of real-time text communication is in-game text chat. // Exemption It is not required to use the Xbox LIVE service to verify real-time text communication. An example of real-time text communication is in-game text chat.
// //
// Intent Protect players from inappropriate language. // Intent Protect players from inappropriate language.
/* bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void*,STRING_VERIFY_RESPONSE *),void* lpParam);
bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void*,STRING_VERIFY_RESPONSE *),void* lpParam);
void CancelQueuedVerifyStrings(int( *Func)(void*,STRING_VERIFY_RESPONSE *),void* lpParam); void CancelQueuedVerifyStrings(int( *Func)(void*,STRING_VERIFY_RESPONSE *),void* lpParam);
void CancelAllVerifyInProgress(void); void CancelAllVerifyInProgress(void);
*/
//bool InputDetected(unsigned long dwUserIndex,wchar_t *pwchInput); //bool InputDetected(unsigned long dwUserIndex,wchar_t *pwchInput);
}; };

View File

@ -30,7 +30,7 @@ private:
#endif #endif
// 4J - added for multithreaded support // 4J - added for multithreaded support
CRITICAL_SECTION m_csLoadCreate; ThreadLock m_csLoadCreate;
// 4J - size of cache is defined by size of one side - must be even // 4J - size of cache is defined by size of one side - must be even
int XZSIZE; int XZSIZE;
int XZOFFSET; int XZOFFSET;

View File

@ -19,7 +19,7 @@ public:
private: private:
int connectionCounter; int connectionCounter;
private: private:
CRITICAL_SECTION pending_cs; // 4J added ThreadLock pending_cs; // 4J added
vector< shared_ptr<PendingConnection> > pending; vector< shared_ptr<PendingConnection> > pending;
vector< shared_ptr<PlayerConnection> > players; vector< shared_ptr<PlayerConnection> > players;

View File

@ -32,14 +32,14 @@
#include "TexturePackRepository.h" #include "TexturePackRepository.h"
#include "DLCTexturePack.h" #include "DLCTexturePack.h"
#include "ProgressListener.h" #include "ProgressListener.h"
#include "PS3\PS3Extras\ShutdownManager.h" #include "Common/Shutdown/ShutdownManager.h"
#include "PlayerChunkMap.h" #include "PlayerChunkMap.h"
WeighedTreasureArray ServerLevel::RANDOM_BONUS_ITEMS; WeighedTreasureArray ServerLevel::RANDOM_BONUS_ITEMS;
C4JThread* ServerLevel::m_updateThread = NULL; C4JThread* ServerLevel::m_updateThread = NULL;
C4JThread::EventArray* ServerLevel::m_updateTrigger; C4JThread::EventArray* ServerLevel::m_updateTrigger;
CRITICAL_SECTION ServerLevel::m_updateCS[3]; ThreadLock ServerLevel::m_updateCS[3];
Level *ServerLevel::m_level[3]; Level *ServerLevel::m_level[3];
int ServerLevel::m_updateChunkX[3][LEVEL_CHUNKS_TO_UPDATE_MAX]; int ServerLevel::m_updateChunkX[3][LEVEL_CHUNKS_TO_UPDATE_MAX];

View File

@ -17,12 +17,12 @@ private:
EntityTracker *tracker; EntityTracker *tracker;
PlayerChunkMap *chunkMap; PlayerChunkMap *chunkMap;
CRITICAL_SECTION m_tickNextTickCS; // 4J added ThreadLock m_tickNextTickCS; // 4J added
set<TickNextTickData, TickNextTickDataKeyCompare> tickNextTickList; // 4J Was TreeSet set<TickNextTickData, TickNextTickDataKeyCompare> tickNextTickList; // 4J Was TreeSet
unordered_set<TickNextTickData, TickNextTickDataKeyHash, TickNextTickDataKeyEq> tickNextTickSet; // 4J Was HashSet unordered_set<TickNextTickData, TickNextTickDataKeyHash, TickNextTickDataKeyEq> tickNextTickSet; // 4J Was HashSet
vector<Pos *> m_queuedSendTileUpdates; // 4J added vector<Pos *> m_queuedSendTileUpdates; // 4J added
CRITICAL_SECTION m_csQueueSendTileUpdates; ThreadLock m_csQueueSendTileUpdates;
protected: protected:
int saveInterval; int saveInterval;
@ -133,7 +133,7 @@ public:
int m_primedTntCount; int m_primedTntCount;
int m_fallingTileCount; int m_fallingTileCount;
CRITICAL_SECTION m_limiterCS; ThreadLock m_limiterCS;
list< shared_ptr<Entity> > m_itemEntities; list< shared_ptr<Entity> > m_itemEntities;
list< shared_ptr<Entity> > m_hangingEntities; list< shared_ptr<Entity> > m_hangingEntities;
list< shared_ptr<Entity> > m_arrowEntities; list< shared_ptr<Entity> > m_arrowEntities;
@ -163,7 +163,7 @@ public:
static int m_randValue[3]; static int m_randValue[3];
static C4JThread::EventArray* m_updateTrigger; static C4JThread::EventArray* m_updateTrigger;
static CRITICAL_SECTION m_updateCS[3]; static ThreadLock m_updateCS[3];
static C4JThread* m_updateThread; static C4JThread* m_updateThread;
static int runUpdate(void* lpParam); static int runUpdate(void* lpParam);

View File

@ -94,7 +94,7 @@ public:
void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo); void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo);
void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs); void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs);
void SetDebugSequence( const char *chSequenceA,int( *Func)(void*),void* lpParam ); void SetDebugSequence( const char *chSequenceA,int( *Func)(void*),void* lpParam );
FLOAT GetIdleSeconds(int iPad); float GetIdleSeconds(int iPad);
bool IsPadConnected(int iPad); bool IsPadConnected(int iPad);
// In-Game values which may have been remapped due to Southpaw, swap triggers, etc // In-Game values which may have been remapped due to Southpaw, swap triggers, etc

View File

@ -559,8 +559,8 @@ app.DebugPrintf("width: %d, height: %d\n", width, height);
// Setup the viewport // Setup the viewport
D3D11_VIEWPORT vp; D3D11_VIEWPORT vp;
vp.Width = (FLOAT)width; vp.Width = (float)width;
vp.Height = (FLOAT)height; vp.Height = (float)height;
vp.MinDepth = 0.0f; vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f; vp.MaxDepth = 1.0f;
vp.TopLeftX = 0; vp.TopLeftX = 0;
@ -1174,7 +1174,7 @@ bool trackStarted = false;
volatile size_t sizeCheckMin = 1160; volatile size_t sizeCheckMin = 1160;
volatile size_t sizeCheckMax = 1160; volatile size_t sizeCheckMax = 1160;
volatile int sectCheck = 48; volatile int sectCheck = 48;
CRITICAL_SECTION memCS; ThreadLock memCS;
unsigned long tlsIdx; unsigned long tlsIdx;
void* XMemAlloc(size_t dwSize, unsigned long dwAllocAttributes) void* XMemAlloc(size_t dwSize, unsigned long dwAllocAttributes)

View File

@ -85,7 +85,7 @@ public:
void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo); void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo);
void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs); void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs);
void SetDebugSequence( const char *chSequenceA,int( *Func)(void*),void* lpParam ); void SetDebugSequence( const char *chSequenceA,int( *Func)(void*),void* lpParam );
FLOAT GetIdleSeconds(int iPad); float GetIdleSeconds(int iPad);
bool IsPadConnected(int iPad); bool IsPadConnected(int iPad);
// In-Game values which may have been remapped due to Southpaw, swap triggers, etc // In-Game values which may have been remapped due to Southpaw, swap triggers, etc

View File

@ -22,7 +22,7 @@ IXACT3WaveBank *SoundEngine::m_pStreamedWaveBank = NULL;
IXACT3WaveBank *SoundEngine::m_pStreamedWaveBankAdditional = NULL; IXACT3WaveBank *SoundEngine::m_pStreamedWaveBankAdditional = NULL;
IXACT3SoundBank *SoundEngine::m_pSoundBank = NULL; IXACT3SoundBank *SoundEngine::m_pSoundBank = NULL;
IXACT3SoundBank *SoundEngine::m_pSoundBank2 = NULL; IXACT3SoundBank *SoundEngine::m_pSoundBank2 = NULL;
CRITICAL_SECTION SoundEngine::m_CS; ThreadLock SoundEngine::m_CS;
X3DAUDIO_HANDLE SoundEngine::m_xact3dInstance; X3DAUDIO_HANDLE SoundEngine::m_xact3dInstance;
vector<SoundEngine::soundInfo *> SoundEngine::currentSounds; vector<SoundEngine::soundInfo *> SoundEngine::currentSounds;

View File

@ -38,7 +38,7 @@ class SoundEngine : public ConsoleSoundEngine
static IXACT3SoundBank *m_pSoundBank; static IXACT3SoundBank *m_pSoundBank;
static IXACT3SoundBank *m_pSoundBank2; static IXACT3SoundBank *m_pSoundBank2;
static CRITICAL_SECTION m_CS; static ThreadLock m_CS;
struct soundInfo struct soundInfo
{ {

View File

@ -50,21 +50,21 @@ XUI_Font::~XUI_Font()
// Desc: Get the dimensions of a text string // Desc: Get the dimensions of a text string
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
void XUI_Font::GetTextExtent( const wchar_t* strText, FLOAT* pWidth, void XUI_Font::GetTextExtent( const wchar_t* strText, float* pWidth,
FLOAT* pHeight, bool bFirstLineOnly ) const float* pHeight, bool bFirstLineOnly ) const
{ {
assert( pWidth != NULL ); assert( pWidth != NULL );
assert( pHeight != NULL ); assert( pHeight != NULL );
// Set default text extent in output parameters // Set default text extent in output parameters
int iWidth = 0; int iWidth = 0;
FLOAT fHeight = 0.0f; float fHeight = 0.0f;
if( strText ) if( strText )
{ {
// Initialize counters that keep track of text extent // Initialize counters that keep track of text extent
int ix = 0; int ix = 0;
FLOAT fy = m_fontData->getFontHeight(); // One character high to start float fy = m_fontData->getFontHeight(); // One character high to start
if( fy > fHeight ) if( fy > fHeight )
fHeight = fy; fHeight = fy;
@ -104,7 +104,7 @@ void XUI_Font::GetTextExtent( const wchar_t* strText, FLOAT* pWidth,
} }
// Convert the width to a float here, load/hit/store. :( // Convert the width to a float here, load/hit/store. :(
FLOAT fWidth = static_cast<FLOAT>(iWidth); // Delay the use if fWidth to reduce LHS pain float fWidth = static_cast<float>(iWidth); // Delay the use if fWidth to reduce LHS pain
// Apply the scale factor to the result // Apply the scale factor to the result
fHeight *= m_fYScaleFactor; fHeight *= m_fYScaleFactor;
// Store the final results // Store the final results
@ -118,10 +118,10 @@ void XUI_Font::GetTextExtent( const wchar_t* strText, FLOAT* pWidth,
// Name: GetTextWidth() // Name: GetTextWidth()
// Desc: Returns the width in pixels of a text string // Desc: Returns the width in pixels of a text string
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
FLOAT XUI_Font::GetTextWidth( const wchar_t* strText ) const float XUI_Font::GetTextWidth( const wchar_t* strText ) const
{ {
FLOAT fTextWidth; float fTextWidth;
FLOAT fTextHeight; float fTextHeight;
GetTextExtent( strText, &fTextWidth, &fTextHeight ); GetTextExtent( strText, &fTextWidth, &fTextHeight );
return fTextWidth; return fTextWidth;
} }
@ -157,7 +157,7 @@ void XUI_Font::Begin()
} }
//// Read the TextureDesc here to ensure no load/hit/store from GetLevelDesc() //// Read the TextureDesc here to ensure no load/hit/store from GetLevelDesc()
//FLOAT vTexScale[4]; //float vTexScale[4];
//vTexScale[0] = 1.0f / TextureDesc.Width; // LHS due to int->float conversion //vTexScale[0] = 1.0f / TextureDesc.Width; // LHS due to int->float conversion
//vTexScale[1] = 1.0f / TextureDesc.Height; //vTexScale[1] = 1.0f / TextureDesc.Height;
//vTexScale[2] = 0.0f; //vTexScale[2] = 0.0f;
@ -191,7 +191,7 @@ void XUI_Font::Begin()
// Desc: Draws text as textured polygons // Desc: Draws text as textured polygons
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
void XUI_Font::DrawText( unsigned long dwColor, const wchar_t* strText, unsigned long dwFlags, void XUI_Font::DrawText( unsigned long dwColor, const wchar_t* strText, unsigned long dwFlags,
FLOAT fMaxPixelWidth ) float fMaxPixelWidth )
{ {
DrawText( m_fCursorX, m_fCursorY, dwColor, strText, dwFlags, fMaxPixelWidth ); DrawText( m_fCursorX, m_fCursorY, dwColor, strText, dwFlags, fMaxPixelWidth );
} }
@ -200,8 +200,8 @@ void XUI_Font::DrawText( unsigned long dwColor, const wchar_t* strText, unsigned
// Name: DrawShadowText() // Name: DrawShadowText()
// Desc: Draws text as textured polygons // Desc: Draws text as textured polygons
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
void XUI_Font::DrawShadowText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwColor, unsigned long dwShadowColor, void XUI_Font::DrawShadowText( float fOriginX, float fOriginY, unsigned long dwColor, unsigned long dwShadowColor,
const wchar_t* strText, unsigned long dwFlags, FLOAT fMaxPixelWidth) const wchar_t* strText, unsigned long dwFlags, float fMaxPixelWidth)
{ {
float fXShadow=1.0f, fYShadow=1.0f; float fXShadow=1.0f, fYShadow=1.0f;
// 4J Stu - Don't move the drop shadow as much // 4J Stu - Don't move the drop shadow as much
@ -233,8 +233,8 @@ void XUI_Font::DrawShadowText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwC
// TODO: This function should use the Begin/SetVertexData/End() API when it // TODO: This function should use the Begin/SetVertexData/End() API when it
// becomes available. // becomes available.
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
void XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwColor, void XUI_Font::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
const wchar_t* strText, unsigned long dwFlags, FLOAT fMaxPixelWidth, bool darken /*= false*/ ) const wchar_t* strText, unsigned long dwFlags, float fMaxPixelWidth, bool darken /*= false*/ )
{ {
if( NULL == strText ) return; if( NULL == strText ) return;
if( L'\0' == strText[0] ) return; if( L'\0' == strText[0] ) return;
@ -316,7 +316,7 @@ void XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwColor,
fOriginY -= m_fontData->getFontTopPadding(); fOriginY -= m_fontData->getFontTopPadding();
XUI_FontData::SChar sChar = m_fontData->getChar(L'.'); XUI_FontData::SChar sChar = m_fontData->getChar(L'.');
FLOAT fEllipsesPixelWidth = m_fXScaleFactor * 3.0f * (sChar.getOffset() + sChar.getWAdvance()); float fEllipsesPixelWidth = m_fXScaleFactor * 3.0f * (sChar.getOffset() + sChar.getWAdvance());
if( dwFlags & ATGFONT_TRUNCATED ) if( dwFlags & ATGFONT_TRUNCATED )
{ {
@ -327,7 +327,7 @@ void XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwColor,
} }
else else
{ {
FLOAT w, h; float w, h;
GetTextExtent( strText, &w, &h, true ); GetTextExtent( strText, &w, &h, true );
// If not, then clear the flag // If not, then clear the flag
@ -339,14 +339,14 @@ void XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwColor,
// If vertically centered, offset the starting m_fCursorY value // If vertically centered, offset the starting m_fCursorY value
if( dwFlags & ATGFONT_CENTER_Y ) if( dwFlags & ATGFONT_CENTER_Y )
{ {
FLOAT w, h; float w, h;
GetTextExtent( strText, &w, &h ); GetTextExtent( strText, &w, &h );
m_fCursorY = floorf( m_fCursorY - (h * 0.5f) ); m_fCursorY = floorf( m_fCursorY - (h * 0.5f) );
} }
// Add window offsets // Add window offsets
FLOAT Winx = static_cast<FLOAT>(m_rcWindow.x1); float Winx = static_cast<float>(m_rcWindow.x1);
FLOAT Winy = static_cast<FLOAT>(m_rcWindow.y1); float Winy = static_cast<float>(m_rcWindow.y1);
fOriginX += Winx; fOriginX += Winx;
fOriginY += Winy; fOriginY += Winy;
m_fCursorX += Winx; m_fCursorX += Winx;
@ -381,7 +381,7 @@ void XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwColor,
if( dwFlags & ( ATGFONT_RIGHT | ATGFONT_CENTER_X ) ) if( dwFlags & ( ATGFONT_RIGHT | ATGFONT_CENTER_X ) )
{ {
// Get the extent of this line // Get the extent of this line
FLOAT w, h; float w, h;
GetTextExtent( strText, &w, &h, true ); GetTextExtent( strText, &w, &h, true );
// Offset this line's starting m_fCursorX value // Offset this line's starting m_fCursorX value
@ -415,11 +415,11 @@ void XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwColor,
// Translate unprintable characters // Translate unprintable characters
XUI_FontData::SChar sChar = m_fontData->getChar( letter ); XUI_FontData::SChar sChar = m_fontData->getChar( letter );
FLOAT fOffset = m_fXScaleFactor * ( FLOAT )sChar.getOffset(); float fOffset = m_fXScaleFactor * ( float )sChar.getOffset();
FLOAT fAdvance = m_fXScaleFactor * ( FLOAT )sChar.getWAdvance(); float fAdvance = m_fXScaleFactor * ( float )sChar.getWAdvance();
// 4J Use the font max width otherwise scaling doesnt look right // 4J Use the font max width otherwise scaling doesnt look right
FLOAT fWidth = m_fXScaleFactor * (sChar.tu2() - sChar.tu1());//( FLOAT )pGlyph->wWidth; float fWidth = m_fXScaleFactor * (sChar.tu2() - sChar.tu1());//( float )pGlyph->wWidth;
FLOAT fHeight = m_fYScaleFactor * m_fontData->getFontHeight(); float fHeight = m_fYScaleFactor * m_fontData->getFontHeight();
if( 0 == dwNumEllipsesToDraw ) if( 0 == dwNumEllipsesToDraw )
{ {
@ -437,23 +437,23 @@ void XUI_Font::DrawText( FLOAT fOriginX, FLOAT fOriginY, unsigned long dwColor,
// Setup the screen coordinates // Setup the screen coordinates
m_fCursorX += fOffset; m_fCursorX += fOffset;
FLOAT X4 = m_fCursorX; float X4 = m_fCursorX;
FLOAT X1 = X4 + m_fSlantFactor; float X1 = X4 + m_fSlantFactor;
FLOAT X3 = X4 + fWidth; float X3 = X4 + fWidth;
FLOAT X2 = X1 + fWidth; float X2 = X1 + fWidth;
FLOAT Y1 = m_fCursorY; float Y1 = m_fCursorY;
FLOAT Y3 = Y1 + fHeight; float Y3 = Y1 + fHeight;
FLOAT Y2 = Y1; float Y2 = Y1;
FLOAT Y4 = Y3; float Y4 = Y3;
m_fCursorX += fAdvance; m_fCursorX += fAdvance;
// Add the vertices to draw this glyph // Add the vertices to draw this glyph
FLOAT tu1 = sChar.tu1() / (float)m_fontData->getImageWidth(); float tu1 = sChar.tu1() / (float)m_fontData->getImageWidth();
FLOAT tv1 = sChar.tv1() / (float)m_fontData->getImageHeight(); float tv1 = sChar.tv1() / (float)m_fontData->getImageHeight();
FLOAT tu2 = sChar.tu2() / (float)m_fontData->getImageWidth(); float tu2 = sChar.tu2() / (float)m_fontData->getImageWidth();
FLOAT tv2 = sChar.tv2() / (float)m_fontData->getImageHeight(); float tv2 = sChar.tv2() / (float)m_fontData->getImageHeight();
Tesselator *t = Tesselator::getInstance(); Tesselator *t = Tesselator::getInstance();
t->begin(); t->begin();

View File

@ -22,15 +22,15 @@ public:
const int m_iFontData; const int m_iFontData;
const float m_fScaleFactor; const float m_fScaleFactor;
FLOAT m_fXScaleFactor; // Scaling constants float m_fXScaleFactor; // Scaling constants
FLOAT m_fYScaleFactor; float m_fYScaleFactor;
FLOAT m_fSlantFactor; // For italics float m_fSlantFactor; // For italics
DOUBLE m_dRotCos; // Precalculated sine and cosine for italic like rotation DOUBLE m_dRotCos; // Precalculated sine and cosine for italic like rotation
DOUBLE m_dRotSin; DOUBLE m_dRotSin;
D3DRECT m_rcWindow; // Bounds rect if the text window, modify via accessors only! D3DRECT m_rcWindow; // Bounds rect if the text window, modify via accessors only!
FLOAT m_fCursorX; // Current text cursor float m_fCursorX; // Current text cursor
FLOAT m_fCursorY; float m_fCursorY;
bool m_bRotate; bool m_bRotate;
@ -41,14 +41,14 @@ public:
unsigned long refCount; unsigned long refCount;
public: public:
float getScaleFactor() { return m_fScaleFactor; } float getScaleFactor() { return m_fScaleFactor; }
void GetScaleFactors(FLOAT *pfXScaleFactor, FLOAT *pfYScaleFactor) { *pfXScaleFactor = m_fScaleFactor; *pfYScaleFactor = m_fScaleFactor; } void GetScaleFactors(float *pfXScaleFactor, float *pfYScaleFactor) { *pfXScaleFactor = m_fScaleFactor; *pfYScaleFactor = m_fScaleFactor; }
// Accessor functions // Accessor functions
inline void SetSlantFactor( FLOAT fSlantFactor ) inline void SetSlantFactor( float fSlantFactor )
{ {
m_fSlantFactor = fSlantFactor; m_fSlantFactor = fSlantFactor;
} }
inline void SetScaleFactors( FLOAT fXScaleFactor, FLOAT fYScaleFactor ) inline void SetScaleFactors( float fXScaleFactor, float fYScaleFactor )
{ {
// m_fXScaleFactor = m_fYScaleFactor = m_fScaleFactor; // m_fXScaleFactor = m_fYScaleFactor = m_fScaleFactor;
} }
@ -62,16 +62,16 @@ public:
~XUI_Font(); ~XUI_Font();
// Returns the dimensions of a text string // Returns the dimensions of a text string
void GetTextExtent( const wchar_t* strText, FLOAT* pWidth, void GetTextExtent( const wchar_t* strText, float* pWidth,
FLOAT* pHeight, bool bFirstLineOnly=false ) const; float* pHeight, bool bFirstLineOnly=false ) const;
FLOAT GetTextWidth( const wchar_t* strText ) const; float GetTextWidth( const wchar_t* strText ) const;
FLOAT GetCharAdvance( const wchar_t* strChar ) const; float GetCharAdvance( const wchar_t* strChar ) const;
void SetWindow(const D3DRECT &rcWindow ); void SetWindow(const D3DRECT &rcWindow );
void SetWindow( int32_t x1, int32_t y1, int32_t x2, int32_t y2 ); void SetWindow( int32_t x1, int32_t y1, int32_t x2, int32_t y2 );
void GetWindow(D3DRECT &rcWindow) const; void GetWindow(D3DRECT &rcWindow) const;
void SetCursorPosition( FLOAT fCursorX, FLOAT fCursorY ); void SetCursorPosition( float fCursorX, float fCursorY );
void SetRotationFactor( FLOAT fRotationFactor ); void SetRotationFactor( float fRotationFactor );
// Function to create a texture containing rendered text // Function to create a texture containing rendered text
D3DTexture* CreateTexture( const wchar_t* strText, D3DTexture* CreateTexture( const wchar_t* strText,
@ -84,10 +84,10 @@ public:
// Begin() and End(). // Begin() and End().
void Begin(); void Begin();
void DrawText( unsigned long dwColor, const wchar_t* strText, unsigned long dwFlags=0L, void DrawText( unsigned long dwColor, const wchar_t* strText, unsigned long dwFlags=0L,
FLOAT fMaxPixelWidth = 0.0f ); float fMaxPixelWidth = 0.0f );
void DrawText( FLOAT sx, FLOAT sy, unsigned long dwColor, const wchar_t* strText, void DrawText( float sx, float sy, unsigned long dwColor, const wchar_t* strText,
unsigned long dwFlags=0L, FLOAT fMaxPixelWidth = 0.0f, bool darken = false ); unsigned long dwFlags=0L, float fMaxPixelWidth = 0.0f, bool darken = false );
void DrawShadowText( FLOAT sx, FLOAT sy, unsigned long dwColor, unsigned long dwShadowColor, const wchar_t* strText, void DrawShadowText( float sx, float sy, unsigned long dwColor, unsigned long dwShadowColor, const wchar_t* strText,
unsigned long dwFlags=0L, FLOAT fMaxPixelWidth = 0.0f ); unsigned long dwFlags=0L, float fMaxPixelWidth = 0.0f );
void End(); void End();
}; };

View File

@ -365,13 +365,13 @@ void XUI_FontData::Destroy()
} }
/* /*
FLOAT XUI_FontData::GetCharAdvance( const wchar_t* strChar ) float XUI_FontData::GetCharAdvance( const wchar_t* strChar )
{ {
unsigned int uiChar = (unsigned int) *strChar; unsigned int uiChar = (unsigned int) *strChar;
return 0.0f;// m_fontData.getAdvance(m_fontData.getGlyphId(uiChar)); return 0.0f;// m_fontData.getAdvance(m_fontData.getGlyphId(uiChar));
} }
FLOAT XUI_FontData::GetCharWidth( const wchar_t* strChar ) float XUI_FontData::GetCharWidth( const wchar_t* strChar )
{ {
return 0.0f; return 0.0f;
} }

View File

@ -26,15 +26,15 @@ typedef struct GLYPH_ATTR
// Font description // Font description
#define ATGCALCFONTFILEHEADERSIZE(x) ( sizeof(unsigned long) + (sizeof(FLOAT)*4) + sizeof(uint16_t) + (sizeof(wchar_t)*(x)) ) #define ATGCALCFONTFILEHEADERSIZE(x) ( sizeof(unsigned long) + (sizeof(float)*4) + sizeof(uint16_t) + (sizeof(wchar_t)*(x)) )
#define ATGFONTFILEVERSION 5 #define ATGFONTFILEVERSION 5
typedef struct FontFileHeaderImage_t { typedef struct FontFileHeaderImage_t {
unsigned long m_dwFileVersion; // Version of the font file (Must match FONTFILEVERSION) unsigned long m_dwFileVersion; // Version of the font file (Must match FONTFILEVERSION)
FLOAT m_fFontHeight; // Height of the font strike in pixels float m_fFontHeight; // Height of the font strike in pixels
FLOAT m_fFontTopPadding; // Padding above the strike zone float m_fFontTopPadding; // Padding above the strike zone
FLOAT m_fFontBottomPadding; // Padding below the strike zone float m_fFontBottomPadding; // Padding below the strike zone
FLOAT m_fFontYAdvance; // Number of pixels to move the cursor for a line feed float m_fFontYAdvance; // Number of pixels to move the cursor for a line feed
uint16_t m_cMaxGlyph; // Number of font characters (Should be an odd number to maintain unsigned long Alignment) uint16_t m_cMaxGlyph; // Number of font characters (Should be an odd number to maintain unsigned long Alignment)
wchar_t m_TranslatorTable[1]; // ASCII to Glyph lookup table, NOTE: It's m_cMaxGlyph+1 in size. wchar_t m_TranslatorTable[1]; // ASCII to Glyph lookup table, NOTE: It's m_cMaxGlyph+1 in size.
// Entry 0 maps to the "Unknown" glyph. // Entry 0 maps to the "Unknown" glyph.
@ -140,8 +140,8 @@ public:
int Create( int iFontTexture, const void* pFontData ); int Create( int iFontTexture, const void* pFontData );
void Destroy(); void Destroy();
//FLOAT GetCharAdvance( const wchar_t* strChar ); //float GetCharAdvance( const wchar_t* strChar );
//FLOAT GetCharWidth( const wchar_t* strChar ); //float GetCharWidth( const wchar_t* strChar );
//void GetCharMetrics( const wchar_t* strChar, XUICharMetrics *xuiMetrics); //void GetCharMetrics( const wchar_t* strChar, XUICharMetrics *xuiMetrics);
//unsigned short getGlyphId(wchar_t character); //unsigned short getGlyphId(wchar_t character);
}; };

View File

@ -62,7 +62,7 @@ int XUI_FontRenderer::CreateFont( const TypefaceDescriptor * pTypefaceDescriptor
XUI_Font *font = NULL; XUI_Font *font = NULL;
XUI_FontData *fontData = NULL; XUI_FontData *fontData = NULL;
FLOAT scale = 1; float scale = 1;
eFontData efontdata; eFontData efontdata;
if( xuiSize%12==0 ) if( xuiSize%12==0 )

View File

@ -894,7 +894,7 @@ bool trackStarted = false;
volatile size_t sizeCheckMin = 1160; volatile size_t sizeCheckMin = 1160;
volatile size_t sizeCheckMax = 1160; volatile size_t sizeCheckMax = 1160;
volatile int sectCheck = 48; volatile int sectCheck = 48;
CRITICAL_SECTION memCS; ThreadLock memCS;
unsigned long tlsIdx; unsigned long tlsIdx;
void* XMemAlloc(size_t dwSize, unsigned long dwAllocAttributes) void* XMemAlloc(size_t dwSize, unsigned long dwAllocAttributes)

View File

@ -170,8 +170,9 @@ void ArmorItem::setColor(shared_ptr<ItemInstance> item, int color)
{ {
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
printf("Can't dye non-leather!"); printf("Can't dye non-leather!");
throw new UnsupportedOperationException("Can't dye non-leather!"); __debugbreak();
#endif #endif
//throw new UnsupportedOperationException("Can't dye non-leather!");
} }
CompoundTag *tag = item->getTag(); CompoundTag *tag = item->getTag();

View File

@ -48,5 +48,5 @@ public:
byteArray getBiomeIndexBlockAt(int x, int z); byteArray getBiomeIndexBlockAt(int x, int z);
private: private:
CRITICAL_SECTION m_CS; ThreadLock m_CS;
}; };

View File

@ -23,7 +23,8 @@ void BiomeDecorator::decorate(Level *level, Random *random, int xo, int zo)
{ {
app.DebugPrintf("BiomeDecorator::decorate - Already decorating!!\n"); app.DebugPrintf("BiomeDecorator::decorate - Already decorating!!\n");
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
throw new RuntimeException("Already decorating!!"); __debugbreak();
//throw new RuntimeException("Already decorating!!");
#endif #endif
} }
this->level = level; this->level = level;

View File

@ -3,53 +3,47 @@
#include "net.minecraft.world.level.newbiome.layer.h" #include "net.minecraft.world.level.newbiome.layer.h"
#include "net.minecraft.world.level.h" #include "net.minecraft.world.level.h"
#include "BiomeOverrideLayer.h" #include "BiomeOverrideLayer.h"
#include <fstream>
#include <vector>
#include <cstring>
BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup)
{ {
m_biomeOverride = byteArray( width * height ); m_biomeOverride = byteArray( width * height );
#ifdef _UNICODE std::string path;
wstring path = L"GAME:\\GameRules\\biomemap.bin";
void* file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
#ifdef _WINDOWS64
string path = "GameRules\\biomemap.bin";
#else
string path = "GAME:\\GameRules\\biomemap.bin";
#endif
void* file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif
if( file == INVALID_HANDLE_VALUE )
{
unsigned long error = GetLastError();
//assert(false);
app.DebugPrintf("Biome override not found, using plains as default\n");
memset(m_biomeOverride.data,Biome::plains->id,m_biomeOverride.length); #if defined(__ORBIS__) || defined(_DURANGO) || defined(_XBOX)
path = "GAME:/GameRules/biomemap.bin";
#else
path = "GameRules/biomemap.bin";
#endif
std::ifstream file(path, std::ios::binary);
if (!file.is_open())
{
app.DebugPrintf("Biome override not found, using plains as default\n");
std::memset(m_biomeOverride.data, Biome::plains->id, m_biomeOverride.length);
} }
else else
{ {
file.seekg(0, std::ios::end);
std::size_t fileSize = static_cast<std::size_t>(file.tellg());
file.seekg(0, std::ios::beg);
#ifdef _DURANGO if (fileSize > m_biomeOverride.length)
__debugbreak(); // TODO
unsigned long bytesRead,dwFileSize = 0;
#else
unsigned long bytesRead,dwFileSize = GetFileSize(file,NULL);
#endif
if(dwFileSize > m_biomeOverride.length)
{ {
app.DebugPrintf("Biomemap binary is too large!!\n"); app.DebugPrintf("Biomemap binary is too large!!\n");
__debugbreak(); __debugbreak();
} }
bool bSuccess = ReadFile(file,m_biomeOverride.data,dwFileSize,&bytesRead,NULL);
if(bSuccess==false) file.read(reinterpret_cast<char*>(m_biomeOverride.data), fileSize);
if (!file.good())
{ {
app.FatalLoadError(); app.FatalLoadError();
} }
CloseHandle(file);
} }
} }

View File

@ -2,6 +2,7 @@
#include "BoundingBox.h" #include "BoundingBox.h"
#include "Direction.h" #include "Direction.h"
#include "JavaMath.h" #include "JavaMath.h"
#include <climits>
BoundingBox::BoundingBox() BoundingBox::BoundingBox()
{ {

View File

@ -300,7 +300,7 @@ void ButtonTile::checkPressed(Level *level, int x, int y, int z)
bool shouldBePressed; bool shouldBePressed;
updateShape(data); updateShape(data);
Tile::ThreadStorage *tls = (Tile::ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
vector<shared_ptr<Entity> > *entities = level->getEntitiesOfClass(typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1)); vector<shared_ptr<Entity> > *entities = level->getEntitiesOfClass(typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1));
shouldBePressed = !entities->empty(); shouldBePressed = !entities->empty();
delete entities; delete entities;

View File

@ -1,7 +1,8 @@
#include "C4JThread.h" #include "C4JThread.h"
std::vector<C4JThread*> C4JThread::ms_threadList; std::vector<C4JThread*> C4JThread::ms_threadList;
std::mutex C4JThread::ms_threadListMutex; ThreadLock C4JThread::ms_threadListLock;
thread_local C4JThread* C4JThread::tls_currentThread = nullptr; thread_local C4JThread* C4JThread::tls_currentThread = nullptr;
C4JThread C4JThread::m_mainThread("MainThread"); C4JThread C4JThread::m_mainThread("MainThread");
@ -12,20 +13,22 @@ C4JThread::Event::Event(EMode mode)
void C4JThread::Event::Set() void C4JThread::Event::Set()
{ {
std::lock_guard<std::mutex> lock(m_mutex); m_lock.lock();
m_signaled = true; m_signaled = true;
m_cv.notify_all(); m_cv.notify_all();
m_lock.unlock();
} }
void C4JThread::Event::Clear() void C4JThread::Event::Clear()
{ {
std::lock_guard<std::mutex> lock(m_mutex); m_lock.lock();
m_signaled = false; m_signaled = false;
m_lock.unlock();
} }
unsigned long C4JThread::Event::WaitForSignal(int timeoutMs) unsigned long C4JThread::Event::WaitForSignal(int timeoutMs)
{ {
std::unique_lock<std::mutex> lock(m_mutex); m_lock.lock();
if (timeoutMs < 0) if (timeoutMs < 0)
{ {
@ -40,6 +43,7 @@ unsigned long C4JThread::Event::WaitForSignal(int timeoutMs)
if (m_mode == e_modeAutoClear) if (m_mode == e_modeAutoClear)
m_signaled = false; m_signaled = false;
m_lock.unlock();
return 0; return 0;
} }
@ -47,31 +51,40 @@ C4JThread::EventArray::EventArray(int size, Event::EMode mode)
{ {
m_events.reserve(size); m_events.reserve(size);
for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
m_events.emplace_back(mode); {
m_events.push_back(std::unique_ptr<Event>(new Event(mode)));
}
} }
void C4JThread::EventArray::Set(int i) { m_events[i].Set(); } void C4JThread::EventArray::Set(int i)
void C4JThread::EventArray::Clear(int i) { m_events[i].Clear(); } {
m_events[i]->Set();
}
void C4JThread::EventArray::Clear(int i)
{
m_events[i]->Clear();
}
void C4JThread::EventArray::SetAll() void C4JThread::EventArray::SetAll()
{ {
for (auto& e : m_events) e.Set(); for (auto& e : m_events) e->Set();
} }
void C4JThread::EventArray::ClearAll() void C4JThread::EventArray::ClearAll()
{ {
for (auto& e : m_events) e.Clear(); for (auto& e : m_events) e->Clear();
} }
unsigned long C4JThread::EventArray::WaitForSingle(int index, int timeoutMs) unsigned long C4JThread::EventArray::WaitForSingle(int index, int timeoutMs)
{ {
return m_events[index].WaitForSignal(timeoutMs); return m_events[index]->WaitForSignal(timeoutMs);
} }
unsigned long C4JThread::EventArray::WaitForAll(int timeoutMs) unsigned long C4JThread::EventArray::WaitForAll(int timeoutMs)
{ {
for (auto& e : m_events) for (auto& e : m_events)
e.WaitForSignal(timeoutMs); e->WaitForSignal(timeoutMs);
return 0; return 0;
} }
@ -81,7 +94,7 @@ unsigned long C4JThread::EventArray::WaitForAny(int timeoutMs)
{ {
for (auto& e : m_events) for (auto& e : m_events)
{ {
if (e.WaitForSignal(0) == 0) if (e->WaitForSignal(0) == 0)
return 0; return 0;
} }
std::this_thread::sleep_for(std::chrono::milliseconds(1)); std::this_thread::sleep_for(std::chrono::milliseconds(1));
@ -92,9 +105,9 @@ C4JThread::C4JThread(C4JThreadStartFunc* startFunc, void* param, const char* nam
: m_threadParam(param), m_startFunc(startFunc) : m_threadParam(param), m_startFunc(startFunc)
{ {
std::strncpy(m_threadName, name, sizeof(m_threadName)); std::strncpy(m_threadName, name, sizeof(m_threadName));
ms_threadListLock.lock();
std::lock_guard<std::mutex> lock(ms_threadListMutex);
ms_threadList.push_back(this); ms_threadList.push_back(this);
ms_threadListLock.unlock();
} }
C4JThread::C4JThread(const char* mainThreadName) C4JThread::C4JThread(const char* mainThreadName)

View File

@ -33,7 +33,7 @@ public:
private: private:
EMode m_mode; EMode m_mode;
std::mutex m_mutex; ThreadLock m_lock;
std::condition_variable m_cv; std::condition_variable m_cv;
bool m_signaled = false; bool m_signaled = false;
}; };
@ -53,7 +53,7 @@ public:
unsigned long WaitForSingle(int index, int timeoutMs); unsigned long WaitForSingle(int index, int timeoutMs);
private: private:
std::vector<Event> m_events; std::vector<std::unique_ptr<Event>> m_events;
}; };
class EventQueue class EventQueue
@ -72,7 +72,7 @@ public:
void threadPoll(); void threadPoll();
std::queue<void*> m_queue; std::queue<void*> m_queue;
std::mutex m_mutex; ThreadLock m_lock;
EventArray m_startEvent; EventArray m_startEvent;
Event m_finishedEvent; Event m_finishedEvent;
@ -115,7 +115,7 @@ private:
char m_threadName[64]{}; char m_threadName[64]{};
static std::vector<C4JThread*> ms_threadList; static std::vector<C4JThread*> ms_threadList;
static std::mutex ms_threadListMutex; static ThreadLock ms_threadListLock;
static thread_local C4JThread* tls_currentThread; static thread_local C4JThread* tls_currentThread;
static C4JThread m_mainThread; static C4JThread m_mainThread;

View File

@ -1,5 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include "net.minecraft.world.Item.h" #include "net.minecraft.world.item.h"
#include "DyePowderItem.h" #include "DyePowderItem.h"
#include "Tile.h" #include "Tile.h"
#include "ClothTile.h" #include "ClothTile.h"

View File

@ -18,7 +18,7 @@ static int g_currentCompressTiles = 0;
int CompressedTileStorage::deleteQueueIndex; int CompressedTileStorage::deleteQueueIndex;
XLockFreeStack <unsigned char> CompressedTileStorage::deleteQueue[3]; XLockFreeStack <unsigned char> CompressedTileStorage::deleteQueue[3];
CRITICAL_SECTION CompressedTileStorage::cs_write; ThreadLock CompressedTileStorage::cs_write;
#ifdef PSVITA_PRECOMPUTED_TABLE #ifdef PSVITA_PRECOMPUTED_TABLE
// AP - this will create a precomputed table to speed up getData // AP - this will create a precomputed table to speed up getData

View File

@ -98,7 +98,7 @@ public:
static unsigned char compressBuffer[32768 + 256]; static unsigned char compressBuffer[32768 + 256];
static CRITICAL_SECTION cs_write; static ThreadLock cs_write;
int getAllocatedSize(int *count0, int *count1, int *count2, int *count4, int *count8); int getAllocatedSize(int *count0, int *count1, int *count2, int *count4, int *count8);
int getHighestNonEmptyY(); int getHighestNonEmptyY();

View File

@ -4,7 +4,7 @@
#include "Connection.h" #include "Connection.h"
#include "ThreadName.h" #include "ThreadName.h"
#include "compression.h" #include "compression.h"
#include "PS3\PS3Extras\ShutdownManager.h" #include "Common/Shutdown/ShutdownManager.h"
// This should always be enabled, except for debugging use // This should always be enabled, except for debugging use
#ifndef _DEBUG #ifndef _DEBUG
@ -544,7 +544,7 @@ int Connection::runRead(void* lpParam)
Compression::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage();
CRITICAL_SECTION *cs = &con->threadCounterLock; ThreadLock *cs = &con->threadCounterLock;
EnterCriticalSection(cs); EnterCriticalSection(cs);
con->readThreads++; con->readThreads++;
@ -559,7 +559,7 @@ int Connection::runRead(void* lpParam)
; ;
// try { // try {
//Sleep(100L); //sleep(100L);
// TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well // TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well
con->m_hWakeReadThread->WaitForSignal(100L); con->m_hWakeReadThread->WaitForSignal(100L);
} }
@ -592,7 +592,7 @@ int Connection::runWrite(void* lpParam)
Compression::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage();
CRITICAL_SECTION *cs = &con->threadCounterLock; ThreadLock *cs = &con->threadCounterLock;
EnterCriticalSection(cs); EnterCriticalSection(cs);
con->writeThreads++; con->writeThreads++;
@ -607,7 +607,7 @@ int Connection::runWrite(void* lpParam)
while (con->writeTick()) while (con->writeTick())
; ;
//Sleep(100L); //sleep(100L);
// TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well // TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well
waitResult = con->m_hWakeWriteThread->WaitForSignal(100L); waitResult = con->m_hWakeWriteThread->WaitForSignal(100L);
@ -633,7 +633,7 @@ int Connection::runClose(void* lpParam)
//try { //try {
Sleep(2000); sleep(2000);
if (con->running) if (con->running)
{ {
// 4J TODO writeThread.interrupt(); // 4J TODO writeThread.interrupt();
@ -657,7 +657,7 @@ int Connection::runSendAndQuit(void* lpParam)
//try { //try {
Sleep(2000); sleep(2000);
if (con->running) if (con->running)
{ {
// 4J TODO writeThread.interrupt(); // 4J TODO writeThread.interrupt();

View File

@ -53,7 +53,7 @@ private:
bool running; bool running;
queue<shared_ptr<Packet> > incoming; // 4J - was using synchronizedList... queue<shared_ptr<Packet> > incoming; // 4J - was using synchronizedList...
CRITICAL_SECTION incoming_cs; // ... now has this critical section ThreadLock incoming_cs; // ... now has this critical section
queue<shared_ptr<Packet> > outgoing; // 4J - was using synchronizedList - but don't think it is required as usage is wrapped in writeLock critical section queue<shared_ptr<Packet> > outgoing; // 4J - was using synchronizedList - but don't think it is required as usage is wrapped in writeLock critical section
queue<shared_ptr<Packet> > outgoing_slow; // 4J - was using synchronizedList - but don't think it is required as usage is wrapped in writeLock critical section queue<shared_ptr<Packet> > outgoing_slow; // 4J - was using synchronizedList - but don't think it is required as usage is wrapped in writeLock critical section
@ -89,8 +89,8 @@ private:
void _init(); void _init();
// 4J Jev, these might be better of as private // 4J Jev, these might be better of as private
CRITICAL_SECTION threadCounterLock; ThreadLock threadCounterLock;
CRITICAL_SECTION writeLock; ThreadLock writeLock;
public: public:
// 4J Jev, need to delete the critical section. // 4J Jev, need to delete the critical section.

View File

@ -690,7 +690,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); fElapsedTime = fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime); app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime);
PIXEndNamedEvent(); PIXEndNamedEvent();
@ -721,7 +721,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); fElapsedTime = fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime); app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime);
PIXEndNamedEvent(); PIXEndNamedEvent();
@ -938,12 +938,12 @@ int ConsoleSaveFileOriginal::getOriginalSaveVersion()
void ConsoleSaveFileOriginal::LockSaveAccess() void ConsoleSaveFileOriginal::LockSaveAccess()
{ {
EnterCriticalSection(&m_lock); m_lock.lock();
} }
void ConsoleSaveFileOriginal::ReleaseSaveAccess() void ConsoleSaveFileOriginal::ReleaseSaveAccess()
{ {
LeaveCriticalSection(&m_lock); m_lock.unlock();
} }
ESavePlatform ConsoleSaveFileOriginal::getSavePlatform() ESavePlatform ConsoleSaveFileOriginal::getSavePlatform()

View File

@ -26,7 +26,7 @@ private:
#endif #endif
void* pvSaveMem; void* pvSaveMem;
CRITICAL_SECTION m_lock; ThreadLock m_lock;
void PrepareForWrite( FileEntry *file, unsigned long nNumberOfBytesToWrite ); void PrepareForWrite( FileEntry *file, unsigned long nNumberOfBytesToWrite );
void MoveDataBeyond(FileEntry *file, unsigned long nNumberOfBytesToWrite); void MoveDataBeyond(FileEntry *file, unsigned long nNumberOfBytesToWrite);

View File

@ -1369,7 +1369,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); fElapsedTime = fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime); app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime);
PIXEndNamedEvent(); PIXEndNamedEvent();
@ -1392,7 +1392,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); fElapsedTime = fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime); app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime);
PIXEndNamedEvent(); PIXEndNamedEvent();

View File

@ -69,7 +69,7 @@ private:
#endif #endif
void* pvSaveMem; void* pvSaveMem;
CRITICAL_SECTION m_lock; ThreadLock m_lock;
void PrepareForWrite( FileEntry *file, unsigned long nNumberOfBytesToWrite ); void PrepareForWrite( FileEntry *file, unsigned long nNumberOfBytesToWrite );
void MoveDataBeyond(FileEntry *file, unsigned long nNumberOfBytesToWrite); void MoveDataBeyond(FileEntry *file, unsigned long nNumberOfBytesToWrite);

View File

@ -40,8 +40,7 @@
#include "TexturePackRepository.h" #include "TexturePackRepository.h"
#include "DLCTexturePack.h" #include "DLCTexturePack.h"
#include "Common/DLC/DLCPack.h" #include "Common/DLC/DLCPack.h"
#include "PS3\PS3Extras\ShutdownManager.h" #include "Common/Shutdown/ShutdownManager.h"
unsigned long Level::tlsIdx = TlsAlloc(); unsigned long Level::tlsIdx = TlsAlloc();
unsigned long Level::tlsIdxLightCache = TlsAlloc(); unsigned long Level::tlsIdxLightCache = TlsAlloc();
@ -3703,8 +3702,8 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool f
{ {
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime2.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; qwDeltaTime2.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart;
fElapsedTime1 = fSecsPerTick * ((FLOAT)(qwDeltaTime1.QuadPart)); fElapsedTime1 = fSecsPerTick * ((float)(qwDeltaTime1.QuadPart));
fElapsedTime2 = fSecsPerTick * ((FLOAT)(qwDeltaTime2.QuadPart)); fElapsedTime2 = fSecsPerTick * ((float)(qwDeltaTime2.QuadPart));
if( ( darktcc > 0 ) | ( tcc > 0 ) ) if( ( darktcc > 0 ) | ( tcc > 0 ) )
{ {
printf("%d %d %d %f + %f = %f\n", darktcc, tcc, darktcc + tcc, fElapsedTime1 * 1000.0f, fElapsedTime2 * 1000.0f, ( fElapsedTime1 + fElapsedTime2 ) * 1000.0f); printf("%d %d %d %f + %f = %f\n", darktcc, tcc, darktcc + tcc, fElapsedTime1 * 1000.0f, fElapsedTime2 * 1000.0f, ( fElapsedTime1 + fElapsedTime2 ) * 1000.0f);

View File

@ -90,7 +90,7 @@ public:
static const int TICKS_PER_DAY = 20 * 60 * 20; // ORG:20*60*20 static const int TICKS_PER_DAY = 20 * 60 * 20; // ORG:20*60*20
public: public:
CRITICAL_SECTION m_entitiesCS; // 4J added ThreadLock m_entitiesCS; // 4J added
vector<shared_ptr<Entity> > entities; vector<shared_ptr<Entity> > entities;
@ -99,7 +99,7 @@ protected:
public: public:
bool hasEntitiesToRemove(); // 4J added bool hasEntitiesToRemove(); // 4J added
bool m_bDisableAddNewTileEntities; // 4J Added bool m_bDisableAddNewTileEntities; // 4J Added
CRITICAL_SECTION m_tileEntityListCS; // 4J added ThreadLock m_tileEntityListCS; // 4J added
vector<shared_ptr<TileEntity> > tileEntityList; vector<shared_ptr<TileEntity> > tileEntityList;
private: private:
vector<shared_ptr<TileEntity> > pendingTileEntities; vector<shared_ptr<TileEntity> > pendingTileEntities;
@ -508,7 +508,7 @@ public:
virtual bool newFallingTileAllowed() { return true; } virtual bool newFallingTileAllowed() { return true; }
// 4J - added for new lighting from 1.8.2 // 4J - added for new lighting from 1.8.2
CRITICAL_SECTION m_checkLightCS; ThreadLock m_checkLightCS;
private: private:
int m_iHighestY; // 4J-PB - for the end portal in The End int m_iHighestY; // 4J-PB - for the end portal in The End

View File

@ -22,15 +22,15 @@
#ifdef SHARING_ENABLED #ifdef SHARING_ENABLED
CRITICAL_SECTION LevelChunk::m_csSharing; ThreadLock LevelChunk::m_csSharing;
#endif #endif
#ifdef _ENTITIES_RW_SECTION #ifdef _ENTITIES_RW_SECTION
// AP - use a RW critical section so we can have multiple threads reading the same data to avoid a clash // AP - use a RW critical section so we can have multiple threads reading the same data to avoid a clash
CRITICAL_RW_SECTION LevelChunk::m_csEntities; CRITICAL_RW_SECTION LevelChunk::m_csEntities;
#else #else
CRITICAL_SECTION LevelChunk::m_csEntities; ThreadLock LevelChunk::m_csEntities;
#endif #endif
CRITICAL_SECTION LevelChunk::m_csTileEntities; ThreadLock LevelChunk::m_csTileEntities;
bool LevelChunk::touchedSky = false; bool LevelChunk::touchedSky = false;
void LevelChunk::staticCtor() void LevelChunk::staticCtor()

View File

@ -218,15 +218,15 @@ public:
virtual void attemptCompression(); virtual void attemptCompression();
#ifdef SHARING_ENABLED #ifdef SHARING_ENABLED
static CRITICAL_SECTION m_csSharing; // 4J added static ThreadLock m_csSharing; // 4J added
#endif #endif
// 4J added // 4J added
#ifdef _ENTITIES_RW_SECTION #ifdef _ENTITIES_RW_SECTION
static CRITICAL_RW_SECTION m_csEntities; // AP - we're using a RW critical so we can do multiple reads without contention static CRITICAL_RW_SECTION m_csEntities; // AP - we're using a RW critical so we can do multiple reads without contention
#else #else
static CRITICAL_SECTION m_csEntities; static ThreadLock m_csEntities;
#endif #endif
static CRITICAL_SECTION m_csTileEntities; // 4J added static ThreadLock m_csTileEntities; // 4J added
static void staticCtor(); static void staticCtor();
void checkPostProcess(ChunkSource *source, ChunkSource *parent, int x, int z); void checkPostProcess(ChunkSource *source, ChunkSource *parent, int x, int z);
void checkChests(ChunkSource *source, int x, int z ); // 4J added void checkChests(ChunkSource *source, int x, int z ); // 4J added

View File

@ -306,7 +306,7 @@ void LiquidTile::animateTick(Level *level, int x, int y, int z, Random *random)
{ {
if (random->nextInt(100) == 0) if (random->nextInt(100) == 0)
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
double xx = x + random->nextFloat(); double xx = x + random->nextFloat();
double yy = y + tls->yy1; double yy = y + tls->yy1;
double zz = z + random->nextFloat(); double zz = z + random->nextFloat();

View File

@ -4,7 +4,7 @@
#include "LevelData.h" #include "LevelData.h"
#include "McRegionChunkStorage.h" #include "McRegionChunkStorage.h"
CRITICAL_SECTION McRegionChunkStorage::cs_memory; ThreadLock McRegionChunkStorage::cs_memory;
std::deque<DataOutputStream *> McRegionChunkStorage::s_chunkDataQueue; std::deque<DataOutputStream *> McRegionChunkStorage::s_chunkDataQueue;
int McRegionChunkStorage::s_runningThreadCount = 0; int McRegionChunkStorage::s_runningThreadCount = 0;

View File

@ -14,7 +14,7 @@ class McRegionChunkStorage : public ChunkStorage
private: private:
const wstring m_prefix; const wstring m_prefix;
ConsoleSaveFile *m_saveFile; ConsoleSaveFile *m_saveFile;
static CRITICAL_SECTION cs_memory; static ThreadLock cs_memory;
unordered_map<int64_t, byteArray> m_entityData; unordered_map<int64_t, byteArray> m_entityData;

View File

@ -28,7 +28,7 @@ void PerformanceTimer::PrintElapsedTime(const wstring &description)
QueryPerformanceCounter( &qwNewTime ); QueryPerformanceCounter( &qwNewTime );
qwDeltaTime.QuadPart = qwNewTime.QuadPart - m_qwStartTime.QuadPart; qwDeltaTime.QuadPart = qwNewTime.QuadPart - m_qwStartTime.QuadPart;
float fElapsedTime = m_fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); float fElapsedTime = m_fSecsPerTick * ((float)(qwDeltaTime.QuadPart));
app.DebugPrintf("TIMER: %ls: Elapsed time %f\n", description.c_str(), fElapsedTime); app.DebugPrintf("TIMER: %ls: Elapsed time %f\n", description.c_str(), fElapsedTime);
#endif #endif

View File

@ -75,7 +75,7 @@ Icon *PistonBaseTile::getTexture(int face, int data)
// when the piston is extended, either normally // when the piston is extended, either normally
// or because a piston arm animation, the top // or because a piston arm animation, the top
// texture is the furnace bottom // texture is the furnace bottom
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
if (isExtended(data) || tls->xx0 > 0 || tls->yy0 > 0 || tls->zz0 > 0 || tls->xx1 < 1 || tls->yy1 < 1 || tls->zz1 < 1) if (isExtended(data) || tls->xx0 > 0 || tls->yy0 > 0 || tls->zz0 > 0 || tls->xx1 < 1 || tls->yy1 < 1 || tls->zz1 < 1)
{ {
return iconInside; return iconInside;

View File

@ -137,7 +137,7 @@ void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int
progress = 1.0f - progress; progress = 1.0f - progress;
} }
int facing = entity->getFacing(); int facing = entity->getFacing();
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
tls->xx0 = tile->getShapeX0() - Facing::STEP_X[facing] * progress; tls->xx0 = tile->getShapeX0() - Facing::STEP_X[facing] * progress;
tls->yy0 = tile->getShapeY0() - Facing::STEP_Y[facing] * progress; tls->yy0 = tile->getShapeY0() - Facing::STEP_Y[facing] * progress;
tls->zz0 = tile->getShapeZ0() - Facing::STEP_Z[facing] * progress; tls->zz0 = tile->getShapeZ0() - Facing::STEP_Z[facing] * progress;

View File

@ -5,12 +5,12 @@
#include "ThreadName.h" #include "ThreadName.h"
#include "ServerConnection.h" #include "ServerConnection.h"
#include <algorithm> #include <algorithm>
#include "PS3\PS3Extras\ShutdownManager.h" #include "Common/Shutdown/ShutdownManager.h"
// This current socket implementation is for the creation of a single local link. 2 sockets can be created, one for either end of this local // This current socket implementation is for the creation of a single local link. 2 sockets can be created, one for either end of this local
// link, the end (0 or 1) is passed as a parameter to the ctor. // link, the end (0 or 1) is passed as a parameter to the ctor.
CRITICAL_SECTION Socket::s_hostQueueLock[2]; ThreadLock Socket::s_hostQueueLock[2];
std::queue<byte> Socket::s_hostQueue[2]; std::queue<byte> Socket::s_hostQueue[2];
Socket::SocketOutputStreamLocal *Socket::s_hostOutStream[2]; Socket::SocketOutputStreamLocal *Socket::s_hostOutStream[2];
Socket::SocketInputStreamLocal *Socket::s_hostInStream[2]; Socket::SocketInputStreamLocal *Socket::s_hostInStream[2];

View File

@ -92,14 +92,14 @@ private:
int m_end; // 0 for client side or 1 for host side int m_end; // 0 for client side or 1 for host side
// For local connections between the host player and the server // For local connections between the host player and the server
static CRITICAL_SECTION s_hostQueueLock[2]; static ThreadLock s_hostQueueLock[2];
static std::queue<byte> s_hostQueue[2]; static std::queue<byte> s_hostQueue[2];
static SocketOutputStreamLocal *s_hostOutStream[2]; static SocketOutputStreamLocal *s_hostOutStream[2];
static SocketInputStreamLocal *s_hostInStream[2]; static SocketInputStreamLocal *s_hostInStream[2];
// For network connections // For network connections
std::queue<byte> m_queueNetwork[2]; // For input data std::queue<byte> m_queueNetwork[2]; // For input data
CRITICAL_SECTION m_queueLockNetwork[2]; // For input data ThreadLock m_queueLockNetwork[2]; // For input data
SocketInputStreamNetwork *m_inputStream[2]; SocketInputStreamNetwork *m_inputStream[2];
SocketOutputStreamNetwork *m_outputStream[2]; SocketOutputStreamNetwork *m_outputStream[2];
bool m_endClosed[2]; bool m_endClosed[2];

View File

@ -147,7 +147,7 @@ void StemTile::updateDefaultShape()
void StemTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param void StemTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
tls->yy1 = (level->getData(x, y, z) * 2 + 2) / 16.0f; tls->yy1 = (level->getData(x, y, z) * 2 + 2) / 16.0f;
float ss = 0.125f; float ss = 0.125f;
this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float) tls->yy1, 0.5f + ss); this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, (float) tls->yy1, 0.5f + ss);

View File

@ -217,7 +217,7 @@ void Tile::CreateNewThreadStorage()
void Tile::ReleaseThreadStorage() void Tile::ReleaseThreadStorage()
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
delete tls; delete tls;
} }
@ -650,7 +650,7 @@ Tile *Tile::disableMipmap()
void Tile::setShape(float x0, float y0, float z0, float x1, float y1, float z1) void Tile::setShape(float x0, float y0, float z0, float x1, float y1, float z1)
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
tls->xx0 = x0; tls->xx0 = x0;
tls->yy0 = y0; tls->yy0 = y0;
tls->zz0 = z0; tls->zz0 = z0;
@ -700,7 +700,7 @@ bool Tile::isFaceVisible(Level *level, int x, int y, int z, int f)
bool Tile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) bool Tile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
if (face == 0 && tls->yy0 > 0) return true; if (face == 0 && tls->yy0 > 0) return true;
@ -717,7 +717,7 @@ int Tile::getFaceFlags(LevelSource *level, int x, int y, int z)
{ {
int faceFlags = 0; int faceFlags = 0;
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
@ -792,7 +792,7 @@ Icon *Tile::getTexture(int face)
AABB *Tile::getTileAABB(Level *level, int x, int y, int z) AABB *Tile::getTileAABB(Level *level, int x, int y, int z)
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1);
@ -806,7 +806,7 @@ void Tile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxe
AABB *Tile::getAABB(Level *level, int x, int y, int z) AABB *Tile::getAABB(Level *level, int x, int y, int z)
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1);
@ -941,7 +941,7 @@ HitResult *Tile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b)
a = a->add(-xt, -yt, -zt); a = a->add(-xt, -yt, -zt);
b = b->add(-xt, -yt, -zt); b = b->add(-xt, -yt, -zt);
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
Vec3 *xh0 = a->clipX(b, tls->xx0); Vec3 *xh0 = a->clipX(b, tls->xx0);
Vec3 *xh1 = a->clipX(b, tls->xx1); Vec3 *xh1 = a->clipX(b, tls->xx1);
@ -978,7 +978,7 @@ bool Tile::containsX(Vec3 *v)
{ {
if( v == NULL) return false; if( v == NULL) return false;
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return v->y >= tls->yy0 && v->y <= tls->yy1 && v->z >= tls->zz0 && v->z <= tls->zz1; return v->y >= tls->yy0 && v->y <= tls->yy1 && v->z >= tls->zz0 && v->z <= tls->zz1;
@ -988,7 +988,7 @@ bool Tile::containsY(Vec3 *v)
{ {
if( v == NULL) return false; if( v == NULL) return false;
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return v->x >= tls->xx0 && v->x <= tls->xx1 && v->z >= tls->zz0 && v->z <= tls->zz1; return v->x >= tls->xx0 && v->x <= tls->xx1 && v->z >= tls->zz0 && v->z <= tls->zz1;
@ -998,7 +998,7 @@ bool Tile::containsZ(Vec3 *v)
{ {
if( v == NULL) return false; if( v == NULL) return false;
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return v->x >= tls->xx0 && v->x <= tls->xx1 && v->y >= tls->yy0 && v->y <= tls->yy1; return v->x >= tls->xx0 && v->x <= tls->xx1 && v->y >= tls->yy0 && v->y <= tls->yy1;
@ -1063,14 +1063,14 @@ void Tile::handleEntityInside(Level *level, int x, int y, int z, shared_ptr<Enti
void Tile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param void Tile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
} }
double Tile::getShapeX0() double Tile::getShapeX0()
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return tls->xx0; return tls->xx0;
@ -1078,7 +1078,7 @@ double Tile::getShapeX0()
double Tile::getShapeX1() double Tile::getShapeX1()
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return tls->xx1; return tls->xx1;
@ -1086,7 +1086,7 @@ double Tile::getShapeX1()
double Tile::getShapeY0() double Tile::getShapeY0()
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return tls->yy0; return tls->yy0;
@ -1094,7 +1094,7 @@ double Tile::getShapeY0()
double Tile::getShapeY1() double Tile::getShapeY1()
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return tls->yy1; return tls->yy1;
@ -1102,7 +1102,7 @@ double Tile::getShapeY1()
double Tile::getShapeZ0() double Tile::getShapeZ0()
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return tls->zz0; return tls->zz0;
@ -1110,7 +1110,7 @@ double Tile::getShapeZ0()
double Tile::getShapeZ1() double Tile::getShapeZ1()
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return tls->zz1; return tls->zz1;

View File

@ -55,7 +55,7 @@ protected:
int tileId; int tileId;
ThreadStorage(); ThreadStorage();
}; };
static unsigned long tlsIdxShape; static thread_local ThreadStorage tlsShape;
public: public:
// Each new thread that needs to use Vec3 pools will need to call one of the following 2 functions, to either create its own // Each new thread that needs to use Vec3 pools will need to call one of the following 2 functions, to either create its own
// local storage, or share the default storage already allocated by the main thread // local storage, or share the default storage already allocated by the main thread

View File

@ -29,7 +29,7 @@ AABB *TopSnowTile::getAABB(Level *level, int x, int y, int z)
int height = level->getData(x, y, z) & HEIGHT_MASK; int height = level->getData(x, y, z) & HEIGHT_MASK;
if (height >= (MAX_HEIGHT / 2)) if (height >= (MAX_HEIGHT / 2))
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + .5f, z + tls->zz1); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + .5f, z + tls->zz1);
} }
return NULL; return NULL;

View File

@ -165,7 +165,7 @@ void TripWireTile::checkPressed(Level *level, int x, int y, int z)
bool wasPressed = (data & MASK_POWERED) == MASK_POWERED; bool wasPressed = (data & MASK_POWERED) == MASK_POWERED;
bool shouldBePressed = false; bool shouldBePressed = false;
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1)); vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1));
if (!entities->empty()) if (!entities->empty())
{ {

View File

@ -33,7 +33,7 @@ void WaterlilyTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBL
AABB *WaterlilyTile::getAABB(Level *level, int x, int y, int z) AABB *WaterlilyTile::getAABB(Level *level, int x, int y, int z)
{ {
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1);

View File

@ -20,7 +20,7 @@ AABB *WoolCarpetTile::getAABB(Level *level, int x, int y, int z)
{ {
int height = 0; int height = 0;
float offset = 1.0f / SharedConstants::WORLD_RESOLUTION; float offset = 1.0f / SharedConstants::WORLD_RESOLUTION;
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); Tile::ThreadStorage* tls = &Tile::tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if(tls->tileId != this->id) updateDefaultShape(); if(tls->tileId != this->id) updateDefaultShape();
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1);

View File

@ -64,8 +64,8 @@ private:
XMEMCOMPRESSION_CONTEXT compressionContext; XMEMCOMPRESSION_CONTEXT compressionContext;
XMEMDECOMPRESSION_CONTEXT decompressionContext; XMEMDECOMPRESSION_CONTEXT decompressionContext;
#endif #endif
CRITICAL_SECTION rleCompressLock; ThreadLock rleCompressLock;
CRITICAL_SECTION rleDecompressLock; ThreadLock rleDecompressLock;
unsigned char rleCompressBuf[1024*100]; unsigned char rleCompressBuf[1024*100];
static const unsigned int staticRleSize = 1024*200; static const unsigned int staticRleSize = 1024*200;

View File

@ -13,6 +13,8 @@
typedef unsigned int64_t uint64_t; typedef unsigned int64_t uint64_t;
#endif #endif
#include "Common/ThreadLock.h"
#ifdef _WINDOWS64 #ifdef _WINDOWS64
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files: // Windows Header Files:
@ -25,6 +27,8 @@ typedef unsigned int64_t uint64_t;
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <mutex> #include <mutex>
#include <csignal>
#include <cstdlib>
struct LARGE_INTEGER { struct LARGE_INTEGER {
union { union {
@ -38,10 +42,14 @@ struct FILETIME {
unsigned long dwHighDateTime; unsigned long dwHighDateTime;
}; };
#define CRITICAL_SECTION std::mutex
#define ZeroMemory(ptr, size) memset(ptr, 0, size) #define ZeroMemory(ptr, size) memset(ptr, 0, size)
#define __stdcall #define __stdcall
#if defined(__GNUC__) || defined(__clang__)
#define __debugbreak() raise(SIGTRAP)
#else
#define __debugbreak() std::abort()
#endif
#endif #endif
#ifdef _DURANGO #ifdef _DURANGO

View File

@ -6,7 +6,6 @@
#include "SkinBox.h" #include "SkinBox.h"
#include <vector> #include <vector>
#define MULTITHREAD_ENABLE #define MULTITHREAD_ENABLE
@ -93,7 +92,7 @@ template <typename T>
class XLockFreeStack class XLockFreeStack
{ {
std::vector<T*> intStack; std::vector<T*> intStack;
mutable std::mutex m_mutex; mutable ThreadLock m_lock;
public: public:
XLockFreeStack() = default; XLockFreeStack() = default;
@ -103,19 +102,22 @@ public:
void Push(T* data) void Push(T* data)
{ {
std::lock_guard<std::mutex> lock(m_mutex); m_lock.lock();
intStack.push_back(data); intStack.push_back(data);
m_lock.unlock();
} }
T* Pop() T* Pop()
{ {
std::lock_guard<std::mutex> lock(m_mutex); m_lock.lock();
if (intStack.empty()) if (intStack.empty())
return nullptr; return nullptr;
T* ret = intStack.back(); T* ret = intStack.back();
intStack.pop_back(); intStack.pop_back();
m_lock.unlock();
return ret; return ret;
} }
}; };