mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-22 04:01:23 +00:00
NANCY: Implement SetValue
Added support for the simplest of the data access action records. This simply sets or adds to a value inside the TableData struct.
This commit is contained in:
parent
af2ff22907
commit
1369449374
@ -185,6 +185,8 @@ ActionRecord *ActionManager::createActionRecord(uint16 type, Common::SeekableRea
|
||||
return new TextBoxWrite();
|
||||
case 76:
|
||||
return new TextboxClear();
|
||||
case 77:
|
||||
return new SetValue();
|
||||
case 97:
|
||||
return new EventFlags(true);
|
||||
case 98:
|
||||
|
@ -70,7 +70,7 @@ void TableIndexSetValueHS::execute() {
|
||||
break;
|
||||
case kIncrementTableValue:
|
||||
++playerTable->singleValues[_tableIndex - 1];
|
||||
if (playerTable->singleValues[_tableIndex - 1] >= playerTable->singleValues.size() + 1) {
|
||||
if (playerTable->singleValues[_tableIndex - 1] >= (int)playerTable->singleValues.size() + 1) {
|
||||
playerTable->singleValues[_tableIndex - 1] = 1;
|
||||
}
|
||||
break;
|
||||
@ -113,6 +113,40 @@ void TableIndexSetValueHS::execute() {
|
||||
}
|
||||
}
|
||||
|
||||
void SetValue::readData(Common::SeekableReadStream &stream) {
|
||||
_index = stream.readByte();
|
||||
_shouldSet = stream.readByte();
|
||||
_value = stream.readSint16LE();
|
||||
}
|
||||
|
||||
void SetValue::execute() {
|
||||
TableData *playerTable = (TableData *)NancySceneState.getPuzzleData(TableData::getTag());
|
||||
assert(playerTable);
|
||||
|
||||
// nancy8 has 20 single & 20 combo values, later games have 30/10
|
||||
uint numSingleValues = g_nancy->getGameType() <= kGameTypeNancy8 ? 20 : 30;
|
||||
|
||||
if (_index < numSingleValues) {
|
||||
// Single values
|
||||
int16 curValue = playerTable->getSingleValue(_index);
|
||||
if (_shouldSet || curValue == kNoTableValue) {
|
||||
playerTable->setSingleValue(_index, _value);
|
||||
} else {
|
||||
playerTable->setSingleValue(_index, curValue + _value);
|
||||
}
|
||||
} else {
|
||||
// Combo values
|
||||
float curValue = playerTable->getComboValue(_index - numSingleValues);
|
||||
if (_shouldSet || curValue == (float)kNoTableValue) {
|
||||
playerTable->setComboValue(_index - numSingleValues, _value);
|
||||
} else {
|
||||
playerTable->setComboValue(_index - numSingleValues, curValue + _value);
|
||||
}
|
||||
}
|
||||
|
||||
finishExecution();
|
||||
}
|
||||
|
||||
void EventFlags::readData(Common::SeekableReadStream &stream) {
|
||||
if (!_isTerse) {
|
||||
_flags.readData(stream);
|
||||
|
@ -52,6 +52,20 @@ protected:
|
||||
Common::Array<HotspotDescription> _hotspots;
|
||||
};
|
||||
|
||||
// Sets (or adds to) a value inside the TableData struct
|
||||
class SetValue : public ActionRecord {
|
||||
public:
|
||||
void readData(Common::SeekableReadStream &stream) override;
|
||||
void execute() override;
|
||||
|
||||
protected:
|
||||
Common::String getRecordTypeName() const override { return "SetValue"; }
|
||||
|
||||
byte _index = 0;
|
||||
bool _shouldSet = false;
|
||||
int16 _value = kNoTableValue;
|
||||
};
|
||||
|
||||
// Sets up to 10 flags at once.
|
||||
class EventFlags : public ActionRecord {
|
||||
public:
|
||||
|
@ -117,7 +117,7 @@ static const byte kPlayOverlayNoHotspot = 2;
|
||||
static const byte kNoChangeTableValue = 0;
|
||||
static const byte kIncrementTableValue = 1;
|
||||
static const byte kDecrementTableValue = 2;
|
||||
static const int16 kNoChangeTableValue = 9999;
|
||||
static const int16 kNoTableValue = 9999;
|
||||
|
||||
// 3D sound rotation
|
||||
static const byte kRotateAroundX = 0;
|
||||
|
@ -182,7 +182,7 @@ void TableData::synchronize(Common::Serializer &ser) {
|
||||
|
||||
void TableData::setSingleValue(uint16 index, int16 value) {
|
||||
if (singleValues.size() <= index) {
|
||||
singleValues.resize(index, kNoTableValue);
|
||||
singleValues.resize(index + 1, kNoTableValue);
|
||||
}
|
||||
|
||||
singleValues[index] = value;
|
||||
@ -194,7 +194,7 @@ int16 TableData::getSingleValue(uint16 index) const {
|
||||
|
||||
void TableData::setComboValue(uint16 index, float value) {
|
||||
if (comboValues.size() < index) {
|
||||
comboValues.resize(index, kNoTableValue);
|
||||
comboValues.resize(index + 1, kNoTableValue);
|
||||
}
|
||||
|
||||
comboValues[index] = value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user