mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 18:27:26 +00:00
DIRECTOR: LINGO: normalize xlib in openXLib call
In Director, the openXLib call loads an XLib from a file. Resource forks on Mac, dlls on windows. The XLib has it's own name. It looks like the filename, most of the time. ScummVM doesn't read these files, but reimplements them in C. ScummVM's openXLib is a wrapper which loads the XLib in question. A conversion is needed to go from filename to XLib. The conversion is follows these steps: - on mac: strip leading path, i.e. ':', - on windows: strip '.dll' extension, - lowercase and - trimmed The name in the XLibProto struct isn't normalized since that's the variable name as it's know and found by the code.
This commit is contained in:
parent
43650c1a8a
commit
0b777c23a9
@ -118,16 +118,27 @@ void Lingo::initXLibs() {
|
||||
sym.maxArgs = 0;
|
||||
sym.targetType = lib->type;
|
||||
sym.u.bltin = lib->initializer;
|
||||
_xlibInitializers[lib->name] = sym;
|
||||
Common::String xlibName = lib->name;
|
||||
xlibName.toLowercase();
|
||||
_xlibInitializers[xlibName] = sym;
|
||||
}
|
||||
}
|
||||
|
||||
void Lingo::openXLib(Common::String name, ObjectType type) {
|
||||
if (_vm->getPlatform() == Common::kPlatformMacintosh) {
|
||||
|
||||
Common::Platform platform = _vm->getPlatform();
|
||||
if (platform == Common::kPlatformMacintosh) {
|
||||
int pos = name.findLastOf(':');
|
||||
name = name.substr(pos + 1, name.size());
|
||||
} else if (platform == Common::kPlatformWindows) {
|
||||
if (name.hasSuffixIgnoreCase(".dll"))
|
||||
name = name.substr(0, name.size() - 4);
|
||||
}
|
||||
|
||||
// normalize xlib name
|
||||
name.toLowercase();
|
||||
name.trim();
|
||||
|
||||
if (_xlibInitializers.contains(name)) {
|
||||
Symbol sym = _xlibInitializers[name];
|
||||
(*sym.u.bltin)(type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user