Skip to content

Commit

Permalink
SHERLOCK: RT: Implement cmdSetSceneEntryFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jul 12, 2015
1 parent de8cd7e commit 90eb0f1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
6 changes: 3 additions & 3 deletions engines/sherlock/tattoo/tattoo_scene.h
Expand Up @@ -35,12 +35,12 @@ enum {
};

struct SceneTripEntry {
bool _flag;
int _flag;
int _sceneNumber;
int _numTimes;

SceneTripEntry() : _flag(false), _sceneNumber(0), _numTimes(0) {}
SceneTripEntry(bool flag, int sceneNumber, int numTimes) : _flag(flag),
SceneTripEntry() : _flag(0), _sceneNumber(0), _numTimes(0) {}
SceneTripEntry(int flag, int sceneNumber, int numTimes) : _flag(flag),
_sceneNumber(sceneNumber), _numTimes(numTimes) {}
};

Expand Down
27 changes: 26 additions & 1 deletion engines/sherlock/tattoo/tattoo_talk.cpp
Expand Up @@ -726,7 +726,32 @@ OpcodeReturn TattooTalk::cmdSetNPCWalkGraphics(const byte *&str) {
return RET_SUCCESS;
}

OpcodeReturn TattooTalk::cmdSetSceneEntryFlag(const byte *&str) { error("TODO: script opcode (cmdSetSceneEntryFlag)"); }
OpcodeReturn TattooTalk::cmdSetSceneEntryFlag(const byte *&str) {
TattooScene &scene = *(TattooScene *)_vm->_scene;
++str;
int flag = (str[0] - 1) * 256 + str[1] - 1 - (str[1] == 1);

int flag1 = flag & 16383;
if (flag > 16383)
flag1 *= -1;

str += 2;

// Make sure that this instance is not already being tracked
bool found = false;
for (uint idx = 0; idx < scene._sceneTripCounters.size() && !found; ++idx) {
SceneTripEntry &entry = scene._sceneTripCounters[idx];
if (entry._flag == flag1 && entry._sceneNumber == str[0] - 1)
found = true;
}

// Only add it if it's not being tracked already
if (!found)
scene._sceneTripCounters.push_back(SceneTripEntry(flag1, str[0] - 1, str[1] - 1));

++str;
return RET_SUCCESS;
}

OpcodeReturn TattooTalk::cmdSetTalkSequence(const byte *&str) {
TattooPeople &people = *(TattooPeople *)_vm->_people;
Expand Down

0 comments on commit 90eb0f1

Please sign in to comment.