mgkid3310 / AWESome

makes ARMA 3's flights more realistic (GPWS, wind effect, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactoring with ACE Macros causing issues (Current dev version)

BonesCrap opened this issue · comments

Describe the bug
Some features eg. ATC-Radar not working due to CBA macros used in Strings (Code in arguments).
Probably since #48 where CBA-Macros were introduced.
Example in fnc_addRadarScreen.sqf:
_screen addAction ["Watch ATC Radar Screen", "_this call FUNC(radarScreenOn);", nil, 1.011, true, true, "", "(isClass (configFile >> 'CfgPatches' >> 'GVAR(environment)')) && !(_this getVariable ['GVAR(isUsingRadarScreen)', false])", 5];
Notice that the macros FUNC and GVAR don't get converted correctly leading to unintended behavior.

Possible fix
In some instances you can pass the function code not as string, but as code-type in {} however this doesn't apply everywhere. For the other instances I'm not too sure how to fix without decreasing readability.

AFAIK using QUOTE macro works for this

e.g. QUOTE([ARR_2(_player, _target)] call FUNC(canEscortCaptive)) from https://github.com/acemod/ACE3/blob/master/addons/captives/CfgVehicles.hpp

I'll make a fix for this. Thanks for letting me know about this issue :)

8bd8134

This commit should fix the problems

@synixebrett Could you help me check if my commit have any problems with CBA macros?

These lines should not be changed. Since it will break mods that implement this feature.

8bd8134#diff-a07efbd54935c240440be88e3b2d49e4L5

8bd8134#diff-43820218f4327918b40d58e028d476afL17

Everything else looks good

Well I changed the CfgVehicles config. I doubt if there would be other addons that has AWESome related config work. I thought it would be better to unify the variable naming rule.

Fair enough, your call then

@BonesCrap Would it be ok to close this issue since the problem is now solved?

Is the ATC-Screen working for you now? For me it isn't cause the check
(isClass (configFile >> 'CfgPatches' >> QGVAR(environment))
is returning false because orbis_atc_environment was renamed just orbis_atc.
At least in my builds. Do you have the same issue?

I forgot to change that part XP
Since addAction is local, checking whether if the client has AWESome is useless.

84bbf4d
05d84da

Could you test once more?

Unfortunately it doesn't seem to work, I couldn't see why. Am I stupid or do these functions not show up in the functions viewer? Tried to look there to find out what broke but didn't find them.

Hmm AFAIK there should be no problem after the last commits the radar should work. Can you double check if you are using the latest code?

I am using the latest code, looked around for a little while, and I think the problem is the comma inside the QUOTE macro (or any macro for that matter). Running the code through preprocessFile yields funny results, eg:
QUOTE(!(_this getVariable [QGVAR(isUsingRadarScreen), false]) processes to
"!(_this getVariable ["orbis_atc_isUsingRadarScreen" false])"
So it omits the comma in this case.

Also I think QQGVAR would be the correct choice here, since it is inside outer quotes.

Done some further testing and the comma is indeed causing the problems, I got a workaround:
Add #define COMMA , to the file and replace the comma inside the QUOTE macro with COMMA.
This is working, however it seems like very bad style. What should be used is probably the GETVAR macro, unfortunately I did't get that to work.

Seems right, gotta use GETVAR SETVAR and SETPVAR. I'll leave a comment once it's done.

https://ace3mod.com/wiki/development/coding-guidelines.html#221-setvariable-getvariable-family-macros

Does using QGVAR inside QUOTE cause no problems?

c9be4a2

removed macros inside quotes for now until a nice fix is found. Works for me now

Works fin now.