Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MISC] VScript VGUI inconsistently ignores "vgui/" escape on Linux #252

Open
Blixibon opened this issue Oct 28, 2023 · 3 comments
Open

[MISC] VScript VGUI inconsistently ignores "vgui/" escape on Linux #252

Blixibon opened this issue Oct 28, 2023 · 3 comments
Labels
Bug Something isn't working 🐧 Linux Mapbase - Related to Linux

Comments

@Blixibon
Copy link
Member

Describe the bug

When an image is set in VScript VGUI, this line of code navigates outside of the vgui directory, which is used by default for VGUI images.

V_snprintf( fileName, sizeof( fileName ), "../%s", imageName );

On Linux, this path sometimes does not resolve. A message is printed to the console containing the directory escape as though it was a direct part of the path:

material "vgui/../swarm/ach_weapon_expert_locked" not found

Example of this occurring:

image

However, in some cases, this does not happen and the path successfully navigates to the material outside of the vgui folder.

Steps to reproduce

The circumstances in which this produces an error are not currently known. You can run this simple clientside vscript to create a VGUI image, although it may not produce the error by default.

local panel = vgui.CreatePanel( "ImagePanel", vgui.GetClientDLLRootPanel(), "" );
panel.MakeReadyForUse();
panel.SetVisible( true );
panel.SetPaintEnabled( true );
panel.SetPaintBackgroundEnabled( true );
panel.SetSize( 256, 256 );
panel.SetPos( 0, 0 );
panel.SetImage( "brick/brickfloor001a", false );

Expected behavior

The path should resolve to a material outside of the vgui directory.

@Blixibon Blixibon added Bug Something isn't working 🐧 Linux Mapbase - Related to Linux labels Oct 28, 2023
@samisalreadytaken
Copy link

I found out what is happening here. Apparently the game looks for the existence of the "vgui" directory before loading any material. Why does it do that, I don't know.

As you can see from the screenshots below, creating an empty "vgui" directory fixes it.

Screenshot_2023-11-09_14-07-00

Screenshot_2023-11-09_14-08-33

@Blixibon
Copy link
Member Author

Well, that's not the worst cause this could've had 🥴

Is there anything you think could be done to mitigate this? Automatically creating a materials/vgui folder in every search directory and/or trying to narrow down the specific search directory the code is trying to use might be possible, but I'm not sure what that would look like or how difficult it would be to implement. Perhaps just warning users to include the folder themselves would suffice. I'm curious if you have any input.

@samisalreadytaken
Copy link

Creating the directory wouldn't work with VPKs, so that could ultimately lead to more confusion. Also this check seems to be done (presumably) on game mount, creating the path after mods are mounted doesn't work. I can't think of a solution or a hack right now.

It is worth noting that this only happens with IImage object returned from scheme manager scheme()->GetImage(), and not with surface()->DrawSetTextureFile() which is usually used for loading images in vgui and can be used to implement IImage. Only existing vgui controls (ImagePanel, AvatarImage) are affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working 🐧 Linux Mapbase - Related to Linux
Projects
None yet
Development

No branches or pull requests

2 participants