Opened 8 months ago

Closed 6 days ago

#15016 closed defect (fixed)

COMMON: macresman.cpp (i think) interferes with "Mass Add"

Reported by: raziel- Owned by: sev-
Priority: high Component: --Unset--
Version: Keywords: director engine
Cc: Game:

Description

ScummVM 2.9.0git (Mar 11 2024 21:02:00)
Using SDL backend with SDL 2.30.1
Features compiled in: Vorbis MP3 RGB zLib MPEG2 MikMod Theora VPX AAC A/52 FreeType2 FriBiDi JPEG PNG GIF cloud (servers, local) ENet SDL2 TinyGL OpenGL (with shaders)

When i let a "Mass Add" run over my Games: partition i get a lot of instances where a requester window comes up, asking me to insert volume
_(underscore)_(underscore)MACOSX/Games:
while searching for gamefiles (see screenshot).

I don't have such a subdirectory in my partition.
The only instance of that name, i could find, is in common/macresman.cpp on line 188

I don't have the slightest idea how to suppress that.
It takes about a minute for the OS requester to go away by itself or hundreds of clicks.

I could turn those requesters off for my platform solely (just like it's done in
backends/platforms/sdl/amigaos/amigaos-main.cpp, lines 59 and 66)
but i wouldn't know what kind of impact or intrusion that would bring or if it's even possible, since it would a platform command(?)

Please advise

AmigAOS4 - BE - SDL - PPC
gcc (adtools build 11.3.0) 11.3.0

Attachments (1)

AmigaDOS_001.png (19.4 KB ) - added by raziel- 8 months ago.

Download all attachments as: .zip

Change History (20)

by raziel-, 8 months ago

Attachment: AmigaDOS_001.png added

comment:1 by digitall, 6 months ago

@raziel- : You compile from scratch? If so, are you enabling all engines? Just be aware that the Mac Resource Manager is used by various engines in detection of resources. So you may want to try disabling a few of the engines which use this and see if the mass add stops being noisy? I would suspect this may be the DIRECTOR engine... so try ./configure --disable-engine=director && make clean && make

The other engines which use Macresman include pegasus, hadesch, groovie, wage, kyra, scumm, sci, mohawk, saga and composer. You may want to try cutting these down and seeing which is the main cause of this...

comment:2 by raziel-, 6 months ago

@digitall

yes, and yes

will do when i get back home

thank you

comment:3 by raziel-, 6 months ago

@digitall

i can confirm that the director engine is the noisy one.

all the other engines you listed are fine, no windows coming up, doing what they should in an automated fashion with Mass Add.

something director engine does that the others avoid?
anything i can do to fix it?

thank you

comment:4 by raziel-, 6 months ago

Keywords: director engine added

comment:5 by sev-, 2 weeks ago

This is definitely related to your backend.

What we are trying to do is call Common::FSNode::exists(). E.g. a normal check for a file existence. This happens in hundreds of other places for other reasons, so should be fixed by the backend.

comment:6 by raziel-, 2 weeks ago

@sev-

