VOYEUR: More cleanup

This commit is contained in:
Strangerke 2014-02-19 07:27:52 +01:00
parent 311471c857
commit 2a62c310c3
3 changed files with 5 additions and 46 deletions

View File

@ -491,8 +491,6 @@ public:
class ThreadResource {
public:
static int _useCount[8];
static byte *_threadDataPtr;
static CMapResource *_cmd14Pal;
static void initUseCount();
static void unloadAllStacks(VoyeurEngine *vm);
@ -505,7 +503,6 @@ private:
byte *getDataOffset();
void getButtonsText();
void getButtonsFlags();
void getButtonsUnused();
void performOpenCard();
const byte *getRecordOffset(const byte *p);
const byte *getNextRecord(const byte *p);
@ -543,18 +540,13 @@ public:
int _savedStackId;
int _newStateId;
int _newStackId;
int _flags;
int _fieldA[8]; // Useless variable
int _field2A[8]; // Useless variable
int _stateFlags;
int _stateCount;
int _parseCount;
uint32 _nextStateId;
byte *_threadInfoPtr;
byte _buttonFlags[64];
const byte *_field8E[64]; // Useless variable
byte _buttonIds[64];
const byte *_buttonUnused[48];
byte *_ctlPtr;
byte *_playCommandsPtr;
public:

View File

@ -28,13 +28,9 @@
namespace Voyeur {
int ThreadResource::_useCount[8];
byte *ThreadResource::_threadDataPtr;
CMapResource *ThreadResource::_cmd14Pal;
void ThreadResource::init() {
Common::fill(&_useCount[0], &_useCount[8], 0);
_threadDataPtr = nullptr;
_cmd14Pal = nullptr;
}
ThreadResource::ThreadResource(BoltFilesState &state, const byte *src):
@ -43,7 +39,6 @@ ThreadResource::ThreadResource(BoltFilesState &state, const byte *src):
_stackId = READ_LE_UINT16(&src[0]);
_savedStateId = READ_LE_UINT16(&src[0]);
_savedStackId = READ_LE_UINT16(&src[0]);
_flags = src[8];
_ctlPtr = nullptr;
_aptPos = Common::Point(-1, -1);
}
@ -88,13 +83,10 @@ void ThreadResource::unloadAStack(int stackId) {
}
bool ThreadResource::doState() {
_flags |= 1;
if (!getStateInfo())
return false;
getButtonsFlags();
getButtonsUnused();
_vm->_glGoState = -1;
_vm->_glGoStack = -1;
@ -108,11 +100,9 @@ bool ThreadResource::doState() {
}
bool ThreadResource::getStateInfo() {
_flags &= 0xff;
int id = READ_LE_UINT16(_ctlPtr);
if (id <= _stateId) {
_flags |= 0x8000;
return false;
} else {
uint32 fld = READ_LE_UINT32(_ctlPtr + 2);
@ -137,8 +127,7 @@ bool ThreadResource::getStateInfo() {
byte *ThreadResource::getDataOffset() {
uint32 offset = READ_LE_UINT32(_ctlPtr + 10);
_threadDataPtr = _ctlPtr + offset;
return _threadDataPtr;
return _ctlPtr + offset;
}
void ThreadResource::getButtonsText() {
@ -149,12 +138,10 @@ void ThreadResource::getButtonsText() {
++p;
if (*p++ & 0x80) {
assert(idx < 63);
_field8E[idx] = getRecordOffset(p);
p += 4;
}
++idx;
_field8E[idx] = NULL;
}
}
}
@ -178,17 +165,6 @@ void ThreadResource::getButtonsFlags() {
}
}
void ThreadResource::getButtonsUnused() {
int idx = 0;
for (const byte *p = _threadInfoPtr; *p++ != 0x4A; p = getNextRecord(p)) {
assert(idx < 47);
_buttonUnused[idx++] = getRecordOffset(p);
_buttonUnused[idx] = nullptr;
p += 4;
}
}
void ThreadResource::unloadAllStacks(VoyeurEngine *vm) {
if (vm->_stampFlags & 1) {
for (int i = 0; i < 8; ++i) {
@ -310,8 +286,6 @@ void ThreadResource::cardAction(const byte *card) {
}
bool ThreadResource::chooseSTAMPButton(int buttonId) {
_flags &= ~1;
for (int idx = 0; idx < _stateCount; ++idx) {
if (_buttonIds[idx] == buttonId) {
const byte *card = getSTAMPCard(idx);
@ -888,11 +862,7 @@ const byte *ThreadResource::cardPerform(const byte *card) {
case 41:
bVal = *card++;
assert(bVal < 8);
_fieldA[bVal] = READ_LE_UINT32(card);
card += 4;
_field2A[bVal] = READ_LE_UINT16(card);
card += 2;
card += 6;
case 45:
_newStateId = _nextStateId;
@ -1553,10 +1523,7 @@ bool ThreadResource::goToState(int stackId, int stateId) {
}
void ThreadResource::savePrevious() {
if (_savedStateId == _stateId && _stackId == _savedStackId) {
_flags &= ~1;
} else {
_flags |= 1;
if (_savedStateId != _stateId || _stackId != _savedStackId) {
_savedStateId = _stateId;
_savedStackId = _stackId;
}

View File

@ -808,7 +808,7 @@ void VoyeurEngine::doTapePlaying() {
}
bool VoyeurEngine::checkForMurder() {
int v = _controlPtr->_state->_victimMurderIndex;
int oldMurderIndex = _controlPtr->_state->_victimMurderIndex;
for (int idx = 0; idx < _voy._eventCount; ++idx) {
VoyeurEvent &evt = _voy._events[idx];
@ -854,7 +854,7 @@ bool VoyeurEngine::checkForMurder() {
}
}
_controlPtr->_state->_victimMurderIndex = v;
_controlPtr->_state->_victimMurderIndex = oldMurderIndex;
_voy._videoEventId = -1;
return false;
}