ALL: Remove direct use of OSystem::createMutex()
This commit is contained in:
parent
6372c5d845
commit
cf068bcc08
17 changed files with 87 additions and 101 deletions
|
@ -162,7 +162,6 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
|
|||
_currentShakeXOffset(0), _currentShakeYOffset(0),
|
||||
_paletteDirtyStart(0), _paletteDirtyEnd(0),
|
||||
_screenIsLocked(false),
|
||||
_graphicsMutex(0),
|
||||
_displayDisabled(false),
|
||||
#ifdef USE_SDL_DEBUG_FOCUSRECT
|
||||
_enableFocusRectDebugCode(false), _enableFocusRect(false), _focusRect(),
|
||||
|
@ -175,8 +174,6 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
|
|||
|
||||
_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
|
||||
|
||||
_graphicsMutex = g_system->createMutex();
|
||||
|
||||
#ifdef USE_SDL_DEBUG_FOCUSRECT
|
||||
if (ConfMan.hasKey("use_sdl_debug_focusrect"))
|
||||
_enableFocusRectDebugCode = ConfMan.getBool("use_sdl_debug_focusrect");
|
||||
|
@ -214,7 +211,6 @@ SurfaceSdlGraphicsManager::~SurfaceSdlGraphicsManager() {
|
|||
if (_mouseSurface) {
|
||||
SDL_FreeSurface(_mouseSurface);
|
||||
}
|
||||
g_system->deleteMutex(_graphicsMutex);
|
||||
free(_currentPalette);
|
||||
free(_cursorPalette);
|
||||
delete[] _mouseData;
|
||||
|
@ -1518,7 +1514,7 @@ Graphics::Surface *SurfaceSdlGraphicsManager::lockScreen() {
|
|||
assert(_transactionMode == kTransactionNone);
|
||||
|
||||
// Lock the graphics mutex
|
||||
g_system->lockMutex(_graphicsMutex);
|
||||
_graphicsMutex.lock();
|
||||
|
||||
// paranoia check
|
||||
assert(!_screenIsLocked);
|
||||
|
@ -1547,7 +1543,7 @@ void SurfaceSdlGraphicsManager::unlockScreen() {
|
|||
_forceRedraw = true;
|
||||
|
||||
// Finally unlock the graphics mutex
|
||||
g_system->unlockMutex(_graphicsMutex);
|
||||
_graphicsMutex.unlock();
|
||||
}
|
||||
|
||||
void SurfaceSdlGraphicsManager::fillScreen(uint32 col) {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "graphics/pixelformat.h"
|
||||
#include "graphics/scaler.h"
|
||||
#include "common/events.h"
|
||||
#include "common/system.h"
|
||||
#include "common/mutex.h"
|
||||
|
||||
#include "backends/events/sdl/sdl-events.h"
|
||||
|
||||
|
@ -397,7 +397,7 @@ protected:
|
|||
* Mutex which prevents multiple threads from interfering with each other
|
||||
* when accessing the screen.
|
||||
*/
|
||||
OSystem::MutexRef _graphicsMutex;
|
||||
Common::Mutex _graphicsMutex;
|
||||
|
||||
#ifdef USE_SDL_DEBUG_FOCUSRECT
|
||||
bool _enableFocusRectDebugCode;
|
||||
|
|
|
@ -140,7 +140,7 @@ OSystem_Android::~OSystem_Android() {
|
|||
delete _timerManager;
|
||||
_timerManager = 0;
|
||||
|
||||
deleteMutex(_event_queue_lock);
|
||||
delete _event_queue_lock;
|
||||
|
||||
delete _savefileManager;
|
||||
_savefileManager = 0;
|
||||
|
@ -347,7 +347,7 @@ void OSystem_Android::initBackend() {
|
|||
_mutexManager = new PthreadMutexManager();
|
||||
_timerManager = new DefaultTimerManager();
|
||||
|
||||
_event_queue_lock = createMutex();
|
||||
_event_queue_lock = new Common::Mutex();
|
||||
|
||||
gettimeofday(&_startTime, 0);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "backends/platform/android/portdefs.h"
|
||||
#include "common/fs.h"
|
||||
#include "common/archive.h"
|
||||
#include "common/mutex.h"
|
||||
#include "audio/mixer_intern.h"
|
||||
#include "backends/modular-backend.h"
|
||||
#include "backends/plugins/posix/posix-provider.h"
|
||||
|
@ -100,7 +101,7 @@ private:
|
|||
Common::Queue<Common::Event> _event_queue;
|
||||
Common::Event _queuedEvent;
|
||||
uint32 _queuedEventTime;
|
||||
MutexRef _event_queue_lock;
|
||||
Common::Mutex *_event_queue_lock;
|
||||
|
||||
Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt;
|
||||
int _eventScaleX;
|
||||
|
|
|
@ -277,7 +277,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
up = Common::EVENT_LBUTTONUP;
|
||||
}
|
||||
|
||||
lockMutex(_event_queue_lock);
|
||||
_event_queue_lock->lock();
|
||||
|
||||
if (_queuedEventTime)
|
||||
_event_queue.push(_queuedEvent);
|
||||
|
@ -292,7 +292,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
_queuedEvent = e;
|
||||
_queuedEventTime = getMillis() + kQueuedInputEventDelay;
|
||||
|
||||
unlockMutex(_event_queue_lock);
|
||||
_event_queue_lock->unlock();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -341,11 +341,11 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
return;
|
||||
}
|
||||
|
||||
lockMutex(_event_queue_lock);
|
||||
_event_queue_lock->lock();
|
||||
_event_queue.push(e);
|
||||
e.type = dptype;
|
||||
_event_queue.push(e);
|
||||
unlockMutex(_event_queue_lock);
|
||||
_event_queue_lock->unlock();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -381,7 +381,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
|
||||
e.mouse = dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getMousePosition();
|
||||
|
||||
lockMutex(_event_queue_lock);
|
||||
_event_queue_lock->lock();
|
||||
|
||||
if (_queuedEventTime)
|
||||
_event_queue.push(_queuedEvent);
|
||||
|
@ -392,7 +392,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
_queuedEvent = e;
|
||||
_queuedEventTime = getMillis() + kQueuedInputEventDelay;
|
||||
|
||||
unlockMutex(_event_queue_lock);
|
||||
_event_queue_lock->unlock();
|
||||
return;
|
||||
|
||||
default:
|
||||
|
@ -643,21 +643,21 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
|
|||
}
|
||||
}
|
||||
|
||||
lockMutex(_event_queue_lock);
|
||||
_event_queue_lock->lock();
|
||||
|
||||
if (_queuedEventTime && (getMillis() > _queuedEventTime)) {
|
||||
event = _queuedEvent;
|
||||
_queuedEventTime = 0;
|
||||
// unlockMutex(_event_queue_lock);
|
||||
// _event_queue_lock->unlock();
|
||||
// return true;
|
||||
} else if (_event_queue.empty()) {
|
||||
unlockMutex(_event_queue_lock);
|
||||
_event_queue_lock->unlock();
|
||||
return false;
|
||||
} else {
|
||||
event = _event_queue.pop();
|
||||
}
|
||||
|
||||
unlockMutex(_event_queue_lock);
|
||||
_event_queue_lock->unlock();
|
||||
|
||||
if (Common::isMouseEvent(event)) {
|
||||
if (_graphicsManager)
|
||||
|
@ -668,9 +668,9 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
|
|||
}
|
||||
|
||||
void OSystem_Android::pushEvent(const Common::Event &event) {
|
||||
lockMutex(_event_queue_lock);
|
||||
_event_queue_lock->lock();
|
||||
_event_queue.push(event);
|
||||
unlockMutex(_event_queue_lock);
|
||||
_event_queue_lock->unlock();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,7 +47,7 @@ void Mutex::unlock() {
|
|||
#pragma mark -
|
||||
|
||||
|
||||
StackLock::StackLock(MutexRef mutex, const char *mutexName)
|
||||
StackLock::StackLock(OSystem::MutexRef mutex, const char *mutexName)
|
||||
: _mutex(mutex), _mutexName(mutexName) {
|
||||
lock();
|
||||
}
|
||||
|
|
|
@ -30,23 +30,17 @@ namespace Common {
|
|||
|
||||
class Mutex;
|
||||
|
||||
/**
|
||||
* An pseudo-opaque mutex type. See OSystem::createMutex etc. for more details.
|
||||
*/
|
||||
typedef OSystem::MutexRef MutexRef;
|
||||
|
||||
|
||||
/**
|
||||
* Auxillary class to (un)lock a mutex on the stack.
|
||||
*/
|
||||
class StackLock {
|
||||
MutexRef _mutex;
|
||||
OSystem::MutexRef _mutex;
|
||||
const char *_mutexName;
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
public:
|
||||
explicit StackLock(MutexRef mutex, const char *mutexName = nullptr);
|
||||
explicit StackLock(OSystem::MutexRef mutex, const char *mutexName = nullptr);
|
||||
explicit StackLock(const Mutex &mutex, const char *mutexName = nullptr);
|
||||
~StackLock();
|
||||
};
|
||||
|
@ -58,7 +52,7 @@ public:
|
|||
class Mutex {
|
||||
friend class StackLock;
|
||||
|
||||
MutexRef _mutex;
|
||||
OSystem::MutexRef _mutex;
|
||||
|
||||
public:
|
||||
Mutex();
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
namespace Common {
|
||||
|
||||
MemoryPool *g_refCountPool = nullptr; // FIXME: This is never freed right now
|
||||
MutexRef g_refCountPoolMutex = nullptr;
|
||||
Mutex *g_refCountPoolMutex = nullptr;
|
||||
|
||||
void lockMemoryPoolMutex() {
|
||||
// The Mutex class can only be used once g_system is set and initialized,
|
||||
|
@ -40,18 +40,18 @@ void lockMemoryPoolMutex() {
|
|||
if (!g_system || !g_system->backendInitialized())
|
||||
return;
|
||||
if (!g_refCountPoolMutex)
|
||||
g_refCountPoolMutex = g_system->createMutex();
|
||||
g_system->lockMutex(g_refCountPoolMutex);
|
||||
g_refCountPoolMutex = new Mutex();
|
||||
g_refCountPoolMutex->lock();
|
||||
}
|
||||
|
||||
void unlockMemoryPoolMutex() {
|
||||
if (g_refCountPoolMutex)
|
||||
g_system->unlockMutex(g_refCountPoolMutex);
|
||||
g_refCountPoolMutex->unlock();
|
||||
}
|
||||
|
||||
void String::releaseMemoryPoolMutex() {
|
||||
if (g_refCountPoolMutex){
|
||||
g_system->deleteMutex(g_refCountPoolMutex);
|
||||
delete g_refCountPoolMutex;
|
||||
g_refCountPoolMutex = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ namespace Lure {
|
|||
|
||||
SoundManager::SoundManager() {
|
||||
Disk &disk = Disk::getReference();
|
||||
_soundMutex = g_system->createMutex();
|
||||
|
||||
int index;
|
||||
_descs = disk.getEntry(SOUND_DESC_RESOURCE_ID);
|
||||
|
@ -86,9 +85,9 @@ SoundManager::~SoundManager() {
|
|||
removeSounds();
|
||||
_activeSounds.clear();
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
_playingSounds.clear();
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
|
||||
delete _descs;
|
||||
delete _soundData;
|
||||
|
@ -98,8 +97,6 @@ SoundManager::~SoundManager() {
|
|||
delete _driver;
|
||||
_driver = NULL;
|
||||
}
|
||||
|
||||
g_system->deleteMutex(_soundMutex);
|
||||
}
|
||||
|
||||
void SoundManager::saveToStream(Common::WriteStream *stream) {
|
||||
|
@ -300,7 +297,7 @@ void SoundManager::syncSounds() {
|
|||
_musicVolume = mute ? 0 : MIN(255, ConfMan.getInt("music_volume"));
|
||||
_sfxVolume = mute ? 0 : MIN(255, ConfMan.getInt("sfx_volume"));
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
MusicListIterator i;
|
||||
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
|
||||
if ((*i)->isMusic())
|
||||
|
@ -308,7 +305,7 @@ void SoundManager::syncSounds() {
|
|||
else
|
||||
(*i)->setVolume(_sfxVolume);
|
||||
}
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
}
|
||||
|
||||
SoundDescResource *SoundManager::findSound(uint8 soundNumber) {
|
||||
|
@ -393,7 +390,7 @@ void SoundManager::fadeOut() {
|
|||
{
|
||||
inProgress = false;
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
MusicListIterator i;
|
||||
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
|
||||
MidiMusic &music = **i;
|
||||
|
@ -403,7 +400,7 @@ void SoundManager::fadeOut() {
|
|||
}
|
||||
}
|
||||
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
g_system->delayMillis(10);
|
||||
}
|
||||
|
||||
|
@ -449,11 +446,11 @@ void SoundManager::musicInterface_Play(uint8 soundNumber, uint8 channelNumber, u
|
|||
dataSize = nextDataOfs - dataOfs;
|
||||
}
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
MidiMusic *sound = new MidiMusic(_driver, _channelsInner, channelNumber, soundNum,
|
||||
isMusic, numChannels, soundStart, dataSize);
|
||||
_playingSounds.push_back(MusicList::value_type(sound));
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
}
|
||||
|
||||
// musicInterface_Stop
|
||||
|
@ -464,7 +461,7 @@ void SoundManager::musicInterface_Stop(uint8 soundNumber) {
|
|||
musicInterface_TidySounds();
|
||||
uint8 soundNum = soundNumber & 0x7f;
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
MusicListIterator i;
|
||||
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
|
||||
if ((*i)->soundNumber() == soundNum) {
|
||||
|
@ -472,7 +469,7 @@ void SoundManager::musicInterface_Stop(uint8 soundNumber) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
}
|
||||
|
||||
// musicInterface_CheckPlaying
|
||||
|
@ -484,7 +481,7 @@ bool SoundManager::musicInterface_CheckPlaying(uint8 soundNumber) {
|
|||
uint8 soundNum = soundNumber & 0x7f;
|
||||
bool result = false;
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
MusicListIterator i;
|
||||
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
|
||||
if ((*i)->soundNumber() == soundNum) {
|
||||
|
@ -492,7 +489,7 @@ bool SoundManager::musicInterface_CheckPlaying(uint8 soundNumber) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -505,14 +502,14 @@ void SoundManager::musicInterface_SetVolume(uint8 channelNum, uint8 volume) {
|
|||
channelNum, volume);
|
||||
musicInterface_TidySounds();
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
MusicListIterator i;
|
||||
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
|
||||
MidiMusic &music = **i;
|
||||
if (music.channelNumber() == channelNum)
|
||||
music.setVolume(volume);
|
||||
}
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
}
|
||||
|
||||
// musicInterface_KillAll
|
||||
|
@ -522,7 +519,7 @@ void SoundManager::musicInterface_KillAll() {
|
|||
debugC(ERROR_INTERMEDIATE, kLureDebugSounds, "musicInterface_KillAll");
|
||||
musicInterface_TidySounds();
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
MusicListIterator i;
|
||||
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
|
||||
(*i)->stopMusic();
|
||||
|
@ -530,7 +527,7 @@ void SoundManager::musicInterface_KillAll() {
|
|||
|
||||
_playingSounds.clear();
|
||||
_activeSounds.clear();
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
}
|
||||
|
||||
// musicInterface_ContinuePlaying
|
||||
|
@ -554,7 +551,7 @@ void SoundManager::musicInterface_TrashReverb() {
|
|||
void SoundManager::musicInterface_TidySounds() {
|
||||
debugC(ERROR_DETAILED, kLureDebugSounds, "musicInterface_TidySounds");
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
MusicListIterator i = _playingSounds.begin();
|
||||
while (i != _playingSounds.end()) {
|
||||
if (!(*i)->isPlaying())
|
||||
|
@ -562,7 +559,7 @@ void SoundManager::musicInterface_TidySounds() {
|
|||
else
|
||||
++i;
|
||||
}
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
}
|
||||
|
||||
void SoundManager::onTimer(void *data) {
|
||||
|
@ -574,7 +571,7 @@ void SoundManager::doTimer() {
|
|||
if (_paused)
|
||||
return;
|
||||
|
||||
g_system->lockMutex(_soundMutex);
|
||||
_soundMutex.lock();
|
||||
|
||||
MusicListIterator i;
|
||||
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
|
||||
|
@ -583,7 +580,7 @@ void SoundManager::doTimer() {
|
|||
music.onTimer();
|
||||
}
|
||||
|
||||
g_system->unlockMutex(_soundMutex);
|
||||
_soundMutex.unlock();
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
|
|
@ -112,7 +112,7 @@ private:
|
|||
bool _isPlaying;
|
||||
bool _nativeMT32;
|
||||
bool _isRoland;
|
||||
Common::MutexRef _soundMutex;
|
||||
Common::Mutex _soundMutex;
|
||||
bool _paused;
|
||||
|
||||
uint _musicVolume;
|
||||
|
|
|
@ -39,7 +39,7 @@ void MiscTests::criticalSection(void *arg) {
|
|||
SharedVars &sv = *((SharedVars *)arg);
|
||||
|
||||
Testsuite::logDetailedPrintf("Before critical section: %d %d\n", sv.first, sv.second);
|
||||
g_system->lockMutex(sv.mutex);
|
||||
sv.mutex->lock();
|
||||
|
||||
// In any case, the two vars must be equal at entry, if mutex works fine.
|
||||
// verify this here.
|
||||
|
@ -58,7 +58,7 @@ void MiscTests::criticalSection(void *arg) {
|
|||
|
||||
sv.second *= sv.first;
|
||||
Testsuite::logDetailedPrintf("After critical section: %d %d\n", sv.first, sv.second);
|
||||
g_system->unlockMutex(sv.mutex);
|
||||
sv.mutex->unlock();
|
||||
|
||||
g_system->getTimerManager()->removeTimerProc(criticalSection);
|
||||
}
|
||||
|
@ -132,17 +132,17 @@ TestExitStatus MiscTests::testMutexes() {
|
|||
Testsuite::writeOnScreen("Installing mutex", Common::Point(0, 100));
|
||||
}
|
||||
|
||||
SharedVars sv = {1, 1, true, g_system->createMutex()};
|
||||
SharedVars sv = {1, 1, true, new Common::Mutex()};
|
||||
|
||||
if (g_system->getTimerManager()->installTimerProc(criticalSection, 100000, &sv, "testbedMutex")) {
|
||||
g_system->delayMillis(150);
|
||||
}
|
||||
|
||||
g_system->lockMutex(sv.mutex);
|
||||
sv.mutex->lock();
|
||||
sv.first++;
|
||||
g_system->delayMillis(1000);
|
||||
sv.second *= sv.first;
|
||||
g_system->unlockMutex(sv.mutex);
|
||||
sv.mutex->unlock();
|
||||
|
||||
// wait till timed process exits
|
||||
if (ConfParams.isSessionInteractive()) {
|
||||
|
@ -151,7 +151,7 @@ TestExitStatus MiscTests::testMutexes() {
|
|||
g_system->delayMillis(3000);
|
||||
|
||||
Testsuite::logDetailedPrintf("Final Value: %d %d\n", sv.first, sv.second);
|
||||
g_system->deleteMutex(sv.mutex);
|
||||
delete sv.mutex;
|
||||
|
||||
if (sv.resultSoFar && 6 == sv.second) {
|
||||
return kTestPassed;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "testbed/testsuite.h"
|
||||
|
||||
#include "common/mutex.h"
|
||||
|
||||
|
||||
namespace Testbed {
|
||||
|
||||
|
@ -33,7 +35,7 @@ struct SharedVars {
|
|||
int first;
|
||||
int second;
|
||||
bool resultSoFar;
|
||||
OSystem::MutexRef mutex;
|
||||
Common::Mutex *mutex;
|
||||
};
|
||||
|
||||
namespace MiscTests {
|
||||
|
|
|
@ -452,7 +452,7 @@ private:
|
|||
void mergeDirtyRects();
|
||||
|
||||
private:
|
||||
//OSystem::MutexRef csModifyingOT;
|
||||
//Common::Mutex csModifyingOT;
|
||||
|
||||
protected:
|
||||
OTList *_otlist;
|
||||
|
|
|
@ -42,7 +42,6 @@ RMInventory::RMInventory() {
|
|||
_items = NULL;
|
||||
_state = CLOSED;
|
||||
_bCombining = false;
|
||||
_csModifyInterface = g_system->createMutex();
|
||||
_nItems = 0;
|
||||
|
||||
Common::fill(_inv, _inv + 256, 0);
|
||||
|
@ -60,7 +59,6 @@ RMInventory::RMInventory() {
|
|||
|
||||
RMInventory::~RMInventory() {
|
||||
close();
|
||||
g_system->deleteMutex(_csModifyInterface);
|
||||
}
|
||||
|
||||
bool RMInventory::checkPointInside(const RMPoint &pt) {
|
||||
|
@ -182,9 +180,9 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr
|
|||
CORO_BEGIN_CODE(_ctx);
|
||||
|
||||
prim->setDst(RMPoint(0, _curPutY));
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim);
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
|
||||
if (_state == SELECTING) {
|
||||
|
||||
|
@ -228,7 +226,7 @@ void RMInventory::removeThis(CORO_PARAM, bool &result) {
|
|||
void RMInventory::removeItem(int code) {
|
||||
for (int i = 0; i < _nInv; i++) {
|
||||
if (_inv[i] == code - 10000) {
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
|
||||
Common::copy(&_inv[i + 1], &_inv[i + 1] + (_nInv - i), &_inv[i]);
|
||||
_nInv--;
|
||||
|
@ -236,7 +234,7 @@ void RMInventory::removeItem(int code) {
|
|||
prepare();
|
||||
drawOT(Common::nullContext);
|
||||
clearOT();
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +245,7 @@ void RMInventory::addItem(int code) {
|
|||
// If we are here, it means that we are adding an item that should not be in the inventory
|
||||
warning("RMInventory::addItem(%d) - Cannot find a valid icon for this item, and then it will not be added to the inventory", code);
|
||||
} else {
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
if (_curPos + 8 == _nInv) {
|
||||
// Break through the inventory! On the flashing pattern
|
||||
_items[28]._icon.setPattern(2);
|
||||
|
@ -258,7 +256,7 @@ void RMInventory::addItem(int code) {
|
|||
prepare();
|
||||
drawOT(Common::nullContext);
|
||||
clearOT();
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,14 +264,14 @@ void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) {
|
|||
if (code <= 10000 || code >= 10101) {
|
||||
error("RMInventory::changeItemStatus(%d) - Specified object code is not valid", code);
|
||||
} else {
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
_items[code - 10000]._icon.setPattern(dwStatus);
|
||||
_items[code - 10000]._status = dwStatus;
|
||||
|
||||
prepare();
|
||||
drawOT(Common::nullContext);
|
||||
clearOT();
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,7 +329,7 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) {
|
|||
|
||||
// Click the right arrow
|
||||
if ((_state == OPENED) && _bBlinkingRight) {
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
_curPos++;
|
||||
|
||||
if (_curPos + 8 >= _nInv) {
|
||||
|
@ -347,13 +345,13 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) {
|
|||
prepare();
|
||||
drawOT(Common::nullContext);
|
||||
clearOT();
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
}
|
||||
|
||||
// Click the left arrow
|
||||
else if ((_state == OPENED) && _bBlinkingLeft) {
|
||||
assert(_curPos > 0);
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
_curPos--;
|
||||
|
||||
if (_curPos == 0) {
|
||||
|
@ -369,7 +367,7 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) {
|
|||
prepare();
|
||||
drawOT(Common::nullContext);
|
||||
clearOT();
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -392,7 +390,7 @@ void RMInventory::rightClick(const RMPoint &mpos) {
|
|||
}
|
||||
|
||||
if ((_state == OPENED) && _bBlinkingRight) {
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
_curPos += 7;
|
||||
if (_curPos + 8 > _nInv)
|
||||
_curPos = _nInv - 8;
|
||||
|
@ -410,10 +408,10 @@ void RMInventory::rightClick(const RMPoint &mpos) {
|
|||
prepare();
|
||||
drawOT(Common::nullContext);
|
||||
clearOT();
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
} else if ((_state == OPENED) && _bBlinkingLeft) {
|
||||
assert(_curPos > 0);
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
_curPos -= 7;
|
||||
if (_curPos < 0)
|
||||
_curPos = 0;
|
||||
|
@ -431,7 +429,7 @@ void RMInventory::rightClick(const RMPoint &mpos) {
|
|||
prepare();
|
||||
drawOT(Common::nullContext);
|
||||
clearOT();
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,7 +457,7 @@ bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) {
|
|||
void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) {
|
||||
if (_state != CLOSED) {
|
||||
// Clean up the OT list
|
||||
g_system->lockMutex(_csModifyInterface);
|
||||
_csModifyInterface.lock();
|
||||
clearOT();
|
||||
|
||||
// DoFrame makes all the objects currently in the inventory be displayed
|
||||
|
@ -506,7 +504,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo
|
|||
if (bNeedRedraw)
|
||||
prepare();
|
||||
|
||||
g_system->unlockMutex(_csModifyInterface);
|
||||
_csModifyInterface.unlock();
|
||||
}
|
||||
|
||||
if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define TONY_INVENTORY_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
#include "common/mutex.h"
|
||||
#include "tony/font.h"
|
||||
#include "tony/game.h"
|
||||
#include "tony/gfxcore.h"
|
||||
|
@ -76,7 +76,7 @@ protected:
|
|||
RMItem _miniInterface;
|
||||
RMText _hints[3];
|
||||
|
||||
OSystem::MutexRef _csModifyInterface;
|
||||
Common::Mutex _csModifyInterface;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
|
|
@ -891,10 +891,10 @@ bool RMCharacter::findPath(short source, short destination) {
|
|||
bool error = false;
|
||||
RMBoxLoc *cur;
|
||||
|
||||
g_system->lockMutex(_csMove);
|
||||
_csMove.lock();
|
||||
|
||||
if (source == -1 || destination == -1) {
|
||||
g_system->unlockMutex(_csMove);
|
||||
_csMove.unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -973,7 +973,7 @@ bool RMCharacter::findPath(short source, short destination) {
|
|||
_pathLength++;
|
||||
}
|
||||
|
||||
g_system->unlockMutex(_csMove);
|
||||
_csMove.unlock();
|
||||
|
||||
return !error;
|
||||
}
|
||||
|
@ -1327,7 +1327,7 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) {
|
|||
_bEndOfPath = false;
|
||||
_bDrawNow = (_curLocation == loc);
|
||||
|
||||
g_system->lockMutex(_csMove);
|
||||
_csMove.lock();
|
||||
|
||||
// If we're walking..
|
||||
if (_status != STAND) {
|
||||
|
@ -1422,7 +1422,7 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) {
|
|||
}
|
||||
}
|
||||
|
||||
g_system->unlockMutex(_csMove);
|
||||
_csMove.unlock();
|
||||
|
||||
// Invoke the DoFrame of the item
|
||||
RMItem::doFrame(bigBuf);
|
||||
|
@ -1616,7 +1616,6 @@ void RMCharacter::removeThis(CORO_PARAM, bool &result) {
|
|||
}
|
||||
|
||||
RMCharacter::RMCharacter() {
|
||||
_csMove = g_system->createMutex();
|
||||
_hEndOfPath = CoroScheduler.createEvent(false, false);
|
||||
_minPath = 0;
|
||||
_curSpeed = 3;
|
||||
|
@ -1644,7 +1643,6 @@ RMCharacter::RMCharacter() {
|
|||
}
|
||||
|
||||
RMCharacter::~RMCharacter() {
|
||||
g_system->deleteMutex(_csMove);
|
||||
CoroScheduler.closeEvent(_hEndOfPath);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define TONY_LOC_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
#include "common/mutex.h"
|
||||
#include "common/file.h"
|
||||
#include "tony/sound.h"
|
||||
#include "tony/utils.h"
|
||||
|
@ -384,7 +384,7 @@ private:
|
|||
int _curSpeed;
|
||||
bool _bEndOfPath;
|
||||
uint32 _hEndOfPath;
|
||||
OSystem::MutexRef _csMove;
|
||||
Common::Mutex _csMove;
|
||||
int _curLocation;
|
||||
bool _bRemoveFromOT;
|
||||
bool _bMovingWithoutMinpath;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue