aboutsummaryrefslogtreecommitdiff
path: root/engines/cge2
diff options
context:
space:
mode:
authoruruk2014-06-10 14:02:33 +0200
committeruruk2014-06-10 14:02:33 +0200
commit71b0a4cc69185ee6b6f01b488a958c7c19503c3f (patch)
tree6edf8669fca6f6e9e56aa50aeff0c86f07270dc1 /engines/cge2
parente10f22b62f85b5d940a4274e65a53b907f2eae4b (diff)
downloadscummvm-rg350-71b0a4cc69185ee6b6f01b488a958c7c19503c3f.tar.gz
scummvm-rg350-71b0a4cc69185ee6b6f01b488a958c7c19503c3f.tar.bz2
scummvm-rg350-71b0a4cc69185ee6b6f01b488a958c7c19503c3f.zip
CGE2: Implement Sprite::labVal().
Diffstat (limited to 'engines/cge2')
-rw-r--r--engines/cge2/vga13h.cpp60
1 files changed, 58 insertions, 2 deletions
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index 7da9535030..486db29061 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -180,8 +180,64 @@ void Sprite::setName(char *newName) {
}
int Sprite::labVal(Action snq, int lab) {
- warning("STUB: Sprite::labVal()");
- return 0;
+ int lv = -1;
+ if (active()) {
+ int n = _actionCtrl[snq]._cnt;
+ CommandHandler::Command *com = snList(snq);
+
+ int i;
+ for (i = 0; i < n; i++)
+ if (com[i]._lab == lab)
+ break;
+ if (i < n)
+ return i;
+ } else {
+ char tmpStr[kLineMax + 1];
+ _vm->mergeExt(tmpStr, _file, kSprExt);
+
+ if (_vm->_resman->exist(tmpStr)) { // sprite description file exist
+ EncryptedStream sprf(_vm, tmpStr);
+ if (sprf.err())
+ error("Bad SPR [%s]", tmpStr);
+
+ int cnt = 0;
+ int section = kIdPhase;
+ ID id;
+ Common::String line;
+
+ while (lv == -1 && !sprf.eos()) {
+ line = sprf.readLine();
+ if (line.empty())
+ continue;
+
+ Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
+
+ char *p;
+ p = _vm->token(tmpStr);
+
+ if (*p == '@') {
+ if (section == snq && atoi(p + 1) == lab)
+ lv = cnt;
+ } else {
+ id = _vm->ident(p);
+ switch (id) {
+ case kIdMTake:
+ case kIdFTake:
+ case kIdNear:
+ case kIdPhase:
+ case kIdSeq:
+ section = id;
+ break;
+ default:
+ if (id < 0 && section == snq)
+ ++cnt;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return lv;
}
CommandHandler::Command *Sprite::snList(Action type) {