Merged loadHotSpotsMads() and loadHotSpotsM4()
svn-id: r34726
This commit is contained in:
parent
2219ccf911
commit
17a51a235f
3 changed files with 73 additions and 82 deletions
|
@ -182,30 +182,62 @@ void HotSpotList::dump() {
|
|||
}
|
||||
}
|
||||
|
||||
void HotSpotList::loadHotSpotsM4(Common::SeekableReadStream* hotspotStream, int hotspotCount) {
|
||||
uint32 HotSpotList::readHotSpotInteger(Common::SeekableReadStream* hotspotStream) {
|
||||
if (_vm->isM4())
|
||||
return hotspotStream->readUint32LE();
|
||||
else
|
||||
return hotspotStream->readUint16LE();
|
||||
}
|
||||
|
||||
void HotSpotList::loadHotSpots(Common::SeekableReadStream* hotspotStream, int hotspotCount) {
|
||||
HotSpot *currentHotSpot;
|
||||
uint32 x1, y1, x2, y2;
|
||||
char buffer[256];
|
||||
uint32 strLength = 0;
|
||||
uint32 index = 0;
|
||||
HotSpot *currentHotSpot;
|
||||
uint32 feetX, feetY;
|
||||
int cursorOffset = (_vm ->isM4()) ? 0 : 1;
|
||||
|
||||
for (int i = 0; i < hotspotCount; i++) {
|
||||
x1 = hotspotStream->readUint32LE();
|
||||
y1 = hotspotStream->readUint32LE();
|
||||
x2 = hotspotStream->readUint32LE();
|
||||
y2 = hotspotStream->readUint32LE();
|
||||
x1 = readHotSpotInteger(hotspotStream);
|
||||
y1 = readHotSpotInteger(hotspotStream);
|
||||
x2 = readHotSpotInteger(hotspotStream);
|
||||
y2 = readHotSpotInteger(hotspotStream);
|
||||
index = add(new HotSpot(x1, y1, x2, y2), i == 0);
|
||||
currentHotSpot = get(index);
|
||||
feetX = hotspotStream->readUint32LE();
|
||||
feetY = hotspotStream->readUint32LE();
|
||||
feetX = readHotSpotInteger(hotspotStream);
|
||||
feetY = readHotSpotInteger(hotspotStream);
|
||||
currentHotSpot->setFeet(feetX, feetY);
|
||||
currentHotSpot->setFacing((uint8)hotspotStream->readByte());
|
||||
currentHotSpot->setActive(hotspotStream->readByte() != 0);
|
||||
currentHotSpot->setCursor((uint8)hotspotStream->readByte());
|
||||
|
||||
if (!_vm->isM4())
|
||||
hotspotStream->readByte(); // unused (always 255)
|
||||
|
||||
index = hotspotStream->readByte(); // cursor
|
||||
if (index == 0)
|
||||
currentHotSpot->setCursor(0);
|
||||
else
|
||||
currentHotSpot->setCursor(index - cursorOffset);
|
||||
|
||||
// Rex Nebular doesn't have this field
|
||||
if (!_vm->isM4() && _vm->getGameType() != GType_RexNebular) {
|
||||
// This looks to be some sort of bitmask. Perhaps it signifies
|
||||
// the valid verbs for this hotspot
|
||||
index = hotspotStream->readUint16LE(); // unknown
|
||||
//printf("%i ", index);
|
||||
}
|
||||
|
||||
if (_vm->isM4())
|
||||
hotspotStream->readByte(); // syntax (unused)
|
||||
hotspotStream->readUint32LE(); // vocabID
|
||||
hotspotStream->readUint32LE(); // verbID
|
||||
|
||||
currentHotSpot->setVocabID(readHotSpotInteger(hotspotStream));
|
||||
currentHotSpot->setVerbID(readHotSpotInteger(hotspotStream));
|
||||
|
||||
// Load hotspot related strings (verb, vocab/noun etc)
|
||||
// These are loaded inside the hotspot data in M4 games,
|
||||
// and inside the global vocab data (vocab.dat) in MADS games
|
||||
if (_vm->isM4()) {
|
||||
strLength = hotspotStream->readUint32LE(); // vocabLength
|
||||
hotspotStream->read(buffer, strLength); // vocab (the hotspot's name)
|
||||
// Capitalize the hotspot's name here
|
||||
|
@ -217,15 +249,16 @@ void HotSpotList::loadHotSpotsM4(Common::SeekableReadStream* hotspotStream, int
|
|||
// Capitalize the hotspot's verb here
|
||||
str_upper(buffer);
|
||||
currentHotSpot->setVerb(buffer);
|
||||
strLength = hotspotStream->readUint32LE(); // prepLength
|
||||
hotspotStream->read(buffer, strLength); // prep
|
||||
str_upper(buffer);
|
||||
|
||||
/* Hotspot names for non-English versions are stored in prep.
|
||||
Prep can be set two ways: For English versions, copy the
|
||||
text from vocab. For non-English versions, use the prep text
|
||||
from the room file.
|
||||
*/
|
||||
strLength = hotspotStream->readUint32LE(); // prepLength
|
||||
hotspotStream->read(buffer, strLength); // prep
|
||||
str_upper(buffer);
|
||||
|
||||
if (strlen(buffer) > 0 && strcmp(buffer, "--") != 0 && strcmp(buffer, "ON") != 0)
|
||||
currentHotSpot->setPrep(buffer);
|
||||
else
|
||||
|
@ -235,58 +268,16 @@ void HotSpotList::loadHotSpotsM4(Common::SeekableReadStream* hotspotStream, int
|
|||
strLength = hotspotStream->readUint32LE(); // spriteLength
|
||||
hotspotStream->read(buffer, strLength); // sprite
|
||||
hotspotStream->readUint16LE(); // sprite hash
|
||||
}
|
||||
}
|
||||
|
||||
void HotSpotList::loadHotSpotsMads(Common::SeekableReadStream* hotspotStream, int hotspotCount) {
|
||||
uint16 x1, y1, x2, y2;
|
||||
HotSpot *currentHotSpot;
|
||||
uint16 feetX, feetY;
|
||||
uint16 index = 0;
|
||||
|
||||
for (int i = 0; i < hotspotCount; i++) {
|
||||
x1 = hotspotStream->readUint16LE();
|
||||
y1 = hotspotStream->readUint16LE();
|
||||
x2 = hotspotStream->readUint16LE();
|
||||
y2 = hotspotStream->readUint16LE();
|
||||
index = add(new HotSpot(x1, y1, x2, y2), i == 0);
|
||||
currentHotSpot = get(index);
|
||||
//printf("x1, y1, x2, y2: %i %i %i %i\n", x1, y1, x2, y2);
|
||||
feetX = hotspotStream->readUint16LE();
|
||||
feetY = hotspotStream->readUint16LE();
|
||||
currentHotSpot->setFeet(feetX, feetY);
|
||||
currentHotSpot->setFacing((uint8)hotspotStream->readByte());
|
||||
index = hotspotStream->readByte(); // unknown (initial facing?)
|
||||
|
||||
hotspotStream->readByte(); // unused (always 255)
|
||||
|
||||
index = hotspotStream->readByte(); // cursor
|
||||
if (index == 0)
|
||||
currentHotSpot->setCursor(0);
|
||||
else
|
||||
currentHotSpot->setCursor(index - 1);
|
||||
|
||||
// Rex Nebular doesn't have this field
|
||||
if (_vm->getGameType() != GType_RexNebular) {
|
||||
// This looks to be some sort of bitmask. Perhaps it signifies
|
||||
// the valid verbs for this hotspot
|
||||
index = hotspotStream->readUint16LE(); // unknown
|
||||
//printf("%i ", index);
|
||||
}
|
||||
|
||||
index = hotspotStream->readUint16LE(); // noun index
|
||||
currentHotSpot->setVocabID(index);
|
||||
currentHotSpot->setVocab(_vm->_globals->getVocab(index - 1));
|
||||
index = hotspotStream->readUint16LE(); // verb index (default left click verb)
|
||||
currentHotSpot->setVerbID(index);
|
||||
if (index != 0) {
|
||||
currentHotSpot->setVerb(_vm->_globals->getVocab(index - 1));
|
||||
} else {
|
||||
currentHotSpot->setVocab("");
|
||||
currentHotSpot->setVerb("");
|
||||
|
||||
if (currentHotSpot->getVocabID() > 0)
|
||||
currentHotSpot->setVocab(_vm->_globals->getVocab(currentHotSpot->getVocabID() - 1));
|
||||
|
||||
if (currentHotSpot->getVerbID() > 0)
|
||||
currentHotSpot->setVerb(_vm->_globals->getVocab(currentHotSpot->getVerbID() - 1));
|
||||
}
|
||||
//printf("%s ", currentHotSpot->getVerb());
|
||||
//printf("%s ", currentHotSpot->getVocab());
|
||||
//printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,9 +105,9 @@ public:
|
|||
|
||||
void dump();
|
||||
|
||||
void loadHotSpotsM4(Common::SeekableReadStream* hotspotStream, int hotspotCount);
|
||||
void loadHotSpotsMads(Common::SeekableReadStream* hotspotStream, int hotspotCount);
|
||||
void loadHotSpots(Common::SeekableReadStream* hotspotStream, int hotspotCount);
|
||||
|
||||
uint32 readHotSpotInteger(Common::SeekableReadStream* hotspotStream);
|
||||
private:
|
||||
typedef Common::Array<HotSpot*> HotSpotArray;
|
||||
HotSpotArray _hotspots;
|
||||
|
|
|
@ -210,9 +210,9 @@ void Scene::loadSceneResources(int sceneNumber) {
|
|||
_sceneResources.parallax->clear();
|
||||
_sceneResources.props->clear();
|
||||
|
||||
_sceneResources.hotspots->loadHotSpotsM4(sceneS, _sceneResources.hotspotCount);
|
||||
_sceneResources.parallax->loadHotSpotsM4(sceneS, _sceneResources.parallaxCount);
|
||||
_sceneResources.props->loadHotSpotsM4(sceneS, _sceneResources.propsCount);
|
||||
_sceneResources.hotspots->loadHotSpots(sceneS, _sceneResources.hotspotCount);
|
||||
_sceneResources.parallax->loadHotSpots(sceneS, _sceneResources.parallaxCount);
|
||||
_sceneResources.props->loadHotSpots(sceneS, _sceneResources.propsCount);
|
||||
|
||||
// Note that toss() deletes the MemoryReadStream
|
||||
_vm->res()->toss(filename);
|
||||
|
@ -235,7 +235,7 @@ void Scene::loadSceneHotSpotsMads(int sceneNumber) {
|
|||
// Clear current hotspot lists
|
||||
_sceneResources.hotspots->clear();
|
||||
|
||||
_sceneResources.hotspots->loadHotSpotsMads(hotspotStream, _sceneResources.hotspotCount);
|
||||
_sceneResources.hotspots->loadHotSpots(hotspotStream, _sceneResources.hotspotCount);
|
||||
|
||||
delete hotspotStream;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue