Page MenuHomeFeedback Tracker

Unintended behavior of __has_include with file patching
Closed, ResolvedPublic


__has_include matches files in unpacked mods even if the mod is not loaded.


Operating System
Windows 10 x64
Steps To Reproduce
  1. Unpack a mod and place it in the Arma 3 root directory.
  2. Create a dummy mod that checks for a file inside the unpacked mod with __has_include.
  3. Start game with file patching enabled, but only load the dummy mod.
  4. Notice that __has_include was true for the dummy mod.

Event Timeline

ookexoo created this task.Oct 2 2021, 6:10 PM
ookexoo edited Steps To Reproduce. (Show Details)

It would be useful if we had a version of __has_include that only checked the internal/virtual file system and not the Arma folder.

dedmen closed this task as Resolved.Oct 6 2021, 6:47 PM
dedmen claimed this task.
dedmen added a subscriber: dedmen.

Fixed on 7th june already...

That fix actually is the root of this issue. Yes, __has_include matches unpacked mods now when file patching is enabled. Problem is that it does so regardless whether the mod is actually loaded or not.

dedmen added a comment.Oct 6 2021, 9:41 PM

Wuht? But the fix did the opposite.
It removed the ability to load files from disk if filePatching is disabled.

Like.. thats EXACTLY what was fixed.

ookexoo added a comment.EditedOct 13 2021, 10:06 PM

I'm sorry for the confusion I created. We were trying to get rid of ACE optionals for ZEN by using __has_include, but still have issues with file patching.
At this point it's more likely an issue on our end, since I take your word that it was fixed. Hence, consider it as resolved.

I finally understood your issue.

Repro (this would've been useful to understand the issue)
Place testo.hpp in your Arma folder.
Enable filepatching.
Use this in config

#if __has_include("\testo.hpp")
blabla blub bla bla

Even though there is no testo.hpp in any mod, the has include still returns true. Because it finds the file in Arma folder.

But here comes the kicker,
#include "\testo.hpp" DOES include the file, even if its not in a mod and only in Arma folder through filePatching. This in fact is a thing mods depend on for UserConfigs, or.. used to.
So this is not a new thing, and also not a unexpected behaviour. has_include checks if a file exists, for the purposes of including it.
So the final answer is, everything works as designed. We might want a separate has_file that has different constraints, but I don't want to do that.