Added Script methods to get the TOT major and minor version

svn-id: r41788
This commit is contained in:
Sven Hesse 2009-06-23 01:19:03 +00:00
parent 510700b086
commit f6118f7a85
4 changed files with 35 additions and 4 deletions

View file

@ -329,7 +329,7 @@ void Draw_v2::printTotText(int16 id) {
ptrEnd = ptr; ptrEnd = ptr;
while (((ptrEnd - dataPtr) < size) && (*ptrEnd != 1)) { while (((ptrEnd - dataPtr) < size) && (*ptrEnd != 1)) {
// Converting to unknown commands/characters to spaces // Converting to unknown commands/characters to spaces
if ((_vm->_game->_script->getData()[0x29] < 0x32) && (*ptrEnd > 3) && (*ptrEnd < 32)) if ((_vm->_game->_script->getVersionMinor() < 2) && (*ptrEnd > 3) && (*ptrEnd < 32))
*ptrEnd = 32; *ptrEnd = 32;
switch (*ptrEnd) { switch (*ptrEnd) {

View file

@ -253,7 +253,7 @@ void Mult_v2::loadImds(Common::SeekableReadStream &data) {
_multData->execPtr = _vm->_game->_script->getData() + _vm->_game->_script->pos(); _multData->execPtr = _vm->_game->_script->getData() + _vm->_game->_script->pos();
_vm->_game->_script->skip(size * 2); _vm->_game->_script->skip(size * 2);
if (_vm->_game->_script->getData()[0x29] < 51) if (_vm->_game->_script->getVersionMinor() < 3)
return; return;
size = data.readSint16LE(); size = data.readSint16LE();
@ -871,7 +871,7 @@ void Mult_v2::animate() {
animObj.newBottom = animObj.newBottom =
MAX(animObj.lastBottom, _vm->_scenery->_toRedrawBottom); MAX(animObj.lastBottom, _vm->_scenery->_toRedrawBottom);
if ((_vm->_game->_script->getData()[0x29] > 50) && if ((_vm->_game->_script->getVersionMinor() > 2) &&
(animObj.newLeft == animObj.lastLeft) && (animObj.newLeft == animObj.lastLeft) &&
(animObj.newTop == animObj.lastTop) && (animObj.newTop == animObj.lastTop) &&
(animObj.newRight == animObj.lastRight) && (animObj.newRight == animObj.lastRight) &&

View file

@ -376,7 +376,10 @@ bool Script::loadTOT(const Common::String &fileName) {
} }
} }
return (_totData != 0); if (_totData == 0)
return false;
return getTOTProperties();
} }
bool Script::loadLOM(const Common::String &fileName) { bool Script::loadLOM(const Common::String &fileName) {
@ -400,6 +403,17 @@ bool Script::loadLOM(const Common::String &fileName) {
return true; return true;
} }
bool Script::getTOTProperties() {
// Offset 39-41: Version in "Major.Minor" string form
if (_totData[40] != '.')
return false;
_versionMajor = _totData[39] - '0';
_versionMinor = _totData[41] - '0';
return true;
}
void Script::unload() { void Script::unload() {
unloadTOT(); unloadTOT();
} }
@ -473,4 +487,12 @@ void Script::call(uint32 offset) {
seek(offset); seek(offset);
} }
uint8 Script::getVersionMajor() const {
return _versionMajor;
}
uint8 Script::getVersionMinor() const {
return _versionMinor;
}
} // End of namespace Gob } // End of namespace Gob

View file

@ -116,6 +116,10 @@ public:
/** Push the current script position and branch to the specified offset. */ /** Push the current script position and branch to the specified offset. */
void call(uint32 offset); void call(uint32 offset);
// Fixed properties
uint8 getVersionMajor() const;
uint8 getVersionMinor() const;
private: private:
struct CallEntry { struct CallEntry {
byte *totPtr; byte *totPtr;
@ -134,6 +138,9 @@ private:
int16 _lomHandle; int16 _lomHandle;
uint8 _versionMajor;
uint8 _versionMinor;
Common::Stack<CallEntry> _callStack; Common::Stack<CallEntry> _callStack;
/** Loading a TOT file. */ /** Loading a TOT file. */
@ -141,6 +148,8 @@ private:
/** Loading a LOM file. */ /** Loading a LOM file. */
bool loadLOM(const Common::String &fileName); bool loadLOM(const Common::String &fileName);
bool getTOTProperties();
/** Unloading a TOT file. */ /** Unloading a TOT file. */
void unloadTOT(); void unloadTOT();
}; };