DIRECTOR: Lingo: Implemented b_field() method

This commit is contained in:
Eugene Sandulenko 2017-02-22 17:05:08 +01:00
parent d2fe6628f2
commit 9cdeb4c88e
3 changed files with 19 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;