Ok, please bear with me as i need to understand what is happening where (not that i'd be able to fix it, but information and stuff)

in common/macresman.cpp, line 170++

SeekableReadStream *MacResManager::openAppleDoubleWithAppleOrOSXNaming(Archive& archive, const Path &fileName) {
	SeekableReadStream *stream = archive.createReadStreamForMember(constructAppleDoubleName(fileName));
	if (stream)
		return stream;

	const ArchiveMemberPtr archiveMember = archive.getMember(fileName);
        const Common::FSNode *plainFsNode = dynamic_cast<const Common::FSNode *>(archiveMember.get());

	// Try finding __MACOSX
	Common::StringArray components = (plainFsNode ? plainFsNode->getPath() : fileName).splitComponents();
	if (components.empty() || components[components.size() - 1].empty())
		return nullptr;
	for (int i = components.size() - 1; i >= 0; i--) {
		Common::StringArray newComponents;
		int j;
		for (j = 0; j < i; j++)
			newComponents.push_back(components[j]);
		newComponents.push_back("__MACOSX");
		for (; j < (int) components.size() - 1; j++)
			newComponents.push_back(components[j]);
		newComponents.push_back("._" + components[(int) components.size() - 1]);

		Common::Path newPath = Common::Path::joinComponents(newComponents);
		stream = archive.createReadStreamForMember(newPath);

		if (!stream) {
			Common::FSNode fsn(newPath);
			if (fsn.exists()) {
				stream = fsn.createReadStream();
			}
		}

		if (stream) {
			bool appleDouble = (stream->readUint32BE() == 0x00051607);
			stream->seek(0);

			if (appleDouble) {
				return stream;
			}
		}
		delete stream;
	}

	return nullptr;
}

This is the only place in the code where __MACOSX is used to look for something...and being "pushed back" (to the current path, i guess?)

While it *does* work, since it *is* added * but in front* of my path, like
__MACOSX/Games:, which obviously doesn't exist (Games: is a partition).

Iiuc (and i sure don't) that is part of a path that should probably go *after* the main search path?
Or even at the end of the current path that is used to look for game files?

But it doesn't.
How do i make that partial path appear at then end of my current search path?

NB:
I have absolutely no idea how MacOS works...is that __MACOSX some special directory where games place their data files?

Please help

Thank you very much

Last edited 2 weeks ago by raziel- (previous) (diff)

comment:7 by sev-, 2 weeks ago

Cross-referencing #14843

comment:8 by sev-, 2 weeks ago

Yes, I see the problem now and it is also mentioned in #14843. E.g. the code is buggy and is trying to look outside of the game folder. It should have constructed filename in a different way.

comment:9 by raziel-, 2 weeks ago

ohhh, goody

rhank you

comment:10 by sev-, 2 weeks ago

Priority: normalhigh

It would be nice to get fixed before release

comment:11 by sev-, 11 days ago

Owner: set to sev-
Resolution: outdated
Status: newclosed

Oops, wrong ticket

Last edited 11 days ago by sev- (previous) (diff)

comment:12 by sev-, 11 days ago

Resolution: outdated
Status: closednew

comment:13 by sev-, 11 days ago

Looking into this with Raziel. Mail sent.

comment:14 by sev-, 10 days ago

In 754827c6:

COMMON: Avoid scanning out of game directory for AppleDouble files. Bug #15016

Also implement sanity check for paths containing drive, e.g. "Games:" on Amiga
or "D:" on Windows.

comment:15 by sev-, 10 days ago

Resolution: fixed
Status: newclosed

Fixed. It was an interesting find.

comment:16 by mikrosk, 8 days ago

Resolution: fixed
Status: closednew

It seems that the issue hasn't been fully fixed: "_ _ MACOSX" is still searched on the level where scummvm(.exe) file is located.

For example, I have on C: the following tree:
a/

b/

scummvm

games/

rama-dos-win-ni-demo-en/

so when I do "cd a/b" and "./scummvm" and then choose "Add game" and go all the way up to "games/rama-dos-win-ni-demo-en" and click "Choose", there are multiple (up to 20!) requests of folder "a/b/_ _ MACOSX".

Last edited 8 days ago by mikrosk (previous) (diff)

comment:17 by raziel-, 8 days ago

@mikrosk

i think this is the intended way

the problem that was fixed was, that it created a search path looking like
_ _MACOSXmyhdd:a/b/
which produced errors because it was obviously non-existant.

looking for a subdir called _ _MACOSX in a given subdir is fine, i guess

comment:18 by mikrosk, 8 days ago

Both #14843 (marked as duplicate of this one) and this ticket explicitly mention "Avoid scanning out of game directory" and this is exactly what is happening, scanning outside of game directory.

comment:19 by sev-, 6 days ago

Resolution: fixed
Status: newclosed

This is normal and expected. This is how our file search is working. You may mix files from different directories, e.g. extrapath and scummvm directory.

Note: See TracTickets for help on using tickets.