Skip to content

Macros expand incorrectly when using files from the base AU mod #32

Description

@cryptonaut

TL;DR:

Macros expand incorrectly due to #defines being set differently by PCF and the base mod.

e.g. GVAR(myVar) expands into a3ue_pcf_core_myVar instead of A3A_core_myVar which breaks various things.


I was having an issue where the terrain manipulators (smooth terrain, clear vegetation, etc) that you can build weren't loading from a persistent save correctly. When loading a save with PCF loaded terrain manipulator objects would show up as floating blue arrows and wouldn't apply the smoothing etc that they were supposed to.

After buildings are loaded from a save they are supposed to run a handler function here:

if isText(configOf _veh >> QGVAR(onBuildingLoaded)) then {
Debug_3("calling %1 on %2 with params %3", QGVAR(onBuildingLoaded), typeOf _veh, [_veh]);
[_veh] call compile getText(configOf _veh >> QGVAR(onBuildingLoaded));
};

Notice the macro QGVAR(onBuildingLoaded) which expands to something like: PREFIX_COMPONENT_onBuildingLoaded.

When the file is loaded in the base AU mod PREFIX is set to A3A and so the function name expands to A3A_core_onBuildingLoaded.

However, when the file is loaded in PCF, it's #includeing it's own script_mod.hpp file which sets PREFIX to a3ue_pcf and so it expands into a3ue_pcf_core_onBuildingLoaded instead! Since that's not a valid handler name, no function gets called and stuff breaks.

A simple fix might be to set PREFIX to A3A so that the macros expand correctly in those files (this is what I did in a personal build and it seems to work fine):

#define PREFIX A3A
#include "..\..\script_component.hpp"
FIX_LINE_NUMBERS()

Or to possibly include the script_component.hpp from the base mod using something like #include "\x\A3A\addons\core\script_component.hpp" but I'm not sure if that could cause other issues.

Note this is kind of a hack though, so it needs some more looking into for a proper fix.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtestingimplemented but requires more testing before the issue is considered complete

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions