diff options
-rw-r--r-- | engines/director/lingo/lingo-builtins.cpp | 16 | ||||
-rw-r--r-- | engines/director/score.cpp | 3 | ||||
-rw-r--r-- | engines/director/score.h | 1 |
3 files changed, 19 insertions, 1 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index f4c26a2193..6411c59d4f 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -1505,7 +1505,21 @@ void Lingo::b_cast(int nargs) { void Lingo::b_field(int nargs) { Datum d = g_lingo->pop(); - warning("STUB: b_field"); + int id; + + if (d.type == STRING) { + if (g_director->getCurrentScore()->_castsNames.contains(*d.u.s)) + id = g_director->getCurrentScore()->_castsNames[*d.u.s]; + else + error("b_filed: Reference to non-existent field: %s", d.u.s->c_str()); + } else if (d.type == INT || d.type == FLOAT) { + d.toInt(); + id = d.u.i; + } else { + error("b_field: Incorrect reference type: %s", d.type2str()); + } + + d.u.i = id; d.type = REFERENCE; diff --git a/engines/director/score.cpp b/engines/director/score.cpp index eb4099275e..b876b777bf 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -653,6 +653,9 @@ void Score::loadCastInfo(Common::SeekableSubReadStreamEndian &stream, uint16 id) debugC(5, kDebugLoading, "CastInfo: name: '%s' directory: '%s', fileName: '%s', type: '%s'", ci->name.c_str(), ci->directory.c_str(), ci->fileName.c_str(), ci->type.c_str()); + if (!ci->name.empty()) + _castsNames[ci->name] = id; + _castsInfo[id] = ci; } diff --git a/engines/director/score.h b/engines/director/score.h index 6db5e33988..2e762f0dad 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -102,6 +102,7 @@ public: Common::Array<Frame *> _frames; Common::HashMap<int, Cast *> _casts; Common::HashMap<uint16, CastInfo *> _castsInfo; + Common::HashMap<Common::String, int> _castsNames; Common::SortedArray<Label *> *_labels; Common::HashMap<uint16, Common::String> _actions; Common::HashMap<uint16, Common::String> _fontMap; |