Moved actor movement detection in state.cpp, together with the other detections and rewrote it to work in a similar fashion to the other detections

svn-id: r44836
This commit is contained in:
Filippos Karapetis 2009-10-09 17:41:59 +00:00
parent a38d6451ba
commit 14f8d50a62
4 changed files with 61 additions and 54 deletions

View file

@ -111,6 +111,7 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc,
_doSoundType = SCI_VERSION_AUTODETECT;
_lofsType = SCI_VERSION_AUTODETECT;
_gfxFunctionsType = SCI_VERSION_AUTODETECT;
_moveCountType = kMoveCountUninitialized;
}
EngineState::~EngineState() {
@ -633,4 +634,40 @@ SciVersion EngineState::detectGfxFunctionsType() {
return _gfxFunctionsType;
}
MoveCountType EngineState::detectMoveCountType() {
if (_moveCountType == kMoveCountUninitialized) {
// SCI0/SCI01 games always increment move count
if (getSciVersion() <= SCI_VERSION_01) {
_moveCountType = kIncrementMoveCount;
return _moveCountType;
}
reg_t motionClass = _segMan->findObjectByName("Motion");
bool found = false;
if (!motionClass.isNull()) {
Object *obj = _segMan->getObject(motionClass);
reg_t fptr;
if (obj && lookup_selector(_segMan, motionClass, _kernel->_selectorCache.doit, NULL, &fptr) == kSelectorMethod) {
byte *buf = _segMan->getScript(fptr.segment)->_buf + fptr.offset;
int checksum = 0;
for (int i = 0; i < 8; i++)
checksum += *(buf++);
_moveCountType = (checksum == 0x216) ? kIncrementMoveCount : kIgnoreMoveCount;
found = true;
}
}
if (!found) {
warning("Move count autodetection failed");
_moveCountType = kIncrementMoveCount; // Most games do this, so best guess
}
debugC(1, kDebugLevelVM, "Detected move count handling: %s", (_moveCountType == kIncrementMoveCount) ? "increment" : "ignore");
}
return _moveCountType;
}
} // End of namespace Sci