diff --git a/AUTHORS.txt b/AUTHORS.txt index 862cb23413..75745d124e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -73,6 +73,7 @@ Raspu86 Riccardo Petricca Robert Boklahánics ramius86 +SilentSpike simon84 Sniperwolf572 Tachi @@ -93,4 +94,6 @@ VyMajoris(W-Cephei) Bla1337 nikolauska adam3adam -Professor +Professor +Winter +Dharma Bellamkonda diff --git a/ace_advanced_ballistics.dll b/ace_advanced_ballistics.dll index 5aa9a66c0c..0a14d846b5 100644 Binary files a/ace_advanced_ballistics.dll and b/ace_advanced_ballistics.dll differ diff --git a/ace_break_line.dll b/ace_break_line.dll index 0379fd6f34..482486ddd3 100644 Binary files a/ace_break_line.dll and b/ace_break_line.dll differ diff --git a/ace_clipboard.dll b/ace_clipboard.dll index 4f77d63f1f..5b4ac1c537 100644 Binary files a/ace_clipboard.dll and b/ace_clipboard.dll differ diff --git a/ace_fcs.dll b/ace_fcs.dll index 4d8790b150..919a4d0e5b 100644 Binary files a/ace_fcs.dll and b/ace_fcs.dll differ diff --git a/addons/advanced_ballistics/$PBOPREFIX$ b/addons/advanced_ballistics/$PBOPREFIX$ new file mode 100644 index 0000000000..1ab65b7c32 --- /dev/null +++ b/addons/advanced_ballistics/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\advanced_ballistics \ No newline at end of file diff --git a/addons/advanced_ballistics/CfgVehicles.hpp b/addons/advanced_ballistics/CfgVehicles.hpp index fda4b9a8ff..4e42f35f72 100644 --- a/addons/advanced_ballistics/CfgVehicles.hpp +++ b/addons/advanced_ballistics/CfgVehicles.hpp @@ -2,7 +2,7 @@ class CfgVehicles { class ACE_Module; class GVAR(ModuleSettings): ACE_Module { scope = 2; - displayName = "Advanced Ballistics"; + displayName = "$STR_ACE_AdvancedBallistics_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Wind_ca.paa)); category = "ACE"; function = QUOTE(DFUNC(initModuleSettings)); @@ -12,26 +12,26 @@ class CfgVehicles { author = "Ruthberg"; class Arguments { class enabled { - displayName = "Advanced Ballistics"; - description = "Enables advanced ballistics"; + displayName = "$STR_ACE_AdvancedBallistics_enabled_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_enabled_Description"; typeName = "BOOL"; defaultValue = 0; }; class alwaysSimulateForSnipers { - displayName = "Always Enabled For Snipers"; - description = "Always enables advanced ballistics when high power optics are used"; + displayName = "$STR_ACE_AdvancedBallistics_alwaysSimulateForSnipers_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_alwaysSimulateForSnipers_Description"; typeName = "BOOL"; defaultValue = 1; }; class disabledInFullAutoMode { - displayName = "Disabled In FullAuto Mode"; - description = "Disables the advanced ballistics during full auto fire"; + displayName = "$STR_ACE_AdvancedBallistics_disabledInFullAutoMod_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_disabledInFullAutoMod_Description"; typeName = "BOOL"; defaultValue = 0; }; class onlyActiveForLocalPlayers { - displayName = "Disabled For Non Local Players"; - description = "Disables the advanced ballistics for bullets coming from other players (enable this if you encounter frame drops during heavy firefights in multiplayer)"; + displayName = "$STR_ACE_AdvancedBallistics_onlyActiveForLocalPlayers_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_onlyActiveForLocalPlayers_Description"; typeName = "BOOL"; defaultValue = 1; }; @@ -44,35 +44,38 @@ class CfgVehicles { }; */ class ammoTemperatureEnabled { - displayName = "Enable Ammo Temperature Simulation"; - description = "Muzzle velocity varies with ammo temperature"; + displayName = "$STR_ACE_AdvancedBallistics_ammoTemperatureEnabled_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_ammoTemperatureEnabled_Description"; typeName = "BOOL"; defaultValue = 1; }; class barrelLengthInfluenceEnabled { - displayName = "Enable Barrel Length Simulation"; - description = "Muzzle velocity varies with barrel length"; + displayName = "$STR_ACE_AdvancedBallistics_barrelLengthInfluenceEnabled_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_barrelLengthInfluenceEnabled_Description"; typeName = "BOOL"; defaultValue = 1; }; class bulletTraceEnabled { - displayName = "Enable Bullet Trace Effect"; - description = "Enables a bullet trace effect to high caliber bullets (only visible when looking through high power optics)"; + displayName = "$STR_ACE_AdvancedBallistics_bulletTraceEnabled_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_bulletTraceEnabled_Description"; typeName = "BOOL"; defaultValue = 1; }; class simulationInterval { - displayName = "Simulation Interval"; - description = "Defines the interval between every calculation step"; + displayName = "$STR_ACE_AdvancedBallistics_simulationInterval_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_simulationInterval_Description"; typeName = "NUMBER"; defaultValue = 0.0; }; class simulationRadius { - displayName = "Simulation Radius"; - description = "Defines the radius around the player (in meters) at which advanced ballistics are applied to projectiles"; + displayName = "$STR_ACE_AdvancedBallistics_simulationRadius_DisplayName"; + description = "$STR_ACE_AdvancedBallistics_simulationRadius_Description"; typeName = "NUMBER"; defaultValue = 3000; }; }; + class ModuleDescription { + description = "$STR_ACE_AdvancedBallistics_Description"; + }; }; -}; +}; \ No newline at end of file diff --git a/addons/advanced_ballistics/XEH_postInit.sqf b/addons/advanced_ballistics/XEH_postInit.sqf index 8efdd6799b..b59737412a 100644 --- a/addons/advanced_ballistics/XEH_postInit.sqf +++ b/addons/advanced_ballistics/XEH_postInit.sqf @@ -4,24 +4,11 @@ GVAR(currentbulletID) = -1; -GVAR(bulletDatabase) = []; -GVAR(bulletDatabaseStartTime) = []; -GVAR(bulletDatabaseSpeed) = []; -GVAR(bulletDatabaseFrames) = []; -GVAR(bulletDatabaseLastFrame) = []; -GVAR(bulletDatabaseHDeflect) = []; -GVAR(bulletDatabaseSpinDrift) = []; -GVAR(bulletDatabaseOccupiedIndices) = []; -GVAR(bulletDatabaseFreeIndices) = []; - -GVAR(WindInfo) = false; -GVAR(WindInfoStart) = time; - GVAR(Protractor) = false; GVAR(ProtractorStart) = time; GVAR(currentGrid) = 0; -GVAR(INIT_MESSAGE_ENABLED) = false; +GVAR(initMessageEnabled) = false; GVAR(extensionAvailable) = true; /* @TODO: Remove this until versioning is in sync with cmake/build versioning diff --git a/addons/advanced_ballistics/XEH_preInit.sqf b/addons/advanced_ballistics/XEH_preInit.sqf index 1d19a9c492..12018ad412 100644 --- a/addons/advanced_ballistics/XEH_preInit.sqf +++ b/addons/advanced_ballistics/XEH_preInit.sqf @@ -6,12 +6,12 @@ PREP(calculateAmmoTemperatureVelocityShift); PREP(calculateAtmosphericCorrection); PREP(calculateBarrelLengthVelocityShift); PREP(calculateRetardation); -PREP(calculateRoughnessLength); PREP(calculateStabilityFactor); -PREP(calculateWindSpeed); PREP(displayProtractor); PREP(handleFired); PREP(initializeTerrainExtension); PREP(initModuleSettings); +PREP(readAmmoDataFromConfig); +PREP(readWeaponDataFromConfig); ADDON = true; diff --git a/addons/advanced_ballistics/functions/fnc_calculateAmmoTemperatureVelocityShift.sqf b/addons/advanced_ballistics/functions/fnc_calculateAmmoTemperatureVelocityShift.sqf index c92e679a66..28df9d1d97 100644 --- a/addons/advanced_ballistics/functions/fnc_calculateAmmoTemperatureVelocityShift.sqf +++ b/addons/advanced_ballistics/functions/fnc_calculateAmmoTemperatureVelocityShift.sqf @@ -4,7 +4,7 @@ * Calculates the ammo temperature induced muzzle velocity shift * * Arguments: - * 0: ammo - classname + * 0: muzzle velocity shift lookup table - m/s * 1: temperature - degrees celcius * * Return Value: @@ -15,17 +15,11 @@ */ #include "script_component.hpp" -private ["_ammo", "_temperature", "_muzzleVelocityTable", "_muzzleVelocityShift", "_temperatureIndexA", "_temperatureIndexB", "_temperatureRatio"]; -_ammo = _this select 0; -_temperature = _this select 1; +private ["_muzzleVelocityShiftTable", "_temperature", "_muzzleVelocityShift", "_temperatureIndexA", "_temperatureIndexB", "_temperatureRatio"]; +_muzzleVelocityShiftTable = _this select 0; +_temperature = _this select 1; -_muzzleVelocityTable = []; - -if (isArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_ammoTempMuzzleVelocityShifts")) then { - _muzzleVelocityTable = getArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_ammoTempMuzzleVelocityShifts"); -}; - -if (count _muzzleVelocityTable != 11) exitWith { 0 }; +if (count _muzzleVelocityShiftTable != 11) exitWith { 0 }; _temperatureIndexA = floor((_temperature + 15) / 5); _temperatureIndexA = 0 max _temperatureIndexA; @@ -37,6 +31,6 @@ _temperatureIndexB = _temperatureIndexB min 10; _temperatureRatio = ((_temperature + 15) / 5) - floor((_temperature + 15) / 5); -_muzzleVelocityShift = (_muzzleVelocityTable select _temperatureIndexA) * (1 - _temperatureRatio) + (_muzzleVelocityTable select _temperatureIndexB) * _temperatureRatio; +_muzzleVelocityShift = (_muzzleVelocityShiftTable select _temperatureIndexA) * (1 - _temperatureRatio) + (_muzzleVelocityShiftTable select _temperatureIndexB) * _temperatureRatio; _muzzleVelocityShift diff --git a/addons/advanced_ballistics/functions/fnc_calculateBarrelLengthVelocityShift.sqf b/addons/advanced_ballistics/functions/fnc_calculateBarrelLengthVelocityShift.sqf index b4cbd5bdc0..de037f49bc 100644 --- a/addons/advanced_ballistics/functions/fnc_calculateBarrelLengthVelocityShift.sqf +++ b/addons/advanced_ballistics/functions/fnc_calculateBarrelLengthVelocityShift.sqf @@ -4,9 +4,10 @@ * Calculates the muzzle velocity shift caused by different barrel lengths * * Arguments: - * 0: ammo - classname - * 0: weapon - classname - * 1: muzzle velocity - m/s + * 0: barrel length - mm + * 1: muzzle velocity lookup table - m/s + * 2: barrel length lookup table - mm + * 3: muzzle velocity - m/s * * Return Value: * 0: muzzle velocity shift - m/s @@ -16,25 +17,13 @@ */ #include "script_component.hpp" -private ["_ammo", "_weapon", "_barrelLength", "_muzzleVelocityTable", "_barrelLengthTable", "_muzzleVelocity", "_lowerIndex", "_upperIndex", "_barrelLengthRatio", "_muzzleVelocityNew"]; -_ammo = _this select 0; -_weapon = _this select 1; -_muzzleVelocity = _this select 2; - -_barrelLength = getNumber(configFile >> "cfgWeapons" >> _weapon >> "ACE_barrelLength"); +private ["_barrelLength", "_muzzleVelocityTable", "_barrelLengthTable", "_muzzleVelocity", "_lowerIndex", "_upperIndex", "_barrelLengthRatio", "_muzzleVelocityNew"]; +_barrelLength = _this select 0; +_muzzleVelocityTable = _this select 1; +_barrelLengthTable = _this select 2; +_muzzleVelocity = _this select 3; if (_barrelLength == 0) exitWith { 0 }; - -_muzzleVelocityTable = []; -_barrelLengthTable = []; - -if (isArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_muzzleVelocities")) then { - _muzzleVelocityTable = getArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_muzzleVelocities"); -}; -if (isArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_barrelLengths")) then { - _barrelLengthTable = getArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_barrelLengths"); -}; - if (count _muzzleVelocityTable != count _barrelLengthTable) exitWith { 0 }; if (count _muzzleVelocityTable == 0 || count _barrelLengthTable == 0) exitWith { 0 }; if (count _muzzleVelocityTable == 1) exitWith { (_muzzleVelocityTable select 0) - _muzzleVelocity }; diff --git a/addons/advanced_ballistics/functions/fnc_calculateWindSpeed.sqf b/addons/advanced_ballistics/functions/fnc_calculateWindSpeed.sqf deleted file mode 100644 index e7b0a322e8..0000000000 --- a/addons/advanced_ballistics/functions/fnc_calculateWindSpeed.sqf +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Ruthberg - * - * Calculates the true wind speed at a given world position - * - * Arguments: - * 0: _this - world position - * - * Return Value: - * 0: wind speed - m/s - * - * Public: No - */ -#include "script_component.hpp" - -private ["_windSpeed", "_windDir", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"]; - -fnc_polar2vect = { - private ["_mag2D"]; - _mag2D = (_this select 0) * cos((_this select 2)); - [_mag2D * sin((_this select 1)), _mag2D * cos((_this select 1)), (_this select 0) * sin((_this select 2))]; -}; - -_windSpeed = vectorMagnitude ACE_wind; -_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); - -// Wind gradient -if (_windSpeed > 0.05) then { - _height = (ASLToATL _this) select 2; - _height = 0 max _height min 20; - if (_height < 20) then { - _roughnessLength = _this call FUNC(calculateRoughnessLength); - _windSpeed = _windSpeed * ln(_height / _roughnessLength) / ln(20 / _roughnessLength); - }; -}; - -// Terrain effect on wind -if (_windSpeed > 0.05) then { - _newWindSpeed = 0; - { - _windSource = [100, _windDir + 180, _x] call fnc_polar2vect; - if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 9) * _windSpeed; - }; - _windSource = [100, _windDir + 180 + _x, 0] call fnc_polar2vect; - if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 9) * _windSpeed; - }; - _windSource = [100, _windDir + 180 - _x, 0] call fnc_polar2vect; - if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 9) * _windSpeed; - }; - } forEach [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - _windSpeed = _newWindSpeed; -}; - -// Obstacle effect on wind -if (_windSpeed > 0.05) then { - _newWindSpeed = 0; - { - _windSource = [20, _windDir + 180, _x] call fnc_polar2vect; - if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 2) * _windSpeed; - }; - _windSource = [20, _windDir + 180 + _x, 0] call fnc_polar2vect; - if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 2) * _windSpeed; - }; - _windSource = [20, _windDir + 180 - _x, 0] call fnc_polar2vect; - if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 2) * _windSpeed; - }; - } forEach [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]; - _windSpeed = _newWindSpeed; -}; -_windSpeed = 0 max _windSpeed; - -_windSpeed diff --git a/addons/advanced_ballistics/functions/fnc_handleFired.sqf b/addons/advanced_ballistics/functions/fnc_handleFired.sqf index f6458b5f41..bb0b649da4 100644 --- a/addons/advanced_ballistics/functions/fnc_handleFired.sqf +++ b/addons/advanced_ballistics/functions/fnc_handleFired.sqf @@ -19,7 +19,7 @@ */ #include "script_component.hpp" -private ["_unit", "_weapon", "_mode", "_ammo", "_magazine", "_caliber", "_bullet", "_abort", "_index", "_opticsName", "_opticType", "_bulletTraceVisible", "_temperature", "_barometricPressure", "_atmosphereModel", "_bulletMass", "_bulletLength", "_airFriction", "_dragModel", "_muzzleVelocity", "_muzzleVelocityShift", "_bulletVelocity", "_bulletSpeed", "_bulletLength", "_barrelTwist", "_twistDirection", "_stabilityFactor", "_transonicStabilityCoef", "_ballisticCoefficients", "_velocityBoundaries"]; +private ["_unit", "_weapon", "_mode", "_ammo", "_magazine", "_caliber", "_bullet", "_abort", "_AmmoCacheEntry", "_WeaponCacheEntry", "_opticsName", "_opticType", "_bulletTraceVisible", "_temperature", "_barometricPressure", "_bulletMass", "_bulletLength", "_muzzleVelocity", "_muzzleVelocityShift", "_bulletVelocity", "_bulletSpeed", "_bulletLength", "_barrelTwist", "_stabilityFactor"]; _unit = _this select 0; _weapon = _this select 1; _mode = _this select 3; @@ -40,7 +40,7 @@ if (GVAR(onlyActiveForLocalPlayers) && !(local _unit)) then { // The shooter is non local if (currentWeapon _unit == primaryWeapon _unit && count primaryWeaponItems _unit > 2) then { _opticsName = (primaryWeaponItems _unit) select 2; - _opticType = getNumber(configFile >> "cfgWeapons" >> _opticsName >> "ItemInfo" >> "opticType"); + _opticType = getNumber(configFile >> "CfgWeapons" >> _opticsName >> "ItemInfo" >> "opticType"); _abort = _opticType != 2; // We only abort if the non local shooter is not a sniper }; } else { @@ -48,19 +48,26 @@ if (GVAR(onlyActiveForLocalPlayers) && !(local _unit)) then { }; }; //if (!GVAR(vehicleGunnerEnabled) && !(_unit isKindOf "Man")) then { _abort = true; }; // We currently do not have firedEHs on vehicles -if (GVAR(disabledInFullAutoMode) && getNumber(configFile >> "cfgWeapons" >> _weapon >> _mode >> "autoFire") == 1) then { _abort = true; }; +if (GVAR(disabledInFullAutoMode) && getNumber(configFile >> "CfgWeapons" >> _weapon >> _mode >> "autoFire") == 1) then { _abort = true; }; if (_abort || !(GVAR(extensionAvailable))) exitWith { - [_bullet, getNumber(configFile >> "cfgAmmo" >> _ammo >> "airFriction")] call EFUNC(winddeflection,updateTrajectoryPFH); + [_bullet, getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction")] call EFUNC(winddeflection,updateTrajectoryPFH); }; -_airFriction = getNumber(configFile >> "cfgAmmo" >> _ammo >> "airFriction"); +_AmmoCacheEntry = uiNamespace getVariable format[QGVAR(%1), _ammo]; +if (isNil {_AmmoCacheEntry}) then { + _AmmoCacheEntry = _ammo call FUNC(readAmmoDataFromConfig); +}; +_WeaponCacheEntry = uiNamespace getVariable format[QGVAR(%1), _weapon]; +if (isNil {_WeaponCacheEntry}) then { + _WeaponCacheEntry = _weapon call FUNC(readWeaponDataFromConfig); +}; _bulletVelocity = velocity _bullet; _muzzleVelocity = vectorMagnitude _bulletVelocity; if (GVAR(barrelLengthInfluenceEnabled)) then { - _muzzleVelocityShift = [_ammo, _weapon, _muzzleVelocity] call FUNC(calculateBarrelLengthVelocityShift); + _muzzleVelocityShift = [_WeaponCacheEntry select 2, _AmmoCacheEntry select 10, _AmmoCacheEntry select 11, _muzzleVelocity] call FUNC(calculateBarrelLengthVelocityShift); if (_muzzleVelocityShift != 0) then { _bulletVelocity = _bulletVelocity vectorAdd ((vectorNormalized _bulletVelocity) vectorMultiply (_muzzleVelocityShift)); _bullet setVelocity _bulletVelocity; @@ -69,8 +76,8 @@ if (GVAR(barrelLengthInfluenceEnabled)) then { }; if (GVAR(ammoTemperatureEnabled)) then { - _temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL _unit) select 2); - _muzzleVelocityShift = [_ammo, _temperature] call FUNC(calculateAmmoTemperatureVelocityShift); + _temperature = ((getPosASL _unit) select 2) call EFUNC(weather,calculateTemperatureAtHeight); + _muzzleVelocityShift = [_AmmoCacheEntry select 9, _temperature] call FUNC(calculateAmmoTemperatureVelocityShift); if (_muzzleVelocityShift != 0) then { _bulletVelocity = _bulletVelocity vectorAdd ((vectorNormalized _bulletVelocity) vectorMultiply (_muzzleVelocityShift)); _bullet setVelocity _bulletVelocity; @@ -85,60 +92,27 @@ if (GVAR(bulletTraceEnabled) && cameraView == "GUNNER") then { } else { if (currentWeapon ACE_player == primaryWeapon ACE_player && count primaryWeaponItems ACE_player > 2) then { _opticsName = (primaryWeaponItems ACE_player) select 2; - _opticType = getNumber(configFile >> "cfgWeapons" >> _opticsName >> "ItemInfo" >> "opticType"); + _opticType = getNumber(configFile >> "CfgWeapons" >> _opticsName >> "ItemInfo" >> "opticType"); _bulletTraceVisible = _opticType == 2; }; }; }; -_caliber = getNumber(configFile >> "cfgAmmo" >> _ammo >> "ACE_caliber"); -_bulletLength = getNumber(configFile >> "cfgAmmo" >> _ammo >> "ACE_bulletLength"); -_bulletMass = getNumber(configFile >> "cfgAmmo" >> _ammo >> "ACE_bulletMass"); -_barrelTwist = getNumber(configFile >> "cfgWeapons" >> _weapon >> "ACE_barrelTwist"); +_caliber = _AmmoCacheEntry select 1; +_bulletLength = _AmmoCacheEntry select 2; +_bulletMass = _AmmoCacheEntry select 3; +_barrelTwist = _WeaponCacheEntry select 0; _stabilityFactor = 1.5; if (_caliber > 0 && _bulletLength > 0 && _bulletMass > 0 && _barrelTwist > 0) then { - _temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL _unit) select 2); + _temperature = ((getPosASL _unit) select 2) call EFUNC(weather,calculateTemperatureAtHeight); _barometricPressure = ((getPosASL _bullet) select 2) call EFUNC(weather,calculateBarometricPressure); _stabilityFactor = [_caliber, _bulletLength, _bulletMass, _barrelTwist, _muzzleVelocity, _temperature, _barometricPressure] call FUNC(calculateStabilityFactor); }; -_twistDirection = 1; -if (isNumber(configFile >> "cfgWeapons" >> _weapon >> "ACE_twistDirection")) then { - _twistDirection = getNumber(configFile >> "cfgWeapons" >> _weapon >> "ACE_twistDirection"); - if (_twistDirection != -1 && _twistDirection != 0 && _twistDirection != 1) then { - _twistDirection = 1; - }; -}; - -_transonicStabilityCoef = 0.5; -if (isNumber(configFile >> "cfgAmmo" >> _ammo >> "ACE_transonicStabilityCoef")) then { - _transonicStabilityCoef = getNumber(configFile >> "cfgAmmo" >> _ammo >> "ACE_transonicStabilityCoef"); -}; - -_dragModel = 1; -_ballisticCoefficients = []; -_velocityBoundaries = []; -_atmosphereModel = "ICAO"; -if (isNumber(configFile >> "cfgAmmo" >> _ammo >> "ACE_dragModel")) then { - _dragModel = getNumber(configFile >> "cfgAmmo" >> _ammo >> "ACE_dragModel"); - if (!(_dragModel in [1, 2, 5, 6, 7, 8])) then { - _dragModel = 1; - }; -}; -if (isArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_ballisticCoefficients")) then { - _ballisticCoefficients = getArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_ballisticCoefficients"); -}; -if (isArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_velocityBoundaries")) then { - _velocityBoundaries = getArray(configFile >> "cfgAmmo" >> _ammo >> "ACE_velocityBoundaries"); -}; -if (isText(configFile >> "cfgAmmo" >> _ammo >> "ACE_standardAtmosphere")) then { - _atmosphereModel = getText(configFile >> "cfgAmmo" >> _ammo >> "ACE_standardAtmosphere"); -}; - GVAR(currentbulletID) = (GVAR(currentbulletID) + 1) % 10000; -"ace_advanced_ballistics" callExtension format["new:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:%18", GVAR(currentbulletID), _airFriction, _ballisticCoefficients, _velocityBoundaries, _atmosphereModel, _dragModel, _stabilityFactor, _twistDirection, _muzzleVelocity, _transonicStabilityCoef, getPosASL _bullet, EGVAR(weather,Latitude), EGVAR(weather,currentTemperature), EGVAR(weather,Altitude), EGVAR(weather,currentHumidity), overcast, floor(time), time - floor(time)]; +"ace_advanced_ballistics" callExtension format["new:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:%18", GVAR(currentbulletID), _AmmoCacheEntry select 0, _AmmoCacheEntry select 6, _AmmoCacheEntry select 7, _AmmoCacheEntry select 8, _AmmoCacheEntry select 5, _stabilityFactor, _WeaponCacheEntry select 1, _muzzleVelocity, _AmmoCacheEntry select 4, getPosASL _bullet, EGVAR(weather,Latitude), EGVAR(weather,currentTemperature), EGVAR(weather,Altitude), EGVAR(weather,currentHumidity), overcast, floor(time), time - floor(time)]; [{ private ["_args", "_index", "_bullet", "_caliber", "_bulletTraceVisible", "_bulletVelocity", "_bulletPosition"]; diff --git a/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf b/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf index 3930526433..93a79138c6 100644 --- a/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf +++ b/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf @@ -22,7 +22,7 @@ _initStartTime = time; _mapSize = getNumber (configFile >> "CfgWorlds" >> worldName >> "MapSize"); if (("ace_advanced_ballistics" callExtension format["init:%1:%2", worldName, _mapSize]) == "Terrain already initialized") exitWith { - if (GVAR(INIT_MESSAGE_ENABLED)) then { + if (GVAR(initMessageEnabled)) then { systemChat "AdvancedBallistics: Terrain already initialized"; }; }; @@ -40,7 +40,7 @@ GVAR(currentGrid) = 0; _initStartTime = _args select 2; if (GVAR(currentGrid) >= _gridCells) exitWith { - if (GVAR(INIT_MESSAGE_ENABLED)) then { + if (GVAR(initMessageEnabled)) then { systemChat format["AdvancedBallistics: Finished terrain initialization in %1 seconds", ceil(time - _initStartTime)]; }; [_this select 1] call cba_fnc_removePerFrameHandler; diff --git a/addons/advanced_ballistics/functions/fnc_readAmmoDataFromConfig.sqf b/addons/advanced_ballistics/functions/fnc_readAmmoDataFromConfig.sqf new file mode 100644 index 0000000000..10e7e60df2 --- /dev/null +++ b/addons/advanced_ballistics/functions/fnc_readAmmoDataFromConfig.sqf @@ -0,0 +1,64 @@ +/* + * Author: Ruthberg + * + * Reads the ammo class config and updates the config cache + * + * Arguments: + * 0: ammo - classname + * + * Return Value: + * 0: [_airFriction, _caliber, _bulletLength, _bulletMass, _transonicStabilityCoef, _dragModel, _ballisticCoefficients, _velocityBoundaries, _atmosphereModel, _ammoTempMuzzleVelocityShifts, _muzzleVelocityTable, _barrelLengthTable] + * + * Return value: + * None + */ +#include "script_component.hpp" + +private ["_ammo", "_airFriction", "_caliber", "_bulletLength", "_bulletMass", "_transonicStabilityCoef", "_dragModel", "_ballisticCoefficients", "_velocityBoundaries", "_atmosphereModel", "_ammoTempMuzzleVelocityShifts", "_muzzleVelocityTable", "_barrelLengthTable", "_result"]; +_ammo = _this; + +_airFriction = getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction"); +_caliber = getNumber(configFile >> "CfgAmmo" >> _ammo >> "ACE_caliber"); +_bulletLength = getNumber(configFile >> "CfgAmmo" >> _ammo >> "ACE_bulletLength"); +_bulletMass = getNumber(configFile >> "CfgAmmo" >> _ammo >> "ACE_bulletMass"); +_transonicStabilityCoef = 0.5; +if (isNumber(configFile >> "CfgAmmo" >> _ammo >> "ACE_transonicStabilityCoef")) then { + _transonicStabilityCoef = getNumber(configFile >> "CfgAmmo" >> _ammo >> "ACE_transonicStabilityCoef"); +}; +_dragModel = 1; +_ballisticCoefficients = []; +_velocityBoundaries = []; +_atmosphereModel = "ICAO"; +if (isNumber(configFile >> "CfgAmmo" >> _ammo >> "ACE_dragModel")) then { + _dragModel = getNumber(configFile >> "CfgAmmo" >> _ammo >> "ACE_dragModel"); + if (!(_dragModel in [1, 2, 5, 6, 7, 8])) then { + _dragModel = 1; + }; +}; +if (isArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_ballisticCoefficients")) then { + _ballisticCoefficients = getArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_ballisticCoefficients"); +}; +if (isArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_velocityBoundaries")) then { + _velocityBoundaries = getArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_velocityBoundaries"); +}; +if (isText(configFile >> "CfgAmmo" >> _ammo >> "ACE_standardAtmosphere")) then { + _atmosphereModel = getText(configFile >> "CfgAmmo" >> _ammo >> "ACE_standardAtmosphere"); +}; +_ammoTempMuzzleVelocityShifts = []; +if (isArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_ammoTempMuzzleVelocityShifts")) then { + _ammoTempMuzzleVelocityShifts = getArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_ammoTempMuzzleVelocityShifts"); +}; +_muzzleVelocityTable = []; +_barrelLengthTable = []; +if (isArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_muzzleVelocities")) then { + _muzzleVelocityTable = getArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_muzzleVelocities"); +}; +if (isArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_barrelLengths")) then { + _barrelLengthTable = getArray(configFile >> "CfgAmmo" >> _ammo >> "ACE_barrelLengths"); +}; + +_result = [_airFriction, _caliber, _bulletLength, _bulletMass, _transonicStabilityCoef, _dragModel, _ballisticCoefficients, _velocityBoundaries, _atmosphereModel, _ammoTempMuzzleVelocityShifts, _muzzleVelocityTable, _barrelLengthTable]; + +uiNamespace setVariable [format[QGVAR(%1), _ammo], _result]; + +_result diff --git a/addons/advanced_ballistics/functions/fnc_readWeaponDataFromConfig.sqf b/addons/advanced_ballistics/functions/fnc_readWeaponDataFromConfig.sqf new file mode 100644 index 0000000000..cbf8731336 --- /dev/null +++ b/addons/advanced_ballistics/functions/fnc_readWeaponDataFromConfig.sqf @@ -0,0 +1,34 @@ +/* + * Author: Ruthberg + * + * Reads the weapon class config and updates the config cache + * + * Arguments: + * 0: ammo - classname + * + * Return Value: + * 0: [_barrelTwist, _twistDirection, _barrelLength] + * + * Return value: + * None + */ +#include "script_component.hpp" + +private ["_weapon", "_barrelTwist", "_twistDirection", "_barrelLength", "_result"]; +_weapon = _this; + +_barrelTwist = getNumber(configFile >> "CfgWeapons" >> _weapon >> "ACE_barrelTwist"); +_twistDirection = 1; +if (isNumber(configFile >> "CfgWeapons" >> _weapon >> "ACE_twistDirection")) then { + _twistDirection = getNumber(configFile >> "CfgWeapons" >> _weapon >> "ACE_twistDirection"); + if (_twistDirection != -1 && _twistDirection != 0 && _twistDirection != 1) then { + _twistDirection = 1; + }; +}; +_barrelLength = getNumber(configFile >> "CfgWeapons" >> _weapon >> "ACE_barrelLength"); + +_result = [_barrelTwist, _twistDirection, _barrelLength]; + +uiNamespace setVariable [format[QGVAR(%1), _weapon], _result]; + +_result diff --git a/addons/advanced_ballistics/script_component.hpp b/addons/advanced_ballistics/script_component.hpp index 3334bb3207..757330a5d0 100644 --- a/addons/advanced_ballistics/script_component.hpp +++ b/addons/advanced_ballistics/script_component.hpp @@ -21,6 +21,5 @@ #define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058 #define STD_AIR_DENSITY_ICAO 1.22498 #define STD_AIR_DENSITY_ASM 1.20885 -#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h)) #define EXTENSION_REQUIRED_VERSION "1.0" diff --git a/addons/advanced_ballistics/stringtable.xml b/addons/advanced_ballistics/stringtable.xml index 0de8071754..565e4bd801 100644 --- a/addons/advanced_ballistics/stringtable.xml +++ b/addons/advanced_ballistics/stringtable.xml @@ -25,5 +25,85 @@ Zobrazit úhloměr Mostrar Transferidor + + Advanced Ballistics + Zaawansowana balistyka + + + Advanced Ballistics + Zaawansowana balistyka + + + Enables advanced ballistics + Aktywuje zaawansowaną balistykę + + + Always Enabled For Snipers + Zawsze akt. dla snajp. + + + Always enables advanced ballistics when high power optics are used + Aktywuje zaawansowaną balistykę zawsze, kiedy używana jest optyka + + + Disabled In FullAuto Mode + Wył. podczas ognia auto. + + + Disables the advanced ballistics during full auto fire + Dezaktywuje zaawansowaną balistykę podczas ognia automatycznego + + + Disabled For Non Local Players + Wyłącz dla nielok. graczy + + + Disables the advanced ballistics for bullets coming from other players (enable this if you encounter frame drops during heavy firefights in multiplayer) + Dezaktywuje zaawansowaną balistykę dla pocisków pochodzących od innych graczy(aktywuj tą opcję jeżeli odczuwasz spadki FPS podczas sporych strzelanin w MP) + + + Enable Ammo Temperature Simulation + Symulacja temp. amunicji + + + Muzzle velocity varies with ammo temperature + Prędkość wylotowa pocisku jest zależna od temperatury amunicji + + + Enable Barrel Length Simulation + Symulacja długości lufy + + + Muzzle velocity varies with barrel length + Prędkość wylotowa pocisku jest zależna od długości lufy + + + Enable Bullet Trace Effect + Efekt smugi pocisku + + + Enables a bullet trace effect to high caliber bullets (only visible when looking through high power optics) + Aktywuje efekt smugi pocisku dla pocisków wysokokalibrowych (widoczne tylko podczas patrzenia przez optykę) + + + Simulation Interval + Interwał symulacji + + + Defines the interval between every calculation step + Określa interwał pomiędzy każdym krokiem kalkulacji + + + Simulation Radius + Zasięg symulacji + + + Defines the radius around the player (in meters) at which advanced ballistics are applied to projectiles + Określa obszar naokoło gracza (w metrach), na którym zaawansowana balistyka jest aplikowana dla pocisków + + + + Moduł ten pozwala aktywować zaawansowaną balistykę biorącą przy obliczeniach trajektorii lotu pocisku pod uwagę takie rzeczy jak temperatura powietrza, ciśnienie atmosferyczne, wilgotność powietrza, siły Coriolisa i Eotvosa, grawitację a także broń z jakiej wykonywany jest strzał oraz rodzaj amunicji. Wszystko to sprowadza się na bardzo dokładne odwzorowanie balistyki. + \ No newline at end of file diff --git a/addons/aircraft/Heli_Attack_01_base_F.hpp b/addons/aircraft/Heli_Attack_01_base_F.hpp index 14ca7ef7cd..26a4605910 100644 --- a/addons/aircraft/Heli_Attack_01_base_F.hpp +++ b/addons/aircraft/Heli_Attack_01_base_F.hpp @@ -891,9 +891,12 @@ class Heli_Attack_01_base_F: Helicopter_Base_F { class OpticsIn { - class WideUnstabalized - { - opticsDisplayName = "WU"; + delete Narrow; + delete Medium; + delete Wide; + + class ACE_WideUnstabilized { + opticsDisplayName = "W NS"; initAngleX = 0; minAngleX = -35; maxAngleX = 10; @@ -910,8 +913,7 @@ class Heli_Attack_01_base_F: Helicopter_Base_F { horizontallyStabilized = 1; gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_wide_F"; }; - class Wide - { + class ACE_Wide: ACE_WideUnstabilized { opticsDisplayName = "W"; initAngleX = 0; minAngleX = -35; @@ -929,8 +931,7 @@ class Heli_Attack_01_base_F: Helicopter_Base_F { horizontallyStabilized = 1; gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_wide_F"; }; - class Medium: Wide - { + class ACE_Medium: ACE_Wide { opticsDisplayName = "M"; initFov = 0.093; minFov = 0.093; @@ -940,8 +941,7 @@ class Heli_Attack_01_base_F: Helicopter_Base_F { horizontallyStabilized = 1; gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_medium_F"; }; - class Narrow: Wide - { + class ACE_Narrow: ACE_Wide { opticsDisplayName = "N"; initFov = 0.029; minFov = 0.029; @@ -952,8 +952,7 @@ class Heli_Attack_01_base_F: Helicopter_Base_F { gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_narrow_F"; }; - class Narrower: Wide - { + class ACE_Narrower: ACE_Wide { opticsDisplayName = "Z"; initFov = 0.01; minFov = 0.01; diff --git a/addons/atragmx/$PBOPREFIX$ b/addons/atragmx/$PBOPREFIX$ new file mode 100644 index 0000000000..c42e89e22d --- /dev/null +++ b/addons/atragmx/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\atragmx \ No newline at end of file diff --git a/addons/atragmx/functions/fnc_parse_input.sqf b/addons/atragmx/functions/fnc_parse_input.sqf index 2534c2a319..31f38f63c9 100644 --- a/addons/atragmx/functions/fnc_parse_input.sqf +++ b/addons/atragmx/functions/fnc_parse_input.sqf @@ -95,36 +95,6 @@ if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) t GVAR(workingMemory) set [1, _muzzleVelocity]; GVAR(workingMemory) set [2, _zeroRange]; -private ["_elevationCur", "_windageCur", "_clickSize", "_clickNumber", "_clickInterval"]; -_elevationCur = GVAR(workingMemory) select 10; -_windageCur = GVAR(workingMemory) select 11; - -switch (GVAR(currentScopeUnit)) do { - case 0: { - _elevationCur = _elevationCur * 3.38; - _windageCur = _windageCur * 3.38; - }; - case 2: { - _elevationCur = _elevationCur / 1.047; - _windageCur = _windageCur / 1.047; - }; - case 3: { - switch (GVAR(workingMemory) select 7) do { - case 0: { _clickSize = 1; }; - case 1: { _clickSize = 1 / 1.047; }; - case 2: { _clickSize = 3.38; }; - }; - _clickNumber = GVAR(workingMemory) select 8; - _clickInterval = _clickSize / _clickNumber; - - _elevationCur = Round(_elevationCur / _clickInterval); - _windageCur = Round(_windageCur / _clickInterval); - }; -}; - -GVAR(workingMemory) set [10, _elevationCur]; -GVAR(workingMemory) set [11, _windageCur]; - [] call FUNC(update_gun); [] call FUNC(update_gun_ammo_data); [] call FUNC(update_atmosphere); diff --git a/addons/ballistics/CfgVehicles.hpp b/addons/ballistics/CfgVehicles.hpp index 82e7fef5e3..0ad697d91e 100644 --- a/addons/ballistics/CfgVehicles.hpp +++ b/addons/ballistics/CfgVehicles.hpp @@ -190,7 +190,7 @@ class CfgVehicles { class ACE_Box_Ammo: NATO_Box_Base { scope = 2; accuracy = 1000; - displayName = "[ACE] Ammo Supply Crate"; + displayName = "$STR_ACE_AmmoSupplyCrate_DisplayName"; model = "\A3\weapons_F\AmmoBoxes\AmmoBox_F"; author = "$STR_ACE_Common_ACETeam"; class TransportMagazines { diff --git a/addons/ballistics/CfgWeapons.hpp b/addons/ballistics/CfgWeapons.hpp index 34c18a90dd..571112697a 100644 --- a/addons/ballistics/CfgWeapons.hpp +++ b/addons/ballistics/CfgWeapons.hpp @@ -1,16 +1,13 @@ +class Single; +class Burst; +class FullAuto; class Mode_SemiAuto; +class Mode_Burst; class Mode_FullAuto; class CfgWeapons { - class DMR_02_base_F; - class DMR_03_base_F; - class DMR_04_base_F; - class DMR_05_base_F; - class DMR_06_base_F; - class GM6_base_F; class LMG_RCWS; - class LRR_base_F; class MGun; class MGunCore; class MMG_01_base_F; @@ -22,19 +19,83 @@ class CfgWeapons { /* Long Rifles */ + class GM6_base_F: Rifle_Long_Base_F { + class Single: Mode_SemiAuto { + dispersion = 0.00029; // radians. Equal to 1.00 MOA. + }; + }; + + class LRR_base_F: Rifle_Long_Base_F { + class Single: Mode_SemiAuto { + dispersion = 0.00020; // radians. Equal to 0.70 MOA. + }; + }; + + class DMR_06_base_F: Rifle_Long_Base_F { + class Single: Mode_SemiAuto { + dispersion = 0.00029; // radians. Equal to 1.00 MOA. + }; + + class FullAuto: Mode_FullAuto { + dispersion = 0.00029; // radians. Equal to 1.00 MOA. + }; + }; + + class DMR_05_base_F: Rifle_Long_Base_F { + class Single: Mode_SemiAuto { + dispersion = 0.00029; // radians. Equal to 1.00 MOA. + }; + + class FullAuto: Mode_FullAuto { + dispersion = 0.00029; // radians. Equal to 1.00 MOA. + }; + }; + + class DMR_04_base_F: Rifle_Long_Base_F { + class Single: Mode_SemiAuto { + dispersion = 0.00029; // radians. Equal to 1.00 MOA. + }; + }; + + class DMR_03_base_F: Rifle_Long_Base_F { + class Single: Mode_SemiAuto { + dispersion = 0.00032; // radians. Equal to 1.10 MOA. + }; + + class FullAuto: Mode_FullAuto { + dispersion = 0.00032; // radians. Equal to 1.10 MOA. + }; + }; + + class DMR_02_base_F: Rifle_Long_Base_F { + class Single: Mode_SemiAuto { + dispersion = 0.000262; // radians. Equal to 0.90 MOA. + }; + }; + + class DMR_01_base_F: Rifle_Long_Base_F { + class WeaponSlotsInfo: WeaponSlotsInfo { + class MuzzleSlot: MuzzleSlot { + compatibleItems[] += {"ACE_muzzle_mzls_B"}; + }; + }; + class Single: Mode_SemiAuto { + dispersion = 0.0004; // radians. Equal to 1.375 MOA. + }; + }; + class EBR_base_F: Rifle_Long_Base_F { class WeaponSlotsInfo: WeaponSlotsInfo { class MuzzleSlot: MuzzleSlot { compatibleItems[] += {"ACE_muzzle_mzls_B"}; }; }; - }; - - class DMR_01_base_F: Rifle_Long_Base_F { - class WeaponSlotsInfo: WeaponSlotsInfo { - class MuzzleSlot: MuzzleSlot { - compatibleItems[] += {"ACE_muzzle_mzls_B"}; - }; + class Single: Mode_SemiAuto { + dispersion = 0.00029; // radians. Equal to 1.00 MOA. + }; + + class FullAuto: Mode_FullAuto { + dispersion = 0.00029; // radians. Equal to 1.00 MOA. }; }; @@ -46,14 +107,6 @@ class CfgWeapons { compatibleItems[] += {"ACE_muzzle_mzls_H"}; }; }; - class Single: Mode_SemiAuto { - dispersion = 0.000800; // radians. Equal to 2.75 MOA. - // Based on widely cited 2 MOA figure for new 5.56 ACR. - }; - - class FullAuto: Mode_FullAuto { - dispersion = 0.00147; // radians. Equal to 5.1 MOA. - }; }; class arifle_MX_SW_F: arifle_MX_Base_F { magazines[] = { @@ -74,14 +127,6 @@ class CfgWeapons { compatibleItems[] = {"muzzle_snds_H","muzzle_snds_H_SW","ACE_muzzle_mzls_H"}; }; }; - class Single: Mode_SemiAuto { - dispersion = 0.000800; // radians. Equal to 2.75 MOA. - // Based on widely cited 2 MOA figure for new 5.56 ACR. - }; - - class manual: FullAuto { - dispersion = 0.00147; // radians. Equal to 5.1 MOA. - }; }; class arifle_MXM_F: arifle_MX_Base_F { magazines[] = { @@ -95,12 +140,11 @@ class CfgWeapons { ACE_barrelTwist=228.6; ACE_barrelLength=457.2; class Single: Single { - dispersion = 0.00029; // radians. Equal to 1 MOA. - // 6.5mm is easily capable of this in a half-tuned rifle. + dispersion = 0.000436; // radians. Equal to 1.50 MOA. }; class FullAuto: FullAuto { - dispersion = 0.000800; // radians. Equal to 2.75 MOA. + dispersion = 0.000436; // radians. Equal to 1.50 MOA. }; }; @@ -112,15 +156,6 @@ class CfgWeapons { compatibleItems[] += {"ACE_muzzle_mzls_H"}; }; }; - class Single: Mode_SemiAuto { - dispersion = 0.000800; // radians. Equal to 2.75 MOA. - // Based on widely cited 2 MOA figure for new 5.56 ACR? - // Use your imagination for fictional weapons! - }; - - class FullAuto: Mode_FullAuto { - dispersion = 0.00147; // radians. Equal to 5.1 MOA. - }; }; @@ -139,13 +174,6 @@ class CfgWeapons { }; ACE_barrelTwist=177.8; ACE_barrelLength=317.5; - class manual: Mode_FullAuto { - dispersion = 0.00175; // radians. Equal to 6 MOA. - }; - - class Single: manual { - dispersion = 0.00175; // radians. Equal to 6 MOA. - }; }; class LMG_Zafir_F: Rifle_Long_Base_F { initSpeed = -1.0; @@ -156,13 +184,6 @@ class CfgWeapons { }; ACE_barrelTwist=304.8; ACE_barrelLength=459.74; - class FullAuto: Mode_FullAuto { - dispersion = 0.00175; // radians. Equal to 6 MOA. - }; - - class Single: Mode_SemiAuto { - dispersion = 0.00175; // radians. Equal to 6 MOA. - }; }; @@ -173,13 +194,6 @@ class CfgWeapons { compatibleItems[] += {"ACE_muzzle_mzls_L"}; }; }; - class Single: Mode_SemiAuto { - dispersion = 0.000727; // radians. Equal to 2.5 MOA, about the limit of mass-produced M855. - }; - - class FullAuto: Mode_FullAuto { - dispersion = 0.00147; // radians. Equal to 5.1 MOA. - }; }; class mk20_base_F: Rifle_Base_F { class WeaponSlotsInfo: WeaponSlotsInfo { @@ -187,14 +201,6 @@ class CfgWeapons { compatibleItems[] += {"ACE_muzzle_mzls_L"}; }; }; - class Single: Mode_SemiAuto { - dispersion = 0.0008727; // radians. Equal to 3 MOA, about the limit of mass-produced M855 plus - // some extra for these worn out Greek Army service rifles. - }; - - class FullAuto: Mode_FullAuto { - dispersion = 0.00147; // radians. Equal to 5.1 MOA. - }; }; @@ -202,12 +208,15 @@ class CfgWeapons { class SDAR_base_F: Rifle_Base_F { initSpeed = -0.989; class Single: Mode_SemiAuto { - dispersion = 0.0008727; // radians. Equal to 3 MOA, about the limit of mass-produced M855 plus - // some extra because Kel-Tec. + dispersion = 0.0008727; // radians. Equal to 3 MOA. }; + class Burst: Mode_Burst { + dispersion = 0.0008727; // radians. Equal to 3 MOA. + }; + class FullAuto: Mode_FullAuto { - dispersion = 0.00147; // radians. Equal to 5.1 MOA. + dispersion = 0.0008727; // radians. Equal to 3 MOA. }; }; class pdw2000_base_F: Rifle_Base_F { @@ -642,11 +651,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; @@ -675,11 +684,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; @@ -708,11 +717,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; @@ -741,11 +750,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; @@ -774,11 +783,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; @@ -807,11 +816,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; @@ -840,11 +849,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; @@ -873,11 +882,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; @@ -906,11 +915,11 @@ class CfgWeapons { }; class MuzzleCoef { - dispersionCoef = "0.8f"; + dispersionCoef = "0.95f"; artilleryDispersionCoef = "1.0f"; fireLightCoef = "0.5f"; - recoilCoef = "1.0f"; - recoilProneCoef = "1.0f"; + recoilCoef = "0.95f"; + recoilProneCoef = "0.95f"; minRangeCoef = "1.0f"; minRangeProbabCoef = "1.0f"; midRangeCoef = "1.0f"; diff --git a/addons/ballistics/README.md b/addons/ballistics/README.md index 2bf158cebc..ac727f83c6 100644 --- a/addons/ballistics/README.md +++ b/addons/ballistics/README.md @@ -1,12 +1,12 @@ ace_ballistics ============== -Changes to weapon and ammunition values. - +Changes to weapon, magazine and ammunition values. ## Maintainers The people responsible for merging changes to this component or answering potential questions. +- [Ruthberg] (http://github.com/Ulteq) - [KoffeinFlummi](https://github.com/KoffeinFlummi) - [commy2](https://github.com/commy2) diff --git a/addons/ballistics/stringtable.xml b/addons/ballistics/stringtable.xml index 7c6d9c85ad..85ac44b4de 100644 --- a/addons/ballistics/stringtable.xml +++ b/addons/ballistics/stringtable.xml @@ -1592,5 +1592,9 @@ Calibre: 12.7x99mm (AMAX)<br/>Cartuchos: 5 Kaliber: 12,7x99mm (AMAX)<br />Lövedékek: 5 + + [ACE] Ammo Supply Crate + [ACE] Skrzynka z amunicją + - \ No newline at end of file + diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index 1e2eb3f201..91c47824fd 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -161,7 +161,7 @@ class CfgVehicles { class GVAR(ModuleSurrender): Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Make Unit Surrender"; + displayName = "$STR_ACE_Captives_ModuleSurrender_DisplayName"; //Make Unit Surrender function = QUOTE(DFUNC(moduleSurrender)); scope = 2; //show in editor scopeCurator = 2; //show in zeus @@ -172,8 +172,8 @@ class CfgVehicles { functionPriority = 0; class Arguments {}; class ModuleDescription: ModuleDescription { - description = "Sync a unit to make them surrender.
Source: ace_captives"; + description = "$STR_ACE_Captives_ModuleSurrender_Description"; //Sync a unit to make them surrender.
Source: ace_captives sync[] = {"AnyAI"}; }; }; -}; +}; \ No newline at end of file diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index f91f24025e..da2192d3d6 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -11,7 +11,7 @@ if (isServer) then { _escortedUnit = _disconnectedPlayer getVariable [QGVAR(escortedUnit), objNull]; if ((!isNull _escortedUnit) && {(attachedTo _escortedUnit) == _disconnectedPlayer}) then { detach _escortedUnit; - systemChat "debug: DC detach"; + //systemChat "debug: DC detach"; }; if (_disconnectedPlayer getVariable [QGVAR(isEscorting), false]) then { _disconnectedPlayer setVariable [QGVAR(isEscorting), false, true]; diff --git a/addons/captives/functions/fnc_canSurrender.sqf b/addons/captives/functions/fnc_canSurrender.sqf index 3b810a0c5c..9ba7cf6de0 100644 --- a/addons/captives/functions/fnc_canSurrender.sqf +++ b/addons/captives/functions/fnc_canSurrender.sqf @@ -1,6 +1,6 @@ /* * Author: PabstMirror - * Checks the conditions for being able to surrender + * Checks the conditions for being able switch surrender states * * Arguments: * 0: caller (player) @@ -18,14 +18,14 @@ PARAMS_2(_unit,_newSurrenderState); -if (currentWeapon _unit != "") exitWith {false}; - private "_returnValue"; _returnValue = if (_newSurrenderState) then { - !(_unit getVariable [QGVAR(isSurrendering), false]); //Not currently surrendering + //no weapon equiped AND not currently surrendering and + (currentWeapon _unit == "") && {!(_unit getVariable [QGVAR(isSurrendering), false])} } else { - (_unit getVariable [QGVAR(isSurrendering), false]); //is Surrendering + //is Surrendering + (_unit getVariable [QGVAR(isSurrendering), false]) }; _returnValue diff --git a/addons/captives/stringtable.xml b/addons/captives/stringtable.xml index def173c55b..07cf780e19 100644 --- a/addons/captives/stringtable.xml +++ b/addons/captives/stringtable.xml @@ -193,5 +193,13 @@ Semmi sincs az egér alatt Nessuna selezione + + Make Unit Surrender + Poddaj się! + + + Sync a unit to make them surrender.<br />Source: ace_captives + Zsynchronizuj z jednostką aby sprawić by się poddała<br />Źródło: ace_captives + diff --git a/addons/common/CfgVehicles.hpp b/addons/common/CfgVehicles.hpp index 5a00c038e7..1adf622494 100644 --- a/addons/common/CfgVehicles.hpp +++ b/addons/common/CfgVehicles.hpp @@ -25,72 +25,72 @@ class CfgVehicles { // += needs a non inherited entry in that class, otherwise it simply overwrites //#include - class Module_F; - class ACE_ModuleCheckPBOs: Module_F { + class Logic; + class Module_F: Logic { + class ModuleDescription {}; + }; + class ACE_ModuleCheckPBOs: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Check PBOs"; + displayName = "$STR_ACE_Common_CheckPBO_DisplayName"; function = QFUNC(moduleCheckPBOs); scope = 2; isGlobal = 1; icon = QUOTE(PATHTOF(UI\Icon_Module_CheckPBO_ca.paa)); class Arguments { class Action { - displayName = "Action"; - description = "What to do with people who do not have the right PBOs?"; + displayName = "$STR_ACE_Common_CheckPBO_Action_DisplayName"; + description = "$STR_ACE_Common_CheckPBO_Action_Description"; class values { class WarnOnce { default = 1; - name = "Warn once"; + name = "$STR_ACE_Common_CheckPBO_Action_WarnOnce"; value = 0; }; class Warn { - name = "Warn (permanent)"; + name = "$STR_ACE_Common_CheckPBO_Action_WarnPerm"; value = 1; }; class Kick { - name = "Kick"; + name = "$STR_ACE_Common_CheckPBO_Action_Kick"; value = 2; }; }; }; class CheckAll { - displayName = "Check all addons"; - description = "Check all addons instead of only those of ACE?"; + displayName = "$STR_ACE_Common_CheckPBO_CheckAll_DisplayName"; + description = "$STR_ACE_Common_CheckPBO_CheckAll_Description"; typeName = "BOOL"; - class values { - class WarnOnce { - default = 1; - name = "No"; - value = 0; - }; - class Warn { - name = "Yes"; - value = 1; - }; - }; + defaultValue = 0; }; class Whitelist { - displayName = "Whitelist"; - description = "What addons are allowed regardless?"; + displayName = "$STR_ACE_Common_CheckPBO_Whitelist_DisplayName"; + description = "$STR_ACE_Common_CheckPBO_Whitelist_Description"; typeName = "STRING"; class values { default = "[]"; }; }; }; + class ModuleDescription: ModuleDescription { + description = "$STR_ACE_Common_CheckPBO_Description"; + }; }; class ACE_ModuleLSDVehicles: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "LSD Vehicles"; + displayName = "$STR_ACE_Common_LSDVehicles_DisplayName"; function = "ACE_Common_fnc_moduleLSDVehicles"; scope = 2; icon = QUOTE(PATHTOF(UI\Icon_Module_LSD_ca.paa)); isGlobal = 1; class Arguments { }; + class ModuleDescription: ModuleDescription { + description = "$STR_ACE_Common_LSDVehicles_Description"; + sync[] = {"AnyVehicle"}; + }; }; class Box_NATO_Support_F; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 4bedd36513..23d26f7c5f 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -185,6 +185,7 @@ PREP(unmuteUnit); PREP(useItem); PREP(useMagazine); PREP(waitAndExecute); +PREP(waveHeightAt); PREP(translateToWeaponSpace); PREP(translateToModelSpace); @@ -314,6 +315,16 @@ if (hasInterface) then { }, 0, []] call cba_fnc_addPerFrameHandler; }; +// Time handling +ACE_time = diag_tickTime; +ACE_realTime = diag_tickTime; +ACE_virtualTime = diag_tickTime; +ACE_diagTime = diag_tickTime; +ACE_gameTime = time; + +PREP(timePFH); +[FUNC(timePFH), 0, []] call cba_fnc_addPerFrameHandler; + // Init toHex [0] call FUNC(toHex); diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 27647f8d00..3f1e5a6308 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -101,7 +101,7 @@ class ACE_Settings { isClientSettable = 1; displayName = "$STR_ACE_Common_SettingFeedbackIconsName"; description = "$STR_ACE_Common_SettingFeedbackIconsDesc"; - values[] = {"Hide", "Top right, downwards", "Top right, to the left", "Top left, downwards", "Top left, to the right"}; + values[] = {"$STR_ACE_Common_Hide", "$STR_ACE_Common_TopRightDown", "$STR_ACE_Common_TopRightLeft", "$STR_ACE_Common_TopLeftDown", "$STR_ACE_Common_TopLeftRight"}; }; class GVAR(SettingProgressBarLocation) { value = 0; @@ -110,7 +110,7 @@ class ACE_Settings { isClientSettable = 1; displayName = "$STR_ACE_Common_SettingProgressbarLocationName"; description = "$STR_ACE_Common_SettingProgressbarLocationDesc"; - values[] = {"Top", "Bottom"}; + values[] = {"$STR_ACE_Common_Top", "$STR_ACE_Common_Bottom"}; }; class GVAR(displayTextColor) { value[] = {0,0,0,0.1}; diff --git a/addons/common/functions/fnc_checkFiles.sqf b/addons/common/functions/fnc_checkFiles.sqf index b0ea8a5200..631329ecee 100644 --- a/addons/common/functions/fnc_checkFiles.sqf +++ b/addons/common/functions/fnc_checkFiles.sqf @@ -49,6 +49,9 @@ _addons = [_addons, {_this find "ace_" == 0}] call FUNC(filter); if (hasInterface) then { ["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage); }; + } else { + // Print the current extension version + diag_log text format ["[ACE] Extension version: %1: %2", _x, (_x callExtension "version")]; }; } forEach getArray (configFile >> "ACE_Extensions" >> "extensions"); diff --git a/addons/common/functions/fnc_timePFH.sqf b/addons/common/functions/fnc_timePFH.sqf new file mode 100644 index 0000000000..ee8fe4a9bb --- /dev/null +++ b/addons/common/functions/fnc_timePFH.sqf @@ -0,0 +1,25 @@ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +private["_lastTime", "_lastRealTime", "_lastVirtualTime", "_lastGameTime", "_delta"]; + +_lastRealTime = ACE_realTime; +_lastGameTime = ACE_gameTime; + +ACE_gameTime = time; +ACE_diagTime = diag_tickTime; + +_delta = ACE_diagTime - _lastRealTime; +if(ACE_gameTime <= _lastGameTime) then { + ACE_paused = true; + // Game is paused or not running + ACE_pausedTime = ACE_pausedTime + _delta; + ACE_virtualPausedTime = ACE_pausedTime + (_delta * accTime); +} else { + ACE_paused = false; + // Time is updating + ACE_realTime = ACE_realTime + _delta; + ACE_virtualTime = ACE_virtualTime + (_delta * accTime); + ACE_time = ACE_virtualTime; +}; + diff --git a/addons/common/functions/fnc_waveHeightAt.sqf b/addons/common/functions/fnc_waveHeightAt.sqf new file mode 100644 index 0000000000..e05e4219b7 --- /dev/null +++ b/addons/common/functions/fnc_waveHeightAt.sqf @@ -0,0 +1,20 @@ +/* + * Author: jaynus + * + * Gets the wave height at a specific location. Uses a logic, so may be performance iffy + * + * Arguments: + * 0: Position ASL to get height at + * + * Return Value: + * Wave height in meters + * + */ +#include "script_component.hpp" + +if(isNil QGVAR(waveHeightLogic)) then { + GVAR(waveHeightLogic) = "Logic" createVehicleLocal [0,0,0]; +}; +GVAR(waveHeightLogic) setPosASL (_this select 0); + +(((getPosASLW GVAR(waveHeightLogic)) select 2) - ((getPosASL GVAR(waveHeightLogic)) select 2)) \ No newline at end of file diff --git a/addons/common/scripts/Version/checkVersionNumber.sqf b/addons/common/scripts/Version/checkVersionNumber.sqf index 1bc002153c..74f130596a 100644 --- a/addons/common/scripts/Version/checkVersionNumber.sqf +++ b/addons/common/scripts/Version/checkVersionNumber.sqf @@ -47,7 +47,7 @@ if (!isServer) then { _index = _files find _x; if (_index == -1) then { - if (_x != "ace_serverconfig") then {_missingAddons pushBack _x;}; + if (_x != "ace_server") then {_missingAddons pushBack _x;}; } else { _clientVersion = _versions select _index; diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 0f05274109..230acd926e 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -470,6 +470,58 @@ Une banane est un fruit qui, d'un point de vue botanique, fait partie du groupe des baies. Produite par plusieurs sortes de grandes plantes à fleurs herbacées du type Musa. A banana é uma fruta comestível, botanicamente uma baga, produzida por vários tipos de plantas herbáceas grandes do genero Musa. + + Check PBOs + Sprawdzaj PBO + + + + Sprawdzaj spójność addonów z serwerem + + + Action + Akcja + + + What to do with people who do not have the right PBOs? + Co zrobić z graczami, którzy nie mają właściwych PBO? + + + Warn once + Ostrzeż raz + + + Warn (permanent) + Ostrzeżenie (permanentne) + + + Kick + Kick + + + Check all addons + Sprawdź wsz. addony + + + Check all addons instead of only those of ACE? + Sprawdzaj wszystkie addony czy tylko te z ACE? + + + Whitelist + Biała lista + + + What addons are allowed regardless? + Jakie addony są dozwolone? + + + LSD Vehicles + Pojazdy LSD + + + Adds LSD effect to synchronized vehicle + Dodaje efekt LSD pod zsynchronizowany pojazd + Toggle Handheld Device @@ -480,4 +532,4 @@ Cycle Handheld Devices - \ No newline at end of file + diff --git a/addons/disarming/functions/fnc_disarmDropItems.sqf b/addons/disarming/functions/fnc_disarmDropItems.sqf index 2cb3e89b5d..bc9abbf127 100644 --- a/addons/disarming/functions/fnc_disarmDropItems.sqf +++ b/addons/disarming/functions/fnc_disarmDropItems.sqf @@ -79,7 +79,7 @@ _holderMagazinesStart = magazinesAmmoCargo _holder; { EXPLODE_2_PVT(_x,_xClassname,_xAmmo); - if ((_xClassname in _listOfItemsToRemove) && {!(_xClassname in UNIQUE_MAGAZINES)}) then { + if ((_xClassname in _listOfItemsToRemove) && {(getNumber (configFile >> "CfgMagazines" >> _xClassname >> "ACE_isUnique")) == 0}) then { _holder addMagazineAmmoCargo [_xClassname, 1, _xAmmo]; _target removeMagazine _xClassname; }; @@ -89,7 +89,7 @@ _targetMagazinesEnd = magazinesAmmo _target; _holderMagazinesEnd = magazinesAmmoCargo _holder; //Verify Mags dropped from unit: -if ( ({((_x select 0) in _listOfItemsToRemove) && {!((_x select 0) in UNIQUE_MAGAZINES)}} count _targetMagazinesEnd) != 0) exitWith { +if (({((_x select 0) in _listOfItemsToRemove) && {(getNumber (configFile >> "CfgMagazines" >> (_x select 0) >> "ACE_isUnique")) == 0}} count _targetMagazinesEnd) != 0) exitWith { _holder setVariable [QGVAR(holderInUse), false]; [_caller, _target, "Debug: Didn't Remove Magazines"] call FUNC(eventTargetFinish); }; @@ -102,7 +102,7 @@ if (!([_targetMagazinesStart, _targetMagazinesEnd, _holderMagazinesStart, _holde //Remove Items, Assigned Items and NVG _holderItemsStart = getitemCargo _holder; -_targetItemsStart = (assignedItems _target) + (items _target); +_targetItemsStart = (assignedItems _target) + (items _target) - (weapons _target); if ((headgear _target) != "") then {_targetItemsStart pushBack (headgear _target);}; if ((goggles _target) != "") then {_targetItemsStart pushBack (goggles _target);}; @@ -132,7 +132,7 @@ _addToCrateCount = []; } forEach _addToCrateClassnames; _holderItemsEnd = getitemCargo _holder; -_targetItemsEnd = (assignedItems _target) + (items _target); +_targetItemsEnd = (assignedItems _target) + (items _target) - (weapons _target); if ((headgear _target) != "") then {_targetItemsEnd pushBack (headgear _target);}; if ((goggles _target) != "") then {_targetItemsEnd pushBack (goggles _target);}; @@ -146,6 +146,16 @@ if ((([_holderItemsEnd select 1] call _fncSumArray) - ([_holderItemsStart select [_caller, _target, "Debug: Items Not Added to Holder"] call FUNC(eventTargetFinish); }; +//Script drop uniforms/vest if empty +if (((uniform _target) != "") && {(uniform _target) in _listOfItemsToRemove} && {(uniformItems _target) isEqualTo []}) then { + _holder addItemCargoGlobal [(uniform _target), 1]; + removeUniform _target; +}; +if (((vest _target) != "") && {(vest _target) in _listOfItemsToRemove} && {(vestItems _target) isEqualTo []}) then { + _holder addItemCargoGlobal [(vest _target), 1]; + removeVest _target; +}; + //If holder is still empty, it will be 'garbage collected' while we wait for the drop 'action' to take place //So add a dummy item and just remove at the end diff --git a/addons/disarming/functions/fnc_getAllGearUnit.sqf b/addons/disarming/functions/fnc_getAllGearUnit.sqf index a319c006ee..99d4b2d7f2 100644 --- a/addons/disarming/functions/fnc_getAllGearUnit.sqf +++ b/addons/disarming/functions/fnc_getAllGearUnit.sqf @@ -19,7 +19,7 @@ PARAMS_1(_target); private ["_allItems", "_classnamesCount", "_index", "_uniqueClassnames"]; -_allItems = ((weapons _target) + (magazines _target) + (items _target) + (assignedItems _target)); +_allItems = (((items _target) + (assignedItems _target)) - (weapons _target)) + (weapons _target) + (magazines _target); if ((backpack _target) != "") then { _allItems pushBack (backpack _target); diff --git a/addons/disarming/functions/fnc_showItemsInListbox.sqf b/addons/disarming/functions/fnc_showItemsInListbox.sqf index 5c809de4a2..b36e53e820 100644 --- a/addons/disarming/functions/fnc_showItemsInListbox.sqf +++ b/addons/disarming/functions/fnc_showItemsInListbox.sqf @@ -28,7 +28,7 @@ private ["_classname", "_count", "_displayName", "_picture"]; _classname = _x; _count = (_itemsCountArray select 1) select _forEachIndex; - if (_classname != DUMMY_ITEM) then { //Don't show the dummy potato + if ((_classname != DUMMY_ITEM) && {_classname != "ACE_FakePrimaryWeapon"}) then { //Don't show the dummy potato or fake weapon switch (true) do { case (isClass (configFile >> "CfgWeapons" >> _classname)): { @@ -53,8 +53,8 @@ private ["_classname", "_count", "_displayName", "_picture"]; }; _listBoxCtrl lbAdd format ["%1", _displayName]; - _listBoxCtrl lbSetData [_forEachIndex, _classname]; - _listBoxCtrl lbSetPicture [_forEachIndex, _picture]; - _listBoxCtrl lbSetTextRight [_forEachIndex, str _count]; + _listBoxCtrl lbSetData [((lbSize _listBoxCtrl) - 1), _classname]; + _listBoxCtrl lbSetPicture [((lbSize _listBoxCtrl) - 1), _picture]; + _listBoxCtrl lbSetTextRight [((lbSize _listBoxCtrl) - 1), str _count]; }; } forEach (_itemsCountArray select 0); diff --git a/addons/disarming/script_component.hpp b/addons/disarming/script_component.hpp index d9bec366dc..9a1ef9156b 100644 --- a/addons/disarming/script_component.hpp +++ b/addons/disarming/script_component.hpp @@ -13,4 +13,3 @@ #define DISARM_CONTAINER "GroundWeaponHolder" #define DUMMY_ITEM "ACE_DebugPotato" -#define UNIQUE_MAGAZINES ["ACE_key_customKeyMagazine"] \ No newline at end of file diff --git a/addons/dragging/functions/fnc_setCarryable.sqf b/addons/dragging/functions/fnc_setCarryable.sqf index bc6da1f04d..2a10ca4897 100644 --- a/addons/dragging/functions/fnc_setCarryable.sqf +++ b/addons/dragging/functions/fnc_setCarryable.sqf @@ -14,7 +14,8 @@ */ #include "script_component.hpp" -private ["_object", "_enableCarry", "_position", "_direction"]; +private ["_carryAction", "_dropAction", "_object", "_enableCarry", "_position", "_direction"]; +//IGNORE_PRIVATE_WARNING("_player", "_target"); _this resize 4; diff --git a/addons/dragging/functions/fnc_setDraggable.sqf b/addons/dragging/functions/fnc_setDraggable.sqf index da2d0310b4..5a42f4e439 100644 --- a/addons/dragging/functions/fnc_setDraggable.sqf +++ b/addons/dragging/functions/fnc_setDraggable.sqf @@ -14,7 +14,8 @@ */ #include "script_component.hpp" -private ["_object", "_enableDrag", "_position", "_direction"]; +private ["_dragAction", "_dropAction", "_object", "_enableDrag", "_position", "_direction"]; +//IGNORE_PRIVATE_WARNING("_player", "_target"); _this resize 4; diff --git a/addons/explosives/CfgModule.hpp b/addons/explosives/CfgModule.hpp index b4f7b65a83..52f70ea3af 100644 --- a/addons/explosives/CfgModule.hpp +++ b/addons/explosives/CfgModule.hpp @@ -1,44 +1,30 @@ -class Module_F; +class Logic; +class Module_F: Logic { + class ModuleDescription {}; +}; class ACE_ModuleExplosive: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Explosive System"; + displayName = "$STR_ACE_Explosive_Module_DisplayName"; function = QUOTE(FUNC(module)); scope = 2; isGlobal = 1; icon = PATHTOF(UI\Icon_Module_Explosives_ca.paa); class Arguments { class RequireSpecialist { - displayName = "Require specialists?"; - description = "Require explosive specialists to disable explosives? Default: No"; + displayName = "$STR_ACE_Explosive_RequireSpecialist_DisplayName"; + description = "$STR_ACE_Explosive_RequireSpecialist_Description"; typeName = "BOOL"; - class values { - class Yes { - name = "Yes"; - value = 1; - }; - class No { - default = 1; - name = "No"; - value = 0; - }; - }; + defaultValue = 0; }; class PunishNonSpecialists { - displayName = "Punish non-specialists?"; - description = "Increase the time it takes to complete actions for non-specialists? Default: Yes"; + displayName = "$STR_ACE_Explosive_PunishNonSpecialists_DisplayName"; + description = "$STR_ACE_Explosive_PunishNonSpecialists_Description"; typeName = "BOOL"; - class values { - class Yes { - default = 1; - name = "Yes"; - value = 1; - }; - class No { - name = "No"; - value = 0; - }; - }; + defaultValue = 1; }; }; -}; + class ModuleDescription: ModuleDescription { + description = "$STR_ACE_Explosive_Module_Description"; + }; +}; \ No newline at end of file diff --git a/addons/explosives/stringtable.xml b/addons/explosives/stringtable.xml index 9d885c236c..5f5076175d 100644 --- a/addons/explosives/stringtable.xml +++ b/addons/explosives/stringtable.xml @@ -1,4 +1,4 @@ - + @@ -505,5 +505,29 @@ Raccogli Pegar + + Explosive System + System ładunków wybuchowych + + + Require specialists? + Wymagaj specjalistów? + + + Require explosive specialists to disable explosives? Default: No + Wymagać saperów do rozbrajania ładunków wybuchowych? Domyślnie: Nie + + + Punish non-specialists? + Karaj nie-specjalistów? + + + Increase the time it takes to complete actions for non-specialists? Default: Yes + Zwiększyć ilość wymaganego czasu do ukończenia akcji dla nie-specjalistów? Domyślnie: Tak + + + + Moduł ten pozwala dostosować opcje związane z ładunkami wybuchowymi, ich podkładaniem oraz rozbrajaniem. + diff --git a/addons/frag/functions/fnc_doSpall.sqf b/addons/frag/functions/fnc_doSpall.sqf index 990fb80f8d..d2e64dbbfb 100644 --- a/addons/frag/functions/fnc_doSpall.sqf +++ b/addons/frag/functions/fnc_doSpall.sqf @@ -4,11 +4,8 @@ GVAR(traceFrags) = true; #endif // ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA"; -private ["_params", "_initialData", "_hpData", "_roundType", "_round", "_object", "_caliber", "_explosive", - "_idh", "_alive", "_exit", "_vm", "_velocity", "_unitDir", "_oldVelocity", "_curVelocity", "_diff", "_polar", - "_pos", "_spallPos", "_i", "_pos1", "_pos2", "_blah", "_data", "_spallPolar", "_c", "_warn", "_m", "_k", - "_gC", "_shellType", "_fragPower", "_spread", "_spallCount", "_elev", "_dir", "_vel", "_spallFragVect", - "_fragment", "_index", "_hitData", "_fragTypes", "_fragType", "_foundObjects"]; + +private ["_params", "_hitData", "_initialData", "_hpData", "_object", "_foundObjects", "_index", "_foundObjecsts", "_roundType", "_round", "_caliber", "_explosive", "_idh", "_alive", "_exit", "_vm", "_velocity", "_oldVelocity", "_curVelocity", "_diff", "_polar", "_unitDir", "_spallPos", "_pos1", "_i", "_pos2", "_blah", "_data", "_spallPolar", "_warn", "_c", "_m", "_k", "_gC", "_fragPower", "_fragTypes", "_spread", "_spallCount", "_elev", "_dir", "_vel", "_spallFragVect", "_fragType", "_fragment", "_pos"]; _params = _this select 0; [(_this select 1)] call cba_fnc_removePerFrameHandler; diff --git a/addons/frag/functions/fnc_frago.sqf b/addons/frag/functions/fnc_frago.sqf index de7c6986d9..43eb9d5a67 100644 --- a/addons/frag/functions/fnc_frago.sqf +++ b/addons/frag/functions/fnc_frago.sqf @@ -9,13 +9,8 @@ if(!isServer) exitWith { }; // _startTime = diag_tickTime; -private ["_round", "_lastPos", "_lastVel", "_shellType", "_gun", "_fragTypes", "_warn", "_atlPos", "_isArmed", - "_fuseDist", "_indirectHitRange", "_fragRange", "_c", "_m", "_k", "_gC", "_fragPower", "_fragPowerRandom", - "_manObjects", "_objects", "_crew", "_fragCount", "_fragArcs", "_doRandom", "_target", "_boundingBox", - "_targetPos", "_distance", "_add", "_bbX", "_bbY", "_bbZ", "_cubic", "_targetVel", "_baseVec", "_dir", - "_currentCount", "_count", "_vecVar", "_i", "_vec", "_fp", "_vel", "_fragType", "_fragObj", "_randomCount", - "_sectorSize", "_sectorOffset", "_randomDir", "_endTime"]; +private ["_startTime", "_round", "_lastPos", "_lastVel", "_shellType", "_gun", "_fragTypes", "_warn", "_atlPos", "_isArmed", "_fuseDist", "_indirectHitRange", "_fragRange", "_c", "_m", "_k", "_gC", "_fragPower", "_fragPowerRandom", "_manObjects", "_objects", "_crew", "_fragCount", "_fragArcs", "_doRandom", "_boundingBox", "_targetPos", "_distance", "_add", "_bbX", "_bbY", "_bbZ", "_cubic", "_targetVel", "_baseVec", "_dir", "_currentCount", "_count", "_vecVar", "_vec", "_fp", "_vel", "_fragType", "_fragObj", "_randomCount", "_sectorSize", "_sectorOffset", "_i", "_randomDir", "_endTime", "_target"]; _round = _this select 0; _lastPos = _this select 1; diff --git a/addons/hearing/CfgVehicles.hpp b/addons/hearing/CfgVehicles.hpp index 6c77255384..16bb47014a 100644 --- a/addons/hearing/CfgVehicles.hpp +++ b/addons/hearing/CfgVehicles.hpp @@ -98,21 +98,21 @@ class CfgVehicles { class ACE_ModuleHearing: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Hearing"; + displayName = "$STR_ACE_Hearing_Module_DisplayName"; function = QFUNC(moduleHearing); scope = 2; isGlobal = 1; icon = PATHTOF(UI\Icon_Module_Hearing_ca.paa); class Arguments { class EnableCombatDeafness { - displayName = "Enable combat deafness?"; - description = "Enable combat deafness?"; + displayName = "$STR_ACE_Hearing_CombatDeafness_DisplayName"; + description = "$STR_ACE_Hearing_CombatDeafness_Description"; typeName = "BOOL"; - class values { - class Yes { name = "Yes"; value = 1; default = 1; }; - class No { name = "No"; value = 0; }; - }; + defaultValue = 1; }; }; + class ModuleDescription { + description = "$STR_ACE_Hearing_Module_Description"; + }; }; }; diff --git a/addons/hearing/stringtable.xml b/addons/hearing/stringtable.xml index e6f59604a3..9e960f6d63 100644 --- a/addons/hearing/stringtable.xml +++ b/addons/hearing/stringtable.xml @@ -109,5 +109,21 @@ Disabilita i fischi nelle orecchie Desabilitar zumbido de ouvidos + + Hearing + Słuch + + + Enable combat deafness? + Wł. głuchotę bojową + + + Enable combat deafness? + Możliwość chwilowej utraty słuchu przy głośnych wystrzałach i jednoczesnym braku włożonych stoperów + + + + Głuchota bojowa pojawia się w momentach, kiedy stoimy w pobliżu broni wielkokalibrowej bez ochrony słuchu, lub np. podczas ostrzału artyleryjskiego. Moduł ten pozwala na włączenie lub wyłączenie tego efektu. + - + \ No newline at end of file diff --git a/addons/interact_menu/CursorMenus.hpp b/addons/interact_menu/CursorMenus.hpp index d13813b92e..16ced412ec 100644 --- a/addons/interact_menu/CursorMenus.hpp +++ b/addons/interact_menu/CursorMenus.hpp @@ -1,47 +1,8 @@ class GVAR(cursorMenu) { idd = 91919; - movingEnable = false; + access = 0; + movingEnable = 0; + enableSimulation = 1; onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(dlgCursorMenu)),_this select 0)]; uiNamespace setVariable [ARR_2(QUOTE(QGVAR(cursorMenuOpened)),true)]); onUnload = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(cursorMenuOpened)),false)]); - objects[] = {}; - /*class controlsBackground { - class Background { - idc = 91920; - moving = 0; - font = "TahomaB"; - text = ""; - sizeEx = 0; - lineSpacing = 0; - access = 0; - type = 0; - style = 0; - size = 1; - colorBackground[] = {0, 0, 0, 0.5}; - colorText[] = {0, 0, 0, 0}; - x = "safezoneX"; - y = "safezoneY"; - w = "safezoneW"; - h = "safezoneH"; - }; - };*/ - class controls { - class Canvas { - idc = 91921; - moving = 0; - font = "TahomaB"; - text = ""; - sizeEx = 0; - lineSpacing = 0; - access = 0; - type = 0; - style = 0; - size = 1; - colorBackground[] = {0, 0, 0, 0}; - colorText[] = {0, 0, 0, 0}; - x = "safezoneX"; - y = "safezoneY"; - w = "safezoneW"; - h = "safezoneH"; - }; - }; }; diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 7e86646b79..ee0ffe9504 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -25,6 +25,21 @@ PREP(renderSelector); PREP(setupTextColors); PREP(splitPath); +// Event handlers for all interact menu controls +DFUNC(handleMouseMovement) = { + if (GVAR(cursorKeepCentered)) then { + GVAR(cursorPos) = GVAR(cursorPos) vectorAdd [_this select 1, _this select 2, 0] vectorDiff [0.5, 0.5, 0]; + setMousePosition [0.5, 0.5]; + } else { + GVAR(cursorPos) = [_this select 1, _this select 2, 0]; + }; +}; +DFUNC(handleMouseButtonDown) = { + if !(GVAR(actionOnKeyRelease)) then { + [GVAR(openedMenuType),true] call FUNC(keyUp); + }; +}; + GVAR(keyDown) = false; GVAR(keyDownSelfAction) = false; GVAR(keyDownTime) = 0; @@ -51,6 +66,7 @@ GVAR(expandedTime) = diag_tickTime; GVAR(iconCtrls) = []; GVAR(iconCount) = 0; +GVAR(collectedActionPoints) = []; GVAR(foundActions) = []; GVAR(lastTimeSearchedActions) = -1000; diff --git a/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf b/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf index 6abcebf47e..62d9ca1094 100644 --- a/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf +++ b/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf @@ -67,12 +67,12 @@ if !({} isEqualTo (_origActionData select 5)) then { if (count _pPath == count _fullPath && {_pPath isEqualTo _fullPath}) then { - _action = [_object, _action, _fullPath] call FUNC(collectActiveActionTree); + _action = [_object, [_actionData,[]], _fullPath] call FUNC(collectActiveActionTree); if ((count _action) > 0) then { _activeChildren pushBack _action; }; }; -} forEach GVAR(objectActions); +} forEach GVAR(objectActionList); // If the original action has no statement, and no children, don't display it diff --git a/addons/interact_menu/functions/fnc_keyDown.sqf b/addons/interact_menu/functions/fnc_keyDown.sqf index 464466ae3a..5976b99223 100644 --- a/addons/interact_menu/functions/fnc_keyDown.sqf +++ b/addons/interact_menu/functions/fnc_keyDown.sqf @@ -37,27 +37,30 @@ GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) || {(_menuType == 1) && {(isWeaponDeployed ACE_player) || GVAR(AlwaysUseCursorSelfInteraction) || {cameraView == "GUNNER"}}} || {(_menuType == 0) && GVAR(AlwaysUseCursorInteraction)}; +// Delete existing controls in case there's any left +GVAR(iconCount) = 0; +for "_i" from 0 to (count GVAR(iconCtrls))-1 do { + ctrlDelete (GVAR(iconCtrls) select _i); + GVAR(ParsedTextCached) set [_i, ""]; +}; +GVAR(iconCtrls) resize GVAR(iconCount); + if (GVAR(useCursorMenu)) then { - createDialog QGVAR(cursorMenu); + (findDisplay 46) createDisplay QGVAR(cursorMenu); //"RscCinemaBorder";// + (finddisplay 91919) displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}]; + (finddisplay 91919) displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}]; // The dialog sets: // uiNamespace getVariable QGVAR(dlgCursorMenu); // uiNamespace getVariable QGVAR(cursorMenuOpened); - ctrlEnable [91921, true]; GVAR(cursorPos) = [0.5,0.5,0]; - ((finddisplay 91919) displayctrl 91921) ctrlAddEventHandler ["MouseMoving", { - if (GVAR(cursorKeepCentered)) then { - GVAR(cursorPos) = GVAR(cursorPos) vectorAdd [_this select 1, _this select 2, 0] vectorDiff [0.5, 0.5, 0]; - setMousePosition [0.5, 0.5]; - } else { - GVAR(cursorPos) = [_this select 1, _this select 2, 0]; - }; - }]; - // handles LMB in cursor mode when action on keyrelease is disabled - ((finddisplay 91919) displayctrl 91921) ctrlAddEventHandler ["MouseButtonDown", { - if (!GVAR(actionOnKeyRelease) && GVAR(actionSelected)) then { - [GVAR(openedMenuType),true] call FUNC(keyUp); - }; - }]; + + _ctrl = (findDisplay 91919) ctrlCreate ["RscStructuredText", 9922]; + _ctrl ctrlSetPosition [safeZoneX, safeZoneY, safeZoneW, safeZoneH]; + _ctrl ctrlCommit 0; + + // handles Mouse moving and LMB in cursor mode when action on keyrelease is disabled + ((finddisplay 91919) displayctrl 9922) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)]; + ((finddisplay 91919) displayctrl 9922) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)]; setMousePosition [0.5, 0.5]; }; diff --git a/addons/interact_menu/functions/fnc_keyUp.sqf b/addons/interact_menu/functions/fnc_keyUp.sqf index 7b24497802..6f1d00276f 100644 --- a/addons/interact_menu/functions/fnc_keyUp.sqf +++ b/addons/interact_menu/functions/fnc_keyUp.sqf @@ -19,7 +19,7 @@ _calledByClicking = _this select 1; if (GVAR(openedMenuType) < 0) exitWith {true}; if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then { - closeDialog 0; + (findDisplay 91919) closeDisplay 2; }; if(GVAR(actionSelected)) then { diff --git a/addons/interact_menu/functions/fnc_renderActionPoints.sqf b/addons/interact_menu/functions/fnc_renderActionPoints.sqf index 8e6cb7d390..0f4f17c017 100644 --- a/addons/interact_menu/functions/fnc_renderActionPoints.sqf +++ b/addons/interact_menu/functions/fnc_renderActionPoints.sqf @@ -14,16 +14,16 @@ GVAR(currentOptions) = []; -private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_target","_player","_action","_cameraPos","_cameraDir", "_lambda", "_nearestObjects", "_pos"]; +private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_target","_player","_action","_cameraPos","_cameraDir", "_lambda", "_nearestObjects", "_pos", "_virtualPoint", "_wavesAtOrigin", "_wavesAtVirtualPoint"]; _player = ACE_player; +_cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL); +_cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos; + _fnc_renderNearbyActions = { // Render all nearby interaction menus #define MAXINTERACTOBJECTS 3 - _cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL); - _cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos; - GVAR(foundActions) = []; GVAR(lastTimeSearchedActions) = diag_tickTime; @@ -101,19 +101,26 @@ _fnc_renderSelfActions = { // Iterate through base level class actions and render them if appropiate _actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target]; _classActions = missionNamespace getVariable [_actionsVarName, []]; + + _pos = if !(GVAR(useCursorMenu)) then { + _virtualPoint = (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition); + _wavesAtOrigin = [(positionCameraToWorld [0, 0, 0])] call EFUNC(common,waveHeightAt); + _wavesAtVirtualPoint = [_virtualPoint] call EFUNC(common,waveHeightAt); + _virtualPoint set [2, ((_virtualPoint select 2) - _wavesAtOrigin + _wavesAtVirtualPoint)]; + _virtualPoint + } else { + [0.5, 0.5] + }; + { _action = _x; - - _pos = if !(GVAR(useCursorMenu)) then { - (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition) - } else { - [0.5, 0.5] - }; [_target, _action, _pos] call FUNC(renderBaseMenu); } forEach _classActions; }; +GVAR(collectedActionPoints) resize 0; + // Render nearby actions, unit self actions or vehicle self actions as appropiate if (GVAR(openedMenuType) == 0) then { @@ -132,3 +139,29 @@ if (GVAR(openedMenuType) == 0) then { } else { ACE_player call _fnc_renderSelfActions; }; + +if (count GVAR(collectedActionPoints) > 1) then { + // Do the oclusion pass + + // Order action points according to z + GVAR(collectedActionPoints) sort true; + + private ["_i","_j","_delta"]; + for [{_i = count GVAR(collectedActionPoints) - 1}, {_i > 0}, {_i = _i - 1}] do { + for [{_j = _i - 1}, {_j >= 0}, {_j = _j - 1}] do { + // Check if action point _i is ocluded by _j + _delta = vectorNormalized ((GVAR(collectedActionPoints) select _i select 1) vectorDiff (GVAR(collectedActionPoints) select _j select 1)); + + // If _i is inside a cone with 20º half angle with origin on _j + if (_delta select 2 > 0.94) exitWith { + GVAR(collectedActionPoints) deleteAt _i; + }; + }; + }; +}; + +// Render the non-ocluded points +{ + EXPLODE_3_PVT(_x,_z,_sPos,_activeActionTree); + [[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu); +} forEach GVAR(collectedActionPoints); diff --git a/addons/interact_menu/functions/fnc_renderBaseMenu.sqf b/addons/interact_menu/functions/fnc_renderBaseMenu.sqf index ca26fb984d..5ee698b547 100644 --- a/addons/interact_menu/functions/fnc_renderBaseMenu.sqf +++ b/addons/interact_menu/functions/fnc_renderBaseMenu.sqf @@ -93,11 +93,17 @@ _fnc_print = { // Check if there's something left for rendering if (count _activeActionTree == 0) exitWith {false}; -//EXPLODE_2_PVT(_activeActionTree,_actionData,_actionChildren); - BEGIN_COUNTER(fnc_renderMenus); -[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu); +// IGNORE_PRIVATE_WARNING(_cameraPos,_cameraDir); +if (count _pos > 2) then { + _sPos pushBack (((_pos call EFUNC(common,positionToASL)) vectorDiff _cameraPos) vectorDotProduct _cameraDir); +} else { + _sPos pushBack 0; +}; + +// Add action point for oclusion and rendering +GVAR(collectedActionPoints) pushBack [_sPos select 2, _sPos, _activeActionTree]; END_COUNTER(fnc_renderMenus); diff --git a/addons/interact_menu/functions/fnc_renderIcon.sqf b/addons/interact_menu/functions/fnc_renderIcon.sqf index 180b5a3c36..44a280a52e 100644 --- a/addons/interact_menu/functions/fnc_renderIcon.sqf +++ b/addons/interact_menu/functions/fnc_renderIcon.sqf @@ -23,6 +23,10 @@ PARAMS_4(_text,_icon,_sPos,_textSettings); if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { _displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]); + if (GVAR(useCursorMenu)) then { + ((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)]; + ((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)]; + }; }; _ctrl = GVAR(iconCtrls) select GVAR(iconCount); diff --git a/addons/interact_menu/functions/fnc_renderSelector.sqf b/addons/interact_menu/functions/fnc_renderSelector.sqf index 7ac9559297..96a495c715 100644 --- a/addons/interact_menu/functions/fnc_renderSelector.sqf +++ b/addons/interact_menu/functions/fnc_renderSelector.sqf @@ -20,6 +20,10 @@ private ["_displayNum", "_ctrl", "_pos"]; if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { _displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]); + if (GVAR(useCursorMenu)) then { + ((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)]; + ((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)]; + }; }; _ctrl = GVAR(iconCtrls) select GVAR(iconCount); diff --git a/addons/interact_menu/functions/fnc_setupTextColors.sqf b/addons/interact_menu/functions/fnc_setupTextColors.sqf index e26ef9dad8..e54d529668 100644 --- a/addons/interact_menu/functions/fnc_setupTextColors.sqf +++ b/addons/interact_menu/functions/fnc_setupTextColors.sqf @@ -12,7 +12,7 @@ */ #include "script_component.hpp" -private ["_menuDepth", "_mixColor", "_pathCount", "_row", "_shadowColor", "_textColor", "_textSize"]; +private ["_menuDepth", "_mixColor", "_pathCount", "_row", "_shadowColor", "_textColor", "_textSize", "_colorShadowMax", "_colorShadowMin", "_colorTextMax", "_colorTextMin", "_shadowSetting"]; //Mixes 2 colors (number arrays) and makes a color string "#AARRGGBB" for structured text _mixColor = { @@ -30,9 +30,16 @@ _mixColor = { _return }; -_textColor = [GVAR(colorTextMin), GVAR(colorTextMax), 1] call _mixColor; -_shadowColor = [GVAR(colorShadowMin), GVAR(colorShadowMax), 1] call _mixColor; -_textSize = switch (GVAR(textSize)) do { +_colorTextMin = missionNamespace getVariable [QGVAR(colorTextMin), [1,1,1,0.25]]; +_colorTextMax = missionNamespace getVariable [QGVAR(colorTextMax), [1,1,1,1]]; +_colorShadowMin = missionNamespace getVariable [QGVAR(colorShadowMin), [0,0,0,0.25]]; +_colorShadowMax = missionNamespace getVariable [QGVAR(colorShadowMax), [0,0,0,1]]; +_shadowSetting = missionNamespace getVariable [QGVAR(shadowSetting), 2]; +_textSize = missionNamespace getVariable [QGVAR(textSize), 2]; + +_textColor = [_colorTextMin, _colorTextMax, 1] call _mixColor; +_shadowColor = [_colorShadowMin, _colorShadowMax, 1] call _mixColor; +_textSize = switch (_textSize) do { case (0): {0.4}; case (1): {0.6}; case (2): {0.8}; @@ -40,20 +47,20 @@ _textSize = switch (GVAR(textSize)) do { case (4): {1.2}; }; -GVAR(colorSelectedSettings) = format ["color='%1' size='%2' shadow='%3' shadowColor='%4' shadowOffset='0.06'", _textColor, _textSize, GVAR(shadowSetting), _shadowColor]; +GVAR(colorSelectedSettings) = format ["color='%1' size='%2' shadow='%3' shadowColor='%4' shadowOffset='0.06'", _textColor, _textSize, _shadowSetting, _shadowColor]; GVAR(textSettingsMatrix) = []; for "_pathCount" from 0 to 15 do { _row = []; for "_menuDepth" from 0 to 15 do { if (_menuDepth > 0) then { - _textColor = [GVAR(colorTextMin), GVAR(colorTextMax), (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor; - _shadowColor = [GVAR(colorShadowMin), GVAR(colorShadowMax), (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor; + _textColor = [_colorTextMin, _colorTextMax, (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor; + _shadowColor = [_colorShadowMin, _colorShadowMax, (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor; } else { - _textColor = [GVAR(colorTextMin), GVAR(colorTextMax), 0] call _mixColor; - _shadowColor = [GVAR(colorShadowMin), GVAR(colorShadowMax), 0] call _mixColor; + _textColor = [_colorTextMin, _colorTextMax, 0] call _mixColor; + _shadowColor = [_colorShadowMin, _colorShadowMax, 0] call _mixColor; }; - _row pushBack format ["color='%1' size='%2' shadow='%3' shadowColor='%4' shadowOffset='0.06'", _textColor, _textSize, GVAR(shadowSetting), _shadowColor]; + _row pushBack format ["color='%1' size='%2' shadow='%3' shadowColor='%4' shadowOffset='0.06'", _textColor, _textSize, _shadowSetting, _shadowColor]; }; GVAR(textSettingsMatrix) pushBack _row; }; diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index 5548311718..804aba1100 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -4,563 +4,562 @@ class CfgVehicles { class ACE_ModuleInteraction: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Interaction System"; + displayName = "$STR_ACE_InteractionSystem_Module_DisplayName"; function = "ACE_Interaction_fnc_moduleInteraction"; scope = 2; isGlobal = 1; icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa); class Arguments { class EnableTeamManagement { - displayName = "Enable Team Management"; - description = "Should players be allowed to use the Team Management Menu? Default: Yes"; + displayName = "$STR_ACE_InteractionSystem_EnableTeamManagement_DisplayName"; + description = "$STR_ACE_InteractionSystem_EnableTeamManagement_Description"; typeName = "BOOL"; - class values { - class Yes { default = 1; name = "Yes"; value = 1;}; - class No { name = "No"; value = 0; }; - }; + defaultValue = 1; }; }; + class ModuleDescription { + description = "$STR_ACE_InteractionSystem_Module_Description"; + }; }; - class Man; - class CAManBase: Man { - class ACE_Actions { - class ACE_MainActions { - displayName = "$STR_ACE_Interaction_MainAction"; - distance = 4; - condition = QUOTE(true); - statement = ""; - icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa"; - selection = "pelvis"; + class Man; + class CAManBase: Man { + class ACE_Actions { + class ACE_MainActions { + displayName = "$STR_ACE_Interaction_MainAction"; + distance = 4; + condition = QUOTE(true); + statement = ""; + icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa"; + selection = "pelvis"; - class ACE_TeamManagement { - displayName = "$STR_ACE_Interaction_TeamManagement"; - condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam) && {GVAR(EnableTeamManagement)}); - statement = ""; - showDisabled = 0; - priority = 3.2; - icon = PATHTOF(UI\team\team_management_ca.paa); - hotkey = "M"; + class ACE_TeamManagement { + displayName = "$STR_ACE_Interaction_TeamManagement"; + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam) && {GVAR(EnableTeamManagement)}); + statement = ""; + showDisabled = 0; + priority = 3.2; + icon = PATHTOF(UI\team\team_management_ca.paa); + hotkey = "M"; - class ACE_AssignTeamRed { - displayName = "$STR_ACE_Interaction_AssignTeamRed"; - condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam)); - statement = QUOTE([ARR_2(_target,'RED')] call DFUNC(joinTeam)); - showDisabled = 1; - icon = PATHTOF(UI\team\team_red_ca.paa); - priority = 2.4; - hotkey = "R"; - }; - class ACE_AssignTeamGreen { - displayName = "$STR_ACE_Interaction_AssignTeamGreen"; - condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam)); - statement = QUOTE([ARR_2(_target,'GREEN')] call DFUNC(joinTeam)); - showDisabled = 1; - icon = PATHTOF(UI\team\team_green_ca.paa); - priority = 2.3; - hotkey = "G"; - }; - class ACE_AssignTeamBlue { - displayName = "$STR_ACE_Interaction_AssignTeamBlue"; - condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam)); - statement = QUOTE([ARR_2(_target,'BLUE')] call DFUNC(joinTeam)); - showDisabled = 1; - icon = PATHTOF(UI\team\team_blue_ca.paa); - priority = 2.2; - hotkey = "B"; - }; - class ACE_AssignTeamYellow { - displayName = "$STR_ACE_Interaction_AssignTeamYellow"; - condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam)); - statement = QUOTE([ARR_2(_target,'YELLOW')] call DFUNC(joinTeam)); - showDisabled = 1; - icon = PATHTOF(UI\team\team_yellow_ca.paa); - priority = 2.1; - hotkey = "Y"; - }; + class ACE_AssignTeamRed { + displayName = "$STR_ACE_Interaction_AssignTeamRed"; + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam)); + statement = QUOTE([ARR_2(_target,'RED')] call DFUNC(joinTeam)); + showDisabled = 1; + icon = PATHTOF(UI\team\team_red_ca.paa); + priority = 2.4; + hotkey = "R"; + }; + class ACE_AssignTeamGreen { + displayName = "$STR_ACE_Interaction_AssignTeamGreen"; + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam)); + statement = QUOTE([ARR_2(_target,'GREEN')] call DFUNC(joinTeam)); + showDisabled = 1; + icon = PATHTOF(UI\team\team_green_ca.paa); + priority = 2.3; + hotkey = "G"; + }; + class ACE_AssignTeamBlue { + displayName = "$STR_ACE_Interaction_AssignTeamBlue"; + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam)); + statement = QUOTE([ARR_2(_target,'BLUE')] call DFUNC(joinTeam)); + showDisabled = 1; + icon = PATHTOF(UI\team\team_blue_ca.paa); + priority = 2.2; + hotkey = "B"; + }; + class ACE_AssignTeamYellow { + displayName = "$STR_ACE_Interaction_AssignTeamYellow"; + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam)); + statement = QUOTE([ARR_2(_target,'YELLOW')] call DFUNC(joinTeam)); + showDisabled = 1; + icon = PATHTOF(UI\team\team_yellow_ca.paa); + priority = 2.1; + hotkey = "Y"; + }; - class ACE_UnassignTeam { - displayName = "$STR_ACE_Interaction_LeaveTeam"; - condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam) && {assignedTeam _target != 'MAIN'}); - statement = QUOTE([ARR_2(_target,'MAIN')] call DFUNC(joinTeam)); - showDisabled = 1; - icon = PATHTOF(UI\team\team_white_ca.paa); - priority = 2.5; - hotkey = "N"; - }; + class ACE_UnassignTeam { + displayName = "$STR_ACE_Interaction_LeaveTeam"; + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam) && {assignedTeam _target != 'MAIN'}); + statement = QUOTE([ARR_2(_target,'MAIN')] call DFUNC(joinTeam)); + showDisabled = 1; + icon = PATHTOF(UI\team\team_white_ca.paa); + priority = 2.5; + hotkey = "N"; + }; + }; + + class ACE_JoinGroup { + displayName = "$STR_ACE_Interaction_JoinGroup"; + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinGroup)); + statement = QUOTE([_player] joinSilent group _target); + showDisabled = 0; + priority = 2.6; + icon = PATHTOF(UI\team\team_management_ca.paa); + hotkey = "J"; + }; + + class ACE_GetDown { + displayName = "$STR_ACE_Interaction_GetDown"; + condition = QUOTE([_target] call DFUNC(canInteractWithCivilian)); + statement = QUOTE([_target] call DFUNC(getDown)); + showDisabled = 0; + priority = 2.2; + }; + class ACE_SendAway { + displayName = "$STR_ACE_Interaction_SendAway"; + condition = QUOTE([_target] call DFUNC(canInteractWithCivilian)); + statement = QUOTE([_target] call DFUNC(sendAway)); + showDisabled = 0; + priority = 2.0; + }; + class ACE_Pardon { + displayName = "$STR_ACE_Interaction_Pardon"; + condition = QUOTE(rating _target < -2000 && {alive _target} && {side group _player == side group _target}); + statement = QUOTE([ARR_3(_target,'{_this addRating -rating _this}',_target)] call DEFUNC(common,execRemoteFnc)); + showDisabled = 0; + priority = 2.5; + }; + }; + class ACE_Torso { + displayName = "$STR_ACE_Interaction_Torso"; + selection = "spine3"; + distance = 1.50; + condition = ""; + statement = ""; + }; + class ACE_Head { + displayName = "$STR_ACE_Interaction_Head"; + selection = "pilot"; + distance = 1.50; + condition = ""; + statement = ""; + }; + class ACE_ArmLeft { + displayName = "$STR_ACE_Interaction_ArmLeft"; + selection = "LeftForeArm"; + distance = 1.50; + condition = ""; + statement = ""; + }; + class ACE_ArmRight { + displayName = "$STR_ACE_Interaction_ArmRight"; + selection = "RightForeArm"; + distance = 1.50; + condition = ""; + statement = ""; + }; + class ACE_LegLeft { + displayName = "$STR_ACE_Interaction_LegLeft"; + selection = "LKnee"; + distance = 1.50; + condition = ""; + statement = ""; + }; + class ACE_LegRight { + displayName = "$STR_ACE_Interaction_LegRight"; + selection = "RKnee"; + distance = 1.50; + condition = ""; + statement = ""; + }; + class ACE_Weapon { + displayName = "$STR_ACE_Interaction_Weapon"; + position = QUOTE(call FUNC(getWeaponPos)); + distance = 1.50; + condition = ""; + statement = ""; + }; + + class ACE_TapShoulderRight { + displayName = "$STR_ACE_Interaction_TapShoulder"; + selection = "rightshoulder"; + distance = 2.0; + condition = QUOTE([ARR_2(_player, _target)] call DFUNC(canTapShoulder)); + statement = QUOTE([ARR_3(_player, _target, 0)] call DFUNC(tapShoulder)); + }; + class ACE_TapShoulderLeft { + displayName = "$STR_ACE_Interaction_TapShoulder"; + selection = "leftshoulder"; + distance = 2.0; + condition = QUOTE([ARR_2(_player, _target)] call DFUNC(canTapShoulder)); + statement = QUOTE([ARR_3(_player, _target, 1)] call DFUNC(tapShoulder)); + }; }; - class ACE_JoinGroup { - displayName = "$STR_ACE_Interaction_JoinGroup"; - condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinGroup)); - statement = QUOTE([_player] joinSilent group _target); - showDisabled = 0; - priority = 2.6; - icon = PATHTOF(UI\team\team_management_ca.paa); - hotkey = "J"; - }; + class ACE_SelfActions { + class ACE_TeamManagement { + displayName = "$STR_ACE_Interaction_TeamManagement"; + condition = QUOTE(GVAR(EnableTeamManagement)); + exceptions[] = {"isNotInside"}; + statement = ""; + showDisabled = 1; + priority = 3.2; + icon = PATHTOF(UI\team\team_management_ca.paa); + hotkey = "M"; - class ACE_GetDown { - displayName = "$STR_ACE_Interaction_GetDown"; - condition = QUOTE([_target] call DFUNC(canInteractWithCivilian)); - statement = QUOTE([_target] call DFUNC(getDown)); - showDisabled = 0; - priority = 2.2; - }; - class ACE_SendAway { - displayName = "$STR_ACE_Interaction_SendAway"; - condition = QUOTE([_target] call DFUNC(canInteractWithCivilian)); - statement = QUOTE([_target] call DFUNC(sendAway)); - showDisabled = 0; - priority = 2.0; - }; - class ACE_Pardon { - displayName = "$STR_ACE_Interaction_Pardon"; - condition = QUOTE(rating _target < -2000 && {alive _target} && {side group _player == side group _target}); - statement = QUOTE([ARR_3(_target,'{_this addRating -rating _this}',_target)] call DEFUNC(common,execRemoteFnc)); - showDisabled = 0; - priority = 2.5; - }; - }; - class ACE_Torso { - displayName = "$STR_ACE_Interaction_Torso"; - selection = "spine3"; - distance = 1.50; - condition = ""; - statement = ""; - }; - class ACE_Head { - displayName = "$STR_ACE_Interaction_Head"; - selection = "pilot"; - distance = 1.50; - condition = ""; - statement = ""; - }; - class ACE_ArmLeft { - displayName = "$STR_ACE_Interaction_ArmLeft"; - selection = "LeftForeArm"; - distance = 1.50; - condition = ""; - statement = ""; - }; - class ACE_ArmRight { - displayName = "$STR_ACE_Interaction_ArmRight"; - selection = "RightForeArm"; - distance = 1.50; - condition = ""; - statement = ""; - }; - class ACE_LegLeft { - displayName = "$STR_ACE_Interaction_LegLeft"; - selection = "LKnee"; - distance = 1.50; - condition = ""; - statement = ""; - }; - class ACE_LegRight { - displayName = "$STR_ACE_Interaction_LegRight"; - selection = "RKnee"; - distance = 1.50; - condition = ""; - statement = ""; - }; - class ACE_Weapon { - displayName = "$STR_ACE_Interaction_Weapon"; - position = QUOTE(call FUNC(getWeaponPos)); - distance = 1.50; - condition = ""; - statement = ""; - }; + class ACE_JoinTeamRed { + displayName = "$STR_ACE_Interaction_JoinTeamRed"; + condition = QUOTE(true); + exceptions[] = {"isNotInside"}; + statement = QUOTE([ARR_2(_player,'RED')] call DFUNC(joinTeam)); + showDisabled = 1; + priority = 2.4; + icon = PATHTOF(UI\team\team_red_ca.paa); + hotkey = "R"; + }; + class ACE_JoinTeamGreen { + displayName = "$STR_ACE_Interaction_JoinTeamGreen"; + condition = QUOTE(true); + exceptions[] = {"isNotInside"}; + statement = QUOTE([ARR_2(_player,'GREEN')] call DFUNC(joinTeam)); + showDisabled = 1; + priority = 2.3; + icon = PATHTOF(UI\team\team_green_ca.paa); + hotkey = "G"; + }; + class ACE_JoinTeamBlue { + displayName = "$STR_ACE_Interaction_JoinTeamBlue"; + condition = QUOTE(true); + exceptions[] = {"isNotInside"}; + statement = QUOTE([ARR_2(_player,'BLUE')] call DFUNC(joinTeam)); + showDisabled = 1; + priority = 2.2; + icon = PATHTOF(UI\team\team_blue_ca.paa); + hotkey = "B"; + }; + class ACE_JoinTeamYellow { + displayName = "$STR_ACE_Interaction_JoinTeamYellow"; + condition = QUOTE(true); + exceptions[] = {"isNotInside"}; + statement = QUOTE([ARR_2(_player,'YELLOW')] call DFUNC(joinTeam)); + showDisabled = 1; + priority = 2.1; + icon = PATHTOF(UI\team\team_yellow_ca.paa); + hotkey = "Y"; + }; - class ACE_TapShoulderRight { - displayName = "$STR_ACE_Interaction_TapShoulder"; - selection = "rightshoulder"; - distance = 2.0; - condition = QUOTE([ARR_2(_player, _target)] call DFUNC(canTapShoulder)); - statement = QUOTE([ARR_3(_player, _target, 0)] call DFUNC(tapShoulder)); - }; - class ACE_TapShoulderLeft { - displayName = "$STR_ACE_Interaction_TapShoulder"; - selection = "leftshoulder"; - distance = 2.0; - condition = QUOTE([ARR_2(_player, _target)] call DFUNC(canTapShoulder)); - statement = QUOTE([ARR_3(_player, _target, 1)] call DFUNC(tapShoulder)); - }; + class ACE_LeaveTeam { + displayName = "$STR_ACE_Interaction_LeaveTeam"; + condition = QUOTE(assignedTeam _player != 'MAIN'); + exceptions[] = {"isNotInside"}; + statement = QUOTE([ARR_2(_player,'MAIN')] call DFUNC(joinTeam)); + showDisabled = 1; + priority = 2.5; + icon = PATHTOF(UI\team\team_white_ca.paa); + hotkey = "N"; + }; + class ACE_BecomeLeader { + displayName = "$STR_ACE_Interaction_BecomeLeader"; + condition = QUOTE(_this call DFUNC(canBecomeLeader)); + exceptions[] = {"isNotInside"}; + statement = QUOTE(_this call DFUNC(doBecomeLeader)); + showDisabled = 1; + priority = 1.0; + icon = PATHTOF(UI\team\team_white_ca.paa); + hotkey = "L"; + }; + class ACE_LeaveGroup { + displayName = "$STR_ACE_Interaction_LeaveGroup"; + condition = QUOTE(count (units group _player) > 1); + exceptions[] = {"isNotInside"}; + statement = QUOTE(_oldGroup = units group _player; _newGroup = createGroup side _player; [_player] joinSilent _newGroup; {_player reveal _x} forEach _oldGroup;); + showDisabled = 1; + priority = 1.2; + icon = PATHTOF(UI\team\team_management_ca.paa); + hotkey = "M"; + }; + }; + + class ACE_Gestures { + displayName = "$STR_ACE_Interaction_Gestures"; + condition = "canStand _target"; + statement = ""; + showDisabled = 1; + priority = 3.5; + icon = PATHTOF(UI\gestures_ca.paa); + hotkey = "G"; + + /*class ACE_Gesture_Advance { + displayName = "$STR_ACE_Interaction_Gestures_Attack"; + condition = "canStand _target"; + statement = "_target playActionNow 'gestureAttack';"; + showDisabled = 1; + priority = 2.0; + };*/ + class ACE_Gesture_Advance { + displayName = "$STR_ACE_Interaction_Gestures_Advance"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow 'gestureAdvance';); + showDisabled = 1; + priority = 1.9; + hotkey = "1"; + }; + class ACE_Gesture_Go { + displayName = "$STR_ACE_Interaction_Gestures_Go"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow ([ARR_2('gestureGo','gestureGoB')] select floor random 2);); + showDisabled = 1; + priority = 1.8; + hotkey = "2"; + }; + class ACE_Gesture_Follow { + displayName = "$STR_ACE_Interaction_Gestures_Follow"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow 'gestureFollow';); + showDisabled = 1; + priority = 1.7; + hotkey = "3"; + }; + /*class ACE_Gesture_Point { + displayName = "$STR_ACE_Interaction_Gestures_Point"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow 'gesturePoint';); + showDisabled = 1; + priority = 1.6; + };*/ + class ACE_Gesture_Up { + displayName = "$STR_ACE_Interaction_Gestures_Up"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow 'gestureUp';); + showDisabled = 1; + priority = 1.5; + hotkey = "4"; + }; + class ACE_Gesture_Cover { + displayName = "$STR_ACE_Interaction_Gestures_Cover"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow 'gestureCover';); + showDisabled = 1; + priority = 1.4; + hotkey = "5"; + }; + class ACE_Gesture_CeaseFire { + displayName = "$STR_ACE_Interaction_Gestures_Cease_Fire"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow 'gestureCeaseFire';); + showDisabled = 1; + priority = 1.3; + hotkey = "6"; + }; + class ACE_Gesture_Freeze { + displayName = "$STR_ACE_Interaction_Gestures_Freeze"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow 'gestureFreeze';); + showDisabled = 1; + priority = 1.2; + hotkey = "7"; + }; + class ACE_Gesture_Yes { + displayName = "$STR_ACE_Interaction_Gestures_Yes"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow ([ARR_2('gestureYes','gestureNod')] select floor random 2);); + showDisabled = 1; + priority = 1.1; + hotkey = "8"; + }; + class ACE_Gesture_No { + displayName = "$STR_ACE_Interaction_Gestures_No"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow 'gestureNo';); + showDisabled = 1; + priority = 1.0; + hotkey = "9"; + }; + class ACE_Gesture_Hi { + displayName = "$STR_ACE_Interaction_Gestures_Hi"; + condition = QUOTE(canStand _target); + statement = QUOTE(_target playActionNow ([ARR_3('gestureHi','gestureHiB','gestureHiC')] select floor random 3);); + showDisabled = 1; + priority = 0.9; + hotkey = "0"; + }; + }; + + class ACE_Equipment { + displayName = "$STR_ACE_Interaction_Equipment"; + condition = QUOTE(true); + exceptions[] = {"isNotInside","notOnMap"}; + statement = ""; + showDisabled = 1; + priority = 4.5; + icon = ""; // @todo + hotkey = "E"; + }; + }; }; - class ACE_SelfActions { - class ACE_TeamManagement { - displayName = "$STR_ACE_Interaction_TeamManagement"; - condition = QUOTE(GVAR(EnableTeamManagement)); - exceptions[] = {"isNotInside"}; - statement = ""; - showDisabled = 1; - priority = 3.2; - icon = PATHTOF(UI\team\team_management_ca.paa); - hotkey = "M"; + class LandVehicle; + class Car: LandVehicle { + class ACE_Actions { + class ACE_MainActions { + displayName = "$STR_ACE_Interaction_MainAction"; + selection = ""; + distance = 10; + condition = "true"; + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; + }; + class ACE_SelfActions { + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; + }; + class Tank: LandVehicle { + class ACE_Actions { + class ACE_MainActions { + displayName = "$STR_ACE_Interaction_MainAction"; + selection = ""; + distance = 10; + condition = "true"; + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; + }; + class ACE_SelfActions { + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; + }; - class ACE_JoinTeamRed { - displayName = "$STR_ACE_Interaction_JoinTeamRed"; - condition = QUOTE(true); - exceptions[] = {"isNotInside"}; - statement = QUOTE([ARR_2(_player,'RED')] call DFUNC(joinTeam)); - showDisabled = 1; - priority = 2.4; - icon = PATHTOF(UI\team\team_red_ca.paa); - hotkey = "R"; + class Air; + class Helicopter: Air { + class ACE_Actions { + class ACE_MainActions { + displayName = "$STR_ACE_Interaction_MainAction"; + selection = ""; + distance = 10; + condition = "true"; + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; }; - class ACE_JoinTeamGreen { - displayName = "$STR_ACE_Interaction_JoinTeamGreen"; - condition = QUOTE(true); - exceptions[] = {"isNotInside"}; - statement = QUOTE([ARR_2(_player,'GREEN')] call DFUNC(joinTeam)); - showDisabled = 1; - priority = 2.3; - icon = PATHTOF(UI\team\team_green_ca.paa); - hotkey = "G"; + class ACE_SelfActions { + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; }; - class ACE_JoinTeamBlue { - displayName = "$STR_ACE_Interaction_JoinTeamBlue"; - condition = QUOTE(true); - exceptions[] = {"isNotInside"}; - statement = QUOTE([ARR_2(_player,'BLUE')] call DFUNC(joinTeam)); - showDisabled = 1; - priority = 2.2; - icon = PATHTOF(UI\team\team_blue_ca.paa); - hotkey = "B"; + }; + class Plane: Air { + class ACE_Actions { + class ACE_MainActions { + displayName = "$STR_ACE_Interaction_MainAction"; + selection = ""; + distance = 10; + condition = "true"; + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; }; - class ACE_JoinTeamYellow { - displayName = "$STR_ACE_Interaction_JoinTeamYellow"; - condition = QUOTE(true); - exceptions[] = {"isNotInside"}; - statement = QUOTE([ARR_2(_player,'YELLOW')] call DFUNC(joinTeam)); - showDisabled = 1; - priority = 2.1; - icon = PATHTOF(UI\team\team_yellow_ca.paa); - hotkey = "Y"; + class ACE_SelfActions { + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; }; + }; - class ACE_LeaveTeam { - displayName = "$STR_ACE_Interaction_LeaveTeam"; - condition = QUOTE(assignedTeam _player != 'MAIN'); - exceptions[] = {"isNotInside"}; - statement = QUOTE([ARR_2(_player,'MAIN')] call DFUNC(joinTeam)); - showDisabled = 1; - priority = 2.5; - icon = PATHTOF(UI\team\team_white_ca.paa); - hotkey = "N"; - }; - class ACE_BecomeLeader { - displayName = "$STR_ACE_Interaction_BecomeLeader"; - condition = QUOTE(_this call DFUNC(canBecomeLeader)); - exceptions[] = {"isNotInside"}; - statement = QUOTE(_this call DFUNC(doBecomeLeader)); - showDisabled = 1; - priority = 1.0; - icon = PATHTOF(UI\team\team_white_ca.paa); - hotkey = "L"; - }; - class ACE_LeaveGroup { - displayName = "$STR_ACE_Interaction_LeaveGroup"; - condition = QUOTE(count (units group _player) > 1); - exceptions[] = {"isNotInside"}; - statement = QUOTE(_oldGroup = units group _player; _newGroup = createGroup side _player; [_player] joinSilent _newGroup; {_player reveal _x} forEach _oldGroup;); - showDisabled = 1; - priority = 1.2; - icon = PATHTOF(UI\team\team_management_ca.paa); - hotkey = "M"; - }; - }; + class Ship; + class Ship_F: Ship { + class ACE_Actions { + class ACE_MainActions { + displayName = "$STR_ACE_Interaction_MainAction"; + selection = ""; + distance = 10; + condition = "true"; - class ACE_Gestures { - displayName = "$STR_ACE_Interaction_Gestures"; - condition = "canStand _target"; - statement = ""; - showDisabled = 1; - priority = 3.5; - icon = PATHTOF(UI\gestures_ca.paa); - hotkey = "G"; + class ACE_Push { + displayName = "$STR_ACE_Interaction_Push"; + distance = 6; + condition = QUOTE(getMass _target < 1000 && {alive _target}); + statement = QUOTE([ARR_2(_target, [ARR_3(2 * (vectorDir _player select 0), 2 * (vectorDir _player select 1), 0.5)])] call DFUNC(push);); + showDisabled = 0; + priority = -1; + }; + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; + }; + class ACE_SelfActions { + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; + }; - /*class ACE_Gesture_Advance { - displayName = "$STR_ACE_Interaction_Gestures_Attack"; - condition = "canStand _target"; - statement = "_target playActionNow 'gestureAttack';"; - showDisabled = 1; - priority = 2.0; - };*/ - class ACE_Gesture_Advance { - displayName = "$STR_ACE_Interaction_Gestures_Advance"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow 'gestureAdvance';); - showDisabled = 1; - priority = 1.9; - hotkey = "1"; + class StaticWeapon: LandVehicle { + class ACE_Actions { + class ACE_MainActions { + displayName = "$STR_ACE_Interaction_MainAction"; + selection = "gunnerview"; + distance = 2; + condition = "true"; + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; + }; }; - class ACE_Gesture_Go { - displayName = "$STR_ACE_Interaction_Gestures_Go"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow ([ARR_2('gestureGo','gestureGoB')] select floor random 2);); - showDisabled = 1; - priority = 1.8; - hotkey = "2"; + class ACE_SelfActions { + class ACE_Passengers { + displayName = "$STR_ACE_Interaction_Passengers"; + condition = "true"; + statement = ""; + insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + }; }; - class ACE_Gesture_Follow { - displayName = "$STR_ACE_Interaction_Gestures_Follow"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow 'gestureFollow';); - showDisabled = 1; - priority = 1.7; - hotkey = "3"; - }; - /*class ACE_Gesture_Point { - displayName = "$STR_ACE_Interaction_Gestures_Point"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow 'gesturePoint';); - showDisabled = 1; - priority = 1.6; - };*/ - class ACE_Gesture_Up { - displayName = "$STR_ACE_Interaction_Gestures_Up"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow 'gestureUp';); - showDisabled = 1; - priority = 1.5; - hotkey = "4"; - }; - class ACE_Gesture_Cover { - displayName = "$STR_ACE_Interaction_Gestures_Cover"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow 'gestureCover';); - showDisabled = 1; - priority = 1.4; - hotkey = "5"; - }; - class ACE_Gesture_CeaseFire { - displayName = "$STR_ACE_Interaction_Gestures_Cease_Fire"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow 'gestureCeaseFire';); - showDisabled = 1; - priority = 1.3; - hotkey = "6"; - }; - class ACE_Gesture_Freeze { - displayName = "$STR_ACE_Interaction_Gestures_Freeze"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow 'gestureFreeze';); - showDisabled = 1; - priority = 1.2; - hotkey = "7"; - }; - class ACE_Gesture_Yes { - displayName = "$STR_ACE_Interaction_Gestures_Yes"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow ([ARR_2('gestureYes','gestureNod')] select floor random 2);); - showDisabled = 1; - priority = 1.1; - hotkey = "8"; - }; - class ACE_Gesture_No { - displayName = "$STR_ACE_Interaction_Gestures_No"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow 'gestureNo';); - showDisabled = 1; - priority = 1.0; - hotkey = "9"; - }; - class ACE_Gesture_Hi { - displayName = "$STR_ACE_Interaction_Gestures_Hi"; - condition = QUOTE(canStand _target); - statement = QUOTE(_target playActionNow ([ARR_3('gestureHi','gestureHiB','gestureHiC')] select floor random 3);); - showDisabled = 1; - priority = 0.9; - hotkey = "0"; - }; - }; + }; - class ACE_Equipment { - displayName = "$STR_ACE_Interaction_Equipment"; - condition = QUOTE(true); - exceptions[] = {"isNotInside","notOnMap"}; - statement = ""; - showDisabled = 1; - priority = 4.5; - icon = ""; // @todo - hotkey = "E"; - }; - }; - }; - - class LandVehicle; - class Car: LandVehicle { - class ACE_Actions { - class ACE_MainActions { - displayName = "$STR_ACE_Interaction_MainAction"; - selection = ""; - distance = 10; - condition = "true"; - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); + class thingX; + class ReammoBox_F: thingX { + class ACE_Actions { + class ACE_MainActions { + displayName = "$STR_ACE_Interaction_MainAction"; + selection = ""; + distance = 2; + condition = "true"; + }; }; - }; + class ACE_SelfActions {}; }; - class ACE_SelfActions { - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - class Tank: LandVehicle { - class ACE_Actions { - class ACE_MainActions { - displayName = "$STR_ACE_Interaction_MainAction"; - selection = ""; - distance = 10; - condition = "true"; - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - class ACE_SelfActions { - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - - class Air; - class Helicopter: Air { - class ACE_Actions { - class ACE_MainActions { - displayName = "$STR_ACE_Interaction_MainAction"; - selection = ""; - distance = 10; - condition = "true"; - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - class ACE_SelfActions { - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - class Plane: Air { - class ACE_Actions { - class ACE_MainActions { - displayName = "$STR_ACE_Interaction_MainAction"; - selection = ""; - distance = 10; - condition = "true"; - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - class ACE_SelfActions { - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - - class Ship; - class Ship_F: Ship { - class ACE_Actions { - class ACE_MainActions { - displayName = "$STR_ACE_Interaction_MainAction"; - selection = ""; - distance = 10; - condition = "true"; - - class ACE_Push { - displayName = "$STR_ACE_Interaction_Push"; - distance = 6; - condition = QUOTE(getMass _target < 1000 && {alive _target}); - statement = QUOTE([ARR_2(_target, [ARR_3(2 * (vectorDir _player select 0), 2 * (vectorDir _player select 1), 0.5)])] call DFUNC(push);); - showDisabled = 0; - priority = -1; - }; - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - class ACE_SelfActions { - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - - class StaticWeapon: LandVehicle { - class ACE_Actions { - class ACE_MainActions { - displayName = "$STR_ACE_Interaction_MainAction"; - selection = "gunnerview"; - distance = 2; - condition = "true"; - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - class ACE_SelfActions { - class ACE_Passengers { - displayName = "$STR_ACE_Interaction_Passengers"; - condition = "true"; - statement = ""; - insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); - }; - }; - }; - - class thingX; - class ReammoBox_F: thingX { - class ACE_Actions { - class ACE_MainActions { - displayName = "$STR_ACE_Interaction_MainAction"; - selection = ""; - distance = 2; - condition = "true"; - }; - }; - class ACE_SelfActions {}; - }; - }; diff --git a/addons/interaction/Menu_Config.hpp b/addons/interaction/Menu_Config.hpp index 38f12066e0..790874a1ac 100644 --- a/addons/interaction/Menu_Config.hpp +++ b/addons/interaction/Menu_Config.hpp @@ -1,46 +1,44 @@ - #define HSPACE 0.5-2.0/16/2 #define VSPACE 0.5-0.3/9/2 -class RscStructuredText; class ACE_Interaction_Button_Base { - tooltip = ""; - //action = "ACE_Interaction_isMousePressed = true;(findDisplay 1713999) closeDisplay 1;_action = ACE_Interaction_Buttons select ACE_Interaction_SelectedButton;ACE_Interaction_SelectedButton = -1; if (call (_action select 2)) then {call (_action select 1)};"; - action = ""; + tooltip = ""; + //action = "ACE_Interaction_isMousePressed = true;(findDisplay 1713999) closeDisplay 1;_action = ACE_Interaction_Buttons select ACE_Interaction_SelectedButton;ACE_Interaction_SelectedButton = -1; if (call (_action select 2)) then {call (_action select 1)};"; + action = ""; - idc = -1; - access = 0; - type = 1; - text = ""; - font = "PuristaMedium"; - sizeEx = "0.8 / 40 / (getResolution select 5)"; - shadow = 2; + idc = -1; + access = 0; + type = 1; + text = ""; + font = "PuristaMedium"; + sizeEx = "0.8 / 40 / (getResolution select 5)"; + shadow = 2; - style = 2; - x = 0; - y = 0; - w = 2.0 / 16 * safezoneW; - h = 0.3 / 9 * safezoneH; + style = 2; + x = 0; + y = 0; + w = 2.0 / 16 * safezoneW; + h = 0.3 / 9 * safezoneH; - offsetX = 0.003; - offsetY = 0.003; - offsetPressedX = 0.002; - offsetPressedY = 0.002; - borderSize = 0; + offsetX = 0.003; + offsetY = 0.003; + offsetPressedX = 0.002; + offsetPressedY = 0.002; + borderSize = 0; - colorText[] = {1,1,1,1}; - colorDisabled[] = {0.5,0.5,0.5,1}; - colorBackground[] = {0,0,0,0.8}; - colorBackgroundDisabled[] = {0,0,0,0.8}; - colorBackgroundActive[] = {1,1,1,0}; - colorFocused[] = {1,1,1,1}; - colorShadow[] = {0,0,0,0}; - colorBorder[] = {1,1,1,0.8}; + colorText[] = {1,1,1,1}; + colorDisabled[] = {0.5,0.5,0.5,1}; + colorBackground[] = {0,0,0,0.8}; + colorBackgroundDisabled[] = {0,0,0,0.8}; + colorBackgroundActive[] = {1,1,1,0}; + colorFocused[] = {1,1,1,1}; + colorShadow[] = {0,0,0,0}; + colorBorder[] = {1,1,1,0.8}; - soundEnter[] = {"\A3\ui_f\data\sound\RscButton\soundEnter",0.09,1}; - soundPush[] = {"\A3\ui_f\data\sound\RscButton\soundPush",0.09,1}; - soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0.09,1}; - soundEscape[] = {"\A3\ui_f\data\sound\RscButton\soundEscape",0.09,1}; + soundEnter[] = {"\A3\ui_f\data\sound\RscButton\soundEnter",0.09,1}; + soundPush[] = {"\A3\ui_f\data\sound\RscButton\soundPush",0.09,1}; + soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0.09,1}; + soundEscape[] = {"\A3\ui_f\data\sound\RscButton\soundEscape",0.09,1}; }; class RscListbox; @@ -49,86 +47,86 @@ class RscText; #define X_OFFSET 0.2 class RscACE_SelectAnItem { - idd = 8854; - movingEnable = 0; - class controls { - class back:IGUIBack { - x = X_OFFSET; - y = 0; - w = 0.6; - h = 0.71; - colorBackground[] = {0, 0, 0, 0.2}; - }; - class header: RscText{ - idc = 8870; - x = X_OFFSET + 0.005; - y = 0.005; - w = 0.59; - h = 0.05; - style = 0x02; - text = ""; - }; - class itemList:RscListBox { - onMouseButtonDblClick = "_this call ACE_Interaction_fnc_onSelectMenuDblClick"; - idc = 8866; - x = X_OFFSET + 0.005; - w = 0.59; - h = 0.54; - y = 0.06; - }; + idd = 8854; + movingEnable = 0; + class controls { + class back:IGUIBack { + x = X_OFFSET; + y = 0; + w = 0.6; + h = 0.71; + colorBackground[] = {0, 0, 0, 0.2}; + }; + class header: RscText{ + idc = 8870; + x = X_OFFSET + 0.005; + y = 0.005; + w = 0.59; + h = 0.05; + style = 0x02; + text = ""; + }; + class itemList:RscListBox { + onMouseButtonDblClick = "_this call ACE_Interaction_fnc_onSelectMenuDblClick"; + idc = 8866; + x = X_OFFSET + 0.005; + w = 0.59; + h = 0.54; + y = 0.06; + }; - class cancelBtnBackground: ACE_Interaction_Button_Base { - type = 0; - style = 2; - idc = -1; - colorBackground[] = {0,0,0,0.5}; - colorBackgroundDisabled[] = {0,0,0,0.5}; - x = X_OFFSET + 0.005; - w = 0.15; - h = 0.1; - y = 0.605; - }; - class approveBtnBackground: ACE_Interaction_Button_Base { - type = 0; - style = 2; - idc = -1; - colorBackground[] = {0,0,0,0.5}; - colorBackgroundDisabled[] = {0,0,0,0.5}; - x = X_OFFSET + 0.445; - y = 0.605; - h = 0.1; - w = 0.15; - }; + class cancelBtnBackground: ACE_Interaction_Button_Base { + type = 0; + style = 2; + idc = -1; + colorBackground[] = {0,0,0,0.5}; + colorBackgroundDisabled[] = {0,0,0,0.5}; + x = X_OFFSET + 0.005; + w = 0.15; + h = 0.1; + y = 0.605; + }; + class approveBtnBackground: ACE_Interaction_Button_Base { + type = 0; + style = 2; + idc = -1; + colorBackground[] = {0,0,0,0.5}; + colorBackgroundDisabled[] = {0,0,0,0.5}; + x = X_OFFSET + 0.445; + y = 0.605; + h = 0.1; + w = 0.15; + }; - class cancelBtn: ACE_Interaction_Button_Base { - idc = 8855; - x = X_OFFSET + 0.005; - w = 0.15; - h = 0.1; - y = 0.605; - style = 2; - text = $STR_ACE_Interaction_Back; //$STR_ACE_Interaction_CancelSelection; - action = "call ACE_Interaction_fnc_hideMenu;"; //'Default' call ACE_Interaction_fnc_openMenu; 'Default' call ACE_Interaction_fnc_openMenuSelf; - colorBackground[] = {0,0,0,0}; - colorBackgroundDisabled[] = {0,0,0,0}; - colorBackgroundActive[] = {1,1,1,0.2}; - colorFocused[] = {0,0,0,0}; + class cancelBtn: ACE_Interaction_Button_Base { + idc = 8855; + x = X_OFFSET + 0.005; + w = 0.15; + h = 0.1; + y = 0.605; + style = 2; + text = $STR_ACE_Interaction_Back; //$STR_ACE_Interaction_CancelSelection; + action = "call ACE_Interaction_fnc_hideMenu;"; //'Default' call ACE_Interaction_fnc_openMenu; 'Default' call ACE_Interaction_fnc_openMenuSelf; + colorBackground[] = {0,0,0,0}; + colorBackgroundDisabled[] = {0,0,0,0}; + colorBackgroundActive[] = {1,1,1,0.2}; + colorFocused[] = {0,0,0,0}; + }; + class approveBtn: ACE_Interaction_Button_Base { + idc = 8860; + x = X_OFFSET + 0.445; + y = 0.605; + h = 0.1; + w = 0.15; + style = 2; + text = $STR_ACE_Interaction_MakeSelection; + action = "call ACE_Interaction_fnc_hideMenu;"; + colorBackground[] = {0,0,0,0}; + colorBackgroundDisabled[] = {0,0,0,0}; + colorBackgroundActive[] = {1,1,1,0.2}; + colorFocused[] = {0,0,0,0}; + }; }; - class approveBtn: ACE_Interaction_Button_Base { - idc = 8860; - x = X_OFFSET + 0.445; - y = 0.605; - h = 0.1; - w = 0.15; - style = 2; - text = $STR_ACE_Interaction_MakeSelection; - action = "call ACE_Interaction_fnc_hideMenu;"; - colorBackground[] = {0,0,0,0}; - colorBackgroundDisabled[] = {0,0,0,0}; - colorBackgroundActive[] = {1,1,1,0.2}; - colorFocused[] = {0,0,0,0}; - }; - }; }; #define GUI_GRID_W (0.025) @@ -136,64 +134,64 @@ class RscACE_SelectAnItem { class RscPicture; class RscInteractionIcon: RscPicture { - x = 19.25 * GUI_GRID_W; - y = 15.75 * GUI_GRID_H; - w = 2*GUI_GRID_H; - h = 2*GUI_GRID_H; + x = 19.25 * GUI_GRID_W; + y = 15.75 * GUI_GRID_H; + w = 2*GUI_GRID_H; + h = 2*GUI_GRID_H; }; class RscInteractionHelperIcon: RscInteractionIcon { - x = 20 * GUI_GRID_W; - y = 16 * GUI_GRID_H; - w = GUI_GRID_H; - h = GUI_GRID_H; + x = 20 * GUI_GRID_W; + y = 16 * GUI_GRID_H; + w = GUI_GRID_H; + h = GUI_GRID_H; }; class RscInteractionText: RscText{ - x = 21 * GUI_GRID_W; - y = 16 * GUI_GRID_H; - w = 8 * GUI_GRID_W; - h = 1.5 * GUI_GRID_H; + x = 21 * GUI_GRID_W; + y = 16 * GUI_GRID_H; + w = 8 * GUI_GRID_W; + h = 1.5 * GUI_GRID_H; }; class RscTitles { - class GVAR(InteractionHelper) { - idd = 9930; - enableSimulation = 1; - movingEnable = 0; - fadeIn=0.5; - fadeOut=0.5; - duration = 10e10; - onLoad = "uiNamespace setVariable ['ACE_Helper_Display', _this select 0];"; + class GVAR(InteractionHelper) { + idd = 9930; + enableSimulation = 1; + movingEnable = 0; + fadeIn=0.5; + fadeOut=0.5; + duration = 10e10; + onLoad = "uiNamespace setVariable ['ACE_Helper_Display', _this select 0];"; - class controls { - class SelectIcon: RscInteractionHelperIcon{ - idc = 1200; - text = PATHTOF(UI\mouse_left_ca.paa); - y = 17.5 * GUI_GRID_H; - }; - class SelectText: RscInteractionText{ - idc = 1000; - y = 17 * GUI_GRID_H; - text = $STR_ACE_Interaction_MakeSelection; - }; - class GoBackIcon: RscInteractionHelperIcon{ - idc = 1201; - text = PATHTOF(UI\mouse_right_ca.paa); - y = 19.5 * GUI_GRID_H; - }; - class GoBackText: RscInteractionText{ - idc = 1001; - y = 19 * GUI_GRID_H; - text = $STR_ACE_Interaction_Back; - }; - class ScrollIcon: RscInteractionHelperIcon{ - idc = 1202; - text = PATHTOF(UI\mouse_scroll_ca.paa); - y = 18.5 * GUI_GRID_H; - }; - class ScrollText: RscInteractionText{ - idc = 1002; - y = 18 * GUI_GRID_H; - text = $STR_ACE_Interaction_ScrollHint; - }; + class controls { + class SelectIcon: RscInteractionHelperIcon{ + idc = 1200; + text = PATHTOF(UI\mouse_left_ca.paa); + y = 17.5 * GUI_GRID_H; + }; + class SelectText: RscInteractionText{ + idc = 1000; + y = 17 * GUI_GRID_H; + text = $STR_ACE_Interaction_MakeSelection; + }; + class GoBackIcon: RscInteractionHelperIcon{ + idc = 1201; + text = PATHTOF(UI\mouse_right_ca.paa); + y = 19.5 * GUI_GRID_H; + }; + class GoBackText: RscInteractionText{ + idc = 1001; + y = 19 * GUI_GRID_H; + text = $STR_ACE_Interaction_Back; + }; + class ScrollIcon: RscInteractionHelperIcon{ + idc = 1202; + text = PATHTOF(UI\mouse_scroll_ca.paa); + y = 18.5 * GUI_GRID_H; + }; + class ScrollText: RscInteractionText{ + idc = 1002; + y = 18 * GUI_GRID_H; + text = $STR_ACE_Interaction_ScrollHint; + }; + }; }; - }; }; diff --git a/addons/interaction/README.md b/addons/interaction/README.md index 92401b2547..8e841e9a58 100644 --- a/addons/interaction/README.md +++ b/addons/interaction/README.md @@ -3,7 +3,6 @@ ace_interaction Provides interaction options between units. - ## Maintainers The people responsible for merging changes to this component or answering potential questions. diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf index 6417043df2..e828c60912 100644 --- a/addons/interaction/XEH_postInit.sqf +++ b/addons/interaction/XEH_postInit.sqf @@ -15,6 +15,7 @@ if (!hasInterface) exitWith {}; GVAR(isOpeningDoor) = false; // restore global fire teams for JIP +private ["_team"]; { _team = _x getVariable [QGVAR(assignedFireTeam), ""]; if (_team != "") then {_x assignTeam _team}; diff --git a/addons/interaction/config.cpp b/addons/interaction/config.cpp index cfca73a90b..7d10e1bef5 100644 --- a/addons/interaction/config.cpp +++ b/addons/interaction/config.cpp @@ -1,26 +1,24 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_interact_menu"}; - author[] = {"commy2", "KoffeinFlummi", "esteldunedain", "bux578"}; - authorUrl = "https://github.com/commy2/"; - VERSION_CONFIG; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_interact_menu"}; + author[] = {"commy2", "KoffeinFlummi", "esteldunedain", "bux578"}; + authorUrl = "https://github.com/commy2/"; + VERSION_CONFIG; + }; }; #include "CfgEventHandlers.hpp" - #include "CfgVehicles.hpp" - -#include +#include "Menu_Config.hpp" class ACE_Settings { - class GVAR(EnableTeamManagement) { - value = 1; - typeName = "BOOL"; - }; + class GVAR(EnableTeamManagement) { + value = 1; + typeName = "BOOL"; + }; }; diff --git a/addons/interaction/functions/fnc_AddSelectableItem.sqf b/addons/interaction/functions/fnc_AddSelectableItem.sqf deleted file mode 100644 index 498b852635..0000000000 --- a/addons/interaction/functions/fnc_AddSelectableItem.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - Author: Garth de Wet (LH) - - Description: - Adds an item to the select menu - - Parameters: - 0: ARRAY/NUMBER - List container - 1: String - Display Name - 2: String - Picture - 3: String/code - data - - Returns: - ARRAY/Number - - Example: -*/ - -#include "script_component.hpp" - -private ["_container", "_displayName", "_picture", "_data", "_index"]; - -_container = _this select 0; -_displayName = _this select 1; -_picture = _this select 2; -_data = _this select 3; - -if (_picture == "" || _picture == "PictureThing") then { - _picture = QUOTE(PATHTOF(UI\dot_ca.paa)); -}; - -_index = lbAdd [_container, _displayName]; -lbSetData [_container, _index, str _data]; -lbSetPicture [_container, _index, _picture]; - -_container diff --git a/addons/interaction/functions/fnc_addPassengerActions.sqf b/addons/interaction/functions/fnc_addPassengerActions.sqf index 82e3b3b4fb..d7e21d4a7b 100644 --- a/addons/interaction/functions/fnc_addPassengerActions.sqf +++ b/addons/interaction/functions/fnc_addPassengerActions.sqf @@ -2,7 +2,7 @@ * Author: esteldunedain * Mount unit actions inside passenger submenu * - * Argument: + * Arguments: * 0: Vehicle * 1: Player * 3: Parameters @@ -10,14 +10,17 @@ * Return value: * Children actions * + * Example: + * array = [target, player, [params]] call ace_interaction_fnc_addPassengerAction + * * Public: No */ #include "script_component.hpp" EXPLODE_3_PVT(_this,_vehicle,_player,_parameters); +EXPLODE_1_PVT(_parameters,_unit); -private ["_unit","_actions"]; -_unit = _parameters select 0; +private ["_varName", "_actionTrees", "_actions"]; _varName = format [QEGVAR(interact_menu,Act_%1), typeOf _unit]; _actionTrees = missionNamespace getVariable [_varName, []]; diff --git a/addons/interaction/functions/fnc_addPassengersActions.sqf b/addons/interaction/functions/fnc_addPassengersActions.sqf index c446be3737..7a7d8618d1 100644 --- a/addons/interaction/functions/fnc_addPassengersActions.sqf +++ b/addons/interaction/functions/fnc_addPassengersActions.sqf @@ -2,7 +2,7 @@ * Author: esteldunedain * Create one action per passenger * - * Argument: + * Arguments: * 0: Vehicle * 1: Player * 3: Parameters @@ -10,6 +10,9 @@ * Return value: * Children actions * + * Example: + * [target, player, [params]] call ace_interaction_fnc_addPassengersActions + * * Public: No */ #include "script_component.hpp" @@ -20,8 +23,9 @@ private ["_actions"]; _actions = []; { + private ["_unit"]; _unit = _x; - if (_x != _player) then { + if (_unit != _player) then { _actions pushBack [ [ @@ -39,4 +43,4 @@ _actions = []; }; } forEach crew _vehicle; -_actions \ No newline at end of file +_actions diff --git a/addons/interaction/functions/fnc_addSelectableItem.sqf b/addons/interaction/functions/fnc_addSelectableItem.sqf new file mode 100644 index 0000000000..74a0e9caea --- /dev/null +++ b/addons/interaction/functions/fnc_addSelectableItem.sqf @@ -0,0 +1,32 @@ +/* + * Author: Garth de Wet (LH) + * Adds an item to the select menu + * + * Arguments: + * 0: List container + * 1: Display name + * 2: Picture + * 3: Data + * + * Return value: + * Container + * + * Example: + * [actions, "Banana", "UI\dot_ca.paa", "bananaContents"] call ace_interaction_fnc_addSelectableItem + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_4(_container,_displayName,_picture,_data); + +if (_picture == "" || _picture == "PictureThing") then { + _picture = QUOTE(PATHTOF(UI\dot_ca.paa)); +}; + +private ["_index"]; +_index = lbAdd [_container, _displayName]; +lbSetData [_container, _index, str _data]; +lbSetPicture [_container, _index, _picture]; + +_container diff --git a/addons/interaction/functions/fnc_applyButtons.sqf b/addons/interaction/functions/fnc_applyButtons.sqf index be35b34877..8aa57d5923 100644 --- a/addons/interaction/functions/fnc_applyButtons.sqf +++ b/addons/interaction/functions/fnc_applyButtons.sqf @@ -1,8 +1,21 @@ -// by commy2 - +/* + * Author: commy2 + * Applies buttons + * + * Arguments: + * None + * + * Return value: + * None + * + * Example: + * call ace_interaction_fnc_applyButtons + * + * Public: No + */ #include "script_component.hpp" -private ["_object", "_actions", "_dlgInteractionDialog", "_ctrlInteractionDialog", "_index", "_ctrlInteractionDialogIcon"]; +private ["_object", "_actions", "_dlgInteractionDialog", "_ctrlInteractionDialog", "_index", "_ctrlInteractionDialogIcon", "_a", "_action", "_count"]; _object = GVAR(Target); _actions = GVAR(Buttons); diff --git a/addons/interaction/functions/fnc_canBecomeLeader.sqf b/addons/interaction/functions/fnc_canBecomeLeader.sqf index 11234ad6d7..1821e41506 100644 --- a/addons/interaction/functions/fnc_canBecomeLeader.sqf +++ b/addons/interaction/functions/fnc_canBecomeLeader.sqf @@ -3,11 +3,11 @@ * Test if can Become Leader of group * * Arguments: - * 0: target - * 1: player + * 0: Target + * 1: Player * * Return Value: - * + * Able to become leader of group * * Example: * [player, player] call ace_interaction_fnc_canBecomeLeader diff --git a/addons/interaction/functions/fnc_canInteractWithCivilian.sqf b/addons/interaction/functions/fnc_canInteractWithCivilian.sqf index 6408d66aa8..c20ac61f94 100644 --- a/addons/interaction/functions/fnc_canInteractWithCivilian.sqf +++ b/addons/interaction/functions/fnc_canInteractWithCivilian.sqf @@ -1,5 +1,18 @@ -// by commy2 - +/* + * Author: commy2 + * Checks if the player can interact with civilian + * + * Arguments: + * 0: Target + * + * Return value: + * Able to interact with civilian + * + * Example: + * [target] call ace_interaction_fnc_canInteractWithCivilian + * + * Public: No + */ #include "script_component.hpp" EXPLODE_2_PVT(_this,_unit,_isCivilian); @@ -8,4 +21,4 @@ if (isNil "_isCivilian") then {_isCivilian = true}; alive _unit && [side _unit != side ACE_player, side group _unit == civilian] select _isCivilian -//&& {count (weapons _unit) == 0} \ No newline at end of file +//&& {count (weapons _unit) == 0} diff --git a/addons/interaction/functions/fnc_canJoinGroup.sqf b/addons/interaction/functions/fnc_canJoinGroup.sqf index d299524925..315da658db 100644 --- a/addons/interaction/functions/fnc_canJoinGroup.sqf +++ b/addons/interaction/functions/fnc_canJoinGroup.sqf @@ -1,10 +1,22 @@ -// by commy2 +/* + * Author: commy2 + * Checks if the player can join a group + * + * Arguments: + * 0: Player + * 1: Target + * + * Return value: + * Able to join a group + * + * Example: + * [player, target] call ace_interaction_fnc_canJoinGroup + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_target"]; - -_unit = _this select 0; -_target = _this select 1; +PARAMS_2(_unit,_target); alive _target && {!(_target getVariable ["ACE_isUnconscious", false])} diff --git a/addons/interaction/functions/fnc_canJoinTeam.sqf b/addons/interaction/functions/fnc_canJoinTeam.sqf index 45f96393a9..b91a5abd5c 100644 --- a/addons/interaction/functions/fnc_canJoinTeam.sqf +++ b/addons/interaction/functions/fnc_canJoinTeam.sqf @@ -1,10 +1,22 @@ -// by commy2 +/* + * Author: commy2 + * Checks if the player can join a team + * + * Arguments: + * 0: Player + * 1: Target + * + * Return value: + * Able to join a team + * + * Example: + * [player, target] call ace_interaction_fnc_canJoinTeam + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_target"]; - -_unit = _this select 0; -_target = _this select 1; +PARAMS_2(_unit,_target); alive _target && {!(_target getVariable ["ACE_isUnconscious", false])} diff --git a/addons/interaction/functions/fnc_canTapShoulder.sqf b/addons/interaction/functions/fnc_canTapShoulder.sqf index 4ea9836117..bbeee51b4a 100644 --- a/addons/interaction/functions/fnc_canTapShoulder.sqf +++ b/addons/interaction/functions/fnc_canTapShoulder.sqf @@ -1,11 +1,22 @@ -// by commy2 - +/* + * Author: commy2 + * Checks if the player can tap a shoulder + * + * Arguments: + * 0: Player + * 1: Target + * + * Return value: + * Able to tap a shoulder + * + * Example: + * [player, target] call ace_interaction_fnc_canTapShoulder + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_target"]; - -_unit = _this select 0; -_target = _this select 1; +PARAMS_2(_unit,_target); _target isKindOf "CAManBase" && {alive _target} && diff --git a/addons/interaction/functions/fnc_doBecomeLeader.sqf b/addons/interaction/functions/fnc_doBecomeLeader.sqf index 24bfa66c11..0fd81cbc96 100644 --- a/addons/interaction/functions/fnc_doBecomeLeader.sqf +++ b/addons/interaction/functions/fnc_doBecomeLeader.sqf @@ -3,8 +3,8 @@ * Become Leader of group * * Arguments: - * 0: target - * 1: player + * 0: Target + * 1: Player * * Return Value: * None diff --git a/addons/interaction/functions/fnc_getDoor.sqf b/addons/interaction/functions/fnc_getDoor.sqf index 91c2161d9f..a085c9a3b8 100644 --- a/addons/interaction/functions/fnc_getDoor.sqf +++ b/addons/interaction/functions/fnc_getDoor.sqf @@ -1,9 +1,25 @@ -// by commy2 +/* + * Author: commy2 + * Get door + * + * Arguments: + * 0: Distance + * + * Return value: + * House objects and door + * 0: House + * 1: Door Name + * + * Example: + * [player, target] call ace_interaction_fnc_getDoor + * + * Public: No + */ #include "script_component.hpp" -private ["_distance", "_position0", "_position1", "_intersections", "_count", "_house", "_door", "_index", "_id"]; +PARAMS_1(_distance); -_distance = _this select 0; +private ["_position0", "_position1", "_intersections", "_count", "_house", "_door"]; _position0 = positionCameraToWorld [0, 0, 0]; _position1 = positionCameraToWorld [0, 0, _distance]; @@ -22,4 +38,5 @@ _intersections = [_house, "GEOM"] intersect [_position0, _position1]; _door = _intersections select 0 select 0; if (isNil "_door") exitWith {[_house, ""]}; + [_house, _door] diff --git a/addons/interaction/functions/fnc_getDoorAnimations.sqf b/addons/interaction/functions/fnc_getDoorAnimations.sqf index ca59ec177c..0de74e61ed 100644 --- a/addons/interaction/functions/fnc_getDoorAnimations.sqf +++ b/addons/interaction/functions/fnc_getDoorAnimations.sqf @@ -1,10 +1,26 @@ -// by commy2 +/* + * Author: commy2 + * Get door animations + * + * Arguments: + * 0: House + * 1: Door + * + * Return value: + * Animation and Locked variable + * 0: Animation + * 1: Locked variable + * + * Example: + * array = [target, "door"] call ace_interaction_fnc_getDoorAnimations + * + * Public: No + */ #include "script_component.hpp" -private ["_house", "_door", "_animations", "_lockedVariable"]; +PARAMS_2(_house,_door); -_house = _this select 0; -_door = _this select 1; +private ["_index", "_animations", "_lockedVariable"]; _index = [ "door_1", diff --git a/addons/interaction/functions/fnc_getDown.sqf b/addons/interaction/functions/fnc_getDown.sqf index ead5dcd290..09d651eadf 100644 --- a/addons/interaction/functions/fnc_getDown.sqf +++ b/addons/interaction/functions/fnc_getDown.sqf @@ -1,21 +1,25 @@ /* * Author: KoffeinFlummi - * - * Forces a civilian to the ground. (chance of failure). + * Forces a civilian to the ground (with a chance of failure) * * Arguments: - * 0: Unit to be sent away (Object) + * 0: Unit * * Return value: - * none + * None + * + * Example: + * [target] call ace_interaction_fnc_getDown + * + * Public: No */ #include "script_component.hpp" #define RADIUS 10 -private ["_unit", "_chance", "_x"]; +PARAMS_1(_unit); -_unit = _this select 0; +private ["_chance", "_x"]; ACE_player playActionNow "GestureGo"; // put something else here. @@ -31,4 +35,4 @@ if (count (weapons ACE_player) > 0) then { _this setUnitPos "DOWN"; }, _x] call CBA_fnc_globalExecute; }; -} foreach (_unit nearEntities ["Civilian", RADIUS]); +} forEach (_unit nearEntities ["Civilian", RADIUS]); diff --git a/addons/interaction/functions/fnc_getSelectedButton.sqf b/addons/interaction/functions/fnc_getSelectedButton.sqf index d1c801e1dc..92768b67f7 100644 --- a/addons/interaction/functions/fnc_getSelectedButton.sqf +++ b/addons/interaction/functions/fnc_getSelectedButton.sqf @@ -1,4 +1,18 @@ -// by commy2 +/* + * Author: commy2 + * Get selected button + * + * Arguments: + * None + * + * Return value: + * Angle + * + * Example: + * call ace_interaction_fnc_getSelectedButton + * + * Public: No + */ #include "script_component.hpp" #define MIN_DISTANCE 0.0065 diff --git a/addons/interaction/functions/fnc_getWeaponPos.sqf b/addons/interaction/functions/fnc_getWeaponPos.sqf index 477e74f9bf..58c8756076 100644 --- a/addons/interaction/functions/fnc_getWeaponPos.sqf +++ b/addons/interaction/functions/fnc_getWeaponPos.sqf @@ -2,18 +2,21 @@ * Author: esteldunedain * Return a suitable position for the action point for the current weapon * - * Argument: - * None + * Arguments: + * None (uses local variable _target) * * Return value: * Children actions * + * Example: + * call ace_interaction_fnc_getWeaponPos + * * Public: No */ #include "script_component.hpp" // IGNORE_PRIVATE_WARNING(_target); -private ["_weaponDir","_refSystem"]; +private ["_weaponDir", "_refSystem"]; _weaponDir = _target weaponDirection currentWeapon _target; _refSystem = _weaponDir call EFUNC(common,createOrthonormalReference); diff --git a/addons/interaction/functions/fnc_hideMenu.sqf b/addons/interaction/functions/fnc_hideMenu.sqf index 54263ef032..89dc49be40 100644 --- a/addons/interaction/functions/fnc_hideMenu.sqf +++ b/addons/interaction/functions/fnc_hideMenu.sqf @@ -1,22 +1,22 @@ /* - Author: Garth de Wet (LH) - - Description: - Closes the Interaction menu - - Parameters: - Nothing - - Returns: - Nothing - - Example: - call FUNC(hideMenu); -*/ + * Author: Garth de Wet (LH) + * Closes the Interaction menu + * + * Arguments: + * None + * + * Return value: + * None + * + * Example: + * call ace_interaction_fnc_hideMenu + * + * Public: No + */ #include "script_component.hpp" closeDialog 0; (findDisplay 1713999) closeDisplay 1; (uiNameSpace getVariable QGVAR(Flow_Display)) closeDisplay 0; GVAR(MainButton) = nil; -call FUNC(hideMouseHint); \ No newline at end of file +call FUNC(hideMouseHint); diff --git a/addons/interaction/functions/fnc_hideMouseHint.sqf b/addons/interaction/functions/fnc_hideMouseHint.sqf index d910352076..69acba25a2 100644 --- a/addons/interaction/functions/fnc_hideMouseHint.sqf +++ b/addons/interaction/functions/fnc_hideMouseHint.sqf @@ -1,22 +1,21 @@ /* - Author(s): - Garth de Wet (LH) - - Description: - Hides the interaction helper text with the mouse buttons at the bottom middle of the screen - - Parameters: - Nothing - - Returns: - Nothing - - Example: - call FUNC(hideMouseHint); -*/ + * Author: Garth de Wet (LH) + * Hides the interaction helper text with the mouse buttons at the bottom middle of the screen + * + * Arguments: + * None + * + * Return value: + * None + * + * Example: + * call ace_interaction_fnc_hideMouseHint + * + * Public: No + */ #include "script_component.hpp" if (isNull (uiNamespace getVariable ["ACE_Helper_Display", objNull])) exitWith{}; (QGVAR(InteractionHelper) call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; -showHUD true; \ No newline at end of file +showHUD true; diff --git a/addons/interaction/functions/fnc_isInRange.sqf b/addons/interaction/functions/fnc_isInRange.sqf index 5048b66001..49ac391871 100644 --- a/addons/interaction/functions/fnc_isInRange.sqf +++ b/addons/interaction/functions/fnc_isInRange.sqf @@ -1,21 +1,24 @@ /* * Author: commy2 - * * Check if the vehicle is in range of the player. * - * Argument: - * 0: Vehicke (Object) - * 1: Distance in meters (Number) + * Arguments: + * 0: Vehicle + * 1: Distance in meters * * Return value: - * (Bool) + * Vehicle in range of player + * + * Example: + * [target, 5] call ace_interaction_fnc_isInRange + * + * Public: No */ #include "script_component.hpp" -private ["_vehicle", "_distance", "_player"]; +PARAMS_2(_vehicle,_distance); -_vehicle = _this select 0; -_distance = _this select 1; +private ["_player", "_position0", "_position1"]; _player = ACE_player; diff --git a/addons/interaction/functions/fnc_joinTeam.sqf b/addons/interaction/functions/fnc_joinTeam.sqf index 2e4d1f2898..cd2ea8c880 100644 --- a/addons/interaction/functions/fnc_joinTeam.sqf +++ b/addons/interaction/functions/fnc_joinTeam.sqf @@ -1,10 +1,24 @@ -// by commy2 +/* + * Author: commy2 + * Assigns a unit to the team + * + * Arguments: + * 0: Unit + * 1: Team + * + * Return value: + * None + * + * Example: + * [target, "YELLOW"] call ace_interaction_fnc_joinTeam + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_team", "_message"]; +PARAMS_2(_unit,_team); -_unit = _this select 0; -_team = _this select 1; +private ["_message"]; _unit setVariable [QGVAR(assignedFireTeam), _team, true]; [_unit, format ["{_this assignTeam '%1'}", _team]] call EFUNC(common,execRemoteFnc); diff --git a/addons/interaction/functions/fnc_moduleInteraction.sqf b/addons/interaction/functions/fnc_moduleInteraction.sqf index 37b7bacba5..bd02093aa0 100644 --- a/addons/interaction/functions/fnc_moduleInteraction.sqf +++ b/addons/interaction/functions/fnc_moduleInteraction.sqf @@ -1,16 +1,24 @@ /* * Author: bux578 - * - * Initializes the Interaction module. + * Initializes the Interaction module * * Arguments: - * Whatever the module provides. (I dunno.) + * 0: Logic + * 1: ??? + * 2: Activation State * - * Return Value: + * Return value: * None + * + * Example: + * [logic, ???, activationState] call ace_interaction_fnc_moduleInteraction + * + * Public: No */ #include "script_component.hpp" +private ["_logic", "_activated"]; + _logic = _this select 0; _activated = _this select 2; diff --git a/addons/interaction/functions/fnc_MoveDown.sqf b/addons/interaction/functions/fnc_moveDown.sqf similarity index 81% rename from addons/interaction/functions/fnc_MoveDown.sqf rename to addons/interaction/functions/fnc_moveDown.sqf index eac30e4008..235f12fb1f 100644 --- a/addons/interaction/functions/fnc_MoveDown.sqf +++ b/addons/interaction/functions/fnc_moveDown.sqf @@ -1,21 +1,22 @@ /* - Author: Garth de Wet (LH) - - Description: - Depending on the passed value, either scrolls down through the list or up. - - Parameters: - NUMBER - Amount to increase current interaction target - - Returns: - Nothing - - Example: - 1 call FUNC(MoveDown); - -1 call FUNC(MoveDown); -*/ + * Author: Garth de Wet (LH) + * Scrolls through the list down or up + * + * Arguments: + * 0: Amount + * + * Return value: + * None + * + * Example: + * [2] call ace_interaction_fnc_moveDown + * + * Public: No + */ #include "script_component.hpp" +private ["_count", "_player", "_vehicle", "_dlgInteractionDialog", "_top", "_i", "", "_ctrl", "_index", "_action", "_color", "_current", "_infoText", "_target"]; + #define CLAMP(x,low,high) (if(x > high)then{high}else{if(x < low)then{low}else{x}}) if (isNil QGVAR(MainButton)) exitWith{}; if (isNil QGVAR(Buttons)) exitWith{}; diff --git a/addons/interaction/functions/fnc_onButtonUp.sqf b/addons/interaction/functions/fnc_onButtonUp.sqf index cee524c55f..da1b55b613 100644 --- a/addons/interaction/functions/fnc_onButtonUp.sqf +++ b/addons/interaction/functions/fnc_onButtonUp.sqf @@ -1,7 +1,21 @@ -// by commy2 +/* + * Author: commy2 + * On button up + * + * Arguments: + * None + * + * Return value: + * None + * + * Example: + * call ace_interaction_fnc_onButtonUp + * + * Public: No + */ #include "script_component.hpp" -private ["_player", "_vehicle", "_target", "_count", "_index", "_action", "_statement", "_condition", "_conditionShow", "_exceptions", "_distance"]; +private ["_player", "_vehicle", "_target", "_count", "_index", "_action", "_statement", "_condition", "_conditionShow", "_distance"]; _player = ACE_player; _vehicle = vehicle _player; @@ -20,11 +34,9 @@ _action = if (_index != -1 && {_index < _count}) then { closeDialog 0; - _statement = _action select 1; _condition = _action select 2; _conditionShow = _action select 7; -_exceptions = _action select 8;// _distance = _action select 9; if ((_distance == 0 || {[GVAR(Target), _distance] call FUNC(isInRange)}) && {[_target, _player] call _condition} && {[_target, _player] call _conditionShow}) then { diff --git a/addons/interaction/functions/fnc_onClick.sqf b/addons/interaction/functions/fnc_onClick.sqf index 29fffb8b94..a240823710 100644 --- a/addons/interaction/functions/fnc_onClick.sqf +++ b/addons/interaction/functions/fnc_onClick.sqf @@ -1,6 +1,20 @@ -// by commy2 +/* + * Author: commy2 + * On click + * + * Arguments: + * Index + * + * Return value: + * None + * + * Example: + * 5 call ace_interaction_fnc_onClick + * + * Public: No + */ #include "script_component.hpp" -private ["_player", "_vehicle", "_target", "_count", "_index", "_action", "_subMenu", "_statement", "_condition", "_conditionShow", "_exceptions", "_distance"]; +private ["_player", "_vehicle", "_target", "_count", "_index", "_action", "_subMenu", "_statement", "_condition", "_conditionShow", "_distance"]; _player = ACE_player; _vehicle = vehicle _player; @@ -29,7 +43,6 @@ if (count _subMenu < 2) then { _statement = _action select 1; _condition = _action select 2; _conditionShow = _action select 7; - _exceptions = _action select 8;// _distance = _action select 9; if ((_distance == 0 || {[GVAR(Target), _distance] call FUNC(isInRange)}) && {[_target, _player] call _condition} && {[_target, _player] call _conditionShow}) then { diff --git a/addons/interaction/functions/fnc_onSelectMenuDblClick.sqf b/addons/interaction/functions/fnc_onSelectMenuDblClick.sqf index 25d307a2eb..18b69ba40d 100644 --- a/addons/interaction/functions/fnc_onSelectMenuDblClick.sqf +++ b/addons/interaction/functions/fnc_onSelectMenuDblClick.sqf @@ -1,4 +1,18 @@ -// by CorruptedHeart, commy2 +/* + * Author: CorruptedHeart, commy2 + * On select menu double click + * + * Arguments: + * None + * + * Return value: + * None + * + * Example: + * call ace_interaction_fnc_onSelectMenuDblClick + * + * Public: No + */ #include "script_component.hpp" call compile (lbData [8866, lbCurSel 8866]) call GVAR(SelectAccept); diff --git a/addons/interaction/functions/fnc_openDoor.sqf b/addons/interaction/functions/fnc_openDoor.sqf index e175e752cb..cb416cedf0 100644 --- a/addons/interaction/functions/fnc_openDoor.sqf +++ b/addons/interaction/functions/fnc_openDoor.sqf @@ -1,19 +1,32 @@ -// by commy2 +/* + * Author: commy2 + * Opens door + * + * Arguments: + * 0: House + * 1: Door + * + * Return value: + * None + * + * Example: + * [house, "door"] call ace_interaction_fnc_openDoor + * + * Public: No + */ #include "script_component.hpp" -private ["_info", "_house", "_door", "_animations", "_lockedVariable"]; +private ["_info", "_animations", "_phase", "_position", "_time", "_usedMouseWheel"]; _info = [2] call FUNC(getDoor); -_house = _info select 0; -_door = _info select 1; +EXPLODE_2_PVT(_info,_house,_door); if (isNull _house) exitWith {}; _animations = [_house, _door] call FUNC(getDoorAnimations); -_lockedVariable = _animations select 1; -_animations = _animations select 0; +EXPLODE_2_PVT(_animations,_animations,_lockedVariable); if (count _animations == 0) exitWith {}; @@ -26,6 +39,7 @@ GVAR(isOpeningDoor) = true; playSound "ACE_Sound_Click"; [_house, _animations] spawn { + private ["_house", "_animations", "_phase", "_position", "_time", "_usedMouseWheel"]; _house = _this select 0; _animations = _this select 1; diff --git a/addons/interaction/functions/fnc_openMenuSelectUI.sqf b/addons/interaction/functions/fnc_openMenuSelectUI.sqf index a13fa6a9f0..e1b6a30df1 100644 --- a/addons/interaction/functions/fnc_openMenuSelectUI.sqf +++ b/addons/interaction/functions/fnc_openMenuSelectUI.sqf @@ -1,44 +1,57 @@ -// by commy2 +/* + * Author: commy2 + * Opens menu select UI + * + * Arguments: + * 0: Unit + * 1: Vehicle + * + * Return value: + * None + * + * Example: + * [unit, vehicle] call ace_interaction_fnc_openMenuSelectUI + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_vehicle", "_cargo"]; +PARAMS_2(_unit,_vehicle); -_unit = _this select 0; -_vehicle = _this select 1; +private ["_cargo", "_actions"]; -// allow interaction with all cargo slots and all ffv slots +// Allow interaction with all cargo slots and all FFV slots _cargo = [_vehicle, ["cargo", "ffv"], true] call EFUNC(common,getVehicleCrew); -// you can only interact if you are in cargo or ffv yourself. exit otherwise +// You can only interact if you are in cargo or FFV yourself. exit otherwise if !(_unit in _cargo) exitWith {}; GVAR(InteractionMenu_Crew) = _cargo; -// prepare: add header and "OK" button to select menu -private "_actions"; +// Prepare: add header and "OK" button to select menu _actions = [localize "STR_ACE_Interaction_InteractionMenu", localize "STR_ACE_Interaction_Interact"] call FUNC(prepareSelectMenu); -// prepare: add all cargo units as options to select menu +// Prepare: add all cargo units as options to select menu { - if (_x != _unit) then { - _actions = [ - _actions, - [_x] call EFUNC(common,getName), - QUOTE(PATHTOF(UI\dot_ca.paa)), - _forEachIndex - ] call FUNC(AddSelectableItem); - }; + if (_x != _unit) then { + _actions = [ + _actions, + [_x] call EFUNC(common,getName), + QUOTE(PATHTOF(UI\dot_ca.paa)), + _forEachIndex + ] call FUNC(addSelectableItem); + }; } forEach _cargo; -// open select menu +// Open select menu [ - _actions, - { - call FUNC(hideMenu); - [0, GVAR(InteractionMenu_Crew) select _this, ""] spawn FUNC(showMenu); - GVAR(InteractionMenu_Crew) = nil; - }, - { - call FUNC(hideMenu); - } + _actions, + { + call FUNC(hideMenu); + [0, GVAR(InteractionMenu_Crew) select _this, ""] spawn FUNC(showMenu); + GVAR(InteractionMenu_Crew) = nil; + }, + { + call FUNC(hideMenu); + } ] call FUNC(openSelectMenu); diff --git a/addons/interaction/functions/fnc_openSelectMenu.sqf b/addons/interaction/functions/fnc_openSelectMenu.sqf index de5459f88c..6e42d3af47 100644 --- a/addons/interaction/functions/fnc_openSelectMenu.sqf +++ b/addons/interaction/functions/fnc_openSelectMenu.sqf @@ -1,36 +1,42 @@ /* - Author: Garth de Wet (LH) - - Description: - Opens the select menu UI and sets up the UI - - Parameters: - 0: ARRAY - items - ARRAY - 0 = Text - 1 = statement to execute - 2 = condition before execute - 3 = showDisabled - 4 = priority - 5 = icon - 6 = extra variables. Passed to the code. - 1: Code - select action - 2: Code - Cancel Action - Returns: - Nothing - - Example: -*/ + * Author: Garth de Wet (LH) + * Opens the select menu UI and sets up the UI + * + * Arguments: + * 0: Items + * 0: Text + * 1: Statement to execute + * 2: Condition before execute + * 3: showDisabled + * 4: Priority + * 5: Icon + * 6: Extra variables passed to the code + * 1: Select Action + * 2: Cancel Action + * + * Return value: + * None + * + * Example: + * [["text", {statement}, {condition}, showDisabled, priority, "icon", [variables]], {selectAction}, {cancelAction}] call ace_interaction_fnc_openSelectMenu + * + * Public: No + */ #include "script_component.hpp" +private["_action", "_count", "_customActions", "_i"]; + if (!(profileNamespace getVariable [QGVAR(FlowMenu), false])) then { GVAR(SelectAccept) = _this select 1; GVAR(SelectCancel) = _this select 2; - buttonSetAction [8855, QUOTE( call GVAR(SelectCancel); )]; // cancel - buttonSetAction [8860, QUOTE( (call compile (lbData [ARR_2(8866, lbCurSel 8866)])) call GVAR(SelectAccept); )]; // accept + buttonSetAction [8855, QUOTE( call GVAR(SelectCancel); )]; // Cancel + buttonSetAction [8860, QUOTE( (call compile (lbData [ARR_2(8866, lbCurSel 8866)])) call GVAR(SelectAccept); )]; // Accept lbSetCurSel [8866, 0]; }else{ - _customActions = _this select 0; + PARAMS_1(_customActions); + + private ["_count", "_action"]; + _count = count _customActions; if (_count == 0) exitWith {}; _customActions call FUNC(sortOptionsByPriority); diff --git a/addons/interaction/functions/fnc_prepareSelectMenu.sqf b/addons/interaction/functions/fnc_prepareSelectMenu.sqf index 593f0d4c47..07bef07b37 100644 --- a/addons/interaction/functions/fnc_prepareSelectMenu.sqf +++ b/addons/interaction/functions/fnc_prepareSelectMenu.sqf @@ -1,28 +1,29 @@ /* - Author: Garth de Wet (LH) - - Description: - Prepares the select menu for use. - - Parameters: - 0: TEXT - Header text - 1: TEXT - Approve button text - - Returns: - ARRAY/NUMBER - container object for use with AddSelectableItem. - - Example: - ["Select Explosive", "Place"] call FUNC(prepareSelectMenu); -*/ + * Author: Garth de Wet (LH) + * Prepares the select menu for use + * + * Arguments: + * 0: Header Text + * 1: Approve Button Text + * + * Return value: + * Container object + * + * Example: + * array = ["Select Explosive", "Place"] call ace_interaction_fnc_prepareSelectMenu + * + * Public: No + */ #include "script_component.hpp" -private ["_buttonAction", "_header", "_buttonText", "_cancelButton"]; +PARAMS_2(_header,_buttonText); + closeDialog 0; -_header = _this select 0; -_buttonText = _this select 1; + if (isNil "_buttonText" or {_buttonText == ""}) then { _buttonText = localize "STR_ACE_Interaction_MakeSelection"; }; + createDialog "RscACE_SelectAnItem"; ctrlSetText [8860, _buttonText]; ctrlSetText [8870, _header]; diff --git a/addons/interaction/functions/fnc_push.sqf b/addons/interaction/functions/fnc_push.sqf index f52a9d40de..946a5118be 100644 --- a/addons/interaction/functions/fnc_push.sqf +++ b/addons/interaction/functions/fnc_push.sqf @@ -1,22 +1,26 @@ /* * Author: KoffeinFlummi - * - * Pushes a boat away from the player. + * Pushes a boat away from the player * * Arguments: - * 0: Boat (object) - * 1: Velocity (vectorlike array) + * 0: Boat + * 1: Velocity * * Return Value: * None + * + * Example: + * [target, [vector]] call ace_interaction_fnc_push + * + * Public: No */ + #include "script_component.hpp" -_boat = _this select 0; -_velocity = _this select 1; +PARAMS_2(_boat,_velocity); if !(local _boat) exitWith { - [_this, QUOTE(FUNC(push)), _boat] call EFUNC(common,execRemoteFnc); + [_this, QUOTE(FUNC(push)), _boat] call EFUNC(common,execRemoteFnc); }; _boat setVelocity _velocity; diff --git a/addons/interaction/functions/fnc_removeTag.sqf b/addons/interaction/functions/fnc_removeTag.sqf index 0894520149..b70f04ec99 100644 --- a/addons/interaction/functions/fnc_removeTag.sqf +++ b/addons/interaction/functions/fnc_removeTag.sqf @@ -1,7 +1,23 @@ -// by commy2 +/* + * Author: commy2 + * Removes tag + * + * Arguments: + * None + * + * Return value: + * None + * + * Example: + * call ace_interaction_fnc_removeTag + * + * Public: No + */ #include "script_component.hpp" 0 spawn { + private ["_index", "_name"]; + waitUntil {player getVariable ["ACE_Name", ""] != ""}; _name = player getVariable ["ACE_Name", ""]; diff --git a/addons/interaction/functions/fnc_sendAway.sqf b/addons/interaction/functions/fnc_sendAway.sqf index 5cd6a9d43a..0dd106de08 100644 --- a/addons/interaction/functions/fnc_sendAway.sqf +++ b/addons/interaction/functions/fnc_sendAway.sqf @@ -1,36 +1,40 @@ /* * Author: KoffeinFlummi - * - * Sends a civilian crowd away (chance of failure). + * Sends a civilian crowd away with a chance of failure * * Arguments: - * 0: Unit to be sent away (Object) + * 0: Unit * * Return value: - * none -*/ + * None + * + * Example: + * [target] call ace_interaction_fnc_sendAway + * + * Public: No + */ #include "script_component.hpp" #define DISTANCE 50 #define RADIUS 10 -private ["_unit", "_chance", "_x"]; +PARAMS_1(_unit); -_unit = _this select 0; +private ["_chance", "_x"]; ACE_player playActionNow "GestureGo"; if (count weapons ACE_player > 0) then { - _chance = 0.8; + _chance = 0.8; } else { - _chance = 0.5; + _chance = 0.5; }; { - if (count (weapons _unit) == 0 and random 1 < _chance) then { - [-2, { - (_this select 0) setUnitPos "AUTO"; - (_this select 0) doMove [(getPos (_this select 0) select 0) + DISTANCE * (eyeDirection (_this select 1) select 0), (getPos (_this select 0) select 1) + DISTANCE * (eyeDirection (_this select 1) select 1), 0]; - }, [_x, ACE_player]] call CBA_fnc_globalExecute; - }; -} foreach (_unit nearEntities ["Civilian", RADIUS]); + if (count (weapons _unit) == 0 and random 1 < _chance) then { + [-2, { + (_this select 0) setUnitPos "AUTO"; + (_this select 0) doMove [(getPos (_this select 0) select 0) + DISTANCE * (eyeDirection (_this select 1) select 0), (getPos (_this select 0) select 1) + DISTANCE * (eyeDirection (_this select 1) select 1), 0]; + }, [_x, ACE_player]] call CBA_fnc_globalExecute; + }; +} forEach (_unit nearEntities ["Civilian", RADIUS]); diff --git a/addons/interaction/functions/fnc_showMouseHint.sqf b/addons/interaction/functions/fnc_showMouseHint.sqf index 5cb96a0eae..e3a9b45f94 100644 --- a/addons/interaction/functions/fnc_showMouseHint.sqf +++ b/addons/interaction/functions/fnc_showMouseHint.sqf @@ -1,28 +1,28 @@ /* - Author(s): - Garth de Wet (LH) - - Description: - Shows the interaction helper text with the mouse buttons at the bottom middle of the screen - - Parameters: - 0: STRING - Left click text - 1: STRING - Right click text - 3: STRING - (Optional) Scroll text - - Returns: - Nothing - - Example: - ["Place Explosive", "Cancel"] call FUNC(showMouseHint); -*/ + * Author: Garth de Wet (LH) + * Shows the interaction helper text with the mouse buttons at the bottom middle of the screen + * + * Arguments: + * 0: Left Click Text + * 1: Right Click Text + * 2: Scroll Text (Optional) + * + * Return value: + * None + * + * Example: + * ["Place Explosive", "Cancel"] call ace_interaction_fnc_showMouseHint + * + * Public: No + */ #include "script_component.hpp" #define GUI_GRID_W (0.025) #define GUI_GRID_H (0.04) -private ["_leftClick", "_rightClick", "_scroll"]; -_leftClick = _this select 0; -_rightClick = _this select 1; + +private ["_scroll", "_display"]; + +PARAMS_2(_leftClick,_rightClick); _scroll = ""; if (count _this > 2) then { _scroll = _this select 2; @@ -44,11 +44,10 @@ if (isNull _display) exitWith{}; if (_scroll == "") exitWith { (_display displayCtrl 1002) ctrlShow false; (_display displayCtrl 1202) ctrlShow false; - - (_display displayCtrl 1001) ctrlSetPosition [21 * GUI_GRID_W, 18 * GUI_GRID_H, 8 * GUI_GRID_W, 1.5 * GUI_GRID_H]; - (_display displayCtrl 1201) ctrlSetPosition [20 * GUI_GRID_W, 18.5 * GUI_GRID_H, 1 * GUI_GRID_W, 1 * GUI_GRID_H]; + (_display displayCtrl 1001) ctrlSetPosition [21 * GUI_GRID_W, 18 * GUI_GRID_H, 8 * GUI_GRID_W, 1.5 * GUI_GRID_H]; + (_display displayCtrl 1201) ctrlSetPosition [20 * GUI_GRID_W, 18.5 * GUI_GRID_H, 1 * GUI_GRID_W, 1 * GUI_GRID_H]; (_display displayCtrl 1001) ctrlCommit 0; (_display displayCtrl 1201) ctrlCommit 0; }; (_display displayCtrl 1002) ctrlSetText _scroll; -showHUD false; \ No newline at end of file +showHUD false; diff --git a/addons/interaction/functions/fnc_sortOptionsByPriority.sqf b/addons/interaction/functions/fnc_sortOptionsByPriority.sqf index 28daa4e7e5..05a4f3bad4 100644 --- a/addons/interaction/functions/fnc_sortOptionsByPriority.sqf +++ b/addons/interaction/functions/fnc_sortOptionsByPriority.sqf @@ -1,4 +1,18 @@ -// by commy2 +/* + * Author: commy2 + * Sort options by priority + * + * Arguments: + * Actions + * + * Return value: + * None + * + * Example: + * customActions call ace_interaction_fnc_sortOptionsByPriority + * + * Public: No + */ #include "script_component.hpp" private ["_actions", "_count", "_index", "_actionN", "_actionM"]; diff --git a/addons/interaction/functions/fnc_tapShoulder.sqf b/addons/interaction/functions/fnc_tapShoulder.sqf index 11fc6b7881..510fa4497f 100644 --- a/addons/interaction/functions/fnc_tapShoulder.sqf +++ b/addons/interaction/functions/fnc_tapShoulder.sqf @@ -1,4 +1,19 @@ -// by commy2 +/* + * Author: commy2 + * Taps a shoulder + * + * Arguments: + * 0: Player + * 1: Target + * + * Return value: + * None + * + * Example: + * [player, target] call ace_interaction_fnc_tapShoulder + * + * Public: No + */ #include "script_component.hpp" EXPLODE_3_PVT(_this,_tapper,_target,_shoulderNum); @@ -13,7 +28,7 @@ if (_target != ACE_player) exitWith { addCamShake [4, 0.5, 5]; -private "_message"; +private ["_message"]; //localize is converting the escaped <> symbols, so just add them here instead of in the stringtable if (_shoulderNum == 0) then { _message = format ["%1 >", (localize "STR_ACE_Interaction_YouWereTappedRight")]; diff --git a/addons/interaction/functions/fnc_updateTooltipPosition.sqf b/addons/interaction/functions/fnc_updateTooltipPosition.sqf index 27148c5aa3..93acd6d203 100644 --- a/addons/interaction/functions/fnc_updateTooltipPosition.sqf +++ b/addons/interaction/functions/fnc_updateTooltipPosition.sqf @@ -1,12 +1,32 @@ -// by commy2 +/* + * Author: commy2 + * Updates tooltip's position + * + * Arguments: + * 0: Tooltip Display + * 1: X Coordinate + * 2: Y Coordinate + * + * Return value: + * None + * + * Example: + * [player, 0.5, 0.5] call ace_interaction_fnc_updateTooltipPosition + * + * Public: No + */ #include "script_component.hpp" +PARAMS_3(_tooltip,_coordinateX,_coordinateY); + +private["_ctrl"]; + disableSerialization; -_ctrl = ctrlParent (_this select 0) displayCtrl 40; +_ctrl = ctrlParent _tooltip displayCtrl 40; _ctrl ctrlSetPosition [ - (_this select 1) + 0.01 * safezoneW, - (_this select 2) + 0.01 * safezoneH, + _coordinateX + 0.01 * safezoneW, + _coordinateY + 0.01 * safezoneH, 2.0 / 16 * safezoneW, 0.3 / 9 * safezoneH ]; diff --git a/addons/interaction/stringtable.xml b/addons/interaction/stringtable.xml index 32a901507b..b2e75ccdff 100644 --- a/addons/interaction/stringtable.xml +++ b/addons/interaction/stringtable.xml @@ -1,4 +1,4 @@ - + @@ -522,7 +522,7 @@ Rot Rojo Rouge - Czerwony + Czerwonych Červený Красный Vermelha @@ -534,7 +534,7 @@ Grün Verde Vert - Zielony + Zielonych Zelený Зеленый Verde @@ -546,7 +546,7 @@ Blau Azul Bleu - Niebieski + Niebieskich Modrý Синий Azul @@ -558,7 +558,7 @@ Gelb Amarillo Jaune - Żółty + Żółtych Žlutý Жёлтый Amarela @@ -666,7 +666,7 @@ Du bist Gruppe %1 beigetreten Te has unido al equipo %1 Tu as rejoint l'équipe %1 - Dołączyłeś do drużyny %1 + Dołączyłeś do %1 Připojil ses do %1 týmu Вы присоединились к группе %1 Você uniu-se à Equipe %1 @@ -793,5 +793,21 @@ Passeggeri Passageiros + + Interaction System + System interakcji + + + Enable Team Management + Wł. zarządzanie drużyną + + + Should players be allowed to use the Team Management Menu? Default: Yes + Czy gracze mogą korzystać z menu zarządzania drużyną? Domyślnie: Tak + + + + Na zarządzanie drużyną składa się: przydział kolorów dla członków drużyny, przejmowanie dowodzenia, dołączanie/opuszczanie drużyn. + - + \ No newline at end of file diff --git a/addons/javelin/CfgVehicles.hpp b/addons/javelin/CfgVehicles.hpp index 48781036ad..1cd527089d 100644 --- a/addons/javelin/CfgVehicles.hpp +++ b/addons/javelin/CfgVehicles.hpp @@ -16,7 +16,7 @@ class CfgVehicles { class MainTurret : MainTurret { weapons[] = { QGVAR(Titan_Static) }; magazines[] = {"1Rnd_GAT_missiles","1Rnd_GAT_missiles","1Rnd_GAT_missiles","1Rnd_GAT_missiles"}; - + turretInfoType = "ACE_RscOptics_javelin"; gunnerOpticsModel = PATHTOF(data\reticle_titan.p3d); opticsZoomMin = 0.08333; @@ -29,12 +29,12 @@ class CfgVehicles { }; }; }; - class O_static_AT_F: AT_01_base_F { + class O_static_AT_F: AT_01_base_F { class Turrets : Turrets { class MainTurret : MainTurret { weapons[] = { QGVAR(Titan_Static) }; magazines[] = {"1Rnd_GAT_missiles","1Rnd_GAT_missiles","1Rnd_GAT_missiles","1Rnd_GAT_missiles"}; - + turretInfoType = "ACE_RscOptics_javelin"; gunnerOpticsModel = PATHTOF(data\reticle_titan.p3d); opticsZoomMin = 0.08333; @@ -47,12 +47,12 @@ class CfgVehicles { }; }; }; - class I_static_AT_F: AT_01_base_F { + class I_static_AT_F: AT_01_base_F { class Turrets : Turrets { class MainTurret : MainTurret { weapons[] = { QGVAR(Titan_Static) }; magazines[] = {"1Rnd_GAT_missiles","1Rnd_GAT_missiles","1Rnd_GAT_missiles","1Rnd_GAT_missiles"}; - + turretInfoType = "ACE_RscOptics_javelin"; gunnerOpticsModel = PATHTOF(data\reticle_titan.p3d); opticsZoomMin = 0.08333; diff --git a/addons/javelin/CfgWeapons.hpp b/addons/javelin/CfgWeapons.hpp index 1bbf713b3b..75aaf7c332 100644 --- a/addons/javelin/CfgWeapons.hpp +++ b/addons/javelin/CfgWeapons.hpp @@ -38,7 +38,7 @@ class CfgWeapons { lockingTargetSound[] = {"",0,1}; lockedTargetSound[] = {"",0,1}; }; - class launch_I_Titan_short_F: launch_Titan_short_base { + class launch_I_Titan_short_F: launch_Titan_short_base { GVAR(enabled) = 1; weaponInfoType = "ACE_RscOptics_javelin"; modelOptics = PATHTOF(data\reticle_titan.p3d); @@ -48,7 +48,7 @@ class CfgWeapons { lockingTargetSound[] = {"",0,1}; lockedTargetSound[] = {"",0,1}; }; - class launch_O_Titan_short_F: launch_Titan_short_base { + class launch_O_Titan_short_F: launch_Titan_short_base { GVAR(enabled) = 1; weaponInfoType = "ACE_RscOptics_javelin"; modelOptics = PATHTOF(data\reticle_titan.p3d); @@ -59,7 +59,7 @@ class CfgWeapons { lockingTargetSound[] = {"",0,1}; lockedTargetSound[] = {"",0,1}; }; - class launch_Titan_short_F: launch_Titan_short_base { + class launch_Titan_short_F: launch_Titan_short_base { GVAR(enabled) = 1; weaponInfoType = "ACE_RscOptics_javelin"; modelOptics = PATHTOF(data\reticle_titan.p3d); diff --git a/addons/kestrel4500/$PBOPREFIX$ b/addons/kestrel4500/$PBOPREFIX$ new file mode 100644 index 0000000000..15660502ce --- /dev/null +++ b/addons/kestrel4500/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\kestrel4500 \ No newline at end of file diff --git a/addons/kestrel4500/XEH_postInit.sqf b/addons/kestrel4500/XEH_postInit.sqf index 24a972c326..eb22aa1de2 100644 --- a/addons/kestrel4500/XEH_postInit.sqf +++ b/addons/kestrel4500/XEH_postInit.sqf @@ -22,4 +22,6 @@ GVAR(MeasuredWindSpeed) = 0; GVAR(ImpellerState) = 0; GVAR(Kestrel4500) = false; -GVAR(Overlay) = false; \ No newline at end of file +GVAR(Overlay) = false; + +[] call FUNC(restoreUserData); \ No newline at end of file diff --git a/addons/kestrel4500/XEH_preInit.sqf b/addons/kestrel4500/XEH_preInit.sqf index 2d5e211a54..7b36167a16 100644 --- a/addons/kestrel4500/XEH_preInit.sqf +++ b/addons/kestrel4500/XEH_preInit.sqf @@ -3,17 +3,17 @@ ADDON = false; PREP(buttonPressed); -PREP(calculateWindSpeed); PREP(canShow); PREP(collectData); PREP(createKestrelDialog); PREP(displayKestrel); PREP(generateOutputData); PREP(measureWindSpeed); +PREP(onCloseDialog); +PREP(onCloseDisplay); +PREP(restoreUserData); +PREP(storeUserData); PREP(updateDisplay); PREP(updateImpellerState); -PREP(onCloseDialog); -PREP(onCloseDisplay); - ADDON = true; diff --git a/addons/kestrel4500/functions/fnc_buttonPressed.sqf b/addons/kestrel4500/functions/fnc_buttonPressed.sqf index f0f9a10db1..1d73f9ac79 100644 --- a/addons/kestrel4500/functions/fnc_buttonPressed.sqf +++ b/addons/kestrel4500/functions/fnc_buttonPressed.sqf @@ -51,3 +51,4 @@ switch (_this) do { }; [] call FUNC(updateDisplay); +[] call FUNC(storeUserData); diff --git a/addons/kestrel4500/functions/fnc_calculateWindSpeed.sqf b/addons/kestrel4500/functions/fnc_calculateWindSpeed.sqf deleted file mode 100644 index 8267f7f729..0000000000 --- a/addons/kestrel4500/functions/fnc_calculateWindSpeed.sqf +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Author: Ruthberg - * - * Calculates the wind speed at a given world position - * - * Arguments: - * 0: _this - world position - * - * Return Value: - * 0: wind speed - m/s - * - * Public: No - */ -#include "script_component.hpp" - -private ["_windSpeed", "_windDir", "_newWindSpeed", "_windSource"]; - -fnc_polar2vect = { - private ["_mag2D"]; - _mag2D = (_this select 0) * cos((_this select 2)); - [_mag2D * sin((_this select 1)), _mag2D * cos((_this select 1)), (_this select 0) * sin((_this select 2))]; -}; - -_windSpeed = vectorMagnitude ACE_wind; -_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); - -// Terrain effect on wind -if (_windSpeed > 0.05) then { - _newWindSpeed = 0; - { - _windSource = [100, _windDir + 180, _x] call fnc_polar2vect; - if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 9) * _windSpeed; - }; - _windSource = [100, _windDir + 180 + _x, 0] call fnc_polar2vect; - if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 9) * _windSpeed; - }; - _windSource = [100, _windDir + 180 - _x, 0] call fnc_polar2vect; - if (!(terrainIntersectASL [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 9) * _windSpeed; - }; - } forEach [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - _windSpeed = _newWindSpeed; -}; - -// Obstacle effect on wind -if (_windSpeed > 0.05) then { - _newWindSpeed = 0; - { - _windSource = [20, _windDir + 180, _x] call fnc_polar2vect; - if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 2) * _windSpeed; - }; - _windSource = [20, _windDir + 180 + _x, 0] call fnc_polar2vect; - if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 2) * _windSpeed; - }; - _windSource = [20, _windDir + 180 - _x, 0] call fnc_polar2vect; - if (!(lineIntersects [_this, _this vectorAdd _windSource])) exitWith { - _newWindSpeed = cos(_x * 2) * _windSpeed; - }; - } forEach [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]; - _windSpeed = _newWindSpeed; -}; -_windSpeed = 0 max _windSpeed; - -_windSpeed diff --git a/addons/kestrel4500/functions/fnc_collectData.sqf b/addons/kestrel4500/functions/fnc_collectData.sqf index a812ad0f7c..60bab4b9ec 100644 --- a/addons/kestrel4500/functions/fnc_collectData.sqf +++ b/addons/kestrel4500/functions/fnc_collectData.sqf @@ -14,13 +14,14 @@ */ #include "script_component.hpp" -private ["_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"]; +private ["_playerAltitude", "_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"]; +_playerAltitude = (getPosASL ACE_player) select 2; if (isNil QGVAR(MIN) || isNil QGVAR(MAX)) then { - _temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2); + _temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); _humidity = EGVAR(weather,currentHumidity); - _barometricPressure = ((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure); - _altitude = EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2); + _barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); + _altitude = EGVAR(weather,Altitude) + _playerAltitude; GVAR(MIN) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude]; GVAR(MAX) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude]; }; @@ -42,9 +43,9 @@ if (GVAR(MinAvgMaxMode) == 1) then { // Wind SPD _windSpeed = call FUNC(measureWindSpeed); - GVAR(MIN) set [1, (GVAR(MIN) select 1) min abs(_windSpeed)]; - GVAR(MAX) set [1, abs(_windSpeed) max (GVAR(MAX) select 1)]; - GVAR(TOTAL) set [1, (GVAR(TOTAL) select 1) + abs(_windSpeed)]; + GVAR(MIN) set [1, (GVAR(MIN) select 1) min _windSpeed]; + GVAR(MAX) set [1, _windSpeed max (GVAR(MAX) select 1)]; + GVAR(TOTAL) set [1, (GVAR(TOTAL) select 1) + _windSpeed]; // CROSSWIND _crosswind = 0; @@ -70,7 +71,7 @@ if (GVAR(MinAvgMaxMode) == 1) then { }; // TEMP -_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2); +_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); GVAR(MIN) set [4, (GVAR(MIN) select 4) min _temperature]; GVAR(MAX) set [4, _temperature max (GVAR(MAX) select 4)]; GVAR(TOTAL) set [4, (GVAR(TOTAL) select 4) + _temperature]; @@ -82,13 +83,13 @@ GVAR(MAX) set [5, _humidity max (GVAR(MAX) select 5)]; GVAR(TOTAL) set [5, (GVAR(TOTAL) select 5) + _humidity]; // BARO -_barometricPressure = ((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure); +_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); GVAR(MIN) set [6, (GVAR(MIN) select 6) min _barometricPressure]; GVAR(MAX) set [6, _barometricPressure max (GVAR(MAX) select 6)]; GVAR(TOTAL) set [6, (GVAR(TOTAL) select 6) + _barometricPressure]; // ALTITUDE -_altitude = EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2); +_altitude = EGVAR(weather,Altitude) + _playerAltitude; GVAR(MIN) set [7, (GVAR(MIN) select 7) min _altitude]; GVAR(MAX) set [7, _altitude max (GVAR(MAX) select 7)]; GVAR(TOTAL) set [7, (GVAR(TOTAL) select 7) + _altitude]; \ No newline at end of file diff --git a/addons/kestrel4500/functions/fnc_generateOutputData.sqf b/addons/kestrel4500/functions/fnc_generateOutputData.sqf index 6b139fe72e..1549bbe9cb 100644 --- a/addons/kestrel4500/functions/fnc_generateOutputData.sqf +++ b/addons/kestrel4500/functions/fnc_generateOutputData.sqf @@ -34,10 +34,11 @@ _textInfoLine2 = ""; _windSpeed = call FUNC(measureWindSpeed); _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); -_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2); -_humidity = EGVAR(weather,currentHumidity); - _playerDir = getDir ACE_player; +_playerAltitude = (getPosASL ACE_player) select 2; + +_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); +_humidity = EGVAR(weather,currentHumidity); GVAR(Direction) = 4 * floor(_playerDir / 90); if (_playerDir % 90 > 10) then { GVAR(Direction) = GVAR(Direction) + 1}; @@ -174,7 +175,7 @@ switch (GVAR(Menu)) do { }; case 6: { // BARO if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round((((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); + _textCenterBig = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); } else { _textCenterLine1Left = "Min"; _textCenterLine2Left = "Avg"; @@ -186,7 +187,7 @@ switch (GVAR(Menu)) do { }; case 7: { // ALTITUDE if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2))); + _textCenterBig = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); } else { _textCenterLine1Left = "Min"; _textCenterLine2Left = "Avg"; @@ -198,7 +199,7 @@ switch (GVAR(Menu)) do { }; case 8: { // User Screen 1 _textCenterLine1Left = Str(round(_playerDir)); - _textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2))); + _textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); _textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10); _textCenterLine1Right = GVAR(Directions) select GVAR(Direction); _textCenterLine2Right = "m"; @@ -207,7 +208,7 @@ switch (GVAR(Menu)) do { case 9: { // User Screen 2 _textCenterLine1Left = Str(round(_temperature * 10) / 10); _textCenterLine2Left = Str(round(_humidity * 100 * 10) / 10); - _textCenterLine3Left = Str(round((1013.25 * exp(-(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2)) / 7990) - 10 * overcast) * 10) / 10); + _textCenterLine3Left = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); _textCenterLine1Right = "C"; _textCenterLine2Right = "%"; _textCenterLine3Right = "hPA"; diff --git a/addons/kestrel4500/functions/fnc_measureWindSpeed.sqf b/addons/kestrel4500/functions/fnc_measureWindSpeed.sqf index eb718906aa..73b4e228d6 100644 --- a/addons/kestrel4500/functions/fnc_measureWindSpeed.sqf +++ b/addons/kestrel4500/functions/fnc_measureWindSpeed.sqf @@ -19,12 +19,13 @@ private ["_playerDir", "_windSpeed", "_windDir"]; _playerDir = getDir ACE_player; _windSpeed = vectorMagnitude ACE_wind; _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); - if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { - _windSpeed = (eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed); + // With wind gradient + _windSpeed = [eyePos ACE_player, true, true, true] call EFUNC(weather,calculateWindSpeed); _windSpeed = abs(cos(_playerDir - _windDir)) * _windSpeed; } else { - _windSpeed = (eyePos ACE_player) call FUNC(calculateWindSpeed); + // Without wind gradient + _windSpeed = [eyePos ACE_player, false, true, true] call EFUNC(weather,calculateWindSpeed); }; if (_windSpeed > 0.3 || {GVAR(MeasuredWindSpeed) > 0.1 && _windSpeed > 0.125}) then { diff --git a/addons/kestrel4500/functions/fnc_restoreUserData.sqf b/addons/kestrel4500/functions/fnc_restoreUserData.sqf new file mode 100644 index 0000000000..3cd96d80af --- /dev/null +++ b/addons/kestrel4500/functions/fnc_restoreUserData.sqf @@ -0,0 +1,18 @@ +/* + * Author: Ruthberg + * Reads user data from profileNamespace + * + * Arguments: + * Nothing + * + * Return Value: + * Nothing + * + * Example: + * call ace_kestrel4500_fnc_restore_user_data + * + * Public: No + */ +#include "script_component.hpp" + +GVAR(Menu) = 0 max (profileNamespace getVariable ["ACE_Kestrel4500_menu", 0]) min ((count GVAR(Menus)) - 1); diff --git a/addons/kestrel4500/functions/fnc_storeUserData.sqf b/addons/kestrel4500/functions/fnc_storeUserData.sqf new file mode 100644 index 0000000000..3b7ce9dd4d --- /dev/null +++ b/addons/kestrel4500/functions/fnc_storeUserData.sqf @@ -0,0 +1,18 @@ +/* + * Author: Ruthberg + * Saves user data into profileNamespace + * + * Arguments: + * Nothing + * + * Return Value: + * Nothing + * + * Example: + * call ace_kestrel4500_fnc_store_user_data + * + * Public: No + */ +#include "script_component.hpp" + +profileNamespace setVariable ["ACE_Kestrel4500_menu", GVAR(menu)]; diff --git a/addons/kestrel4500/script_component.hpp b/addons/kestrel4500/script_component.hpp index b8db2edb78..90c338ebeb 100644 --- a/addons/kestrel4500/script_component.hpp +++ b/addons/kestrel4500/script_component.hpp @@ -10,5 +10,3 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" - -#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h)) diff --git a/addons/laser/functions/fnc_seekerFindLaserSpot.sqf b/addons/laser/functions/fnc_seekerFindLaserSpot.sqf index 77713eb591..346aec837e 100644 --- a/addons/laser/functions/fnc_seekerFindLaserSpot.sqf +++ b/addons/laser/functions/fnc_seekerFindLaserSpot.sqf @@ -1,32 +1,32 @@ -/* - * Author: Nou - * Turn a laser designator on. - * - * Arguments: - * 0: Position of seeker (ASL) - * 1: Direction vector (will be normalized) - * 2: Seeker FOV in degrees - * 3: Seeker wavelength sensitivity range, [1550,1550] is common eye safe. - * 4: Seeker laser code. - * - * Return value: - * Array, [Strongest compatible laser spot ASL pos, owner object] Nil array values if nothing found. - */ - -#include "script_component.hpp" - -private ["_pos", "_seekerWavelengths", "_seekerCode", "_spots", "_buckets", "_excludes", "_bucketIndex", "_finalPos", "_owner", "_obj", "_x", "_method"]; -private ["_emitterWavelength", "_laserCode", "_divergence", "_laser", "_laserPos", "_laserDir", "_res", "_bucketPos", "_bucketList", "_c", "_forEachIndex", "_index"]; -private ["_testPos", "_finalBuckets", "_largest", "_largestIndex", "_finalBucket", "_owners", "_avgX", "_avgY", "_avgZ", "_count", "_maxOwner", "_maxOwnerIndex", "_finalOwner"]; -private["_dir", "_seekerCos", "_seekerFov", "_testDotProduct", "_testPoint", "_testPointVector"]; - -_pos = _this select 0; -_dir = vectorNormalized (_this select 1); +/* + * Author: Nou + * Turn a laser designator on. + * + * Arguments: + * 0: Position of seeker (ASL) + * 1: Direction vector (will be normalized) + * 2: Seeker FOV in degrees + * 3: Seeker wavelength sensitivity range, [1550,1550] is common eye safe. + * 4: Seeker laser code. + * + * Return value: + * Array, [Strongest compatible laser spot ASL pos, owner object] Nil array values if nothing found. + */ + +#include "script_component.hpp" + +private ["_pos", "_seekerWavelengths", "_seekerCode", "_spots", "_buckets", "_excludes", "_bucketIndex", "_finalPos", "_owner", "_obj", "_x", "_method"]; +private ["_emitterWavelength", "_laserCode", "_divergence", "_laser", "_laserPos", "_laserDir", "_res", "_bucketPos", "_bucketList", "_c", "_forEachIndex", "_index"]; +private ["_testPos", "_finalBuckets", "_largest", "_largestIndex", "_finalBucket", "_owners", "_avgX", "_avgY", "_avgZ", "_count", "_maxOwner", "_maxOwnerIndex", "_finalOwner"]; +private["_dir", "_seekerCos", "_seekerFov", "_testDotProduct", "_testPoint", "_testPointVector"]; + +_pos = _this select 0; +_dir = vectorNormalized (_this select 1); _seekerFov = _this select 2; _seekerWavelengths = _this select 3; -_seekerCode = _this select 4; - - +_seekerCode = _this select 4; + + _seekerCos = cos _seekerFov; _spots = []; @@ -47,9 +47,9 @@ _finalOwner = nil; _laser = []; if(IS_CODE(_method)) then { _laser = _x call _method; - } else { - if(IS_STRING(_method)) then { - _laser = _x call (missionNamespace getVariable [_method, {}]); + } else { + if(IS_STRING(_method)) then { + _laser = _x call (missionNamespace getVariable [_method, {}]); } else { if(IS_ARRAY(_method)) then { if(count _method == 2) then { @@ -59,18 +59,18 @@ _finalOwner = nil; _laser = [ATLtoASL (_obj modelToWorldVisual (_method select 0)), (ATLtoASL (_obj modelToWorldVisual (_method select 1))) vectorFromTo (ATLtoASL (_obj modelToWorldVisual (_method select 2)))]; }; }; - }; + }; }; }; _laserPos = _laser select 0; _laserDir = _laser select 1; _res = [_laserPos, _laserDir, _divergence] call FUNC(shootCone); - { - _testPoint = _x select 0; - _testPointVector = vectorNormalized (_testPoint vectorDiff _pos); - _testDotProduct = _dir vectorDotProduct _testPointVector; + { + _testPoint = _x select 0; + _testPointVector = vectorNormalized (_testPoint vectorDiff _pos); + _testDotProduct = _dir vectorDotProduct _testPointVector; if(_testDotProduct > _seekerCos) then { - _spots pushBack [_testPoint, _owner]; + _spots pushBack [_testPoint, _owner]; }; } forEach (_res select 2); }; @@ -128,7 +128,7 @@ if((count _spots) > 0) then { _avgY = 0; _avgZ = 0; { - player sideChat format["x: %1", _x]; + //player sideChat format["x: %1", _x]; _avgX = _avgX + ((_x select 0) select 0); _avgY = _avgY + ((_x select 0) select 1); _avgZ = _avgZ + ((_x select 0) select 2); diff --git a/addons/magazinerepack/functions/fnc_simulateRepackEvents.sqf b/addons/magazinerepack/functions/fnc_simulateRepackEvents.sqf index 4ef69044da..67c5c4630b 100644 --- a/addons/magazinerepack/functions/fnc_simulateRepackEvents.sqf +++ b/addons/magazinerepack/functions/fnc_simulateRepackEvents.sqf @@ -24,7 +24,8 @@ private ["_newMagFnc", "_time", "_events", "_swapAmmoFnc", "_ammoSwaped", "_lowI PARAMS_3(_fullMagazineCount,_arrayOfAmmoCounts,_isBelt); // Sort Ascending - Don't modify original -_arrayOfAmmoCounts = (+_arrayOfAmmoCounts) call BIS_fnc_sortNum; +_arrayOfAmmoCounts = +_arrayOfAmmoCounts; +_arrayOfAmmoCounts sort true; _newMagFnc = { _time = _time + GVAR(TimePerMagazine); diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index d4b6739918..175e5f63c7 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -82,4 +82,8 @@ #define HASHLIST_SET(hashList, index, value) ([hashList, index, value, __FILE__, __LINE__] call EFUNC(common,hashListSet)) #define HASHLIST_PUSH(hashList, value) ([hashList, value, __FILE__, __LINE__] call EFUNC(common,hashListPush)) +// Time functions for accuracy per frame +#define ACE_tickTime (ACE_time + (diag_tickTime - ACE_diagTime)) + + #include "script_debug.hpp" \ No newline at end of file diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index 5777d7223e..c4bd23f779 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -6,7 +6,7 @@ #define MAJOR 3 #define MINOR 0 #define PATCHLVL 0 -#define BUILD 2 +#define BUILD 3 #define VERSION MAJOR.MINOR.PATCHLVL.BUILD #define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD diff --git a/addons/map/CfgVehicles.hpp b/addons/map/CfgVehicles.hpp index 612cadb006..a5194e015e 100644 --- a/addons/map/CfgVehicles.hpp +++ b/addons/map/CfgVehicles.hpp @@ -3,74 +3,66 @@ class CfgVehicles { class ACE_ModuleMap: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Map"; + displayName = "$STR_ACE_Map_Module_DisplayName"; function = QFUNC(moduleMap); scope = 2; isGlobal = 1; icon = PATHTOF(UI\Icon_Module_Map_ca.paa); class Arguments { class MapIllumination { - displayName = "Map illumination?"; - description = "Calculate dynamic map illumination based on light conditions?"; + displayName = "$STR_ACE_Map_MapIllumination_DisplayName"; + description = "$STR_ACE_Map_MapIllumination_Description"; typeName = "BOOL"; - class values { - class Yes { name = "Yes"; value = 1; default = 1; }; - class No { name = "No"; value = 0; }; - }; + defaultValue = 1; }; class MapShake { - displayName = "Map shake?"; - description = "Make map shake when walking?"; + displayName = "$STR_ACE_Map_MapShake_DisplayName"; + description = "$STR_ACE_Map_MapShake_Description"; typeName = "BOOL"; - class values { - class Yes { name = "Yes"; value = 1; default = 1;}; - class No { name = "No"; value = 0; }; - }; + defaultValue = 1; }; class MapLimitZoom { - displayName = "Limit map zoom?"; - description = "Limit the amount of zoom available for the map?"; + displayName = "$STR_ACE_Map_MapLimitZoom_DisplayName"; + description = "$STR_ACE_Map_MapLimitZoom_Description"; typeName = "BOOL"; - class values { - class Yes { name = "Yes"; value = 1; }; - class No { name = "No"; value = 0; default = 1;}; - }; + defaultValue = 0; }; class MapShowCursorCoordinates { - displayName = "Show cursor coordinates?"; - description = "Show the grid coordinates on the mouse pointer?"; + displayName = "$STR_ACE_Map_MapShowCursorCoordinates_DisplayName"; + description = "$STR_ACE_Map_MapShowCursorCoordinates_Description"; typeName = "BOOL"; - class values { - class Yes { name = "Yes"; value = 1; }; - class No { name = "No"; value = 0; default = 1;}; - }; + defaultValue = 0; }; }; + class ModuleDescription { + description = "$STR_ACE_Map_Module_Description"; + }; }; class ACE_ModuleBlueForceTracking: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Blue Force Tracking"; + displayName = "$STR_ACE_Map_BFT_Module_DisplayName"; function = QFUNC(blueForceTrackingModule); scope = 2; isGlobal = 1; icon = PATHTOF(UI\Icon_Module_BFTracking_ca.paa); class Arguments { class Interval { - displayName = "Interval"; - description = "How often the markers should be refreshed (in seconds)"; + displayName = "$STR_ACE_Map_BFT_Interval_DisplayName"; + description = "$STR_ACE_Map_BFT_Interval_Description"; + typeName = "NUMBER"; defaultValue = 1; }; class HideAiGroups { - displayName = "Hide AI groups?"; - description = "Hide markers for 'AI only' groups?"; + displayName = "$STR_ACE_Map_BFT_HideAiGroups_DisplayName"; + description = "$STR_ACE_Map_BFT_HideAiGroups_Description"; typeName = "BOOL"; - class values { - class Yes { name = "Yes"; value = 1; }; - class No { name = "No"; value = 0; default = 1; }; - }; + defaultValue = 0; }; }; + class ModuleDescription { + description = "$STR_ACE_Map_BFT_Module_Description"; + }; }; -}; +}; \ No newline at end of file diff --git a/addons/map/config.cpp b/addons/map/config.cpp index 927d9aeb0f..9d75eaa5c8 100644 --- a/addons/map/config.cpp +++ b/addons/map/config.cpp @@ -87,6 +87,22 @@ class RscMapControl { sizeExGrid = 0.032; }; +class RscMap; +class RscDisplayArcadeMap_Layout_2: RscMap { //"Traditional" Editor: + class controlsBackground { + class CA_Map: RscMapControl { + #include "MapTweaks.hpp" + }; + }; +}; +class RscDisplayArcadeMap_Layout_6: RscMap { //"Streamlined" Editor: + class controlsBackground { + class CA_Map: RscMapControl { + #include "MapTweaks.hpp" + }; + }; +}; + // REGULAR MAP class RscDisplayMainMap { // Tweak map styling diff --git a/addons/map/stringtable.xml b/addons/map/stringtable.xml index 4423bbcfb4..c93ff4c286 100644 --- a/addons/map/stringtable.xml +++ b/addons/map/stringtable.xml @@ -1,6 +1,69 @@  - - - + + + Map + Mapa + + + Map illumination? + Oświetlenie mapy + + + Calculate dynamic map illumination based on light conditions? + Oblicza dynamiczne oświetlenie mapy bazujące na warunkach oświetleniowych + + + Map shake? + Drżenie mapy + + + Make map shake when walking? + Ekran mapy drży podczas ruchu + + + Limit map zoom? + Ograniczony zoom + + + Limit the amount of zoom available for the map? + Ogranicza maksymalny stopień przybliżenia mapy + + + Show cursor coordinates? + Koordynaty pod kursorem + + + Show the grid coordinates on the mouse pointer? + Pokazuje pod kursorem koordynaty wskazanego kwadratu mapy + + + + Moduł ten pozwala dostosować opcje widoku ekranu mapy. + + + Blue Force Tracking + Blue Force Tracking + + + Interval + Interwał + + + How often the markers should be refreshed (in seconds) + Jak często markery powinny być odświeżane (w sekundach) + + + Hide AI groups? + Ukryj grupy AI + + + Hide markers for 'AI only' groups? + Ukrywa markery dla grup złożonych tylko z AI + + + + Pozwala śledzić na mapie pozycje sojuszniczych jednostek za pomocą markerów BFT. + + \ No newline at end of file diff --git a/addons/medical/CfgFactionClasses.hpp b/addons/medical/CfgFactionClasses.hpp index e98b1f84ec..67e3404e91 100644 --- a/addons/medical/CfgFactionClasses.hpp +++ b/addons/medical/CfgFactionClasses.hpp @@ -1,6 +1,6 @@ class CfgFactionClasses { class NO_CATEGORY; class ADDON: NO_CATEGORY { - displayName = "ACE Medical"; + displayName = "$STR_ACE_Medical_Category_DisplayName"; }; }; diff --git a/addons/medical/CfgVehicles.hpp b/addons/medical/CfgVehicles.hpp index 4054a2ee1e..e0a6fbcfa0 100644 --- a/addons/medical/CfgVehicles.hpp +++ b/addons/medical/CfgVehicles.hpp @@ -9,10 +9,9 @@ class CfgVehicles { }; }; class ACE_Module; - // TODO localization for all the modules class ACE_moduleMedicalSettings: ACE_Module { scope = 2; - displayName = "Medical Settings [ACE]"; + displayName = "$STR_ACE_MedicalSettings_Module_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Medical_ca.paa)); category = "ACE_medical"; function = QUOTE(DFUNC(moduleMedicalSettings)); @@ -22,78 +21,78 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class level { - displayName = "Medical Level"; - description = "What is the medical simulation level?"; + displayName = "$STR_ACE_MedicalSettings_level_DisplayName"; + description = "$STR_ACE_MedicalSettings_level_Description"; typeName = "NUMBER"; class values { class normal { - name = "Basic"; + name = "$STR_ACE_MedicalSettings_basic"; value = 1; default = 1; }; class full { - name = "Advanced"; + name = "$STR_ACE_MedicalSettings_advanced"; value = 2; }; }; }; class medicSetting { - displayName = "Medics setting"; - description = "What is the level of detail prefered for medics?"; + displayName = "$STR_ACE_MedicalSettings_medicSetting_DisplayName"; + description = "$STR_ACE_MedicalSettings_medicSetting_Description"; typeName = "NUMBER"; class values { class disable { - name = "Disable medics"; + name = "$STR_ACE_MedicalSettings_medicSetting_disable"; value = 0; }; class normal { - name = "Normal"; + name = "$STR_ACE_MedicalSettings_basic"; value = 1; default = 1; }; class full { - name = "Advanced"; + name = "$STR_ACE_MedicalSettings_advanced"; value = 2; }; }; }; class allowLitterCreation { - displayName = "Enable Litter"; - description = "Enable litter being created upon treatment"; + displayName = "$STR_ACE_MedicalSettings_allowLitterCreation_DisplayName"; + description = "$STR_ACE_MedicalSettings_allowLitterCreation_Description"; typeName = "BOOL"; defaultValue = 1; }; class litterCleanUpDelay { - displayName = "Life time of litter objects"; - description = "How long should litter objects stay? In seconds. -1 is forever."; + displayName = "$STR_ACE_MedicalSettings_litterCleanUpDelay_DisplayName"; + description = "$STR_ACE_MedicalSettings_litterCleanUpDelay_Description"; typeName = "NUMBER"; defaultValue = 1800; }; class enableScreams { - displayName = "Enable Screams"; - description = "Enable screaming by injuried units"; + displayName = "$STR_ACE_MedicalSettings_enableScreams_DisplayName"; + description = "$STR_ACE_MedicalSettings_enableScreams_Description"; typeName = "BOOL"; defaultValue = 1; }; class playerDamageThreshold { - displayName = "Player Damage"; - description = "What is the damage a player can take before being killed?"; + displayName = "$STR_ACE_MedicalSettings_playerDamageThreshold_DisplayName"; + description = "$STR_ACE_MedicalSettings_playerDamageThreshold_Description"; typeName = "NUMBER"; defaultValue = 1; }; class AIDamageThreshold { - displayName = "AI Damage"; - description = "What is the damage an AI can take before being killed?"; + displayName = "$STR_ACE_MedicalSettings_AIDamageThreshold_DisplayName"; + description = "$STR_ACE_MedicalSettings_AIDamageThreshold_Description"; typeName = "NUMBER"; defaultValue = 1; }; class enableUnconsciousnessAI { - displayName = "AI Unconsciousness"; - description = "Allow AI to go unconscious"; + displayName = "$STR_ACE_MedicalSettings_enableUnconsciousnessAI_DisplayName"; + description = "$STR_ACE_MedicalSettings_enableUnconsciousnessAI_Description"; typeName = "NUMBER"; class values { class disable { - name = "Disabled"; + name = "$STR_ACE_Medical_disabled"; value = 0; }; class normal { @@ -102,45 +101,45 @@ class CfgVehicles { default = 1; }; class full { - name = "Enabled"; + name = "$STR_ACE_Medical_enabled"; value = 2; }; }; }; class preventInstaDeath { - displayName = "Prevent instant death"; - description = "Have a unit move to unconscious instead of death"; + displayName = "$STR_ACE_MedicalSettings_preventInstaDeath_DisplayName"; + description = "$STR_ACE_MedicalSettings_preventInstaDeath_Description"; typeName = "BOOL"; defaultValue = 0; }; class bleedingCoefficient { - displayName = "Bleeding coefficient"; - description = "Coefficient to modify the bleeding speed"; + displayName = "$STR_ACE_MedicalSettings_bleedingCoefficient_DisplayName"; + description = "$STR_ACE_MedicalSettings_bleedingCoefficient_Description"; typeName = "NUMBER"; defaultValue = 1; }; class painCoefficient { - displayName = "Pain coefficient"; - description = "Coefficient to modify the pain intensity"; + displayName = "$STR_ACE_MedicalSettings_painCoefficient_DisplayName"; + description = "$STR_ACE_MedicalSettings_painCoefficient_Description"; typeName = "NUMBER"; defaultValue = 1; }; class keepLocalSettingsSynced { - displayName = "Sync status"; - description = "Keep unit status synced. Recommended on."; + displayName = "$STR_ACE_MedicalSettings_keepLocalSettingsSynced_DisplayName"; + description = "$STR_ACE_MedicalSettings_keepLocalSettingsSynced_Description"; typeName = "BOOL"; defaultValue = 1; }; }; class ModuleDescription { - description = "Provides a medical system for both players and AI."; + description = "$STR_ACE_MedicalSettings_Module_Description"; sync[] = {}; }; }; class ACE_moduleAdvancedMedicalSettings: ACE_Module { scope = 2; - displayName = "Advanced Medical Settings [ACE]"; + displayName = "$STR_ACE_AdvancedMedicalSettings_Module_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Medical_ca.paa)); category = "ACE_medical"; function = QUOTE(FUNC(moduleAdvancedMedicalSettings)); @@ -151,80 +150,81 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class enableFor { - displayName = "Enabled for"; - description = "Select what units the advanced medical system will be enabled for"; + displayName = "$STR_ACE_AdvancedMedicalSettings_enableFor_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_enableFor_Description"; typeName = "NUMBER"; class values { class playableUnits { - name = "Players only."; + name = "$STR_ACE_Medical_playeronly"; value = 0; default = 1; }; class playableUnitsAndAI { - name = "Players and AI"; + name = "$STR_ACE_Medical_playersandai"; value = 1; }; }; }; class enableAdvancedWounds { - displayName = "Enable Advanced wounds"; - description = "Allow reopening of bandaged wounds?"; + displayName = "$STR_ACE_AdvancedMedicalSettings_enableAdvancedWounds_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_enableAdvancedWounds_Description"; typeName = "BOOL"; defaultValue = 0; }; class enableVehicleCrashes { - displayName = "Vehicle Crashes"; - description = "Do units take damage from a vehicle crash?"; + displayName = "$STR_ACE_AdvancedMedicalSettings_enableVehicleCrashes_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_enableVehicleCrashes_Description"; typeName = "BOOL"; defaultValue = 1; }; class medicSetting_PAK { - displayName = "Allow PAK"; - description = "Who can use the PAK for full heal?"; + displayName = "$STR_ACE_AdvancedMedicalSettings_medicSetting_PAK_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_medicSetting_PAK_Description"; typeName = "NUMBER"; class values { - class anyone { name = "Anyone"; value = 0; }; - class Medic { name = "Medics only"; value = 1; default = 1; }; - class Special { name = "Doctors only"; value = 2; }; + class anyone { name = "$STR_ACE_AdvancedMedicalSettings_anyone"; value = 0; }; + class Medic { name = "$STR_ACE_AdvancedMedicalSettings_Medic"; value = 1; default = 1; }; + class Special { name = "$STR_ACE_AdvancedMedicalSettings_Special"; value = 2; }; }; }; class consumeItem_PAK { - displayName = "Remove PAK on use"; - description = "Should PAK be removed on usage?"; + displayName = "$STR_ACE_AdvancedMedicalSettings_consumeItem_PAK_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_consumeItem_PAK_Description"; + typeName = "NUMBER"; class values { - class keep { name = "No"; value = 0; }; - class remove { name = "Yes"; value = 1; default = 1; }; + class keep { name = "$STR_ACE_Medical_No"; value = 0; }; + class remove { name = "$STR_ACE_Medical_Yes"; value = 1; default = 1; }; }; }; class useLocation_PAK { - displayName = "Locations PAK"; - description = "Where can the personal aid kit be used?"; + displayName = "$STR_ACE_AdvancedMedicalSettings_useLocation_PAK_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_useLocation_PAK_Description"; typeName = "NUMBER"; class values { - class anywhere { name = "Anywhere"; value = 0; }; - class vehicle { name = "Medical Vehicles"; value = 1; }; - class facility { name = "Medical facility"; value = 2; }; - class vehicleAndFacility { name = "Vehicles & facility"; value = 3; default = 1; }; - class disabled { name = "Disabled"; value = 4;}; + class anywhere { name = "$STR_ACE_AdvancedMedicalSettings_anywhere"; value = 0; }; + class vehicle { name = "$STR_ACE_AdvancedMedicalSettings_vehicle"; value = 1; }; + class facility { name = "$STR_ACE_AdvancedMedicalSettings_facility"; value = 2; }; + class vehicleAndFacility { name = "$STR_ACE_AdvancedMedicalSettings_vehicleAndFacility"; value = 3; default = 1; }; + class disabled { name = "$STR_ACE_AdvancedMedicalSettings_disabled"; value = 4;}; }; }; class medicSetting_SurgicalKit: medicSetting_PAK { - displayName = "Allow Surgical kit (Adv)"; - description = "Who can use the surgical kit?"; + displayName = "$STR_ACE_AdvancedMedicalSettings_medicSetting_SurgicalKit_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_medicSetting_SurgicalKit_Description"; }; class consumeItem_SurgicalKit: consumeItem_PAK { - displayName = "Remove Surgical kit (Adv)"; - description = "Should Surgical kit be removed on usage?"; + displayName = "$STR_ACE_AdvancedMedicalSettings_consumeItem_SurgicalKit_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_consumeItem_SurgicalKit_Description"; }; class useLocation_SurgicalKit: useLocation_PAK { - displayName = "Locations Surgical kit (Adv)"; - description = "Where can the Surgical kit be used?"; + displayName = "$STR_ACE_AdvancedMedicalSettings_useLocation_SurgicalKit_DisplayName"; + description = "$STR_ACE_AdvancedMedicalSettings_useLocation_SurgicalKit_Description"; }; }; class ModuleDescription { - description = "Configure the treatment settings from ACE Medical"; + description = "$STR_ACE_AdvancedMedicalSettings_Module_Description"; sync[] = {}; }; }; @@ -232,7 +232,7 @@ class CfgVehicles { class ACE_moduleReviveSettings: ACE_Module { scope = 2; - displayName = "Revive Settings [ACE]"; + displayName = "$STR_ACE_ReviveSettings_Module_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Medical_ca.paa)); category = "ACE_medical"; function = QUOTE(DFUNC(moduleReviveSettings)); @@ -242,37 +242,37 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class enableRevive { - displayName = "Enable Revive"; - description = "Enable a basic revive system"; + displayName = "$STR_ACE_ReviveSettings_enableRevive_DisplayName"; + description = "$STR_ACE_ReviveSettings_enableRevive_Description"; typeName = "NUMBER"; defaultValue = 0; class values { - class disable { name = "Disabled"; value = 0; default = 1;}; - class playerOnly { name = "Player only"; value = 1; }; - class playerAndAI { name = "Player & AI"; value = 2; }; + class disable { name = "$STR_ACE_Medical_disabled"; value = 0; default = 1;}; + class playerOnly { name = "$STR_ACE_Medical_playeronly"; value = 1; }; + class playerAndAI { name = "$STR_ACE_Medical_playersandai"; value = 2; }; }; }; class maxReviveTime { - displayName = "Max Revive time"; - description = "Max amount of seconds a unit can spend in revive state"; + displayName = "$STR_ACE_ReviveSettings_maxReviveTime_DisplayName"; + description = "$STR_ACE_ReviveSettings_maxReviveTime_Description"; typeName = "NUMBER"; defaultValue = 120; }; class amountOfReviveLives { - displayName = "Max Revive lives"; - description = "Max amount of lives a unit. 0 or -1 is disabled."; + displayName = "$STR_ACE_ReviveSettings_amountOfReviveLives_DisplayName"; + description = "$STR_ACE_ReviveSettings_amountOfReviveLives_Description"; typeName = "NUMBER"; defaultValue = -1; }; }; class ModuleDescription { - description = "Provides a medical system for both players and AI."; + description = "$STR_ACE_ReviveSettings_Module_Description"; sync[] = {}; }; }; class ACE_moduleAssignMedicRoles: Module_F { scope = 2; - displayName = "Set Medic Class [ACE]"; + displayName = "$STR_ACE_AssignMedicRoles_Module_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Medical_ca.paa)); category = "ACE_medical"; function = QUOTE(FUNC(moduleAssignMedicRoles)); @@ -283,41 +283,41 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class EnableList { - displayName = "List"; - description = "List of unit names that will be classified as medic, separated by commas."; + displayName = "$STR_ACE_AssignMedicRoles_EnableList_DisplayName"; + description = "$STR_ACE_AssignMedicRoles_EnableList_Description"; defaultValue = ""; typeName = "STRING"; }; class role { - displayName = "Is Medic"; - description = "Medics allow for more advanced treatment in case of Advanced Medic roles enabled"; + displayName = "$STR_ACE_AssignMedicRoles_role_DisplayName"; + description = "$STR_ACE_AssignMedicRoles_role_Description"; typeName = "NUMBER"; class values { class none { - name = "None"; + name = "$STR_ACE_AssignMedicRoles_role_none"; value = 0; }; class medic { - name = "Regular medic"; + name = "$STR_ACE_AssignMedicRoles_role_medic"; value = 1; default = 1; }; class doctor { - name = "Doctor (Only Advanced Medics)"; + name = "$STR_ACE_AssignMedicRoles_role_doctor"; value = 2; }; }; }; }; class ModuleDescription { - description = "Assigns the ACE medic class to a unit"; + description = "$STR_ACE_AssignMedicRoles_Module_Description"; sync[] = {}; }; }; class ACE_moduleAssignMedicVehicle: Module_F { scope = 2; - displayName = "Set Medical Vehicle [ACE]"; + displayName = "$STR_ACE_AssignMedicVehicle_Module_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Medical_ca.paa)); category = "ACE_medical"; function = QUOTE(FUNC(moduleAssignMedicalVehicle)); @@ -328,22 +328,23 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class EnableList { - displayName = "List"; - description = "List of vehicles that will be classified as medical vehicle, separated by commas."; + displayName = "$STR_ACE_AssignMedicVehicle_EnableList_DisplayName"; + description = "$STR_ACE_AssignMedicVehicle_EnableList_Description"; defaultValue = ""; typeName = "STRING"; }; class enabled { - displayName = "Is Medical Vehicle"; - description = "Whatever or not the objects in the list will be a medical vehicle."; + displayName = "$STR_ACE_AssignMedicVehicle_enabled_DisplayName"; + description = "$STR_ACE_AssignMedicVehicle_enabled_Description"; + typeName = "NUMBER"; class values { class none { - name = "No"; + name = "$STR_ACE_Medical_No"; value = 0; }; class medic { - name = "Yes"; + name = "$STR_ACE_Medical_Yes"; value = 1; default = 1; }; @@ -351,13 +352,13 @@ class CfgVehicles { }; }; class ModuleDescription { - description = "Assigns the ACE medic class to a unit"; + description = "$STR_ACE_AssignMedicVehicle_Module_Description"; sync[] = {}; }; }; class ACE_moduleAssignMedicalFacility: Module_F { scope = 2; - displayName = "Set Medical Facility [ACE]"; + displayName = "$STR_ACE_AssignMedicalFacility_Module_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Medical_ca.paa)); category = "ACE_medical"; function = QUOTE(FUNC(moduleAssignMedicalFacility)); @@ -368,13 +369,13 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class enabled { - displayName = "Is Medical Facility"; - description = "Registers an object as a medical facility for CMS"; + displayName = "$STR_ACE_AssignMedicalFacility_enabled_DisplayName"; + description = "$STR_ACE_AssignMedicalFacility_enabled_Description"; typeName = "BOOL"; }; }; class ModuleDescription { - description = "Defines an object as a medical facility for CMS. This allows for more advanced treatments. Can be used on buildings and vehicles. "; + description = "$STR_ACE_AssignMedicalFacility_Module_Description"; sync[] = {}; }; }; @@ -897,7 +898,7 @@ class CfgVehicles { class ACE_medicalSupplyCrate: NATO_Box_Base { scope = 2; accuracy = 1000; - displayName = "[ACE] Medical Supply Crate (Basic)"; + displayName = "$STR_ACE_medicalSupplyCrate"; model = PATHTOF(data\ace_medcrate.p3d); author = "$STR_ACE_Common_ACETeam"; class TransportItems { @@ -932,7 +933,7 @@ class CfgVehicles { }; }; class ACE_medicalSupplyCrate_advanced: ACE_medicalSupplyCrate { - displayName = "[ACE] Medical Supply Crate (Advanced)"; + displayName = "$STR_ACE_medicalSupplyCrate_advanced"; class TransportItems { class ACE_fieldDressing { name = "ACE_fieldDressing"; diff --git a/addons/medical/config.cpp b/addons/medical/config.cpp index 566de29f91..cd0fe0e66c 100644 --- a/addons/medical/config.cpp +++ b/addons/medical/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { weapons[] = {"ACE_fieldDressing", "ACE_packingBandage", "ACE_elasticBandage", "ACE_tourniquet", "ACE_morphine", "ACE_atropine", "ACE_epinephrine", "ACE_plasmaIV", "ACE_plasmaIV_500", "ACE_plasmaIV_250", "ACE_bloodIV", "ACE_bloodIV_500", "ACE_bloodIV_250", "ACE_salineIV", "ACE_salineIV_500", "ACE_salineIV_250", "ACE_quikclot", "ACE_personalAidKit", "ACE_surgicalKit", "ACE_bodyBag"}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_interaction","ace_modules", "ace_apl"}; - author[] = {"Glowbal", "KoffienFlummi"}; + author[] = {"Glowbal", "KoffeinFlummi"}; authorUrl = ""; VERSION_CONFIG; }; diff --git a/addons/medical/functions/fnc_actionCheckPulseLocal.sqf b/addons/medical/functions/fnc_actionCheckPulseLocal.sqf index 85e9bee828..b283068ec7 100644 --- a/addons/medical/functions/fnc_actionCheckPulseLocal.sqf +++ b/addons/medical/functions/fnc_actionCheckPulseLocal.sqf @@ -24,7 +24,7 @@ if (!alive _unit) then { _heartRate = 0; }; _heartRateOutput = "STR_ACE_Medical_Check_Pulse_Output_5"; -_logOutPut = "No heart rate"; +_logOutPut = localize "STR_ACE_Medical_Check_Pulse_None"; if (_heartRate > 1.0) then { if ([_caller] call FUNC(isMedic)) then { diff --git a/addons/medical/functions/fnc_createLitter.sqf b/addons/medical/functions/fnc_createLitter.sqf index 8682cc24d5..6797785763 100644 --- a/addons/medical/functions/fnc_createLitter.sqf +++ b/addons/medical/functions/fnc_createLitter.sqf @@ -38,12 +38,18 @@ _litter = getArray (_config >> "litter"); _createLitter = { private["_position", "_litterClass", "_direction"]; - _position = getPos (_this select 0); + + // @TODO: handle carriers over water + // For now, don't spawn litter if we are over water to avoid floating litter + if(surfaceIsWater (getPos (_this select 0))) exitWith { false }; + + _position = getPosATL (_this select 0); + _position = [_position select 0, _position select 1, 0]; _litterClass = _this select 1; if (random(1) >= 0.5) then { - _position = [(_position select 0) + random 2, (_position select 1) + random 2, _position select 2]; + _position = [(_position select 0) + random 1, (_position select 1) + random 1, _position select 2]; } else { - _position = [(_position select 0) - random 2, (_position select 1) - random 2, _position select 2]; + _position = [(_position select 0) - random 1, (_position select 1) - random 1, _position select 2]; }; _direction = (random 360); diff --git a/addons/medical/functions/fnc_handleCreateLitter.sqf b/addons/medical/functions/fnc_handleCreateLitter.sqf index 617d05e519..681116f226 100644 --- a/addons/medical/functions/fnc_handleCreateLitter.sqf +++ b/addons/medical/functions/fnc_handleCreateLitter.sqf @@ -14,7 +14,10 @@ if (isNil QGVAR(allCreatedLitter)) then { _litterObject = _litterClass createVehicleLocal _position; _litterObject setDir _direction; - +_litterObject setPosATL _position; +// Move the litter next frame to get rid of HORRIBLE spacing, fixes #1112 +[{ (_this select 0) setPosATL (_this select 1); }, [_litterObject, _position]] call EFUNC(common,execNextFrame); + _maxLitterCount = getArray (configFile >> "ACE_Settings" >> QGVAR(litterSimulationDetail) >> "_values") select GVAR(litterSimulationDetail); if((count GVAR(allCreatedLitter)) > _maxLitterCount ) then { // gank the first litter object, and spawn ours. diff --git a/addons/medical/functions/fnc_isInMedicalVehicle.sqf b/addons/medical/functions/fnc_isInMedicalVehicle.sqf index cffc24410d..5422ce8e1f 100644 --- a/addons/medical/functions/fnc_isInMedicalVehicle.sqf +++ b/addons/medical/functions/fnc_isInMedicalVehicle.sqf @@ -21,4 +21,4 @@ _vehicle = vehicle _unit; if (_unit == _vehicle) exitWith {false}; if (_unit in [driver _vehicle, gunner _vehicle, commander _vehicle]) exitWith {false}; -_vehicle getVariable [QGVAR(isMedic), getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "attendant") == 1] +_vehicle getVariable [QGVAR(medicClass), getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "attendant") == 1] diff --git a/addons/medical/functions/fnc_isMedicalVehicle.sqf b/addons/medical/functions/fnc_isMedicalVehicle.sqf index 7be406e556..5e9283852f 100644 --- a/addons/medical/functions/fnc_isMedicalVehicle.sqf +++ b/addons/medical/functions/fnc_isMedicalVehicle.sqf @@ -15,4 +15,4 @@ private ["_vehicle"]; _vehicle = _this select 0; -_vehicle getVariable [QGVAR(isMedic), getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "attendant") == 1] +(_vehicle getVariable [QGVAR(medicClass), getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "attendant")]) > 0 diff --git a/addons/medical/functions/fnc_moduleAssignMedicalVehicle.sqf b/addons/medical/functions/fnc_moduleAssignMedicalVehicle.sqf index 539d428da0..af6de73ce1 100644 --- a/addons/medical/functions/fnc_moduleAssignMedicalVehicle.sqf +++ b/addons/medical/functions/fnc_moduleAssignMedicalVehicle.sqf @@ -37,7 +37,7 @@ if (!isNull _logic) then { _list = "[" + _nilCheckPassedList + "]"; _parsedList = [] call compile _list; - _setting = _logic getvariable ["enabled", false]; + _setting = _logic getvariable ["enabled", 0]; _objects = synchronizedObjects _logic; if (!(_objects isEqualTo []) && _parsedList isEqualTo []) then { { diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index 215d9ae766..89544cbdf8 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -1144,7 +1144,7 @@ Saline IV (1000ml) Физраствор для в/в вливания (1000 мл) - Solución Salina IV (1000ml) + Salino IV (1000ml) Solution saline 0.9% IV (1000ml) Sól fizjologiczna IV (1000ml) Kochsalzlösung (1000ml) @@ -2701,5 +2701,369 @@ Снятие жгута ... Togliendo il laccio emostatico ... + + ACE Medical + ACE Opcje medyczne + + + Medical Settings [ACE] + Ustawienia medyczne [ACE] + + + Medical Level + Poziom medyczny + + + What is the medical simulation level? + Jaki jest poziom symulacji medycznej? + + + Basic + Podstawowy + + + Advanced + Zaawansowany + + + Medics setting + Poziom medyków + + + What is the level of detail prefered for medics? + Jaki jest poziom detali medycznych wyświetlanych dla medyków? + + + Disable medics + Wyłącz medyków + + + Enable Litter + Aktywuj odpadki + + + Enable litter being created upon treatment + Twórz odpadki medyczne podczas leczenia + + + Life time of litter objects + Długość życia odpadków + + + How long should litter objects stay? In seconds. -1 is forever. + Ile czasu musi upłynąć, aby odpadki zaczęły znikać? W sekundach. -1 dla nieskończoności. + + + Enable Screams + Aktywuj wrzaski + + + Enable screaming by injuried units + Aktywuj wrzeszczenie z bólu przez ranne jednostki + + + Player Damage + Próg obrażeń graczy + + + What is the damage a player can take before being killed? + Jaki jest próg obrażeń, jakie gracz może otrzymać zanim zostanie zabity? + + + AI Damage + Próg obrażeń AI + + + What is the damage an AI can take before being killed? + Jaki jest próg obrażeń, jakie AI może otrzymać zanim zostanie zabite? + + + AI Unconsciousness + Nieprzytomność AI + + + Allow AI to go unconscious + Czy AI może być nieprzytomne od odniesionych obrażeń? + + + Disabled + Wyłączone + + + Enabled + Włączone + + + Prevent instant death + Wył. natychmiast. śmierć + + + Have a unit move to unconscious instead of death + Spraw, aby jednostka została przeniesiona do stanu nieprzytomności zamiast ginąć na miejscu od śmiertelnych obrażeń + + + Bleeding coefficient + Mnożnik krwawienia + + + Coefficient to modify the bleeding speed + Mnożnik modyfikujący prędkość wykrwawiania się + + + Pain coefficient + Mnożnik bólu + + + Coefficient to modify the pain intensity + Mnożnik modyfikujący intensywność bólu + + + Sync status + Synchronizuj status + + + Keep unit status synced. Recommended on. + Utrzymuj synchronizację statusu jednostek. Zalecane zostawienie tej opcji włączonej. + + + Provides a medical system for both players and AI. + Moduł ten dostarcza system medyczny dla graczy oraz AI. + + + Advanced Medical Settings [ACE] + Zaawansowane ustawienia medyczne [ACE] + + + Enabled for + Aktywne dla + + + Select what units the advanced medical system will be enabled for + Wybierz dla kogo zaawansowany system medyczny będzie aktywny + + + Players only + Tylko dla graczy + + + Players and AI + Gracze oraz AI + + + Enable Advanced wounds + Akt. zaawansowane rany + + + Allow reopening of bandaged wounds? + Pozwól na otwieranie się zabandażowanych ran? + + + Vehicle Crashes + Obrażenia od kolizji + + + Do units take damage from a vehicle crash? + Czy jednostki otrzymują obrażenia w wyniku kolizji pojazdów? + + + Allow PAK + Ust. apteczek osobistych + + + Who can use the PAK for full heal? + Kto może skorzystać z apteczki osobistej w celu pełnego uleczenia? + + + Anyone + Wszyscy + + + Medics only + Tylko medycy + + + Doctors only + Tylko doktorzy + + + Remove PAK on use + Usuń apteczkę po użyciu + + + Should PAK be removed on usage? + Czy apteczka osobista powinna zniknąć z ekwipunku po jej użyciu? + + + Locations PAK + Ogr. apteczek osobistych + + + Where can the personal aid kit be used? + Gdzie można korzystać z apteczek osobistych? + + + Anywhere + Wszędzie + + + Medical vehicles + Pojazdy medyczne + + + Medical facility + Budynki medyczne + + + Vehicles & facility + Pojazdy i budynki medyczne + + + Disabled + Wyłączone + + + Allow Surgical kit (Adv) + Ust. zestawu chirurg. + + + Who can use the surgical kit? + Kto może skorzystać z zestawu chirurgicznego w celu zszycia ran? + + + Remove Surgical kit (Adv) + Usuń zest. chir. po użyciu + + + Should Surgical kit be removed on usage? + Czy zestaw chirurgiczny powinien zniknąć z ekwipunku po jego użyciu? + + + Locations Surgical kit (Adv) + Ogr. zestawu chirurg. + + + Where can the Surgical kit be used? + Gdzie można korzystać z zestawu chirurgicznego? + + + Configure the treatment settings from ACE Medical + Skonfiguruj zaawansowane ustawienia leczenia systemu medycznego ACE + + + Revive Settings [ACE] + Ustawienia wskrzeszania [ACE] + + + Enable Revive + Aktywuj wskrzeszanie + + + Enable a basic revive system + Aktywuj podstawowy system wskrzeszania + + + Max Revive time + Maks. czas agonii + + + Max amount of seconds a unit can spend in revive state + Maksymalna długość agonii w sekundach (czas na wskrzeszenie) + + + Max Revive lives + Maks. ilość wskrzeszeń + + + Max amount of lives a unit. 0 or -1 is disabled. + Maksymalna ilość wskrzeszeń. Wpisz 0 lub -1 aby wyłączyć. + + + Provides a medical system for both players and AI. + Moduł ten aktywuje podstawowy system wskrzeszania. Jednostka po otrzymaniu śmiertelnych obrażeń przechodzi do stanu agonii, która trwa określoną długość czasu. W tym czasie aby wskrzesić i jednocześnie odratować jednostkę należy opatrzeć jej rany i wykonać RKO. + + + Set Medic Class [ACE] + Ustaw klasę medyka [ACE] + + + List + Lista + + + List of unit names that will be classified as medic, separated by commas. + Lista nazw jednostek, które są sklasyfikowane jako medycy, oddzielone przecinkami. + + + Is Medic + Klasa medyczna + + + + + + + None + Żadna + + + Regular medic + Zwykły medyk + + + Doctor (Only Advanced Medics) + Doktor (tylko zaawansowani medycy) + + + Assigns the ACE medic class to a unit + Moduł ten przypisuje klasę medyka ACE do jednostek. + + + Set Medical Vehicle [ACE] + Ustaw pojazd medyczny [ACE] + + + List + Lista + + + List of vehicles that will be classified as medical vehicle, separated by commas. + Lista nazw pojazdów, które są sklasyfikowane jako pojazdy medyczne, oddzielone przecinkami. + + + Is Medical Vehicle + Jest pojazdem med. + + + Whatever or not the objects in the list will be a medical vehicle. + Czy pojazdy z tej listy są pojazdami medycznymi. + + + Assigns the ACE medic class to a unit + Moduł ten pozwala na przypisanie danym pojazdom statusu pojazdów medycznych. Wewnątrz takiego pojazdu można wykonywać zaawansowane zabiegi medyczne. + + + Set Medical Facility [ACE] + Ustaw budynek medyczny [ACE] + + + Is Medical Facility + Jest budynkiem med. + + + Registers an object as a medical facility + Przypisuje danemu obiektowi status budynku medycznego + + + Defines an object as a medical facility. This allows for more advanced treatments. Can be used on buildings and vehicles. + Moduł ten pozwala przypisać status budynku medycznego danemu obiektowi. Budynek taki pozwala na wykonywanie zaawansowanych zabiegów medycznych. Może być użyte na pojazdach i budynkach. + + + [ACE] Medical Supply Crate (Basic) + [ACE] Skrzynka z zapasami medycznymi (podstawowa) + + + [ACE] Medical Supply Crate (Advanced) + [ACE] Skrzynka z zapasami medycznymi (zaawansowana) + diff --git a/addons/microdagr/CfgVehicles.hpp b/addons/microdagr/CfgVehicles.hpp index fe803a2ae4..ba9e12ae5c 100644 --- a/addons/microdagr/CfgVehicles.hpp +++ b/addons/microdagr/CfgVehicles.hpp @@ -46,7 +46,7 @@ class CfgVehicles { class GVAR(dagrModule): Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "MicroDAGR Map Fill"; + displayName = "$STR_ACE_Dagr_Module_DisplayName"; function = QFUNC(moduleMapFill); scope = 2; isGlobal = 1; @@ -54,18 +54,18 @@ class CfgVehicles { functionPriority = 0; class Arguments { class MapDataAvailable { - displayName = "MicroDAGR Map Fill"; // Argument label - description = "How much map data is filled on MicroDAGR's "; // Tooltip description - typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" + displayName = "$STR_ACE_Dagr_MapDataAvailable_DisplayName"; + description = "$STR_ACE_Dagr_MapDataAvailable_Description"; + typeName = "NUMBER"; class values { - class None {name = "Full Satellite + Buildings"; value = MAP_DETAIL_SAT; default = 1;}; - class Side {name = "Topographical + Roads"; value = MAP_DETAIL_TOPOROADS;}; - class Unique {name = "None (Cannot use map view)"; value = MAP_DETAIL_NONE;}; + class None {name = "$STR_ACE_Dagr_None"; value = MAP_DETAIL_SAT; default = 1;}; + class Side {name = "$STR_ACE_Dagr_Side"; value = MAP_DETAIL_TOPOROADS;}; + class Unique {name = "$STR_ACE_Dagr_Unique"; value = MAP_DETAIL_NONE;}; }; }; }; class ModuleDescription: ModuleDescription { - description = "Controls how much data is filled on the microDAGR items. Less data restricts the map view to show less on the minimap.
Source: microDAGR.pbo"; + description = "$STR_ACE_Dagr_Module_Description"; }; }; diff --git a/addons/microdagr/stringtable.xml b/addons/microdagr/stringtable.xml index af2b303f2b..b1bac6976b 100644 --- a/addons/microdagr/stringtable.xml +++ b/addons/microdagr/stringtable.xml @@ -220,7 +220,7 @@ SetWP WP setzen - Establecer PR + Fijar PR Установить МТ Nastavit WP UstawPT @@ -301,5 +301,33 @@ Chiudi MicroDAGR Fechar MicroDAGR + + MicroDAGR Map Fill + Wypełnienie mapy MicroDAGR + + + MicroDAGR Map Fill + Wypełnienie mapy MicroDAGR + + + How much map data is filled on MicroDAGR's + Jak duża część informacji mapy jest załadowana do MicroDAGR? + + + Full Satellite + Buildings + Pełna satelitarna + budynki + + + Topographical + Roads + Topograficzna + drogi + + + None (Cannot use map view) + Żadna (wyłącza ekran mapy) + + + Controls how much data is filled on the microDAGR items. Less data restricts the map view to show less on the minimap.<br />Source: microDAGR.pbo + Moduł ten pozwala kontrolować jak duża ilość informacji jest załadowana do przedmiotów MicroDAGR. Mniejsza ilość danych ogranicza widok mapy pokazując mniej rzeczy na minimapie.<br />Źródło: microDAGR.pbo + diff --git a/addons/missileguidance/ACE_Settings.hpp b/addons/missileguidance/ACE_Settings.hpp index d489ef15f3..c04e6c080c 100644 --- a/addons/missileguidance/ACE_Settings.hpp +++ b/addons/missileguidance/ACE_Settings.hpp @@ -5,6 +5,6 @@ class ACE_Settings { isClientSettable = 1; displayName = "$STR_ACE_MissileGuidance"; description = "$STR_ACE_MissileGuidance_Desc"; - values[] = {"Off", "Player Only", "Player and AI"}; + values[] = {"$STR_ACE_MissileGuidance_Off", "$STR_ACE_MissileGuidance_PlayerOnly", "$STR_ACE_MissileGuidance_PlayerAndAi"}; }; }; \ No newline at end of file diff --git a/addons/missileguidance/stringtable.xml b/addons/missileguidance/stringtable.xml index dcb2be486c..798b2aafcd 100644 --- a/addons/missileguidance/stringtable.xml +++ b/addons/missileguidance/stringtable.xml @@ -18,7 +18,7 @@ Zaawansowane namierzanie rakiet, lub ZNR, dostarcza wiele poprawek do systemu namierzania rakiet oraz dodaje nowe tryby strzału. Jest to wymagana opcja dla broni rakietowych. Guida dei missili avanzata, o AMG, offre diversi miglioramenti alla teleguida di missili. E' anche un sistema necessario per i tipi di armi missile. Продвинутое наведение ракет, или ПНР, обеспечивает множество усовершествований для наведения и стрельбы ракет. Также, это система, необходимая для всех ракетных типов оружия. - Guiado Avanzado de Misiles, o AMG en sus siglas en inglés, ofrece múltiples mejoras en el fijado y disparo de misiles. Es también un sistema requerido para armas de tipo misil. + El guiado avanzado de misiles, o AMG en sus siglas en inglés, ofrece múltiples mejoras en el fijado y disparo de misiles. Es también un sistema requerido para armas de tipo misil. Das Erweiterte Raketenlenksystem, auch ERls genannt, bietet viele Verbesserungen zum Aufschalten und Feuern mittels gelenkten Raketen. Le guidage avancé de missile, ou AMG en anglais, apporte de multiple améliorations au verouillage et au tir de missiles. C'est aussi un framework requis pour tout arme de type missile. A fejlett rakétairányító (vagy AMG) többféle módosítást tartalmaz a rakéták célkövetéséhez és tüzeléséhez. Ez egy szükséges keresztrendszer a rakéta-alapú fegyverekhez. @@ -97,5 +97,17 @@ Hellfire II AGM-114K lézer-irányított rakéta Управляемая ракета лазерного наведения Hellfire II AGM-114K + + Off + Wyłącz + + + Player Only + Tylko gracz + + + Player and AI + Gracz oraz AI + diff --git a/addons/missionmodules/CfgFactionClasses.hpp b/addons/missionmodules/CfgFactionClasses.hpp index 792f4d31e3..6f320805fb 100644 --- a/addons/missionmodules/CfgFactionClasses.hpp +++ b/addons/missionmodules/CfgFactionClasses.hpp @@ -1,6 +1,6 @@ class CfgFactionClasses { class NO_CATEGORY; class ACE_missionModules: NO_CATEGORY { - displayName = "ACE Mission Modules"; + displayName = "$STR_ACE_MissionModules_Category_DisplayName"; }; }; \ No newline at end of file diff --git a/addons/missionmodules/CfgVehicles.hpp b/addons/missionmodules/CfgVehicles.hpp index 35a937c660..a08e78f17b 100644 --- a/addons/missionmodules/CfgVehicles.hpp +++ b/addons/missionmodules/CfgVehicles.hpp @@ -8,7 +8,7 @@ class CfgVehicles { // TODO make a curator variant for this class ACE_moduleAmbianceSound: Module_F { scope = 2; - displayName = "Ambiance Sounds [ACE]"; + displayName = "$STR_ACE_MissionModules_AmbianceSounds_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Ambient_Sounds_ca.paa)); category = "ACE_missionModules"; function = QUOTE(FUNC(moduleAmbianceSound)); @@ -18,51 +18,51 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class soundFiles { - displayName = "Sounds"; - description = "Class names of the ambiance sounds to be played. Seperated by ','"; + displayName = "$STR_ACE_MissionModules_AmbianceSounds_soundFiles_DisplayName"; + description = "$STR_ACE_MissionModules_AmbianceSounds_soundFiles_Description"; typeName = "STRING"; defaultValue = ""; }; class minimalDistance { - displayName = "Minimal Distance"; - description = "Used for calculating a random position and sets the minimal distance between the players and the played sound file(s)"; + displayName = "$STR_ACE_MissionModules_AmbianceSounds_minimalDistance_DisplayName"; + description = "$STR_ACE_MissionModules_AmbianceSounds_minimalDistance_Description"; typeName = "NUMBER"; defaultValue = 400; }; class maximalDistance { - displayName = "Maximum Distance"; - description = "Used for calculating a random position and sets the maximum distance between the players and the played sound file(s)"; + displayName = "$STR_ACE_MissionModules_AmbianceSounds_maximalDistance_DisplayName"; + description = "$STR_ACE_MissionModules_AmbianceSounds_maximalDistance_Description"; typeName = "NUMBER"; defaultValue = 900; }; class minimalDelay { - displayName = "Minimal Delay"; - description = "Minimal delay between sounds played"; + displayName = "$STR_ACE_MissionModules_AmbianceSounds_minimalDelay_DisplayName"; + description = "$STR_ACE_MissionModules_AmbianceSounds_minimalDelay_Description"; typeName = "NUMBER"; defaultValue = 10; }; class maximalDelay { - displayName = "Maximum Delay"; - description = "Maximum delay between sounds played"; + displayName = "$STR_ACE_MissionModules_AmbianceSounds_maximalDelay_DisplayName"; + description = "$STR_ACE_MissionModules_AmbianceSounds_maximalDelay_Description"; typeName = "NUMBER"; defaultValue = 170; }; class followPlayers { - displayName = "Follow Players"; - description = "Follow players. If set to false, loop will play sounds only nearby logic position."; + displayName = "$STR_ACE_MissionModules_AmbianceSounds_followPlayers_DisplayName"; + description = "$STR_ACE_MissionModules_AmbianceSounds_followPlayers_Description"; typeName = "BOOL"; defaultValue = 0; }; class soundVolume { - displayName = "Volume"; - description = "The volume of the sounds played"; + displayName = "$STR_ACE_MissionModules_AmbianceSounds_soundVolume_DisplayName"; + description = "$STR_ACE_MissionModules_AmbianceSounds_soundVolume_Description"; typeName = "NUMBER"; defaultValue = 1; }; }; class ModuleDescription { - description = "Ambiance sounds loop (synced across MP)"; + description = "$STR_ACE_MissionModules_AmbianceSounds_Description"; sync[] = {}; }; }; -}; +}; \ No newline at end of file diff --git a/addons/missionmodules/stringtable.xml b/addons/missionmodules/stringtable.xml new file mode 100644 index 0000000000..1532827378 --- /dev/null +++ b/addons/missionmodules/stringtable.xml @@ -0,0 +1,73 @@ + + + + + ACE Mission Modules + ACE Moduły misji + + + Ambiance Sounds [ACE] + Dźwięki [ACE] + + + Sounds + Dźwięki + + + Class names of the ambiance sounds to be played. Seperated by ',' + Class name-y dźwięków do odtwarzania. Oddzielone przy użyciu ',' + + + Minimal Distance + Minimalny dystans + + + Used for calculating a random position and sets the minimal distance between the players and the played sound file(s) + Używany do obliczania losowej pozycji a także ustawia minimalny dystans pomiędzy graczami a odtwarzanymi plikami dźwiękowymi + + + Maximum Distance + Maksymalny dystans + + + Used for calculating a random position and sets the maximum distance between the players and the played sound file(s) + Używany do obliczania losowej pozycji a także ustawia maksymalny dystans pomiędzy graczami a odtwarzanymi plikami dźwiękowymi + + + Minimal Delay + Minimalne opóźnienie + + + Minimal delay between sounds played + Minimalne opóźnienie pomiędzy odtwarzanymi dźwiękami + + + Maximum Delay + Maksymalne opóźnienie + + + Maximum delay between sounds played + Maksymalne opóźnienie pomiędzy odtwarzanymi dźwiękami + + + Follow Players + Podążaj za graczami + + + Follow players. If set to false, loop will play sounds only nearby logic position. + Podążaj za graczami. Jeżeli ustawione na 'Nie', pętla będzie odtwarzana tylko w pobliżu pozycji logiki. + + + Volume + Głośność + + + The volume of the sounds played + Głośność odtwarzanych dźwięków + + + Ambiance sounds loop (synced across MP) + Pętla odtwarzania dzwięków (synchronizowana na MP) + + + \ No newline at end of file diff --git a/addons/mk6mortar/CfgVehicles.hpp b/addons/mk6mortar/CfgVehicles.hpp index baf74fa2c4..e4a9d0f2a5 100644 --- a/addons/mk6mortar/CfgVehicles.hpp +++ b/addons/mk6mortar/CfgVehicles.hpp @@ -50,7 +50,7 @@ class CfgVehicles { class GVAR(module): Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "MK6 Settings"; + displayName = "$STR_ACE_mk6mortar_Module_DisplayName"; function = QFUNC(moduleInit); scope = 2; isGlobal = 0; @@ -58,26 +58,26 @@ class CfgVehicles { functionPriority = 0; class Arguments { class airResistanceEnabled { - displayName = "Air Resistance"; - description = "For Player Shots, Model Air Resistance and Wind Effects"; + displayName = "$STR_ACE_mk6mortar_airResistanceEnabled_DisplayName"; + description = "$STR_ACE_mk6mortar_airResistanceEnabled_Description"; typeName = "BOOL"; defaultValue = 1; }; class allowComputerRangefinder { - displayName = "Allow MK6 Computer"; - description = "Show the Computer and Rangefinder (these NEED to be removed if you enable air resistance)"; + displayName = "$STR_ACE_mk6mortar_allowComputerRangefinder_DisplayName"; + description = "$STR_ACE_mk6mortar_allowComputerRangefinder_Description"; typeName = "BOOL"; defaultValue = 0; }; class allowCompass { - displayName = "Allow MK6 Compass"; - description = "Show the MK6 Digital Compass"; + displayName = "$STR_ACE_mk6mortar_allowCompass_DisplayName"; + description = "$STR_ACE_mk6mortar_allowCompass_Description"; typeName = "BOOL"; defaultValue = 1; }; }; class ModuleDescription: ModuleDescription { - description = ""; + description = "$STR_ACE_mk6mortar_Module_Description"; }; }; -}; +}; \ No newline at end of file diff --git a/addons/mk6mortar/functions/fnc_handleFired.sqf b/addons/mk6mortar/functions/fnc_handleFired.sqf index e2b440c520..284560b775 100644 --- a/addons/mk6mortar/functions/fnc_handleFired.sqf +++ b/addons/mk6mortar/functions/fnc_handleFired.sqf @@ -42,8 +42,7 @@ if (_bisAirFriction != 0) exitWith {ERROR("Non zero base airFriction");}; //Calculate air density: _altitude = (getPosASL _vehicle) select 2; -#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h)) -_temperature = GET_TEMPERATURE_AT_HEIGHT(_altitude); +_temperature = _altitude call EFUNC(weather,calculateTemperatureAtHeight); _pressure = _altitude call EFUNC(weather,calculateBarometricPressure); _relativeHumidity = EGVAR(weather,currentHumidity); _airDensity = [_temperature, _pressure, _relativeHumidity] call EFUNC(weather,calculateAirDensity); diff --git a/addons/mk6mortar/script_component.hpp b/addons/mk6mortar/script_component.hpp index cb74d552de..e1d56d087e 100644 --- a/addons/mk6mortar/script_component.hpp +++ b/addons/mk6mortar/script_component.hpp @@ -2,11 +2,11 @@ #include "\z\ace\Addons\main\script_mod.hpp" #ifdef DEBUG_ENABLED_MK6MORTAR - #define DEBUG_MODE_FULL + #define DEBUG_MODE_FULL #endif #ifdef DEBUG_SETTINGS_MK6MORTAR - #define DEBUG_SETTINGS DEBUG_SETTINGS_MK6MORTAR + #define DEBUG_SETTINGS DEBUG_SETTINGS_MK6MORTAR #endif #include "\z\ace\Addons\main\script_macros.hpp" diff --git a/addons/mk6mortar/stringtable.xml b/addons/mk6mortar/stringtable.xml index fd2fe4aa4c..37c7d322ad 100644 --- a/addons/mk6mortar/stringtable.xml +++ b/addons/mk6mortar/stringtable.xml @@ -49,5 +49,37 @@ Nabít Carica + + MK6 Settings + Moździerz MK6 - Ustawienia + + + Air Resistance + Opór powietrza + + + For Player Shots, Model Air Resistance and Wind Effects + Modeluj opór powietrza oraz wpływ wiatru na tor lotu pocisku dla strzałów z moździerza MK6 przez graczy + + + Allow MK6 Computer + Komputer MK6 + + + Show the Computer and Rangefinder (these NEED to be removed if you enable air resistance) + Zezwól na komputer i dalmierz (opcja ta MUSI zostać wyłączona jeżeli aktywowałeś opór powietrza) + + + Allow MK6 Compass + Kompas MK6 + + + Show the MK6 Digital Compass + Pokaż kompas MK6 + + + + Moduł ten pozwala dostosować ustawienia moździerza MK6. + diff --git a/addons/modules/XEH_preInit.sqf b/addons/modules/XEH_preInit.sqf index dfbbe2c2b9..7573d34352 100644 --- a/addons/modules/XEH_preInit.sqf +++ b/addons/modules/XEH_preInit.sqf @@ -3,7 +3,6 @@ ADDON = false; PREP(moduleInit); -PREP(bi_moduleProjectile); GVAR(moduleInitCollection) = []; diff --git a/addons/modules/config.cpp b/addons/modules/config.cpp index 4fc3b8b60d..c5880e7bb1 100644 --- a/addons/modules/config.cpp +++ b/addons/modules/config.cpp @@ -23,9 +23,6 @@ class CfgVehicles { init = QUOTE(_this call DFUNC(moduleInit)); }; }; - class ModuleOrdnance_F: Module_F { - function = "ace_modules_fnc_bi_moduleProjectile"; - }; }; -#include "CfgEventHandlers.hpp" +#include "CfgEventHandlers.hpp" \ No newline at end of file diff --git a/addons/nametags/CfgVehicles.hpp b/addons/nametags/CfgVehicles.hpp index ec005c8218..fabd3b09cb 100644 --- a/addons/nametags/CfgVehicles.hpp +++ b/addons/nametags/CfgVehicles.hpp @@ -1,69 +1,72 @@ class CfgVehicles { - class Module_F; + class Logic; + class Module_F: Logic { + class ModuleDescription {}; + }; class ACE_ModuleNameTags : Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Name Tags"; + displayName = "$STR_ACE_NameTags_Module_DisplayName"; function = QFUNC(moduleNameTags); scope = 2; isGlobal = 1; icon = QUOTE(PATHTOF(UI\Icon_Module_NameTags_ca.paa)); class Arguments { class PlayerNamesViewDistance { - displayName = "Player Names View Dist."; - description = "Distance in meters at which player names are shown. Default: 5"; + displayName = "$STR_ACE_NameTags_PlayerNamesViewDistance_DisplayName"; + description = "$STR_ACE_NameTags_PlayerNamesViewDistance_Description"; typeName = "NUMBER"; defaultValue = 5; }; class showNamesForAI { - displayName = "Show name tags for AI?"; - description = "Show the name and rank tags for friendly AI units? Default: Do not force"; + displayName = "$STR_ACE_NameTags_showNamesForAI_DisplayName"; + description = "$STR_ACE_NameTags_showNamesForAI_Description"; typeName = "NUMBER"; class values { class DoNotForce { default = 1; - name = "Do Not Force"; + name = "$STR_ACE_NameTags_DoNotForce"; value = -1; }; class ForceHide { - name = "Force Hide"; + name = "$STR_ACE_NameTags_ForceHide"; value = 0; }; class ForceShow { - name = "Force show"; + name = "$STR_ACE_NameTags_ForceShow"; value = 1; }; }; }; class showVehicleCrewInfo { - displayName = "Show crew info?"; - description = "Show vehicle crew info, or by default allows players to choose it on their own. Default: Do Not Force"; + displayName = "$STR_ACE_NameTags_showVehicleCrewInfo_DisplayName"; + description = "$STR_ACE_NameTags_showVehicleCrewInfo_Description"; typeName = "NUMBER"; class values { class DoNotForce { default = 1; - name = "Do Not Force"; + name = "$STR_ACE_NameTags_DoNotForce"; value = -1; }; class ForceHide { - name = "Force Hide"; + name = "$STR_ACE_NameTags_ForceHide"; value = 0; }; class ForceShow { - name = "Force Show"; + name = "$STR_ACE_NameTags_ForceShow"; value = 1; }; }; }; class showCursorTagForVehicles { - displayName = "Show for Vehicles"; - description = "Show cursor NameTag for vehicle commander (only if client has name tags enabled)Default: No"; + displayName = "$STR_ACE_NameTags_showCursorTagForVehicles_DisplayName"; + description = "$STR_ACE_NameTags_showCursorTagForVehicles_Description"; typeName = "BOOL"; - class values { - class Yes {name = "Yes"; value = 1;}; - class No {default = 1; name = "No"; value = 0;}; - }; + defaultValue = 0; }; }; + class ModuleDescription: ModuleDescription { + description = "$STR_ACE_NameTags_Module_Description"; + }; }; -}; +}; \ No newline at end of file diff --git a/addons/nametags/config.cpp b/addons/nametags/config.cpp index dce054a9ec..b14873779c 100644 --- a/addons/nametags/config.cpp +++ b/addons/nametags/config.cpp @@ -27,7 +27,8 @@ class ACE_Settings { typeName = "SCALAR"; isClientSettable = 1; displayName = "$STR_ACE_NameTags_ShowPlayerNames"; - values[] = {"Disabled", "Enabled", "Only Cursor", "Only On Keypress", "Only Cursor and KeyPress"}; + description = "$STR_ACE_NameTags_ShowPlayerNames_Desc"; + values[] = {"$STR_ACE_Common_Disabled", "$STR_ACE_Common_Enabled", "$STR_ACE_Common_OnlyCursor", "$STR_ACE_Common_OnlyOnKeypress", "$STR_ACE_Common_OnlyCursorAndKeyPress"}; }; class GVAR(showPlayerRanks) { value = 1; @@ -57,7 +58,8 @@ class ACE_Settings { typeName = "SCALAR"; isClientSettable = 1; displayName = "$STR_ACE_NameTags_ShowSoundWaves"; - values[] = {"Disabled", "Use Nametag settings", "Always Show All"}; + description = "$STR_ACE_NameTags_ShowSoundWaves_Desc"; + values[] = {"$STR_ACE_Common_Disabled", "$STR_ACE_Common_NameTagSettings", "$STR_ACE_Common_AlwaysShowAll"}; }; class GVAR(PlayerNamesViewDistance) { value = 5; diff --git a/addons/nametags/stringtable.xml b/addons/nametags/stringtable.xml index 8daae5cd5d..ef94140510 100644 --- a/addons/nametags/stringtable.xml +++ b/addons/nametags/stringtable.xml @@ -88,7 +88,7 @@ Show SoundWaves (requires player names) Schallwellen anzeigen (benötigt Spielernamen) - Mostrar onda sonora (requiere Mostrar nombres de jugadores) + Mostrar onda sonora (requiere Mostrar nombres de jugadores) Индикатор разговора (при вкл. именах) Zobrazit SoundWaves (vyžaduje jména hráčů) Pokaż fale dźwiękowe (wymagana opcja Pokaż imiona graczy) @@ -109,5 +109,93 @@ Colore dei nomi non appartenenti al gruppo Cor padrão do nome (unidades fora do grupo) + + Name Tags + Ustawienia imion + + + Player Names View Dist. + Zasięg imion graczy + + + Distance in meters at which player names are shown. Default: 5 + Dystans w metrach, na którym wyświetlane są imiona graczy. Domyślnie: 5 + + + Show name tags for AI? + Imiona AI + + + Show the name and rank tags for friendly AI units? Default: Do not force + Pokaż imiona i rangi przyjaznych jednostek AI? Domyślnie: Nie wymuszaj + + + Do Not Force + Nie wymuszaj + + + Force Hide + Wymuś ukrycie + + + Force show + Wymuś wyświetlanie + + + Show crew info? + Pokaż załogę + + + Show vehicle crew info, or by default allows players to choose it on their own. Default: Do Not Force + Pokaż informacje o obsadzie pojazdu, lub pozwól graczom ustawić tą opcje według własnego uznania. Domyślnie: Nie wymuszaj + + + Show for Vehicles + Pokaż dla pojazdów + + + Show cursor NameTag for vehicle commander (only if client has name tags enabled)Default: No + Pokazuj imię dowódcy pojazdu nad pojazdem (tylko jeżeli klient ma włączone imiona graczy). Domyślnie: Nie + + + + Moduł ten pozwala dostosować ustawienia i zasięg wyświetlania imion. + + + Disabled + Wyłączone + + + Enabled + Włączone + + + Only Cursor + Tylko pod kursorem + + + Only On Keypress + Tylko po wciśnięciu klawisza + + + Only Cursor and KeyPress + Tylko pod kursorem i po wciśnięciu klawisza + + + Use Nametag settings + Użyj ustawień imion + + + Always Show All + Zawsze pokazuj wszystkie + + + + Opcja ta pozwala dostosować sposób wyświetlania imion nad głowami graczy. Opcja "Tylko po wciśnięciu klawisza" wyświetla imiona tylko przytrzymania klawisza "Modyfikator" dostępnego w menu ustawień addonów -> ACE3. + + + + Opcja ta pozwala dostosować sposób wyświetlania efektu fal dźwiękowych nad głowami mówiących graczy, wyświetlanych po przytrzymaniu klawisza PTT. Opcja ta współpracuje z TFAR oraz ACRE2. + diff --git a/addons/nightvision/$PBOPREFIX$ b/addons/nightvision/$PBOPREFIX$ new file mode 100644 index 0000000000..4a3d560db5 --- /dev/null +++ b/addons/nightvision/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\nightvision \ No newline at end of file diff --git a/addons/optionsmenu/CfgVehicles.hpp b/addons/optionsmenu/CfgVehicles.hpp index 2a19aa2966..52895acb66 100644 --- a/addons/optionsmenu/CfgVehicles.hpp +++ b/addons/optionsmenu/CfgVehicles.hpp @@ -1,9 +1,8 @@ class CfgVehicles { class ACE_Module; - // TODO localization for all the modules class ACE_moduleAllowConfigExport: ACE_Module { scope = 2; - displayName = "Allow Config Export [ACE]"; + displayName = "$STR_AllowConfigExport_Module_DisplayName"; //icon = ""; category = "ACE"; function = QUOTE(DFUNC(moduleAllowConfigExport)); @@ -13,16 +12,15 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class allowconfigurationExport { - displayName = "Allow"; - description = "Allow export of all settings to a server config formatted."; + displayName = "$STR_AllowConfigExport_allowconfigurationExport_DisplayName"; + description = "$STR_AllowConfigExport_allowconfigurationExport_Description"; typeName = "BOOL"; defaultValue = 1; }; }; class ModuleDescription { - description = "When allowed, you have access to the settings modification and export in SP. Clicking export will place the formated config on your clipboard."; + description = "$STR_AllowConfigExport_Module_Description"; sync[] = {}; }; }; - }; \ No newline at end of file diff --git a/addons/optionsmenu/stringtable.xml b/addons/optionsmenu/stringtable.xml index d5de0c1426..22a1a88cfa 100644 --- a/addons/optionsmenu/stringtable.xml +++ b/addons/optionsmenu/stringtable.xml @@ -241,5 +241,49 @@ Escalar o menu de opções Proporzioni della interfaccia utente + + Allow Config Export [ACE] + Pozwól na eksport ustawień [ACE] + + + Allow + Zezwól + + + Allow export of all settings to a server config formatted. + Zezwól na eksport wszystkich ustawień do formatu konfiguracji serwera. + + + When allowed, you have access to the settings modification and export in SP. Clicking export will place the formated config on your clipboard. + Jeżeli ustawione na zezwól, wtedy będziesz mieć dostęp do ekranu modyfikacji wszystich ustawień i zmiennych ACE, a także będziesz mieć możliwość eksportu tychże ustawień do formatu rozpoznawalnego przez userconfig serwera. Kliknięcie opcji Eksportuj skopiuje wszystkie ustawienia do schowka. Działa tylko w trybie SP. + + + Hide + Ukryj + + + Top right, downwards + Po prawej u góry, w dół + + + Top right, to the left + Po prawej u góry, do lewej + + + Top left, downwards + Po lewej u góry, w dół + + + Top left, to the right + Po lewej u góry, do prawej + + + Top + Góra + + + Bottom + Dół + diff --git a/addons/realisticnames/CfgVehicles.hpp b/addons/realisticnames/CfgVehicles.hpp index 0fa3111243..cf1ce87b80 100644 --- a/addons/realisticnames/CfgVehicles.hpp +++ b/addons/realisticnames/CfgVehicles.hpp @@ -407,7 +407,7 @@ class CfgVehicles { displayName = "$STR_ACE_RealisticNames_launch_RPG32_Name"; }; - class Weapon_launch_Titan_F: Launcher_Base_F { + /*class Weapon_launch_Titan_F: Launcher_Base_F { displayName = "$STR_ACE_RealisticNames_launch_Titan_Name"; }; @@ -417,13 +417,13 @@ class CfgVehicles { class Weapon_launch_B_Titan_F: Launcher_Base_F { displayName = "$STR_ACE_RealisticNames_launch_Titan_Name"; - }; + };*/ //class Weapon_launch_I_Titan_F: Weapon_launch_B_Titan_F {}; //class Weapon_launch_O_Titan_F: Weapon_launch_B_Titan_F {}; - class Weapon_launch_launch_B_Titan_short_F: Launcher_Base_F { + /*class Weapon_launch_launch_B_Titan_short_F: Launcher_Base_F { displayName = "$STR_ACE_RealisticNames_launch_Titan_short_Name"; - }; + };*/ //class Weapon_launch_I_Titan_short_F: Weapon_launch_launch_B_Titan_short_F {}; //class Weapon_launch_O_Titan_short_F: Weapon_launch_launch_B_Titan_short_F {}; diff --git a/addons/realisticnames/CfgWeapons.hpp b/addons/realisticnames/CfgWeapons.hpp index 8eb3c04577..e61457df5d 100644 --- a/addons/realisticnames/CfgWeapons.hpp +++ b/addons/realisticnames/CfgWeapons.hpp @@ -181,12 +181,12 @@ class CfgWeapons { displayName = "$STR_ACE_RealisticNames_launch_RPG32_Name"; }; - class launch_Titan_base: Launcher_Base_F { + /*class launch_Titan_base: Launcher_Base_F { displayName = "$STR_ACE_RealisticNames_launch_Titan_Name"; }; class launch_Titan_short_base: launch_Titan_base { displayName = "$STR_ACE_RealisticNames_launch_Titan_short_Name"; - }; + };*/ class launch_NLAW_F: Launcher_Base_F { displayName = "$STR_ACE_RealisticNames_launch_NLAW_Name"; diff --git a/addons/reload/XEH_postInit.sqf b/addons/reload/XEH_postInit.sqf index 149317c136..4444fe1e34 100644 --- a/addons/reload/XEH_postInit.sqf +++ b/addons/reload/XEH_postInit.sqf @@ -18,6 +18,11 @@ if !(hasInterface) exitWith {}; {false}, [19, [false, true, false]], false] call cba_fnc_addKeybind; +["setAmmoSync", { + //To propagate the setAmmo change, do it on all clients + PARAMS_3(_unit,_weapon,_ammo); + _unit setAmmo [_weapon, _ammo]; +}] call EFUNC(common,addEventhandler); // Listen for attempts to link ammo ["linkedAmmo", { @@ -45,7 +50,7 @@ if !(hasInterface) exitWith {}; // Add the ammo _ammoAdded = _ammoMissing min (_magazine select 1); - _receiver setAmmo [currentWeapon _receiver, _ammoCount + _ammoAdded]; + ["setAmmoSync", [_receiver, (currentWeapon _receiver), (_ammoCount + _ammoAdded)]] call EFUNC(common,globalEvent); if ((_magazine select 1) - _ammoAdded > 0) then { ["returnedAmmo", [_giver], [_giver,_receiver,[_magazineType,(_magazine select 1) - _ammoAdded]]] call EFUNC(common,targetEvent); diff --git a/addons/respawn/$PBOPREFIX$ b/addons/respawn/$PBOPREFIX$ new file mode 100644 index 0000000000..072ffe81e3 --- /dev/null +++ b/addons/respawn/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\respawn \ No newline at end of file diff --git a/addons/respawn/CfgVehicleClasses.hpp b/addons/respawn/CfgVehicleClasses.hpp index 8d4eeb139c..19ed9fede8 100644 --- a/addons/respawn/CfgVehicleClasses.hpp +++ b/addons/respawn/CfgVehicleClasses.hpp @@ -1,5 +1,5 @@ class CfgVehicleClasses { class GVAR(Rallypoints) { - displayName = "ACE Respawn"; + displayName = "$STR_ACE_Respawn_EditorCategory"; }; }; diff --git a/addons/respawn/CfgVehicles.hpp b/addons/respawn/CfgVehicles.hpp index 2f963a12d3..e90f4ba08e 100644 --- a/addons/respawn/CfgVehicles.hpp +++ b/addons/respawn/CfgVehicles.hpp @@ -1,9 +1,12 @@ class CfgVehicles { - class Module_F; + class Logic; + class Module_F: Logic { + class ModuleDescription {}; + }; class ACE_ModuleRespawn: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Respawn System"; + displayName = "$STR_ACE_Respawn_Module_DisplayName"; function = QFUNC(module); scope = 2; isGlobal = 1; @@ -11,43 +14,52 @@ class CfgVehicles { class Arguments { class SavePreDeathGear { - displayName = "Save Gear?"; - description = "Respawn with the gear a soldier had just before his death?"; + displayName = "$STR_ACE_Respawn_SavePreDeathGear_DisplayName"; + description = "$STR_ACE_Respawn_SavePreDeathGear_Description"; typeName = "BOOL"; defaultValue = 0; }; class RemoveDeadBodiesDisconnected { - displayName = "Remove bodies?"; - description = "Remove player bodies after disconnect?"; + displayName = "$STR_ACE_Respawn_RemoveDeadBodiesDisconnected_DisplayName"; + description = "$STR_ACE_Respawn_RemoveDeadBodiesDisconnected_Description"; typeName = "BOOL"; defaultValue = 1; }; }; + class ModuleDescription: ModuleDescription { + description = "$STR_ACE_Respawn_Module_Description"; + }; }; class ACE_ModuleFriendlyFire: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Friendly Fire Messages"; + displayName = "$STR_ACE_FriendlyFire_Module_DisplayName"; function = QFUNC(moduleFriendlyFire); scope = 2; isGlobal = 1; icon = QUOTE(PATHTOF(UI\Icon_Module_FriendlyFire_ca.paa)); class Arguments {}; + class ModuleDescription: ModuleDescription { + description = "$STR_ACE_FriendlyFire_Module_Description"; + }; }; class ACE_ModuleRallypoint: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Rallypoint System"; + displayName = "$STR_ACE_Rallypoint_Module_DisplayName"; function = QFUNC(moduleRallypoint); scope = 2; isGlobal = 1; icon = QUOTE(PATHTOF(UI\Icon_Module_Rallypoint_ca.paa)); class Arguments {}; + class ModuleDescription: ModuleDescription { + description = "$STR_ACE_Rallypoint_Module_Description"; + }; }; // team leader @@ -55,7 +67,7 @@ class CfgVehicles { class CAManBase : Man { class ACE_SelfActions { class ACE_MoveRallypoint { - displayName = "Move Rallypoint"; + displayName = "$STR_ACE_Rallypoint_MoveRallypoint"; condition = QUOTE([ARR_2(_player, side group _player)] call FUNC(canMoveRallypoint)); statement = QUOTE([ARR_2(_player, side group _player)] call FUNC(moveRallypoint)); showDisabled = 0; diff --git a/addons/respawn/stringtable.xml b/addons/respawn/stringtable.xml index 539bb4b530..d7d5b7ac98 100644 --- a/addons/respawn/stringtable.xml +++ b/addons/respawn/stringtable.xml @@ -145,5 +145,53 @@ Rallypoint Nezávislý Ponto de encontro Independente + + Respawn System + System odrodzenia + + + Save Gear? + Zapisać ekwipunek? + + + Respawn with the gear a soldier had just before his death? + Odradzaj z ekwipunkiem jaki żołnierz miał tuż przed swoją śmiercią? + + + Remove bodies? + Usuwać ciała? + + + Remove player bodies after disconnect? + Usuwaj ciała graczy po rozłączeniu z serwera? + + + + Moduł ten pozwala dostosować ustawienia odrodzenia (respawnu). + + + Friendly Fire Messages + Wiadomości Friendly Fire + + + + Użycie tego modułu na misji spowoduje wyświetlenie wiadomości na czacie w przypadku, kiedy zostanie popełniony friendly fire - wyświetlona zostanie wtedy wiadomość kto kogo zabił. + + + Rallypoint System + System punktu zbiórki + + + + Moduł ten pozwala zastosować na misji "punkt zbiórki", do którego można szybko przeteleportować się z "bazy". Wymaga postawienia odpowiednich obiektów na mapie - bazy oraz flagi. Obydwa dostępne są w kategorii Puste -> ACE Odrodzenie. + + + Move Rallypoint + Przenieś punkt zbiórki + + + ACE Respawn + ACE Odrodzenie + diff --git a/addons/safemode/stringtable.xml b/addons/safemode/stringtable.xml index b31b5ab25f..80097580cd 100644 --- a/addons/safemode/stringtable.xml +++ b/addons/safemode/stringtable.xml @@ -4,7 +4,7 @@ Safe Mode Waffe sichern - Seguro puesto + Poner seguro Bezpiecznik Pojistka Biztonságos mód @@ -28,13 +28,13 @@ Put on Safety Waffe gesichert - Poner seguro + Seguro puesto Zabezpieczono broń Přepnout pojistku Biztonsági kapcsoló helyretolása Поставить на предохранитель Sécurité mise - Metti la sicura + Sicura inserita Colocar Segurança @@ -50,4 +50,4 @@ Tirou Segurança - + \ No newline at end of file diff --git a/addons/switchunits/CfgVehicles.hpp b/addons/switchunits/CfgVehicles.hpp index 429970b1a0..0f76c78568 100644 --- a/addons/switchunits/CfgVehicles.hpp +++ b/addons/switchunits/CfgVehicles.hpp @@ -3,63 +3,51 @@ class CfgVehicles { class ACE_ModuleSwitchUnits: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "SwitchUnits System"; + displayName = "$STR_ACE_SwitchUnits_Module_DisplayName"; function = FUNC(module); scope = 2; isGlobal = 1; icon = QUOTE(PATHTOF(UI\Icon_Module_SwitchUnits_ca.paa)); class Arguments { class SwitchToWest { - displayName = "Switch to West?"; - description = "Allow switching to west units?"; + displayName = "$STR_ACE_SwitchUnits_SwitchToWest_DisplayName"; + description = "$STR_ACE_SwitchUnits_SwitchToWest_Description"; typeName = "BOOL"; - class values { - class Yes {name = "Yes"; value = 1;}; - class No {default = 1; name = "No"; value = 0;}; - }; + defaultValue = 0; }; class SwitchToEast { - displayName = "Switch to East?"; - description = "Allow switching to east units?"; + displayName = "$STR_ACE_SwitchUnits_SwitchToEast_DisplayName"; + description = "$STR_ACE_SwitchUnits_SwitchToEast_Description"; typeName = "BOOL"; - class values { - class Yes {name = "Yes"; value = 1;}; - class No {default = 1; name = "No"; value = 0;}; - }; + defaultValue = 0; }; class SwitchToIndependent { - displayName = "Switch to Independent?"; - description = "Allow switching to independent units?"; + displayName = "$STR_ACE_SwitchUnits_SwitchToIndependent_DisplayName"; + description = "$STR_ACE_SwitchUnits_SwitchToIndependent_Description"; typeName = "BOOL"; - class values { - class Yes {name = "Yes"; value = 1;}; - class No {default = 1; name = "No"; value = 0;}; - }; + defaultValue = 0; }; class SwitchToCivilian { - displayName = "Switch to Civilian?"; - description = "Allow switching to civilian units?"; + displayName = "$STR_ACE_SwitchUnits_SwitchToCivilian_DisplayName"; + description = "$STR_ACE_SwitchUnits_SwitchToCivilian_Description"; typeName = "BOOL"; - class values { - class Yes {name = "Yes"; value = 1;}; - class No {default = 1; name = "No"; value = 0;}; - }; + defaultValue = 0; }; class EnableSafeZone { - displayName = "Enable Safe Zone?"; - description = "Enable a safe zone around enemy units? Players can't switch to units inside of the safe zone."; + displayName = "$STR_ACE_SwitchUnits_EnableSafeZone_DisplayName"; + description = "$STR_ACE_SwitchUnits_EnableSafeZone_Description"; typeName = "BOOL"; - class values { - class Yes {default = 1; name = "Yes"; value = 1;}; - class No {name = "No"; value = 0;}; - }; + defaultValue = 1; }; class SafeZoneRadius { - displayName = "Safe Zone Radius"; - description = "The safe zone around players from a different team. Default: 200"; + displayName = "$STR_ACE_SwitchUnits_SafeZoneRadius_DisplayName"; + description = "$STR_ACE_SwitchUnits_SafeZoneRadius_Description"; typeName = "NUMBER"; defaultValue = 100; }; }; + class ModuleDescription { + description = "$STR_ACE_SwitchUnits_Module_Description"; + }; }; -}; +}; \ No newline at end of file diff --git a/addons/switchunits/functions/fnc_handleMapClick.sqf b/addons/switchunits/functions/fnc_handleMapClick.sqf index bfe36f13ea..e8efa2640f 100644 --- a/addons/switchunits/functions/fnc_handleMapClick.sqf +++ b/addons/switchunits/functions/fnc_handleMapClick.sqf @@ -28,14 +28,9 @@ _sideNearest = []; if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then { _sideNearest pushBack _x; }; -} forEach (nearestObjects [_pos, ["Man"], 20]); - +} forEach (nearestObjects [_pos, ["Man"], 15]); if (count _sideNearest > 0) then { - private ["_switchUnit"]; - - _switchUnit = _sideNearest select 0; - [ACE_player, _switchUnit] call FUNC(switchUnit); - + [_sideNearest select 0] call FUNC(switchUnit); openMap false; }; diff --git a/addons/switchunits/functions/fnc_initPlayer.sqf b/addons/switchunits/functions/fnc_initPlayer.sqf index c2857f1091..67669c071c 100644 --- a/addons/switchunits/functions/fnc_initPlayer.sqf +++ b/addons/switchunits/functions/fnc_initPlayer.sqf @@ -17,8 +17,6 @@ #include "script_component.hpp" -private ["_playerUnit", "_sides"]; - PARAMS_2(_playerUnit,_sides); if (vehicle _playerUnit == _playerUnit) then { diff --git a/addons/switchunits/functions/fnc_startSwitchUnits.sqf b/addons/switchunits/functions/fnc_startSwitchUnits.sqf index ef344475b9..7985bfa094 100644 --- a/addons/switchunits/functions/fnc_startSwitchUnits.sqf +++ b/addons/switchunits/functions/fnc_startSwitchUnits.sqf @@ -16,13 +16,10 @@ #include "script_component.hpp" - -private "_player"; -_player = _this select 0; - +PARAMS_1(_player); if (GVAR(EnableSwitchUnits)) then { - private ["_sides"]; + private "_sides"; _sides = []; if(GVAR(SwitchToWest)) then {_sides pushBack west;}; diff --git a/addons/switchunits/functions/fnc_switchUnit.sqf b/addons/switchunits/functions/fnc_switchUnit.sqf index b1879b0999..c263bdd721 100644 --- a/addons/switchunits/functions/fnc_switchUnit.sqf +++ b/addons/switchunits/functions/fnc_switchUnit.sqf @@ -32,11 +32,11 @@ if (GVAR(EnableSafeZone)) then { _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers); _nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter); - + if (count _nearestEnemyPlayers > 0) exitWith { _leave = true; }; - + }; // exitWith doesn't exit past the "if(EnableSafeZone)" block @@ -56,14 +56,14 @@ DFUNC(pfhSwitchUnit) = { private ["_args", "_unit", "_oldUnit", "_respawnEhId", "_oldOwner"]; _args = _this select 0; - + _unit = _args select 0; _oldUnit = _args select 1; - - - + + + if (local _unit) exitWith { - + _oldUnit setVariable [QGVAR(IsPlayerControlled), false, true]; _oldUnit setVariable [QGVAR(PlayerControlledName), "", true]; @@ -89,9 +89,9 @@ DFUNC(pfhSwitchUnit) = { }; [localize "STR_ACE_SwitchUnits_SwitchedUnit"] call EFUNC(common,displayTextStructured); - + [(_this select 1)] call cba_fnc_removePerFrameHandler; - + }; }; diff --git a/addons/switchunits/stringtable.xml b/addons/switchunits/stringtable.xml index 8121e3e61e..cdde0f8ff1 100644 --- a/addons/switchunits/stringtable.xml +++ b/addons/switchunits/stringtable.xml @@ -25,5 +25,61 @@ Questa unità è troppo vicina al nemico. Essa unidade está muito perta do inimigo. + + SwitchUnits System + System zmiany stron + + + Switch to West? + Zmiana na Zachód? + + + Allow switching to west units? + Pozwolić zmieniać graczom stronę na Zachód? + + + Switch to East? + Zmiana na Wschód? + + + Allow switching to east units? + Pozwolić zmieniać graczom stronę na Wschód? + + + Switch to Independent? + Zmiana na Ruch Oporu? + + + Allow switching to independent units? + Pozwolić zmieniać stronę na Ruch Oporu? + + + Switch to Civilian? + Zmiana na Cywili? + + + Allow switching to civilian units? + Pozwolić zmieniać stronę na Cywili? + + + Enable Safe Zone? + Aktywuj bezp. strefę? + + + Enable a safe zone around enemy units? Players can't switch to units inside of the safe zone. + Aktywuje bezpieczną strefę wokół jednostek przeciwnika. Gracze nie mogą zmieniać strony wewnątrz tej strefy. + + + Safe Zone Radius + Promień bezp. strefy + + + The safe zone around players from a different team. Default: 200 + Promień bezpiecznej strefy wokół graczy z innych drużyn. Domyślnie: 200 + + + + + diff --git a/addons/thermals/config.cpp b/addons/thermals/config.cpp index 252a440535..07d19d1b50 100644 --- a/addons/thermals/config.cpp +++ b/addons/thermals/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {ace_common}; + requiredAddons[] = {"ace_common"}; author[] = {"[TF]Nkey"}; authorUrl = "https://github.com/michail-nikolaev/"; VERSION_CONFIG; diff --git a/addons/vehiclelock/CfgMagazines.hpp b/addons/vehiclelock/CfgMagazines.hpp index 100df8065b..d57e8fff6f 100644 --- a/addons/vehiclelock/CfgMagazines.hpp +++ b/addons/vehiclelock/CfgMagazines.hpp @@ -6,5 +6,6 @@ class CfgMagazines { descriptionShort = "$STR_ACE_Vehicle_Item_Custom_Description"; count = 1; mass = 0; + ACE_isUnique = 1; }; }; diff --git a/addons/vehiclelock/CfgVehicles.hpp b/addons/vehiclelock/CfgVehicles.hpp index 94bcf34317..60cb67d4c4 100644 --- a/addons/vehiclelock/CfgVehicles.hpp +++ b/addons/vehiclelock/CfgVehicles.hpp @@ -69,7 +69,7 @@ class CfgVehicles { class ACE_VehicleLock_ModuleSetup: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Vehicle Lock Setup"; + displayName = "$STR_ACE_VehicleLock_Module_DisplayName"; function = QFUNC(moduleInit); scope = 2; isGlobal = 0; @@ -77,37 +77,37 @@ class CfgVehicles { functionPriority = 0; class Arguments { class LockVehicleInventory { - displayName = "Lock Vehicle Inventory"; - description = "Locks the inventory of locked vehicles"; + displayName = "$STR_ACE_VehicleLock_LockVehicleInventory_DisplayName"; + description = "$STR_ACE_VehicleLock_LockVehicleInventory_Description"; typeName = "BOOL"; defaultValue = 0; }; class VehicleStartingLockState { - displayName = "Vehicle Starting Lock State"; // Argument label - description = "Set lock state for all vehicles (removes ambiguous lock states)"; // Tooltip description - typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" + displayName = "$STR_ACE_VehicleLock_VehicleStartingLockState_DisplayName"; + description = "$STR_ACE_VehicleLock_VehicleStartingLockState_Description"; + typeName = "NUMBER"; class values { - class None {name = "As Is"; value = 0; default = 1;}; - class Side {name = "Locked"; value = 1;}; - class Unique {name = "Unlocked"; value = 2;}; + class None {name = "$STR_ACE_VehicleLock_VehicleStartingLockState_AsIs"; value = 0; default = 1;}; + class Side {name = "$STR_ACE_VehicleLock_VehicleStartingLockState_Locked"; value = 1;}; + class Unique {name = "$STR_ACE_VehicleLock_VehicleStartingLockState_Unlocked"; value = 2;}; }; }; class DefaultLockpickStrength { - displayName = "Default Lockpick Strength"; - description = "Default Time to lockpick (in seconds). Default: 10"; - typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" - defaultValue = "10"; // Default text filled in the input box + displayName = "$STR_ACE_VehicleLock_DefaultLockpickStrength_DisplayName"; + description = "$STR_ACE_VehicleLock_DefaultLockpickStrength_Description"; + typeName = "NUMBER"; + defaultValue = "10"; }; }; class ModuleDescription: ModuleDescription { - description = "Settings for lockpick strength and initial vehicle lock state. Removes ambiguous lock states.
Source: vehiclelock.pbo"; + description = "$STR_ACE_VehicleLock_Module_Description"; }; }; class ACE_VehicleLock_ModuleSyncedAssign: Module_F { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; - displayName = "Vehicle Key Assign"; + displayName = "$STR_ACE_VehicleLock_VehicleKeyAssign_Module_DisplayName"; function = QFUNC(moduleSync); scope = 2; isGlobal = 0; @@ -115,8 +115,8 @@ class CfgVehicles { functionPriority = 0; class Arguments {}; class ModuleDescription: ModuleDescription { - description = "Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. Only valid for objects present at mission start.
Source: vehiclelock.pbo"; + description = "$STR_ACE_VehicleLock_VehicleKeyAssign_Module_Description"; sync[] = {"AnyPlayer", "AnyVehicle"}; }; }; -}; +}; \ No newline at end of file diff --git a/addons/vehiclelock/stringtable.xml b/addons/vehiclelock/stringtable.xml index 6ccfc8347b..4738d045df 100644 --- a/addons/vehiclelock/stringtable.xml +++ b/addons/vehiclelock/stringtable.xml @@ -133,5 +133,57 @@ Una chaive che apr ela maggior parte dei veicoli civili Uma chave que abre a maioria dos veículos civis. + + Vehicle Lock Setup + Ustawienie blokady pojazdów + + + Lock Vehicle Inventory + Zablokuj ekwipunek pojazdu + + + Locks the inventory of locked vehicles + Blokuje dostęp do ekwipunku pojazdu + + + Vehicle Starting Lock State + Początkowy stan blok. poj. + + + Set lock state for all vehicles (removes ambiguous lock states) + Ustawia początkowy stan blokady dla wszystkich pojazdów (usuwa dwuznaczne stany blokady) + + + As Is + Jak jest + + + Locked + Zablokowany + + + Unlocked + Odblokowany + + + Default Lockpick Strength + Czas włamywania + + + Default Time to lockpick (in seconds). Default: 10 + Domyślny czas potrzebny na otwarcie pojazdu (w sekundach). Domyślnie: 10 + + + Settings for lockpick strength and initial vehicle lock state. Removes ambiguous lock states.<br />Source: vehiclelock.pbo + Ustawienia czasu włamywania oraz domyślnego stanu blokady pojazdów. Wyłącza dwuznaczne ustawienia blokady. Moduł ten umożliwia więc np. zamknięcie pojazdów przeciwnika na klucz tak, że gracze bez odpowiedniego sprzętu (wytrycha) nie będą mogli ich używać.<br />Źródło: vehiclelock.pbo + + + Vehicle Key Assign + Przydział kluczyka do pojazdu + + + Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. Only valid for objects present at mission start.<br />Source: vehiclelock.pbo + Zsynchronizuj z pojazdami i graczami. Rozda klucze dla graczy dla każdego zsynchronizowanego pojazdu. Działa tylko na pojazdy obecne na misji od samego początku (postawione w edytorze).<br />Źródło: vehiclelock.pbo + diff --git a/addons/viewdistance/$PBOPREFIX$ b/addons/viewdistance/$PBOPREFIX$ new file mode 100644 index 0000000000..278df54db3 --- /dev/null +++ b/addons/viewdistance/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\viewdistance \ No newline at end of file diff --git a/addons/viewdistance/ACE_Settings.hpp b/addons/viewdistance/ACE_Settings.hpp new file mode 100644 index 0000000000..ba773f5fc5 --- /dev/null +++ b/addons/viewdistance/ACE_Settings.hpp @@ -0,0 +1,42 @@ +class ACE_Settings { + class GVAR(viewDistanceOnFoot) { + typeName = "SCALAR"; + isClientSettable = 1; + value = 11; // index, NOT value // Can set it to client's actual viewdistance in the init function once ACE_Settings supports numbers (if ever). + values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf + displayName = "Client View Distance (On Foot)"; + description = "Changes in game view distance when the player is on foot."; + }; + class GVAR(viewDistanceLandVehicle) { + typeName = "SCALAR"; + isClientSettable = 1; + value = 11; // index, NOT value + values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf + displayName = "Client View Distance (Land Vehicle)"; + description = "Changes in game view distance when the player is in a land vehicle."; + }; + class GVAR(viewDistanceAirVehicle) { + typeName = "SCALAR"; + isClientSettable = 1; + value = 11; // index, NOT value + values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf + displayName = "Client View Distance (Air Vehicle)"; + description = "Changes in game view distance when the player is in an air vehicle."; + }; + class GVAR(limitViewDistance) { + typeName = "SCALAR"; + value = 10000; // Value, NOT index. 10000 is the maximum in A3 + displayName = "View Distance Limit"; + description = "Limit for client's view distance set here and can overridden by module"; + }; + class GVAR(objectViewDistanceCoeff) { + typeName = "SCALAR"; + isClientSettable = 1; + value = 0; // index. Actual coefficient is given by functions/fnc_returnObjectCoeff.sqf + values[] = {"Off","Very Low","Low","Medium","High","Very High"}; + displayName = "Dynamic Object View Distance"; + description = "Sets the object view distance as a coefficient of the view distance."; + }; +}; + +// To do: include string table style displayName & description. \ No newline at end of file diff --git a/addons/viewdistance/CfgEventHandlers.hpp b/addons/viewdistance/CfgEventHandlers.hpp new file mode 100644 index 0000000000..0f1d8878ba --- /dev/null +++ b/addons/viewdistance/CfgEventHandlers.hpp @@ -0,0 +1,12 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; \ No newline at end of file diff --git a/addons/viewdistance/CfgVehicles.hpp b/addons/viewdistance/CfgVehicles.hpp new file mode 100644 index 0000000000..870c669601 --- /dev/null +++ b/addons/viewdistance/CfgVehicles.hpp @@ -0,0 +1,20 @@ +class CfgVehicles { + class ACE_Module; + class GVAR(ModuleSettings) : ACE_Module { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + function = QUOTE(DFUNC(initModule)); + displayName = "View Distance Limiter"; + scope = 2; + isGlobal = 1; + //icon = ""; // needs an icon + class Arguments { + class moduleViewDistanceLimit { + displayName = "View Distance Limit"; + description = "Sets the limit for how high clients can raise their view distance (<= 10000)"; + typeName = "NUMBER"; + defaultValue = 10000; + }; + }; + }; +}; \ No newline at end of file diff --git a/addons/viewdistance/XEH_postInit.sqf b/addons/viewdistance/XEH_postInit.sqf new file mode 100644 index 0000000000..925ec0739e --- /dev/null +++ b/addons/viewdistance/XEH_postInit.sqf @@ -0,0 +1,29 @@ +#include "script_component.hpp" + +if (!hasInterface) exitWith {}; + +// Force the view distance down to the limit. +if (viewDistance > GVAR(limitViewDistance)) then { + setViewDistance GVAR(limitViewDistance); +}; + +// Adapt view distance when the player is created or changed according to whether client is on foot or vehicle. +["playerChanged",{ + [true] call FUNC(adaptViewDistance); +}] call ace_common_fnc_addEventHandler; + +// Set the EH which waits for any of the view distance settings to be changed, so that the effect is show immediately +["SettingChanged",{ + if ((_this select 0 == QGVAR(viewDistanceOnFoot)) || + {_this select 0 == QGVAR(viewDistanceLandVehicle)} || + {_this select 0 == QGVAR(viewDistanceAirVehicle)} || + {_this select 0 == QGVAR(objectViewDistanceCoeff)}) then { + + [true] call FUNC(adaptViewDistance); + }; +}] call ace_common_fnc_addEventHandler; + +// Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle +["playerVehicleChanged",{ + [false] call FUNC(adaptViewDistance) +}] call ace_common_fnc_addEventHandler; \ No newline at end of file diff --git a/addons/viewdistance/XEH_preInit.sqf b/addons/viewdistance/XEH_preInit.sqf new file mode 100644 index 0000000000..a68416cada --- /dev/null +++ b/addons/viewdistance/XEH_preInit.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(initModule); +PREP(returnValue); +PREP(returnObjectCoeff); +PREP(changeViewDistance); +PREP(adaptViewDistance); + +ADDON = true; \ No newline at end of file diff --git a/addons/viewdistance/config.cpp b/addons/viewdistance/config.cpp new file mode 100644 index 0000000000..a1afbcc93f --- /dev/null +++ b/addons/viewdistance/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Winter"}; + authorUrl = "https://github.com/Winter259"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "ACE_Settings.hpp" +#include "CfgVehicles.hpp" \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_adaptViewDistance.sqf b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf new file mode 100644 index 0000000000..5012b40c93 --- /dev/null +++ b/addons/viewdistance/functions/fnc_adaptViewDistance.sqf @@ -0,0 +1,37 @@ +/* + * Author: Winter + * Sets the player's current view distance according to whether s/he is on foot, in a land vehicle or in an air vehicle. + * + * + * Arguments: + * 0: Show Prompt + * + * Return Value: + * None + * + * Example: + * [] call ace_viewdistance_fnc_adaptViewDistance; + * + * Public: No + */ + +#include "script_component.hpp" + +PARAMS_1(_show_prompt); + +private["_land_vehicle","_air_vehicle"]; + +_land_vehicle = (vehicle ACE_player) isKindOf "LandVehicle"; +_air_vehicle = (vehicle ACE_player) isKindOf "Air"; + +if (!_land_vehicle && !_air_vehicle) exitWith { + [GVAR(viewDistanceOnFoot),_show_prompt] call FUNC(changeViewDistance); +}; + +if (_land_vehicle) exitWith { + [GVAR(viewDistanceLandVehicle),_show_prompt] call FUNC(changeViewDistance); +}; + +if (_air_vehicle) exitWith { + [GVAR(viewDistanceAirVehicle),_show_prompt] call FUNC(changeViewDistance); +}; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_changeViewDistance.sqf b/addons/viewdistance/functions/fnc_changeViewDistance.sqf new file mode 100644 index 0000000000..61b568bc2a --- /dev/null +++ b/addons/viewdistance/functions/fnc_changeViewDistance.sqf @@ -0,0 +1,48 @@ +/* + * Author: Winter + * Sets the player's current view distance according to allowed values. + * + * + * Arguments: + * 0: View Distance setting INDEX + * 1: Show Prompt + * + * Return Value: + * None + * + * Example: + * [] call ace_viewdistance_fnc_changeViewDistance; + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_text","_new_view_distance","_view_distance_limit","_object_view_distance_coeff"]; + +PARAMS_2(_index_requested,_show_prompt); + +_new_view_distance = [_index_requested] call FUNC(returnValue); // changes the setting index into an actual view distance value +_object_view_distance_coeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff); // changes the setting index into a coefficient. +_view_distance_limit = GVAR(limitViewDistance); // Grab the limit + +if (_new_view_distance <= _view_distance_limit) then { + if (_show_prompt) then { + _text = parseText format ["View Distance: %1
Object View Distance Coefficient: %2
",str(_new_view_distance),str(_object_view_distance_coeff)]; + [_text,2] call EFUNC(common,displayTextStructured); + }; + setViewDistance _new_view_distance; + if (_object_view_distance_coeff > 0) then { + setObjectViewDistance (_object_view_distance_coeff * _new_view_distance); + }; +} +else { + if (_show_prompt) then { + _text = parseText format ["That option is invalid! The limit is: %1
Object View Distance Coefficient: %2
",str(_view_distance_limit),str(_object_view_distance_coeff)]; + [_text,2] call EFUNC(common,displayTextStructured); + }; + setViewDistance _view_distance_limit; + if (_object_view_distance_coeff > 0) then { + setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit); + }; +}; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_initModule.sqf b/addons/viewdistance/functions/fnc_initModule.sqf new file mode 100644 index 0000000000..cff8e9685f --- /dev/null +++ b/addons/viewdistance/functions/fnc_initModule.sqf @@ -0,0 +1,28 @@ +/* + * Author: Winter + * Initialises the view distance limiter module + * + * + * Arguments: + * 0: logic + * 1: Synchronised Units + * 2: Module Activated + * + * Return Value: + * None + * + */ + +#include "script_component.hpp" + +if (!isServer) exitWith {}; + +PARAMS_3(_logic,_units,_activated); + +if (!_activated) exitWith { + diag_log text "[ACE]: View Distance Limit Module is placed but NOT active."; +}; + +[_logic, QGVAR(limitViewDistance),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule); + +diag_log format ["[ACE]: View Distance Limit Module Initialized. Limit set by module: %1",GVAR(limitViewDistance)]; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf b/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf new file mode 100644 index 0000000000..145b8ae9e6 --- /dev/null +++ b/addons/viewdistance/functions/fnc_returnObjectCoeff.sqf @@ -0,0 +1,34 @@ +/* + * Author: Winter + * Returns the object view distance coefficient according to the given index + * + * + * Arguments: + * 0: Object View Distance setting Index + * + * Return Value: + * Object View Distance + * + * Example: + * [2] call ace_viewdistance_fnc_returnObjectCoeff; + * + * Public: No + */ + +#include "script_component.hpp" + +PARAMS_1(_index); + +private ["_return"]; + +_return = switch (_index) do { + case 0: {0.00}; // Off + case 1: {0.20}; // Very Low + case 2: {0.40}; // Low + case 3: {0.60}; // Medium + case 4: {0.80}; // High + case 5: {1.00}; // Very High + default {0.50}; // something broke if this returns +}; + +_return; \ No newline at end of file diff --git a/addons/viewdistance/functions/fnc_returnValue.sqf b/addons/viewdistance/functions/fnc_returnValue.sqf new file mode 100644 index 0000000000..9d4725c72e --- /dev/null +++ b/addons/viewdistance/functions/fnc_returnValue.sqf @@ -0,0 +1,40 @@ +/* + * Author: Winter + * Returns the view distance value according to the given index + * + * + * Arguments: + * 0: View Distance Index + * + * Return Value: + * View Distance + * + * Example: + * [2] call ace_viewdistance_fnc_returnViewDistanceValue; + * + * Public: No + */ + +#include "script_component.hpp" + +PARAMS_1(_index); + +private ["_return"]; + +_return = switch (_index) do { + case 0: {1500}; + case 1: {2000}; + case 2: {2500}; + case 3: {3000}; + case 4: {3500}; + case 5: {4000}; + case 6: {5000}; + case 7: {6000}; + case 8: {7000}; + case 9: {8000}; + case 10: {9000}; + case 11: {10000}; + default {1000}; +}; + +_return; \ No newline at end of file diff --git a/addons/viewdistance/functions/script_component.hpp b/addons/viewdistance/functions/script_component.hpp new file mode 100644 index 0000000000..4b7df89f37 --- /dev/null +++ b/addons/viewdistance/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\viewdistance\script_component.hpp" \ No newline at end of file diff --git a/addons/viewdistance/script_component.hpp b/addons/viewdistance/script_component.hpp new file mode 100644 index 0000000000..79e0e488cc --- /dev/null +++ b/addons/viewdistance/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT viewdistance +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_VIEWDISTANCE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_VIEWDISTANCE + #define DEBUG_SETTINGS DEBUG_SETTINGS_VIEWDISTANCE +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/weaponselect/XEH_postInit.sqf b/addons/weaponselect/XEH_postInit.sqf index ab77f5d2ee..d4fd02122f 100644 --- a/addons/weaponselect/XEH_postInit.sqf +++ b/addons/weaponselect/XEH_postInit.sqf @@ -16,7 +16,7 @@ if !(hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //1 Key +[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 1 Key) ["ACE3 Weapons", QGVAR(SelectRifleNew), localize "STR_ACE_WeaponSelect_SelectRifle", { @@ -30,7 +30,7 @@ if !(hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //2 Key +[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 2 Key) ["ACE3 Weapons", QGVAR(SelectRifleMuzzleNew), localize "STR_ACE_WeaponSelect_SelectRifleMuzzle", { @@ -44,7 +44,7 @@ if !(hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //3 Key +[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 3 Key) ["ACE3 Weapons", QGVAR(SelectLauncherNew), localize "STR_ACE_WeaponSelect_SelectLauncher", { @@ -58,7 +58,7 @@ if !(hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //4 Key +[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 4 Key) ["ACE3 Weapons", QGVAR(SelectBinocularNew), localize "STR_ACE_WeaponSelect_SelectBinocular", { @@ -72,7 +72,7 @@ if !(hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //5 Key +[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 5 Key) ["ACE3 Weapons", QGVAR(SelectGrenadeFrag), localize "STR_ACE_WeaponSelect_SelectGrenadeFrag", { @@ -119,9 +119,9 @@ if !(hasInterface) exitWith {}; ["ACE3 Vehicles", QGVAR(EngineOn), localize "STR_ACE_WeaponSelect_EngineOn", { // Conditions: canInteract - if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, (vehicle ACE_player), []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if !(ACE_player != vehicle ACE_player && {ACE_player == driver vehicle ACE_player} && {!isEngineOn vehicle ACE_player}) exitWith {false}; + if !((ACE_player != vehicle ACE_player) && {ACE_player == driver vehicle ACE_player} && {!isEngineOn vehicle ACE_player}) exitWith {false}; // Statement (vehicle ACE_player) engineOn true; @@ -133,7 +133,7 @@ if !(hasInterface) exitWith {}; ["ACE3 Vehicles", QGVAR(EngineOff), localize "STR_ACE_WeaponSelect_EngineOff", { // Conditions: canInteract - if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, (vehicle ACE_player), []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific if !(ACE_player != vehicle ACE_player && {ACE_player == driver vehicle ACE_player} && {isEngineOn vehicle ACE_player}) exitWith {false}; @@ -147,49 +147,49 @@ if !(hasInterface) exitWith {}; ["ACE3 Vehicles", QGVAR(SelectMainGunNew), localize "STR_ACE_WeaponSelect_SelectMainGun", { // Conditions: canInteract - if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, (vehicle ACE_player), []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific if !(ACE_player != vehicle ACE_player) exitWith {false}; // Statement [ACE_player, vehicle ACE_player, 0] call FUNC(selectWeaponVehicle); - false + true }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //3 Key +[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 3 Key) ["ACE3 Vehicles", QGVAR(SelectMachineGunNew), localize "STR_ACE_WeaponSelect_SelectMachineGun", { // Conditions: canInteract - if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, (vehicle ACE_player), []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific if !(ACE_player != vehicle ACE_player) exitWith {false}; // Statement [ACE_player, vehicle ACE_player, 1] call FUNC(selectWeaponVehicle); - false + true }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //4 Key +[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 4 Key) ["ACE3 Vehicles", QGVAR(SelectMissilesNew), localize "STR_ACE_WeaponSelect_SelectMissiles", { // Conditions: canInteract - if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, (vehicle ACE_player), []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific if !(ACE_player != vehicle ACE_player) exitWith {false}; // Statement [ACE_player, vehicle ACE_player, 2] call FUNC(selectWeaponVehicle); - false + true }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //5 Key +[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 5 Key) ["ACE3 Vehicles", QGVAR(FireSmokeLauncher), localize "STR_ACE_WeaponSelect_FireSmokeLauncher", { // Conditions: canInteract - if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, (vehicle ACE_player), []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific if !(ACE_player != vehicle ACE_player && {ACE_player == commander vehicle ACE_player}) exitWith {false}; diff --git a/addons/weather/CfgVehicles.hpp b/addons/weather/CfgVehicles.hpp index 3de925e446..d2b5bddcba 100644 --- a/addons/weather/CfgVehicles.hpp +++ b/addons/weather/CfgVehicles.hpp @@ -2,7 +2,7 @@ class CfgVehicles { class ACE_Module; class GVAR(ModuleSettings): ACE_Module { scope = 2; - displayName = "Weather"; + displayName = "$STR_ACE_Weather_Module_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Wind_ca.paa)); category = "ACE"; function = QUOTE(DFUNC(initModuleSettings)); @@ -12,41 +12,44 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class enableServerController { - displayName = "Weather propagation"; - description = "Enables sever side weather propagation"; + displayName = "$STR_ACE_Weather_enableServerController_DisplayName"; + description = "$STR_ACE_Weather_enableServerController_Description"; typeName = "BOOL"; defaultValue = 1; }; class useACEWeather { - displayName = "ACE Weather"; - description = "Overrides the default weather (editor, mission settings) with ACE weather (map based)"; + displayName = "$STR_ACE_Weather_useACEWeather_DisplayName"; + description = "$STR_ACE_Weather_useACEWeather_Description"; typeName = "BOOL"; defaultValue = 1; }; class syncRain { - displayName = "Sync Rain"; - description = "Synchronizes rain"; + displayName = "$STR_ACE_Weather_syncRain_DisplayName"; + description = "$STR_ACE_Weather_syncRain_Description"; typeName = "BOOL"; defaultValue = 1; }; class syncWind { - displayName = "Sync Wind"; - description = "Synchronizes wind"; + displayName = "$STR_ACE_Weather_syncWind_DisplayName"; + description = "$STR_ACE_Weather_syncWind_Description"; typeName = "BOOL"; defaultValue = 1; }; class syncMisc { - displayName = "Sync Misc"; - description = "Synchronizes lightnings, rainbow, fog, ..."; + displayName = "$STR_ACE_Weather_syncMisc_DisplayName"; + description = "$STR_ACE_Weather_syncMisc_Description"; typeName = "BOOL"; defaultValue = 1; }; class serverUpdateInterval { - displayName = "Update Interval"; - description = "Defines the interval (seconds) between weather updates"; + displayName = "$STR_ACE_Weather_serverUpdateInterval_DisplayName"; + description = "$STR_ACE_Weather_serverUpdateInterval_Description"; typeName = "NUMBER"; defaultValue = 60; }; }; + class ModuleDescription { + description = "$STR_ACE_Weather_Module_Description"; + }; }; -}; +}; \ No newline at end of file diff --git a/addons/weather/XEH_preInit.sqf b/addons/weather/XEH_preInit.sqf index 0f49226432..85166ce356 100644 --- a/addons/weather/XEH_preInit.sqf +++ b/addons/weather/XEH_preInit.sqf @@ -5,6 +5,9 @@ ADDON = false; PREP(calculateAirDensity); PREP(calculateBarometricPressure); +PREP(calculateRoughnessLength); +PREP(calculateTemperatureAtHeight); +PREP(calculateWindSpeed); PREP(displayWindInfo); PREP(getMapData); PREP(getWind); diff --git a/addons/weather/config.cpp b/addons/weather/config.cpp index 39cf223518..18059fe9e8 100644 --- a/addons/weather/config.cpp +++ b/addons/weather/config.cpp @@ -5,8 +5,8 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"q1184", "Rocko", "esteldunedain","Ruthberg"}; + requiredAddons[] = {"ace_common", "ace_modules"}; + author[] = {"q1184", "Rocko", "esteldunedain", "Ruthberg"}; VERSION_CONFIG; }; }; diff --git a/addons/weather/functions/fnc_calculateBarometricPressure.sqf b/addons/weather/functions/fnc_calculateBarometricPressure.sqf index c65d343c93..1e1d47098c 100644 --- a/addons/weather/functions/fnc_calculateBarometricPressure.sqf +++ b/addons/weather/functions/fnc_calculateBarometricPressure.sqf @@ -14,7 +14,4 @@ */ #include "script_component.hpp" -private ["_altitude"]; -_altitude = _this; - -(1013.25 * exp(-(GVAR(Altitude) + _altitude) / 7990) - 10 * overcast) +(1013.25 * exp(-(GVAR(Altitude) + _this) / 7990) - 10 * overcast) diff --git a/addons/advanced_ballistics/functions/fnc_calculateRoughnessLength.sqf b/addons/weather/functions/fnc_calculateRoughnessLength.sqf similarity index 100% rename from addons/advanced_ballistics/functions/fnc_calculateRoughnessLength.sqf rename to addons/weather/functions/fnc_calculateRoughnessLength.sqf diff --git a/addons/weather/functions/fnc_calculateTemperatureAtHeight.sqf b/addons/weather/functions/fnc_calculateTemperatureAtHeight.sqf new file mode 100644 index 0000000000..dd31dfe05e --- /dev/null +++ b/addons/weather/functions/fnc_calculateTemperatureAtHeight.sqf @@ -0,0 +1,17 @@ +/* + * Author: Ruthberg + * + * Calculates the temperature based on altitude and weather + * + * Arguments: + * 0: height - meters + * + * Return Value: + * 0: temperature - degrees celsius + * + * Return value: + * None + */ +#include "script_component.hpp" + +(GVAR(currentTemperature) - 0.0065 * _this) diff --git a/addons/weather/functions/fnc_calculateWindSpeed.sqf b/addons/weather/functions/fnc_calculateWindSpeed.sqf new file mode 100644 index 0000000000..b5cde4e959 --- /dev/null +++ b/addons/weather/functions/fnc_calculateWindSpeed.sqf @@ -0,0 +1,90 @@ +/* + * Author: Ruthberg + * + * Calculates the true wind speed at a given world position + * + * Arguments: + * 0: world position - posASL + * 1: Account for wind gradient + * 2: Account for terrain + * 3: Account for obstacles + * + * Return Value: + * 0: wind speed - m/s + * + * Public: No + */ +#include "script_component.hpp" + +private ["_windSpeed", "_windDir", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"]; + +EXPLODE_4_PVT(_this,_position,_windGradientEnabled,_terrainEffectEnabled,_obstacleEffectEnabled); + +fnc_polar2vect = { + private ["_mag2D"]; + _mag2D = (_this select 0) * cos((_this select 2)); + [_mag2D * sin((_this select 1)), _mag2D * cos((_this select 1)), (_this select 0) * sin((_this select 2))]; +}; + +_windSpeed = vectorMagnitude ACE_wind; +_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); + +// Wind gradient +if (_windGradientEnabled) then { + if (_windSpeed > 0.05) then { + _height = (ASLToATL _position) select 2; + _height = 0 max _height min 20; + if (_height < 20) then { + _roughnessLength = _position call FUNC(calculateRoughnessLength); + _windSpeed = _windSpeed * abs(ln(_height / _roughnessLength) / ln(20 / _roughnessLength)); + }; + }; +}; + +// Terrain effect on wind +if (_terrainEffectEnabled) then { + if (_windSpeed > 0.05) then { + _newWindSpeed = 0; + { + _windSource = [100, _windDir + 180, _x] call fnc_polar2vect; + if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith { + _newWindSpeed = cos(_x * 9) * _windSpeed; + }; + _windSource = [100, _windDir + 180 + _x, 0] call fnc_polar2vect; + if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith { + _newWindSpeed = cos(_x * 9) * _windSpeed; + }; + _windSource = [100, _windDir + 180 - _x, 0] call fnc_polar2vect; + if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith { + _newWindSpeed = cos(_x * 9) * _windSpeed; + }; + } forEach [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + _windSpeed = _newWindSpeed; + }; +}; + +// Obstacle effect on wind +if (_obstacleEffectEnabled) then { + if (_windSpeed > 0.05) then { + _newWindSpeed = 0; + { + _windSource = [20, _windDir + 180, _x] call fnc_polar2vect; + if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith { + _newWindSpeed = cos(_x * 2) * _windSpeed; + }; + _windSource = [20, _windDir + 180 + _x, 0] call fnc_polar2vect; + if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith { + _newWindSpeed = cos(_x * 2) * _windSpeed; + }; + _windSource = [20, _windDir + 180 - _x, 0] call fnc_polar2vect; + if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith { + _newWindSpeed = cos(_x * 2) * _windSpeed; + }; + } forEach [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]; + _windSpeed = _newWindSpeed; + }; +}; + +_windSpeed = 0 max _windSpeed; + +_windSpeed diff --git a/addons/weather/functions/fnc_displayWindInfo.sqf b/addons/weather/functions/fnc_displayWindInfo.sqf index 7996503719..e81463f41a 100644 --- a/addons/weather/functions/fnc_displayWindInfo.sqf +++ b/addons/weather/functions/fnc_displayWindInfo.sqf @@ -38,15 +38,14 @@ GVAR(WindInfo) = true; _windIndex = 12; _windColor = [1, 1, 1, 1]; - - // Toogle behaviour depending on ace_advanced_ballistics being used or not - // @todo, check ACE_AB is actually enabled - _windSpeed = if (isClass (configFile >> "CfgPatches" >> "ACE_Advanced_Ballistics")) then { - (eyePos ACE_player) call EFUNC(advanced_ballistics,calculateWindSpeed); + _windSpeed = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { + // With wind gradient + [eyePos ACE_player, true, true, true] call FUNC(calculateWindSpeed); } else { - vectorMagnitude ACE_wind; + // Without wind gradient + [eyePos ACE_player, false, true, true] call FUNC(calculateWindSpeed); }; - + if (_windSpeed > 0.2) then { _playerDir = getDir ACE_player; _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); diff --git a/addons/weather/stringtable.xml b/addons/weather/stringtable.xml index 2008fc7bc1..02c0964e03 100644 --- a/addons/weather/stringtable.xml +++ b/addons/weather/stringtable.xml @@ -13,5 +13,61 @@ Zobrazit informace o větru Mostrar informação do vento + + Weather + Pogoda + + + Multiplayer synchronized ACE weather module + Synchronizowana pogoda ACE + + + Weather propagation + Zmiany pogody + + + Enables server side weather propagation + Aktywuje zmiany pogody po stronie serwera + + + ACE Weather + Pogoda ACE + + + Overrides the default weather (editor, mission settings) with ACE weather (map based) + Nadpisuje domyślne ustawienia pogody (edytor, wywiad) przy użyciu pogody ACE (zależna od mapy) + + + Sync Rain + Synchronizuj deszcz + + + Synchronizes rain + Synchronizuje deszcz + + + Sync Wind + Synchronizuj wiatr + + + Synchronizes wind + Synchronizuje wiatr + + + Sync Misc + Synchronizuj różne + + + Synchronizes lightnings, rainbow, fog, ... + Synchronizuje pioruny, tęcze, mgłę, ... + + + Update Interval + Interwał aktualizacji + + + Defines the interval (seconds) between weather updates + Określa interwał (sekundy) pomiędzy aktualizacjami pogody + \ No newline at end of file diff --git a/addons/winddeflection/$PBOPREFIX$ b/addons/winddeflection/$PBOPREFIX$ new file mode 100644 index 0000000000..e36be56aec --- /dev/null +++ b/addons/winddeflection/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\winddeflection \ No newline at end of file diff --git a/addons/winddeflection/CfgVehicles.hpp b/addons/winddeflection/CfgVehicles.hpp index 1c24c0a386..f7e2a33980 100644 --- a/addons/winddeflection/CfgVehicles.hpp +++ b/addons/winddeflection/CfgVehicles.hpp @@ -2,7 +2,7 @@ class CfgVehicles { class ACE_Module; class GVAR(ModuleSettings): ACE_Module { scope = 2; - displayName = "Wind Deflection"; + displayName = "$STR_ACE_Weather_windDeflection_DisplayName"; icon = QUOTE(PATHTOF(UI\Icon_Module_Wind_ca.paa)); category = "ACE"; function = QUOTE(DFUNC(initModuleSettings)); @@ -12,29 +12,32 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; class Arguments { class enabled { - displayName = "Wind Deflection"; - description = "Enables wind deflection"; + displayName = "$STR_ACE_Weather_deflectionModule_DisplayName"; + description = "$STR_ACE_Weather_deflectionModule_Description"; typeName = "BOOL"; defaultValue = 1; }; class vehicleEnabled { - displayName = "Vehicle Enabled"; - description = "Enables wind deflection for static/vehicle gunners"; + displayName = "$STR_ACE_Weather_vehicleEnabled_DisplayName"; + description = "$STR_ACE_Weather_vehicleEnabled_Description"; typeName = "BOOL"; defaultValue = 1; }; class simulationInterval { - displayName = "Simulation Interval"; - description = "Defines the interval between every calculation step"; + displayName = "$STR_ACE_Weather_simulationInterval_DisplayName"; + description = "$STR_ACE_Weather_simulationInterval_Description"; typeName = "NUMBER"; defaultValue = 0.05; }; class simulationRadius { - displayName = "Simulation Radius"; - description = "Defines the radius around the player (in meters) at which projectiles are wind deflected"; + displayName = "$STR_ACE_Weather_simulationRadius_DisplayName"; + description = "$STR_ACE_Weather_simulationRadius_Description"; typeName = "NUMBER"; defaultValue = 3000; }; }; + class ModuleDescription { + description = "$STR_ACE_Weather_windDeflection_Description"; + }; }; -}; +}; \ No newline at end of file diff --git a/addons/winddeflection/stringtable.xml b/addons/winddeflection/stringtable.xml index 4ebcc81bee..806bf4c449 100644 --- a/addons/winddeflection/stringtable.xml +++ b/addons/winddeflection/stringtable.xml @@ -62,6 +62,46 @@ Umidità: %1% Humidade: %1% + + Wind Deflection + Wpływ wiatru + + + Wind Deflection + Wpływ wiatru + + + Enables wind deflection + Aktywuje wpływ wiatru na trajektorię lotu pocisków + + + Vehicle Enabled + Włączone dla pojazdów + + + Enables wind deflection for static/vehicle gunners + Aktywuje wpływ wiatru na trajektorię lotu pocisków dla broni statycznej i na pojazdach + + + Simulation Interval + Interwał symulacji + + + Defines the interval between every calculation step + Określa interwał pomiędzy każdym krokiem kalkulacji + + + Simulation Radius + Zasięg symulacji + + + Defines the radius around the player (in meters) at which projectiles are wind deflected + Określa obszar naokoło gracza (w metrach), na którym pociski są znoszone przez wiatr + + + Wind influence on projectiles trajectory + Wpływ wiatru na trajektorię lotu pocisków + diff --git a/addons/zeus/$PBOPREFIX$ b/addons/zeus/$PBOPREFIX$ new file mode 100644 index 0000000000..ae5a20d62d --- /dev/null +++ b/addons/zeus/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\zeus \ No newline at end of file diff --git a/addons/zeus/ACE_Settings.hpp b/addons/zeus/ACE_Settings.hpp new file mode 100644 index 0000000000..536790ba26 --- /dev/null +++ b/addons/zeus/ACE_Settings.hpp @@ -0,0 +1,23 @@ +class ACE_Settings { + class GVAR(zeusAscension) { + typeName = "BOOL"; + value = 0; + }; + class GVAR(zeusBird) { + typeName = "BOOL"; + value = 0; + }; + class GVAR(remoteWind) { + typeName = "BOOL"; + value = 0; + }; + class GVAR(radioOrdnance) { + typeName = "BOOL"; + value = 0; + }; + class GVAR(revealMines) { + typeName = "SCALAR"; + value = 0; + values[] = {"Disabled", "Partially", "Fully"}; + }; +}; diff --git a/addons/zeus/CfgEventHandlers.hpp b/addons/zeus/CfgEventHandlers.hpp new file mode 100644 index 0000000000..f0a9f14d91 --- /dev/null +++ b/addons/zeus/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/zeus/CfgFactionClasses.hpp b/addons/zeus/CfgFactionClasses.hpp new file mode 100644 index 0000000000..bf34546727 --- /dev/null +++ b/addons/zeus/CfgFactionClasses.hpp @@ -0,0 +1,6 @@ +class CfgFactionClasses { + class NO_CATEGORY; + class ADDON: NO_CATEGORY { + displayName = "ACE Zeus"; + }; +}; diff --git a/addons/zeus/CfgVehicles.hpp b/addons/zeus/CfgVehicles.hpp new file mode 100644 index 0000000000..5750ab52d6 --- /dev/null +++ b/addons/zeus/CfgVehicles.hpp @@ -0,0 +1,80 @@ +class CfgVehicles { + class Module_F; + class ModuleEmpty_F; + class ACE_Module; + + class GVAR(moduleZeusSettings): ACE_Module { + scope = 2; + displayName = "Zeus Settings [ACE]"; + //icon = QUOTE(PATHTOF(iconGoesHere)); + category = "ACE_zeus"; + function = QUOTE(DFUNC(moduleZeusSettings)); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + author = "SilentSpike"; + class Arguments { + class zeusAscension { + displayName = "Ascension Messages"; + description = "Display global popup messages when a player is assigned as Zeus."; + typeName = "BOOL"; + defaultValue = 0; + }; + class zeusBird { + displayName = "Zeus Eagle"; + description = "Spawn an eagle that follows the Zeus camera."; + typeName = "BOOL"; + defaultValue = 0; + }; + class remoteWind { + displayName = "Wind Sounds"; + description = "Play wind sounds when Zeus remote controls a unit."; + typeName = "BOOL"; + defaultValue = 0; + }; + class radioOrdnance { + displayName = "Ordnance Warning"; + description = "Play a radio warning when Zeus uses ordnance."; + typeName = "BOOL"; + defaultValue = 0; + }; + class revealMines { + displayName = "Reveal Mines"; + description = "Reveal mines to allies and/or place map markers."; + typeName = "NUMBER"; + class values { + class disable { + name = "Disabled"; + value = 0; + default = 1; + }; + class partial { + name = "Reveal to Allies"; + value = 1; + }; + class full { + name = "Allies + Map Markers"; + value = 2; + }; + }; + }; + }; + class ModuleDescription { + description = "Provides control over various aspects of Zeus."; + sync[] = {}; + }; + }; + + class ModuleCurator_F: Module_F { + function = QUOTE(DFUNC(moduleCuratorDelay)); + }; + class ModuleMine_F: ModuleEmpty_F { + function = QUOTE(DFUNC(bi_moduleMine)); + }; + class ModuleOrdnance_F: Module_F { + function = QUOTE(DFUNC(bi_moduleProjectile)); + }; + class ModuleRemoteControl_F: Module_F { + function = QUOTE(DFUNC(bi_moduleRemoteControl)); + }; +}; diff --git a/addons/zeus/XEH_preInit.sqf b/addons/zeus/XEH_preInit.sqf new file mode 100644 index 0000000000..5841245e65 --- /dev/null +++ b/addons/zeus/XEH_preInit.sqf @@ -0,0 +1,12 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(bi_moduleCurator); +PREP(bi_moduleMine); +PREP(bi_moduleProjectile); +PREP(bi_moduleRemoteControl); +PREP(moduleCuratorDelay); +PREP(moduleZeusSettings); + +ADDON = true; diff --git a/addons/zeus/config.cpp b/addons/zeus/config.cpp new file mode 100644 index 0000000000..4bdc1cd5e1 --- /dev/null +++ b/addons/zeus/config.cpp @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common","ace_modules"}; + author[] = {"SilentSpike"}; + authorUrl = "https://github.com/SilentSpike"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgFactionClasses.hpp" +#include "CfgVehicles.hpp" +#include "ACE_Settings.hpp" diff --git a/addons/zeus/functions/fnc_bi_moduleCurator.sqf b/addons/zeus/functions/fnc_bi_moduleCurator.sqf new file mode 100644 index 0000000000..9ae35a4ce4 --- /dev/null +++ b/addons/zeus/functions/fnc_bi_moduleCurator.sqf @@ -0,0 +1,333 @@ +/* + * Author: Bohemia Interactive + * Module function for initalizing zeus + * Edited to remove eagle and global ascension message + * + * Arguments: + * 0: The logic object + * + * Return Value: + * nil + * + * Public: No + */ + +#include "script_component.hpp" + +_logic = _this select 0; +_units = _this select 1; +_activated = _this select 2; + +if (_activated) then { + + //--- Terminate when not created on the server + if (!isserver && local _logic && isnull (getassignedcuratorunit _logic)) exitwith { + [format ["%1 is trying to create curator logic ModuleCurator_F",profilename],"bis_fnc_error",false] call bis_fnc_mp; + deletevehicle _logic; + }; + + //--- Get curator owner + _ownerVar = _logic getvariable ["owner",""]; + _ownerUID = parsenumber _ownerVar; + if (cheatsenabled) then { + _ownerVarArray = toarray _ownerVar; + _ownerVarArray resize 3; + if (tostring _ownerVarArray == "DEV") then {_ownerUID = 1;}; + }; + if (_ownerVar == "" && !ismultiplayer) then { + ["Curator owner not defined, player used instead in singleplayer."] call bis_fnc_error; + _ownerVar = player call bis_fnc_objectvar; + }; + if (_ownerUID > 0 && !ismultiplayer) then { + _ownerVar = player call bis_fnc_objectvar; + }; + _isAdmin = _ownerVar == "#adminLogged" || _ownerVar == "#adminVoted"; + + //--- Wipe out the variable so clients can't access it + _logic setvariable ["owner",nil]; + + //--- Server + if (isserver) then { + + //--- Prepare admin variable + _adminVar = ""; + if (_isAdmin) then { + _letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]; + _adminVar = "admin_"; + for "_i" from 0 to 9 do {_adminVar = _adminVar + (_letters call bis_fnc_selectrandom);}; + _logic setvariable ["adminVar",_adminVar,true]; + }; + + //--- Get allowed addons + _addonsType = _logic getvariable ["Addons",0]; + _addons = []; + switch _addonsType do { + + //--- All (including unofficial ones) + case 3: { + _cfgPatches = configfile >> "cfgpatches"; + for "_i" from 0 to (count _cfgPatches - 1) do { + _class = _cfgPatches select _i; + if (isclass _class) then {_addons set [count _addons,configname _class];}; + }; + _addons call bis_fnc_activateaddons; + removeallcuratoraddons _logic; + _logic addcuratoraddons _addons; + }; + + //--- All active + case 2: {}; + + //--- All mission + case 1: { + _addonsList = []; + { + _addonsList = _addonsList + (unitaddons typeof _x); + } foreach (entities "all"); + removeallcuratoraddons _logic; + _logic addcuratoraddons _addonsList; + }; + + //--- None + case 0: { + removeallcuratoraddons _logic; + }; + }; + + //--- Handle ownership + [_logic,_ownerVar,_ownerUID,_adminVar] spawn { + scriptname "BIS_fnc_moduleCurator: Owner"; + + _logic = _this select 0; + _ownerVar = _this select 1; + _ownerUID = _this select 2; + _adminVar = _this select 3; + + if (_adminVar != "") then {_ownerVar = _adminVar;}; + + _forced = _logic getvariable ["forced",0] > 0; + _name = _logic getvariable ["name",""]; + if (_name == "") then {_name = localize "STR_A3_curator";}; + + //--- Wait until mission starts + waituntil {time > 0}; + + //--- Refresh addon list, so it's broadcasted to clients + _addons = curatoraddons _logic; + removeAllCuratorAddons _logic; + _logic addcuratoraddons _addons; + + while {true} do { + //--- Wait for player to become Zeus + switch true do { + case (_ownerUID > 0): { + waituntil { + sleep 0.01; + {getplayeruid _x == _ownerVar} count playableunits > 0 + }; + }; + default { + waituntil {isplayer (missionnamespace getvariable [_ownerVar,objnull])}; + }; + }; + + //--- Assign + _player = objnull; + switch true do { + case (_ownerUID > 0): { + { + if (getplayeruid _x == _ownerVar) exitwith {_player = _x;}; + } foreach playableunits; + }; + default { + _player = missionnamespace getvariable [_ownerVar,objnull]; + }; + }; + + waituntil {unassigncurator _logic; isnull (getassignedcuratorunit _logic)}; + waituntil {_player assignCurator _logic; getassignedcuratorunit _logic == _player}; + + //--- Add radio channels + { + _x radiochanneladd [_player]; + } foreach (_logic getvariable ["channels",[]]); + + // Added by ACE_zeus to toggle ascension messages + if (GVAR(zeusAscension)) then { + //--- Sent notification to all assigned players + { + if (isplayer _x) then { + [["CuratorAssign",[_name,name _player]],"bis_fnc_showNotification",_x] call bis_fnc_mp; + }; + } foreach (curatoreditableobjects _logic); + }; + + [_logic,"curatorUnitAssigned",[_logic,_player]] call bis_fnc_callscriptedeventhandler; + + //--- Forced interface + //if (_forced) then { + // [[true,true],"bis_fnc_forceCuratorInterface",_player] call bis_fnc_mp; + //}; + + //--- Wait for player to stop being Zeus + switch true do { + case (_ownerUID > 0): { + waituntil { + sleep 0.01; + {getplayeruid _x == _ownerVar} count playableunits == 0 + }; + }; + default { + waituntil {_player != missionnamespace getvariable [_ownerVar,objnull]}; + }; + }; + + //--- Add radio channels + { + _x radiochannelremove [_player]; + } foreach (_logic getvariable ["channels",[]]); + + //--- Unassign + waituntil {unassigncurator _logic; isnull (getassignedcuratorunit _logic)}; + }; + }; + + // Added by ACE_zeus to toggle eagle + if (GVAR(zeusBird)) then { + //--- Create bird + _birdType = _logic getvariable ["birdType","eagle_f"]; + if (_birdType != "") then { + _bird = createvehicle [_birdType,[100,100,100],[],0,"none"]; + _logic setvariable ["bird",_bird,true]; + }; + }; + + //--- Activated all future addons + _addons = []; + { + if (typeof _x == "ModuleCuratorAddAddons_F") then { + _paramAddons = call compile ("[" + (_x getvariable ["addons",""]) + "]"); + { + if !(_x in _addons) then {_addons set [count _addons,_x];}; + { + if !(_x in _addons) then {_addons set [count _addons,_x];}; + } foreach (unitaddons _x); + } foreach _paramAddons; + }; + } foreach (synchronizedobjects _logic); + _addons call bis_fnc_activateaddons; + + // Added by ACE_zeus to toggle eagle + if (GVAR(zeusBird)) then { + //--- Locality changed + _logic addeventhandler [ + "local", + { + _logic = _this select 0; + _bird = _logic getvariable ["bird",objnull]; + _bird setowner owner _logic; + } + ]; + }; + }; + + //--- Player + if (hasinterface) then { + waituntil {local player}; + _serverCommand = if (_ownerVar == "#adminLogged") then {"#shutdown"} else {"#kick"}; + + //--- Black effect until the interface is open + _forced = _logic getvariable ["forced",0] > 0; + if (_forced) then { + _isCurator = switch true do { + case (_ownerUID > 0): { + getplayeruid player == _ownerVar + }; + case (_isAdmin): { + isserver || servercommandavailable _serverCommand + }; + default { + player == missionnamespace getvariable [_ownerVar,objnull] + }; + }; + if (_isCurator) then { + [true,true] spawn bis_fnc_forceCuratorInterface; + ("RscDisplayCurator" call bis_fnc_rscLayer) cuttext ["","black in",1e10]; + }; + }; + + //--- Check if player is server admin + if (_isAdmin) then { + _adminVar = _logic getvariable ["adminVar",""]; + _logic setvariable ["adminVar",nil]; + if (isserver) then { + //--- Host + missionnamespace setvariable [_adminVar,player]; + } else { + //--- Client + [_logic,_adminVar,_serverCommand] spawn { + scriptname "BIS_fnc_moduleCurator: Admin check"; + + _logic = _this select 0; + _adminVar = _this select 1; + _serverCommand = _this select 2; + while {true} do { + waituntil {sleep 0.1; servercommandavailable _serverCommand}; + missionnamespace setvariable [_adminVar,player]; + publicvariable _adminVar; + _respawn = player addeventhandler ["respawn",format ["%1 = _this select 0; publicvariable '%1';",_adminVar]]; + + waituntil {sleep 0.1; !servercommandavailable _serverCommand}; + missionnamespace setvariable [_adminVar,objnull]; + publicvariable _adminVar; + player removeeventhandler ["respawn",_respawn]; + }; + }; + }; + }; + + [_logic] spawn { + _logic = _this select 0; + sleep 1; + waituntil {alive player}; + + //--- Show warning when Zeus key is not assigned + if (count (actionkeys "curatorInterface") == 0) then { + [ + format [ + localize "str_a3_cfgvehicles_modulecurator_f_keyNotAssigned", + (["IGUI","WARNING_RGB"] call bis_fnc_displaycolorget) call bis_fnc_colorRGBAtoHTML + ] + ] call bis_fnc_guiMessage; + }; + + //--- Show hint about pinging for players + if ( + isnil {profilenamespace getvariable "bis_fnc_curatorPinged_done"} + && + {isTutHintsEnabled} + && + {isnull getassignedcuratorlogic player} + && + {player in curatoreditableobjects _logic} + ) then { + sleep 0.5; + [["Curator","Ping"]] call bis_fnc_advHint; + }; + }; + + //--- Add local event handlers + _logic addeventhandler ["curatorFeedbackMessage",{_this call bis_fnc_showCuratorFeedbackMessage;}]; + _logic addeventhandler ["curatorPinged",{_this call bis_fnc_curatorPinged;}]; + _logic addeventhandler ["curatorObjectPlaced",{_this call bis_fnc_curatorObjectPlaced;}]; + _logic addeventhandler ["curatorObjectEdited",{_this call bis_fnc_curatorObjectEdited;}]; + _logic addeventhandler ["curatorWaypointPlaced",{_this call bis_fnc_curatorWaypointPlaced;}]; + + _logic addeventhandler ["curatorObjectDoubleClicked",{(_this select 1) call bis_fnc_showCuratorAttributes;}]; + _logic addeventhandler ["curatorGroupDoubleClicked",{(_this select 1) call bis_fnc_showCuratorAttributes;}]; + _logic addeventhandler ["curatorWaypointDoubleClicked",{(_this select 1) call bis_fnc_showCuratorAttributes;}]; + _logic addeventhandler ["curatorMarkerDoubleClicked",{(_this select 1) call bis_fnc_showCuratorAttributes;}]; + + player call bis_fnc_curatorRespawn; + }; +}; diff --git a/addons/zeus/functions/fnc_bi_moduleMine.sqf b/addons/zeus/functions/fnc_bi_moduleMine.sqf new file mode 100644 index 0000000000..b5063c7fed --- /dev/null +++ b/addons/zeus/functions/fnc_bi_moduleMine.sqf @@ -0,0 +1,48 @@ +/* + * Author: Bohemia Interactive + * Module function for spawning mines + * Edited to remove forced map markers and mines being revealed to players + * + * Arguments: + * 0: The logic object + * + * Return Value: + * nil + * + * Public: No + */ + +#include "script_component.hpp" + +_logic = _this select 0; +_units = _this select 1; +_activated = _this select 2; + +if (_activated) then { + _explosive = gettext (configfile >> "cfgvehicles" >> typeof _logic >> "explosive"); + if (_explosive != "") then { + _explosive = createvehicle [_explosive,position _logic,[],0,"none"]; + _explosive attachto [_logic]; + + // Added by ACE_zeus to control if mines are revealed + if (GVAR(revealMines) > 0) then { + //--- Reveal the mine to curator's side + { + _side = (getassignedcuratorunit _x) call bis_fnc_objectSide; + _side revealmine _explosive; + } foreach (objectcurators _logic); + + if (GVAR(revealMines) > 1) then { + //--- Mark minefields in the map + [] spawn bis_fnc_drawMinefields; + }; + }; + + //--- Show hint to curator who placed the object + [[["Curator","PlaceMines"],nil,nil,nil,nil,nil,nil,true],"bis_fnc_advHint",_logic] call bis_fnc_mp; + + waituntil {sleep 0.1; isnull _explosive || isnull _logic || !alive _logic}; + if (isnull _logic) then {deletevehicle _explosive;} else {_explosive setdamage 1;}; + deletevehicle _logic; + }; +}; diff --git a/addons/modules/functions/fnc_bi_moduleProjectile.sqf b/addons/zeus/functions/fnc_bi_moduleProjectile.sqf similarity index 96% rename from addons/modules/functions/fnc_bi_moduleProjectile.sqf rename to addons/zeus/functions/fnc_bi_moduleProjectile.sqf index 56e3eb9883..6e2ee35387 100644 --- a/addons/modules/functions/fnc_bi_moduleProjectile.sqf +++ b/addons/zeus/functions/fnc_bi_moduleProjectile.sqf @@ -2,6 +2,7 @@ * Author: Bohemia Interactive * Module function for spawning projectiles * Used by Curator artillery modules etc + * Edited to remove radio warning and add ballistics support * * Arguments: * 0: The logic object @@ -12,6 +13,8 @@ * Public: No */ +#include "script_component.hpp" + _fnc_scriptNameParentTemp = if !(isnil '_fnc_scriptName') then {_fnc_scriptName} else {'BIS_fnc_moduleProjectile'}; private ['_fnc_scriptNameParent']; _fnc_scriptNameParent = _fnc_scriptNameParentTemp; @@ -133,8 +136,11 @@ if (_activated) then { //--- Create sound source _soundSource = if (_soundSourceClass != "") then {createSoundSource [_soundSourceClass,_pos,[],0]} else {objnull}; - //--- Play radio warning - [] call _fnc_playRadio; + // Added by ACE_zeus to toggle ordnance radio message + if (GVAR(radioOrdnance)) then { + //--- Play radio warning + [] call _fnc_playRadio; + }; //--- Update if (_attach) then { diff --git a/addons/zeus/functions/fnc_bi_moduleRemoteControl.sqf b/addons/zeus/functions/fnc_bi_moduleRemoteControl.sqf new file mode 100644 index 0000000000..57b325b585 --- /dev/null +++ b/addons/zeus/functions/fnc_bi_moduleRemoteControl.sqf @@ -0,0 +1,171 @@ +/* + * Author: Bohemia Interactive + * Module function for remote controlling units as zeus + * Edited to remove global wind sound + * + * Arguments: + * 0: The logic object + * + * Return Value: + * nil + * + * Public: No + */ + +#include "script_component.hpp" + +_logic = _this select 0; +_units = _this select 1; +_activated = _this select 2; + +if (_activated && local _logic && !isnull curatorcamera) then { + + //--- Terminate when remote control is already in progress + if !(isnull (missionnamespace getvariable ["bis_fnc_moduleRemoteControl_unit",objnull])) exitwith {}; + + //--- Get unit under cursor + _unit = objnull; + _mouseOver = missionnamespace getvariable ["bis_fnc_curatorObjectPlaced_mouseOver",[""]]; + if ((_mouseOver select 0) == typename objnull) then {_unit = _mouseOver select 1;}; + _unit = effectivecommander _unit; + + //--- Check if the unit is suitable + _error = ""; + if !(side group _unit in [east,west,resistance,civilian]) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorEmpty";}; + if (isplayer _unit) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer";}; + if !(alive _unit) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorDestroyed";}; + if (isnull _unit) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorNull";}; + if !(isnull (_unit getvariable ["bis_fnc_moduleRemoteControl_owner",objnull])) then {_error = localize "str_a3_cfgvehicles_moduleremotecontrol_f_errorControl";}; + + if (_error == "") then { + _unit spawn { + scriptname "bis_fnc_moduleRemoteControl: Loop"; + _unit = _this; + _vehicle = vehicle _unit; + _vehicleRole = str assignedvehiclerole _unit; + + bis_fnc_moduleRemoteControl_unit = _unit; + _unit setvariable ["bis_fnc_moduleRemoteControl_owner",player,true]; + + // Added by ACE_zeus to toggle remote control wind sound + if (GVAR(remoteWind)) then { + //--- Play wind cue to all players + [format ["wind%1",ceil random 5],"bis_fnc_playsound"] call bis_fnc_mp; + }; + + _blur = ppeffectcreate ["RadialBlur",144]; + _blur ppeffectenable true; + _blur ppeffectadjust [0,0,0.3,0.3]; + _blur ppeffectcommit 0; + _blur ppeffectadjust [0.03,0.03,0.1,0.1]; + _blur ppeffectcommit 1; + + _cam = "camera" camcreate getposatl curatorcamera; + _cam cameraeffect ["internal","back"]; + _cam campreparetarget (screentoworld [0.5,0.5]); + _cam camcommitprepared 0; + _cam campreparetarget _unit; + _cam campreparefov 0.1; + _cam camcommitprepared 1; + sleep 0.75; + + ("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black out",0.25]; + sleep 0.25; + + //--- Wait for interface to close + (finddisplay 312) closedisplay 2; + waituntil {isnull curatorcamera}; + + //--- Switch + player remotecontrol _unit; + if (cameraon != _vehicle) then { + _vehicle switchcamera cameraview; + }; + + ppeffectdestroy _blur; + _cam cameraeffect ["terminate","back"]; + camdestroy _cam; + + _color = ppeffectcreate ["colorCorrections",1896]; + _color ppeffectenable true; + _color ppeffectadjust [1,1,0,[0,0,0,1],[1,1,1,1],[0,0,0,0],[0.9,0.0,0,0,0,0.5,1]]; + _color ppeffectcommit 0; + + _curator = getassignedcuratorlogic player; + [_curator,"curatorObjectRemoteControlled",[_curator,player,_unit,true]] call bis_fnc_callScriptedEventHandler; + [["Curator","RemoteControl"],nil,nil,nil,nil,nil,nil,true] call bis_fnc_advHint; + + sleep 0.3; + _color ppeffectadjust [1,1,0,[0,0,0,1],[1,1,1,1],[0,0,0,0],[0.9,0.85,0,0,0,0.5,1]]; + _color ppeffectcommit 0.3; + ("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black in",0.5]; + + //--- Back to player + _vehicle = vehicle _unit; + _vehicleRole = str assignedvehiclerole _unit; + _rating = rating player; + waituntil { + //--- Refresh when vehicle or vehicle role changes + if ((vehicle _unit != _vehicle || str assignedvehiclerole _unit != _vehicleRole) && {alive _unit}) then { + player remotecontrol _unit; + _vehicle = vehicle _unit; + _vehicleRole = str assignedvehiclerole _unit; + }; + if (rating player < _rating) then { + player addrating (-rating player + _rating); + }; + sleep 0.01; + !isnull curatorcamera + || + {cameraon == vehicle player} + || + {!alive _unit} //--- Also isnull check, objNull is not alive + || + {isnull getassignedcuratorlogic player} + //|| + //{_unit getvariable ["bis_fnc_moduleRemoteControl_owner",objnull] != player} //--- Another curator stole the unit + }; + + player addrating (-rating player + _rating); + objnull remotecontrol _unit; + _unit setvariable ["bis_fnc_moduleRemoteControl_owner",nil,true]; + + //--- Death screen + if ( + isnull curatorcamera + && + {cameraon != vehicle player} + && + {!isnull _unit} + && + {!isnull getassignedcuratorlogic player} + //&& + //{(_unit getvariable ["bis_fnc_moduleRemoteControl_owner",objnull] == player)} + ) then { + sleep 2; + ("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black out",1]; + sleep 1; + }; + _unitPos = getposatl _unit; + _camPos = [_unitPos,10,direction _unit + 180] call bis_fnc_relpos; + _camPos set [2,(_unitPos select 2) + (getterrainheightasl _unitPos) - (getterrainheightasl _camPos) + 10]; + //[_camPos,_unit] call bis_fnc_setcuratorcamera; + (getassignedcuratorlogic player) setvariable ["bis_fnc_modulecuratorsetcamera_params",[_camPos,_unit]]; + + sleep 0.1; //--- Engine needs a delay in case controlled unit was deleted + ("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black in",1e10]; + opencuratorinterface; + ppeffectdestroy _color; + + waituntil {!isnull curatorcamera}; + player switchcamera cameraview; + bis_fnc_moduleRemoteControl_unit = nil; + ("bis_fnc_moduleRemoteCurator" call bis_fnc_rscLayer) cuttext ["","black in",1]; + [_curator,"curatorObjectRemoteControlled",[_curator,player,_unit,false]] call bis_fnc_callScriptedEventHandler; + sleep 0.01; + }; + } else { + [objnull,_error] call bis_fnc_showCuratorFeedbackMessage; + }; + deletevehicle _logic; +}; diff --git a/addons/zeus/functions/fnc_moduleCuratorDelay.sqf b/addons/zeus/functions/fnc_moduleCuratorDelay.sqf new file mode 100644 index 0000000000..734cf1a999 --- /dev/null +++ b/addons/zeus/functions/fnc_moduleCuratorDelay.sqf @@ -0,0 +1,19 @@ +/* + * Author: SilentSpike + * Function that delays the execution of the curator module function + * Allows ascension and bird settings to be set by module beforehand + * + * Arguments: + * 0: The module logic + * 1: units + * 2: activated + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +[{_this spawn DFUNC(bi_moduleCurator);},_this] call EFUNC(common,execNextFrame); diff --git a/addons/zeus/functions/fnc_moduleZeusSettings.sqf b/addons/zeus/functions/fnc_moduleZeusSettings.sqf new file mode 100644 index 0000000000..3a582f7196 --- /dev/null +++ b/addons/zeus/functions/fnc_moduleZeusSettings.sqf @@ -0,0 +1,29 @@ +/* + * Author: SilentSpike + * Module for adjusting various aspects of zeus + * + * Arguments: + * 0: The module logic + * 1: units + * 2: activated + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_logic", "_units", "_activated"]; +_logic = _this select 0; +_units = _this select 1; +_activated = _this select 2; + +if !(_activated) exitWith {}; + +[_logic, QGVAR(zeusAscension), "zeusAscension"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(zeusBird), "zeusBird"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(radioOrdnance), "radioOrdnance"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(revealMines), "revealMines"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(remoteWind), "remoteWind"] call EFUNC(common,readSettingFromModule); diff --git a/addons/zeus/functions/script_component.hpp b/addons/zeus/functions/script_component.hpp new file mode 100644 index 0000000000..35453cc4e8 --- /dev/null +++ b/addons/zeus/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\zeus\script_component.hpp" \ No newline at end of file diff --git a/addons/zeus/script_component.hpp b/addons/zeus/script_component.hpp new file mode 100644 index 0000000000..7211b28f7d --- /dev/null +++ b/addons/zeus/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT zeus +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_ZEUS + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_ZEUS + #define DEBUG_SETTINGS DEBUG_SETTINGS_ZEUS +#endif + +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/documentation/feature/advanced_ballistics.md b/documentation/feature/advanced_ballistics.md new file mode 100644 index 0000000000..9a63e3dd10 --- /dev/null +++ b/documentation/feature/advanced_ballistics.md @@ -0,0 +1,24 @@ +--- +layout: wiki +title: Advanced Ballistics +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_ballistics`, `ace_weather`, `ace_modules` diff --git a/documentation/feature/ai.md b/documentation/feature/ai.md new file mode 100644 index 0000000000..682295307c --- /dev/null +++ b/documentation/feature/ai.md @@ -0,0 +1,30 @@ +--- +layout: wiki +title: AI (Artifical Intelligence) +group: feature +order: 5 +parent: wiki +--- + +## Overview + +### Adjusted AI skill values +The idea here is to reduce the AI's godlike aiming capabilties while retaining it's high intelligence. The AI should be smart enough to move through a town, but also be 'human' in their reaction time and aim. +Note: All these values can still be adjusted via scripts, these arrays just change what 0 & 1 are for setSkill. + +### Firing in burst mode +AIs will now use the automatic mode of their weapons on short distances, instead of always relying on firing single shots in quick succession. + +### Longer engagement ranges +The maximum engagement ranges are increased: AI will fire in bursts with variable length on high ranges of 500 - 700 meters, depending on their weapon and optic. + +### No deadzones in CQB +Some weapons had minimum engagement ranges. If you were as close as 2 meters to an AAF soldier, he wouldn't open fire, because the AI couldn't find any valid fire mode for their weapon. ACE 3 removes this behaviour mostly notable in CQB by adding a valid firing mode. + +### No scripting +All changes of ACE 3 AI are config based to ensure full compatibility with advanced AI modifications like ASR AI. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/aircraft.md b/documentation/feature/aircraft.md new file mode 100644 index 0000000000..2e879c31f6 --- /dev/null +++ b/documentation/feature/aircraft.md @@ -0,0 +1,43 @@ +--- +layout: wiki +title: Aircraft +group: feature +order: 5 +parent: wiki +--- + +## Overview + +### Adjusted flight behaviour +Changes the flight behaviour of various aircraft. + +### Various adjustments to aircraft and gunships munitions +- Higher capacity magazines for the comanche. +- Gatling rate of fire (ROF) increased. +- AP rockets have less splash damage. + +### Missile lock warnings +Adds missile-lock warning systems to helicopters and planes based on the various real life capabilities. + +### Semi-automatic flare mode +Adds the semi-automatic flare mode known from Arma 2. The key to switch the mode still exists in Arma 3's key settings, but is unused. + +### Ejecting from pilot and copilot seats +Pilots and copilots of all helicopters can now eject. + +### Laser marker for wildcat +Adds a laser marker to the copilot seat of the Wildcat. + +### HUD for AH-9 +Adds a HUD to the AH-9 based on the comanches HUD. + + +## Usage + +### Adjusted flight behaviour +Changes the flight behaviour of various aircraft. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/apl.md b/documentation/feature/apl.md new file mode 100644 index 0000000000..5f15cb04b9 --- /dev/null +++ b/documentation/feature/apl.md @@ -0,0 +1,24 @@ +--- +layout: wiki +title: APL +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_main` diff --git a/documentation/feature/atragmx.md b/documentation/feature/atragmx.md new file mode 100644 index 0000000000..b1ff57de25 --- /dev/null +++ b/documentation/feature/atragmx.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: ATragMX +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common`, `ace_weather` diff --git a/documentation/feature/attach.md b/documentation/feature/attach.md new file mode 100644 index 0000000000..b9dd4243f5 --- /dev/null +++ b/documentation/feature/attach.md @@ -0,0 +1,36 @@ +--- +layout: wiki +title: Attach +group: feature +parent: wiki +--- + +## Overview + +### Attach items to uniform +Enables player to attach IR grenades and chemlights to themselves. + +### IR Strobe +Adds an attachable IR strobe, which is only visible using night vision devices and offers better visibility than IR grenades. + + +## Usage + +### attaching to yourself +- Press the self interaction key +- go to the equipment section +- choose the item to attach + +same thing to detach + +### attaching to a vehicle +- Approach the vehicle and use the interaction key +- Attach item section +- Choose your item and where you want to place it + +to detach the item use the interaction key from outside the vehicle + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/backpacks.md b/documentation/feature/backpacks.md new file mode 100644 index 0000000000..e1b935ee79 --- /dev/null +++ b/documentation/feature/backpacks.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Backpacks +group: feature +parent: wiki +--- + +## Overview + +### Lock backpack +Adds the ability to lock backpacks. Locked backpacks can't be accessed by others. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/ballistics.md b/documentation/feature/ballistics.md new file mode 100644 index 0000000000..41c177b8dd --- /dev/null +++ b/documentation/feature/ballistics.md @@ -0,0 +1,40 @@ +--- +layout: wiki +title: Ballistics +group: feature +parent: wiki +--- + +## Overview + +### Realistic rifle ammunition +Changes include adjusted muzzle velocity, air friction and dispersion based on real life values. + +### Body armour nerf +Nerfs protection values of vests, CSAT uniforms and various campaign only gear to more realistic levels comparable to Arma 2 levels. + +### Realistic silencers and sub-sonic ammunition +Silencers no longer decrease the muzzle velocity and are generally less effective when used with normal ammunition. They now only remove the muzzle blast and flash. To prevent the crack caused by super sonic projectiles, ACE introduces sub sonic ammunition. This is also fully compatible with AI. Sub sonic ammunition is available for the calibers 5.56mm, 6.5mm and 7.62mm. + +### Armour piercing ammunition +Armour piercing rounds have higher penetration values against light armoured targets or other obstacles on the battlefield. Their drawback is a slighly decreased man-stopping power. AP rounds are available for the calibers 5.56mm, 6.5mm and 7.62mm. + +### IR-Dim tracer ammunition +IR-Dim ammunition is similar to tracer rounds, but their tracers are only visible using night vision devices. + +### M118 Long range ammunition +The M14 EBR now uses ammunition with decreased muzzle velocity and air friction to improve precission on long ranges. + +### Flash suppressors +Flash suppressors are similar to sound suppressors and prevent the muzzle flash reducing visibilty without decreasing combat effectiveness. Flash suppressors are available for the calibers 5.56mm, 6.5mm, 7.62mm, .45 ACP and 9mm. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/captives.md b/documentation/feature/captives.md new file mode 100644 index 0000000000..81a8d268fd --- /dev/null +++ b/documentation/feature/captives.md @@ -0,0 +1,46 @@ +--- +layout: wiki +title: Captives +group: feature +parent: wiki +--- + +## Overview + +### Take captives +Introduces a captivity system for taking and moving prisoners. + +### Load and unload captives into / from vehicles +You can load and unload captives from vehicles using ACE 3 interactions. + +### Frisk captives +You can frisk a restrained captive. + +### Surrendering +You can surrender, while surrendering AI will cease fire. + + +## Usage + +### Capturing someone +- You need cable ties. +- Approach the victim / convict and use the interaction button. +- The interaction is around the hands in the form of a handcuffs icon. +- To free someone it's the same +- Use the interaction key, check around the hands for the handcuffs icon. + +### Escorting a captive +- Interact with the captive. +- Select the escort prisoner option. +- To stop escorting just scroll down or use self interaction. + +### Loading and unloading a captive in vehicle +- Escort the person. +- Approach the vehicle you desire to load the captive in. +- Interact with the vehicle and load him. +- Same for unloading, interact with the vehicle then unload. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/common.md b/documentation/feature/common.md new file mode 100644 index 0000000000..357f2f4578 --- /dev/null +++ b/documentation/feature/common.md @@ -0,0 +1,17 @@ +--- +layout: wiki +title: Common +group: feature +parent: wiki +--- + +## Overview + +Module that provides common features required by many other modules. + + +## Dependencies + +`ace_main` + +Note: The Common module is required by many other modules. Disabling it is not recommended. diff --git a/documentation/feature/difficulties.md b/documentation/feature/difficulties.md new file mode 100644 index 0000000000..3171ecbb39 --- /dev/null +++ b/documentation/feature/difficulties.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Difficulties +group: feature +parent: wiki +--- + +## Overview + +### Elite mode adjustments +Adjusts the default settings for the hardest difficulty to more closely resemble A2 settings. (No crosshair, stat screen, death messages...) + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/disarming.md b/documentation/feature/disarming.md new file mode 100644 index 0000000000..f1c18e91af --- /dev/null +++ b/documentation/feature/disarming.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Disarming +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/disposable.md b/documentation/feature/disposable.md new file mode 100644 index 0000000000..737b8631c5 --- /dev/null +++ b/documentation/feature/disposable.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Disposable +group: feature +parent: wiki +--- + +## Overview + +### NLAW disposable anti tank weapon +Makes the NLAW disposable and provides the tools for other addons to do the same. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/dragging.md b/documentation/feature/dragging.md new file mode 100644 index 0000000000..1e47bc39e4 --- /dev/null +++ b/documentation/feature/dragging.md @@ -0,0 +1,24 @@ +--- +layout: wiki +title: Dragging +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/explosives.md b/documentation/feature/explosives.md new file mode 100644 index 0000000000..aca67ecc96 --- /dev/null +++ b/documentation/feature/explosives.md @@ -0,0 +1,28 @@ +--- +layout: wiki +title: Explosives +group: feature +parent: wiki +--- + +## Overview + +### Advanced explosives placement +Enables more precise placement of explosives. + +### More trigger types +Offers different trigger types, like clackers and dead man switches. + +### Attack explosives to vehicles +Enables attaching explosives to vehicles. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/fcs.md b/documentation/feature/fcs.md new file mode 100644 index 0000000000..52d229e718 --- /dev/null +++ b/documentation/feature/fcs.md @@ -0,0 +1,29 @@ +--- +layout: wiki +title: FCS (Fire Control System) +group: feature +parent: wiki +--- + +## Overview + +### Fire control system +Offers a custom fire control system for tanks and helicopters. It enables engaging stationary and moving targets. + +### Manual lasing targets +Changes the default rangefinders, including those in vehicles, to require manual lasing. + +### Air burst ammunition +Anti air cannons can now use airburst ammunition. It will explode on the FCS' zeroed in range. + + +## Usage + +To engage moving targets, place the crosshair on the enemy vehicle and press and hold tab. Follow the moving target with your crosshair for about 2 seconds and release tab. The optic will now be adjusted sideways to ensure a hit. + +To use manual lasing, place the crosshair on the object to range and press and hold tab. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/flashsuppressors.md b/documentation/feature/flashsuppressors.md new file mode 100644 index 0000000000..8da42ac4ed --- /dev/null +++ b/documentation/feature/flashsuppressors.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Flash Suppressors +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/frag.md b/documentation/feature/frag.md new file mode 100644 index 0000000000..644f76de83 --- /dev/null +++ b/documentation/feature/frag.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Frag +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/gforces.md b/documentation/feature/gforces.md new file mode 100644 index 0000000000..bfa1c64ab7 --- /dev/null +++ b/documentation/feature/gforces.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: G-Forces +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/goggles.md b/documentation/feature/goggles.md new file mode 100644 index 0000000000..b4eaf3b00f --- /dev/null +++ b/documentation/feature/goggles.md @@ -0,0 +1,24 @@ +--- +layout: wiki +title: Goggles +group: feature +parent: wiki +--- + +## Overview + +### Visual Effects for eyewear +Adds color tint to sunglasses and other eyewear. Causes raindrops to appear on +the screen in rain. Causes dirt to appear on the screen when dirt is kicked up +nearby (e.g. explsions, rotor wash, bullet impacts). + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/grenades.md b/documentation/feature/grenades.md new file mode 100644 index 0000000000..1a334160cc --- /dev/null +++ b/documentation/feature/grenades.md @@ -0,0 +1,28 @@ +--- +layout: wiki +title: Grenades +group: feature +parent: wiki +--- + +## Overview + +### Throw modes +Provides different modes for throwing grenades (high throw, precision throw and drop mode). + +### Hand flares +Adds throwable hand flares in the colors white, red, green and yellow. Additionally buffs existing flares. + +### M84 stun grenade +Adds stun grenade. This will also affect AI. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/hearing.md b/documentation/feature/hearing.md new file mode 100644 index 0000000000..11d734dceb --- /dev/null +++ b/documentation/feature/hearing.md @@ -0,0 +1,26 @@ +--- +layout: wiki +title: Hearing +group: feature +parent: wiki +--- + +## Overview + +### Hearing damage simulation +Introduces hearing damage caused by nearby explosions and large-caliber weapons. + +### Earplugs +Adds ear plugs to mitigate that effect. Soldiers with high caliber weapons or +missile launchers will be equipped with those, but remember to put them in. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/hitreactions.md b/documentation/feature/hitreactions.md new file mode 100644 index 0000000000..7a6f11c4c4 --- /dev/null +++ b/documentation/feature/hitreactions.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Hit Reactions +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/interact_menu.md b/documentation/feature/interact_menu.md new file mode 100644 index 0000000000..91da5b6f62 --- /dev/null +++ b/documentation/feature/interact_menu.md @@ -0,0 +1,27 @@ +--- +layout: wiki +title: Interact Menu +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` + +Note: The Interact Menu module is required by many other modules. Disabling it is not recommended. diff --git a/documentation/feature/interaction.md b/documentation/feature/interaction.md new file mode 100644 index 0000000000..3c3bc110bb --- /dev/null +++ b/documentation/feature/interaction.md @@ -0,0 +1,27 @@ +--- +layout: wiki +title: Interaction +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interact_menu` + +Note: The Interaction module is required by many other modules. Disabling it is not recommended. diff --git a/documentation/feature/inventory.md b/documentation/feature/inventory.md new file mode 100644 index 0000000000..fc60f8920b --- /dev/null +++ b/documentation/feature/inventory.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Inventory +group: feature +parent: wiki +--- + +## Overview + +### Resized inventory UI +Makes the inventory dialog bigger and increases the number of items that can be seen in the list at once. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/javelin.md b/documentation/feature/javelin.md index b253a25fc9..674a90a7fd 100644 --- a/documentation/feature/javelin.md +++ b/documentation/feature/javelin.md @@ -1,13 +1,23 @@ --- layout: wiki -title: Javelin/Titan Locking and Firing +title: Javelin group: feature -order: 5 parent: wiki --- -## 1. Overview -Blah blah blah +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. Steps to lock titan/Javelin: @@ -17,5 +27,9 @@ Steps to lock titan/Javelin: 4. Hold TAB over a target, it will start beeping and the constraint boxes will appear 5. Once the beeping changes to LOCK tone, and the lock crosshairs appear, click fire without releasing tab - CTRL+TAB is default key to change firemode (configurable as a key) + + +## Dependencies + +`ace_main`, `ace_common`, `ace_missileguidance` diff --git a/documentation/feature/kestrel4500.md b/documentation/feature/kestrel4500.md new file mode 100644 index 0000000000..7376b63c06 --- /dev/null +++ b/documentation/feature/kestrel4500.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Kestrel 4500 +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common`, `ace_weather` diff --git a/documentation/feature/laser.md b/documentation/feature/laser.md new file mode 100644 index 0000000000..cb8450e700 --- /dev/null +++ b/documentation/feature/laser.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Laser +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/laser_selfdesignate.md b/documentation/feature/laser_selfdesignate.md new file mode 100644 index 0000000000..6ad4ed52b9 --- /dev/null +++ b/documentation/feature/laser_selfdesignate.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Laser Self-Designate +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_laser` diff --git a/documentation/feature/laserpointer.md b/documentation/feature/laserpointer.md new file mode 100644 index 0000000000..81757563c4 --- /dev/null +++ b/documentation/feature/laserpointer.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Laser Pointer +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/logistics_uavbattery.md b/documentation/feature/logistics_uavbattery.md new file mode 100644 index 0000000000..6c066deba4 --- /dev/null +++ b/documentation/feature/logistics_uavbattery.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Logistics - UAV Battery +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/logistics_wirecutter.md b/documentation/feature/logistics_wirecutter.md new file mode 100644 index 0000000000..b4d68aa452 --- /dev/null +++ b/documentation/feature/logistics_wirecutter.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Logistics - Wirecutter +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/magazinerepack.md b/documentation/feature/magazinerepack.md new file mode 100644 index 0000000000..4c288ebe6f --- /dev/null +++ b/documentation/feature/magazinerepack.md @@ -0,0 +1,24 @@ +--- +layout: wiki +title: Magazine Repack +group: feature +parent: wiki +--- + +## Overview + +### Repacking magazines +Adds ability to repack magazines of the same type. An optional module provides +options to adjust the repacking time of single rounds and whole magazines to +the mission maker. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/main.md b/documentation/feature/main.md new file mode 100644 index 0000000000..0e6a75d5c7 --- /dev/null +++ b/documentation/feature/main.md @@ -0,0 +1,17 @@ +--- +layout: wiki +title: Main +group: feature +parent: wiki +--- + +## Overview + +Main module which acts as the ACE core module. + + +## Dependencies + +Arma 3 and CBA + +Note: Note: The Main module is required by all other modules. Do not disable it! diff --git a/documentation/feature/map.md b/documentation/feature/map.md new file mode 100644 index 0000000000..417bbc6898 --- /dev/null +++ b/documentation/feature/map.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Map +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/maptools.md b/documentation/feature/maptools.md new file mode 100644 index 0000000000..e0577e2b69 --- /dev/null +++ b/documentation/feature/maptools.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Map Tools +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/markers.md b/documentation/feature/markers.md new file mode 100644 index 0000000000..f96b8257c6 --- /dev/null +++ b/documentation/feature/markers.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Markers +group: feature +parent: wiki +--- + +## Overview + +### Improved marker placement +Expands the "Insert Marker" menu and allows to rotate map markers. Shows the currently selected channel to prevent misplacement. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/medical-system.md b/documentation/feature/medical-system.md index 443fb4b182..2528cc9c3f 100644 --- a/documentation/feature/medical-system.md +++ b/documentation/feature/medical-system.md @@ -68,3 +68,6 @@ Morphine is used to alleviate large amounts of pain. Has an effect similar to He Epinephrine is used to increase heart rate and blood pressure and alleviate unconsciousness. Epinephrine is a synthetic form of Adrenaline, which is naturally produced in the body. It can also be applied to counter-act the effects of Atropine. Be careful though, as it may only be given once. _Epinephrine must never be given to a casualty with a high heart rate or blood pressure._ + +## Dependencies +`ace_interaction`, `ace_modules`, `ace_apl` diff --git a/documentation/feature/microdagr.md b/documentation/feature/microdagr.md new file mode 100644 index 0000000000..e8ffa69d8d --- /dev/null +++ b/documentation/feature/microdagr.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: MicroDAGR +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/missileguidance.md b/documentation/feature/missileguidance.md new file mode 100644 index 0000000000..65a37b6950 --- /dev/null +++ b/documentation/feature/missileguidance.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Missile Guidance +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_laser` diff --git a/documentation/feature/missionmodules.md b/documentation/feature/missionmodules.md new file mode 100644 index 0000000000..1a9be336d5 --- /dev/null +++ b/documentation/feature/missionmodules.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Mission Modules +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/mk6mortar.md b/documentation/feature/mk6mortar.md new file mode 100644 index 0000000000..dd5f8136e3 --- /dev/null +++ b/documentation/feature/mk6mortar.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Mk6 Mortar +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/movement.md b/documentation/feature/movement.md new file mode 100644 index 0000000000..a40be05380 --- /dev/null +++ b/documentation/feature/movement.md @@ -0,0 +1,34 @@ +--- +layout: wiki +title: Movement +group: feature +parent: wiki +--- + +## Overview + +### Jumping +Adds the ability to jump when pressing the vault key while moving. (V - key) + +### Minor animation tweaks +Walking slowly with the weapon lowered now has a less silly looking animation. + +### Fatigue adjustments +Soldiers get fatigued slower, but regain their stamina slower aswell. Fatigued soldiers have a faster walking speed and no longer turn into snails. + +### Weight display +Adds a weight of the current loadout display in the inventory to estimate the fatigue gain while moving in combat. Can be adjusted to display lb. instead of kg in the ACE Options Menu. + +### Optics view in all stances +The player can now use the sights of rifles and pistols in all prone stances. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/nametags.md b/documentation/feature/nametags.md new file mode 100644 index 0000000000..4882882c7d --- /dev/null +++ b/documentation/feature/nametags.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Nametags +group: feature +parent: wiki +--- + +## Overview + +### Nametag and rank display +Adds nametags and soldier ranks to friendly players in multiplayer. This can be adjusted in the ACE Options Menu to not display the rank, display all nametags of nearby soldiers instead of those who are looked directly at, to require a button press to show the nametags or to disable them altogether. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/nightvision.md b/documentation/feature/nightvision.md new file mode 100644 index 0000000000..c600e54f50 --- /dev/null +++ b/documentation/feature/nightvision.md @@ -0,0 +1,31 @@ +--- +layout: wiki +title: Nightvision +group: feature +parent: wiki +--- + +## Overview + +### Multiple Generation NVGs +Adds different night vision devices with varying image quality and field of +view. New Classnames for Generations 1, 2, and 4 NVGs (default ArmA3 NVGs +represents Generation 3) and a wide view NVG. + +### Blending effects +Adds a blending effect depending on ammunition type when firing while using a +night vision device. Especially tracer rounds are bright, but you can use the + IR-dim tracers from the Ballistics module to reduce tis effect. + +### Brightness adjustment +Enables the user to manually adjust NVG brightness. + + + +## Usage +Use Alt+PageUp and Alt+PageDown to adjust NVG brightness. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/noidle.md b/documentation/feature/noidle.md new file mode 100644 index 0000000000..67fc875ff9 --- /dev/null +++ b/documentation/feature/noidle.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: No Idle +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/noradio.md b/documentation/feature/noradio.md new file mode 100644 index 0000000000..104d9ae01e --- /dev/null +++ b/documentation/feature/noradio.md @@ -0,0 +1,23 @@ +--- +layout: wiki +title: No Radio +group: feature +parent: wiki +--- + +## Overview + +### Silent avatar +Mutes the player's automatic callouts ("Enemy man, 100 meters, front!"). +Does not mute AI callouts. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/norearm.md b/documentation/feature/norearm.md new file mode 100644 index 0000000000..8a6243c1d9 --- /dev/null +++ b/documentation/feature/norearm.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: No Rearm +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/optics.md b/documentation/feature/optics.md new file mode 100644 index 0000000000..2b23b70ce8 --- /dev/null +++ b/documentation/feature/optics.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Optics +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/optionsmenu.md b/documentation/feature/optionsmenu.md new file mode 100644 index 0000000000..a7e8ddca37 --- /dev/null +++ b/documentation/feature/optionsmenu.md @@ -0,0 +1,27 @@ +--- +layout: wiki +title: Options Menu +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` + +Note: The Options Menu module is utilized by many other modules. Disabling it is not recommended. diff --git a/documentation/feature/overheating.md b/documentation/feature/overheating.md new file mode 100644 index 0000000000..aaf3bbcacf --- /dev/null +++ b/documentation/feature/overheating.md @@ -0,0 +1,35 @@ +--- +layout: wiki +title: Overheating +group: feature +parent: wiki +--- + +## Overview + +### Weapon Jamming +Adds a propability to jam a weapon when firing. Jams can be cleared by +reloading or by using the clear jam-key. + +### Temperature simulation +Introduces weapon temperature simulation depending on weapon and bullet +mass. Hot weapons are more prone to jamming. Depending on weapon type +the accuracy and in extreme cases the muzzle velocity might be reduced +on high temperatues. Adds smoke puff and heat refraction effects to +indicate this. + +### Spare barrels +Adds the ability to changes barrels on machine guns to compensate for those +effects. + + +## Usage +To clear a jammed weapon, press Shift+R. + + +*needs documentation on swapping barrels* + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/overpressure.md b/documentation/feature/overpressure.md new file mode 100644 index 0000000000..34a357ae0c --- /dev/null +++ b/documentation/feature/overpressure.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Overpressure +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +List of modules that must be present for this module to work. diff --git a/documentation/feature/parachute.md b/documentation/feature/parachute.md new file mode 100644 index 0000000000..4c2a9a1a39 --- /dev/null +++ b/documentation/feature/parachute.md @@ -0,0 +1,30 @@ +--- +layout: wiki +title: Parachute +group: feature +parent: wiki +--- + +## Overview + +### Altimeter +Removes the altitude and descend speed UI elements when free-falling and +parachuting on higher difficulties and instead adds an altimeter watch type +item. + +### Non-steerable parachute +Adds a non-steerable parachute variant for jet pilots. + +### Landing animation +Smoothens parachute landing animation. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/protection.md b/documentation/feature/protection.md new file mode 100644 index 0000000000..3b1e2effce --- /dev/null +++ b/documentation/feature/protection.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Protection +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/ragdolls.md b/documentation/feature/ragdolls.md new file mode 100644 index 0000000000..e0bc56017a --- /dev/null +++ b/documentation/feature/ragdolls.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Ragdolls +group: feature +parent: wiki +--- + +## Overview + +### Adjusted Ragdolls +Changes the ragdolls to react more to the force of shots and explosions. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/realisticnames.md b/documentation/feature/realisticnames.md new file mode 100644 index 0000000000..8482cda456 --- /dev/null +++ b/documentation/feature/realisticnames.md @@ -0,0 +1,23 @@ +--- +layout: wiki +title: Realistic Names +group: feature +parent: wiki +--- + +## Overview + +### Real names +Changes the names of vehicles, magazines, weapons, grenades, explosive charges +and mines to their respective real-world counterparts whenever possible. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/recoil.md b/documentation/feature/recoil.md new file mode 100644 index 0000000000..f7182fc66f --- /dev/null +++ b/documentation/feature/recoil.md @@ -0,0 +1,28 @@ +--- +layout: wiki +title: Recoil +group: feature +parent: wiki +--- + +## Overview + +### Recoil adjustment +Overhauls the recoil system reducing upwards recoil. + +### Advanced cam shake +Introducing camshake when firing on foot or as vehicle gunner depending on stance and weapon type. + +### Burst dispersion +Firing in longer burst (> 3 rounds per burst) slightly reduces the accuracy. Firing machine guns in bursts is now useful. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/reload.md b/documentation/feature/reload.md new file mode 100644 index 0000000000..4efcd26b5e --- /dev/null +++ b/documentation/feature/reload.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Reload +group: feature +parent: wiki +--- + +## Overview + +### Ammo count +Hides the actual round count of magazines and removes the icon when the current magazine is emptied. The player can instead check the magazine weight, but that gives only estimated values for magazines with more than 10 rounds. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/reloadlaunchers.md b/documentation/feature/reloadlaunchers.md new file mode 100644 index 0000000000..3cec2ef66f --- /dev/null +++ b/documentation/feature/reloadlaunchers.md @@ -0,0 +1,24 @@ +--- +layout: wiki +title: Reload Launchers +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/respawn.md b/documentation/feature/respawn.md new file mode 100644 index 0000000000..2e0009b9cf --- /dev/null +++ b/documentation/feature/respawn.md @@ -0,0 +1,28 @@ +--- +layout: wiki +title: Respawn +group: feature +parent: wiki +--- + +## Overview + +### Respawn with same gear +Requires the Respawn Gear module to be placed. Respawned soldiers now have their loadout when killed. + +### Friendly Fire messages +Shows friendly fire warnings in system chat if the module is placed. Works even in higher difficulties where kill messages are normally disabled. + +### Rallypoints +Adds rallypoints to all 3 sides to enable teleportation from base spawn to FOBs. Requires some setup from the mission maker. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/safemode.md b/documentation/feature/safemode.md new file mode 100644 index 0000000000..a7e1481d6e --- /dev/null +++ b/documentation/feature/safemode.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Safe Mode +group: feature +parent: wiki +--- + +## Overview + +### Safety +You can now use the safety mode of any weapon. Switching weapon modes takes the safety off. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/scopes.md b/documentation/feature/scopes.md new file mode 100644 index 0000000000..9d84ab81d9 --- /dev/null +++ b/documentation/feature/scopes.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Scopes +group: feature +parent: wiki +--- + +## Overview + +### Sniper Scope Adjustment +Enables snipers to adjust their scopes horizontally and vertically in mils. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/smallarms.md b/documentation/feature/smallarms.md new file mode 100644 index 0000000000..3f75d065ed --- /dev/null +++ b/documentation/feature/smallarms.md @@ -0,0 +1,28 @@ +--- +layout: wiki +title: Small Arms +group: feature +parent: wiki +--- + +## Overview + +### Magazine Names +Unifies the name formatting of magazines similar to Arma 2 standards. + +### No tracers in non-tracer mags +Assault rifles no longer have tracer rounds in their non-tracer magazines. This doesn't effect the additional tracers in the last rounds of machine gun magazines. + +### Real magazine round counts +All pistol and sub machine gun magazines now have adjusted capacaties to match their real life counterparts. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/switchunits.md b/documentation/feature/switchunits.md new file mode 100644 index 0000000000..7955241ba1 --- /dev/null +++ b/documentation/feature/switchunits.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Switch Units +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/testmissions.md b/documentation/feature/testmissions.md new file mode 100644 index 0000000000..e68dac2758 --- /dev/null +++ b/documentation/feature/testmissions.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Test Missions +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/thermals.md b/documentation/feature/thermals.md new file mode 100644 index 0000000000..72d903980e --- /dev/null +++ b/documentation/feature/thermals.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Thermals +group: feature +parent: wiki +--- + +## Overview + +### Body Warmth +Adjusts the thermal properties of humans making them less like torches. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/vector.md b/documentation/feature/vector.md new file mode 100644 index 0000000000..64ec925669 --- /dev/null +++ b/documentation/feature/vector.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Vector +group: feature +parent: wiki +--- + +## Overview + +### Vector IV Rangefinder +Adds the Vector IV rangefinder, including all real-life usage modes (distance between two points, angle between two points etc.) + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/vehiclelock.md b/documentation/feature/vehiclelock.md new file mode 100644 index 0000000000..b815ea5150 --- /dev/null +++ b/documentation/feature/vehiclelock.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Vehicle Lock +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_interaction` diff --git a/documentation/feature/vehicles.md b/documentation/feature/vehicles.md new file mode 100644 index 0000000000..437b2db8be --- /dev/null +++ b/documentation/feature/vehicles.md @@ -0,0 +1,46 @@ +--- +layout: wiki +title: Vehicles +group: feature +parent: wiki +--- + +## Overview + +### Speedlimiter +Adds ability to limit the max. speed of any vehicle. + +### Engine start delay +The engine has to be started before the vehicle can move. Starting the engine takes aprox. 1 to 2 seconds. + +### Fuel capacity +The range of all vehicle gets signifigantly reduced to reflect ranges of their real life counterparts. Scaled down to match the relative short distances in Arma. A full vehicle on mission start should still most likely never need a refueling during a mission. + +### Main gun muzzles +APCs and Tanks now share a muzzle for all ammunition types of their main guns. This prevents an exploit that skips the reloading time of a round or clip while changing the ammunition type. Also makes it possible to switch between ammunition types using the scroll wheel like in Arma 2. + +### Boat machine gun tracers +NATO and AAF armed boats now use their respective tracer colours like any vehicle when they fire their rear gun. (Red for BluFor, yellow for Indep) + +### Improved smoke launcher of Fennek (Strider) +Reduced smoke shell count and launch angle of the AAF Fennek to match the models smoke launcher. + +### Stabilized optic of Fennek (Strider) +Stabilizes the commander's view in the Fennek (Strider). + +### Vehicle mounted machine guns ROF +The rate of fire of vehicle mounted miniguns and machine guns is adjusted to match real life values. + +### 120mm gun and mortar behavior +MBT main guns and mortars can no longer lock on enemies. The AT rounds of both now have raised cost values to encourage the AI to not use those rounds against foot soldiers over their machine guns or HE rounds. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/weaponselect.md b/documentation/feature/weaponselect.md new file mode 100644 index 0000000000..b843adb01a --- /dev/null +++ b/documentation/feature/weaponselect.md @@ -0,0 +1,34 @@ +--- +layout: wiki +title: Weapon Select +group: feature +parent: wiki +--- + +## Overview + +### Weapon select +The number key can be used to quickly switch between weapons. (1 key - pistol, 2 key - rifle, 3 key - grenade launcher, 4 key - rocket launcher, 5 key - binocular) + +### Holster weapon +Adds the ability to holster a weapon on the back. (0 key) + +### Engine select +Quickly turn engine on and off (1 key - turn off, 2 key - turn on) + +### Weapon select +Quickly switch between vehicle weapons (1-3 key) + +### Grenade select +To prevent accidents a grenade has to be selected before it can be thrown. Toggles between explosive and non-explosive grenades. When spamming the throw key, the player won't automatically switch to frag grenades when all smokes are used up. Also shows an indicator to quickly see how many grenades are left when selecting and after throwing (6 key - switch between frag grenades, 7 key - switch between other grenades) + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common` diff --git a/documentation/feature/weather.md b/documentation/feature/weather.md new file mode 100644 index 0000000000..7b0ff23308 --- /dev/null +++ b/documentation/feature/weather.md @@ -0,0 +1,25 @@ +--- +layout: wiki +title: Weather +group: feature +parent: wiki +--- + +## Overview + +### Sub-feature 1 +Short description of sub-feature 1. + +### Sub-feature 2 +Short description of sub-feature 2. + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_common`, `ace_modules` diff --git a/documentation/feature/windeflection.md b/documentation/feature/windeflection.md new file mode 100644 index 0000000000..f665f9a0ae --- /dev/null +++ b/documentation/feature/windeflection.md @@ -0,0 +1,22 @@ +--- +layout: wiki +title: Wind Deflection +group: feature +parent: wiki +--- + +## Overview + +### Wind Deflection +Adds ballistic influences of wind, air density and temperature + + +## Usage + +Short overview of how to use the feature, e.g. menu options, key bindings, +instructions. May not apply to all modules. + + +## Dependencies + +`ace_weather` diff --git a/documentation/framework/settings.md b/documentation/framework/settings.md new file mode 100644 index 0000000000..3106cb2254 --- /dev/null +++ b/documentation/framework/settings.md @@ -0,0 +1,85 @@ +--- +layout: wiki +title: Settings Framework +group: framework +order: 5 +parent: wiki +--- + +ACE contains an extensive settings framework that allows you to tweak the modification without having to mess around with deleting pbos. These settings are all handled server side and broadcasted to the clients connecting to that server. This ensures that everyone playing on the server will have a uniform experience. + +Part of this settings framework are global settings and client settings. Both use the same underlaying framework, with the difference that client settings can be adjusted by clients, where global settings can not. + + +## 1. How do they work + +Settings are entries in the config that get translated to `missionnamespace` global variables. An example settings entry looks like this: + +``` + class ACE_module_sampleSetting { + // Value + value = 1; + + // Type (SCALAR, BOOL, STRING, ARRAY, COLOR) + typeName = "SCALAR"; + + // Force the setting? + force = 0; + + // Does it appear on the options menu? + isClientSettable = 1; + + // The following settings only apply when isClientSettable == 1 + // Stringtable entry with the setting name + displayName = "$STR_ACE_Common_SettingName"; + + // Stringtable entry with the setting description + description = "$STR_ACE_Common_SettingDescription"; + + // Stringtable entries that describe the options + // Only applies if typeName == "SCALAR"; and is optional + values[] = {"Disabled", "Enabled", "Only Cursor", "Only On Keypress", "Only Cursor and KeyPress"}; + }; +``` + +Settings are defined from the mods config but can be adjusted through the following methods: +* Optional config entries +* Mission side modules + +## 2. Load order + +The load order for the settings are: +* 1. Mod Config +* 2. Server Config +* 3. Mission config +* 4. Placed down mission modules + +What this means is that at any the 3 points after the mod config it is possible to insert your adjusted settings and force those (optionally). This is a powerful tool for server admins, whom can ensure that everyone is using uniform settings across the board on their server. And it provides mission makers the ability to easily set settings for their mission, without creating a large dependancy on ACE; you do not have to place down mission modules. + +## 3. How do I use them? + +In the 'how do they work' chapter an example of settings was shown. This is the same for any settings config. The only difference is the location. For ACE modules, the settings are placed in the class `ACE_settings`. The same goes for the mission config. + +The server config setting entries are done through our optional ACE_server.pbo, which can be found in the optionals folder of @ace. It also contains a userconfig folder, which inside contains the file ace\serverconfig.hpp. This is the location ACE settings are placed. There is no need for a sub class. + +### 3.1 Getting all the settings! + +ACE contains a lot of settings; to tweak everything to your liking manually therefor can be quite a task. We have provided the option to export all settings in single player. For this, follow these simple steps: + +* Open the editor. +* Under modules (f7), find ACE, `Config Export [ACE]`. +* Place down the module, ensure that the allow parameter is set to yes. +* Press preview, once in game, press Esc and open the ACE Options dialog (top left) +* This is the dialog where you can modify client side settings. On the bottom left of it, you will now see a button called 'Config Export'. Press it and a new dialog opens. +* You are now in the dialog that allows you to adjust all settings from ACE. Tweak this to your liking. +* Once you are done tweaking, press the 'Export' button and all settings will be copied to your clipboard. +* Paste the settings in your serverconfig.hpp file and done. + +Note that the format copied to your clipboard by this can also be used in the mission config, as long as they are in the class `ACE_Settings`. + +### 3.2 Loading up the serverconfig + +As stated before, the serverconfig gets loaded through the optional ACE_server.pbo. This pbo is only required (and should only be used on) the server - clients do not need to have this! It is for this reason we have not signed this pbo. + +Load the ACE_server.pbo like any other addon you do on your server. Advised is to create an @aceServer mod folder and load that through `-serverMod=@aceServer`. + diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 9f4a8a29fa..54db16213d 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -1,11 +1,20 @@ cmake_minimum_required (VERSION 3.0) project (ACE) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +if(WIN32) +add_definitions(/DWINVER=0x0600 /D_WIN32_WINNT=0x0600) +endif() + if (NOT CMAKE_BUILD_TYPE AND CMAKE_COMPILER_IS_GNUCXX) message(STATUS "No build type selected, default to Debug") set(CMAKE_BUILD_TYPE "Debug") endif() +option(DEVEL "DEVEL" OFF) +option(USE_BULLET "USE_BULLET" OFF) +option(USE_DIRECTX "USE_DIRECTX" OFF) option(USE_64BIT_BUILD "USE_64BIT_BUILD" OFF) option(USE_STATIC_LINKING "USE_STATIC_LINKING" ON) @@ -14,16 +23,69 @@ if(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_FLAGS "-std=c++11 -march=i686 -m32 -O2 -s -fPIC -fpermissive") set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++") -else() - set(CMAKE_CXX_FLAGS_DEBUG "/D _DEBUG /MTd /Zi /Ob0 /Od /RTC1") - set(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + message(ERROR "SUPPORT NOT COMPLETE") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /arch:SSE2 /Qpar-report:2") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /D _DEBUG /MTd /Zi /Ob0 /Od /RTC1") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} /MT /O1 /Ob1 /D NDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MT /O2 /Ob2 /D NDEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} /MT /Zi /O2 /Ob1 /D NDEBUG") +endif() + +include_directories("common") + +if(USE_BULLET) + # Dependencies + # + set(BACKUP_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) + set(BACKUP_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + set(BACKUP_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + + add_definitions(-DUSE_DIRECTX) + add_subdirectory(lib/bullet3) + + set_target_properties(App_BasicExample PROPERTIES FOLDER Bullet3) + set_target_properties(App_HelloWorld PROPERTIES FOLDER Bullet3) + set_target_properties(App_ExampleBrowser PROPERTIES FOLDER Bullet3) + set_target_properties(Bullet2FileLoader PROPERTIES FOLDER Bullet3) + set_target_properties(Bullet3Collision PROPERTIES FOLDER Bullet3) + set_target_properties(Bullet3Dynamics PROPERTIES FOLDER Bullet3) + set_target_properties(Bullet3Geometry PROPERTIES FOLDER Bullet3) + set_target_properties(Bullet3Common PROPERTIES FOLDER Bullet3) + set_target_properties(Bullet3OpenCL_clew PROPERTIES FOLDER Bullet3) + set_target_properties(BulletCollision PROPERTIES FOLDER Bullet3) + set_target_properties(BulletDynamics PROPERTIES FOLDER Bullet3) + set_target_properties(BulletFileLoader PROPERTIES FOLDER Bullet3) + set_target_properties(BulletSoftBody PROPERTIES FOLDER Bullet3) + + set_target_properties(BulletWorldImporter PROPERTIES FOLDER Bullet3) + set_target_properties(BulletXmlWorldImporter PROPERTIES FOLDER Bullet3) + set_target_properties(ConvexDecomposition PROPERTIES FOLDER Bullet3) + set_target_properties(GIMPACTUtils PROPERTIES FOLDER Bullet3) + set_target_properties(gtest PROPERTIES FOLDER Bullet3) + set_target_properties(gwen PROPERTIES FOLDER Bullet3) + set_target_properties(HACD PROPERTIES FOLDER Bullet3) + set_target_properties(OpenGLWindow PROPERTIES FOLDER Bullet3) + set_target_properties(LinearMath PROPERTIES FOLDER Bullet3) + + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BACKUP_ARCHIVE_OUTPUT_DIRECTORY}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BACKUP_LIBRARY_OUTPUT_DIRECTORY}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BACKUP_RUNTIME_OUTPUT_DIRECTORY}) + + include_directories(BEFORE "lib/bullet3/src") +endif() +if(USE_DIRECTX) + add_definitions(-DUSE_DIRECTX) + set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) + find_package (DirectX) + link_directories (BEFORE ${DirectX_D3DX11_LIBRARY}) + include_directories (BEFORE ${DirectX_D3DX11_INCLUDE_DIR} ) +endif() +if(DEVEL) + add_definitions(-DDEVEL) endif() -file(GLOB ACE_COMMON_SOURCES common/*.h common/*.hpp common/*.c common/*.cpp) -add_library(ace_common STATIC ${ACE_COMMON_SOURCES}) -include_directories(AFTER "common") string(TIMESTAMP ACE_BUILDSTAMP "%Y-%m-%dT%H:%M:%SZ") set(ACE_VERSION_MAJOR 3) @@ -50,13 +112,29 @@ if(MSVC) set(GLOBAL_RC ${CMAKE_CURRENT_BINARY_DIR}/common/ace_version_win32.rc) endif() -include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}/common) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/common) set(GLOBAL_SOURCES ${GLOBAL_RC}) + # Add extensions to build here +add_subdirectory(common) + +# Extensions + add_subdirectory(fcs) add_subdirectory(break_line) add_subdirectory(clipboard) add_subdirectory(advanced_ballistics) +# Test Extension for dynamically loading/unloading built extensions; does not build in release +if (DEVEL) + add_subdirectory(dynload) + add_subdirectory(tests) + if(USE_DIRECTX) + add_subdirectory(lib/directxtk) + endif() +endif() + + + message("Build Type: ${CMAKE_BUILD_TYPE}") \ No newline at end of file diff --git a/extensions/advanced_ballistics/AdvancedBallistics.cpp b/extensions/advanced_ballistics/AdvancedBallistics.cpp index e6c55184a7..48865f7f6b 100644 --- a/extensions/advanced_ballistics/AdvancedBallistics.cpp +++ b/extensions/advanced_ballistics/AdvancedBallistics.cpp @@ -1,4 +1,4 @@ -#include "ace_common.h" +#include "shared.hpp" #include #include @@ -235,9 +235,11 @@ extern "C" void __stdcall RVExtension(char *output, int outputSize, const char *function) { + ZERO_OUTPUT(); + if (!strcmp(function, "version")) { - int n = sprintf_s(output, outputSize, "%s", ACE_FULL_VERSION_STR); - return; + int n = sprintf(output, "%s", ACE_FULL_VERSION_STR); + EXTENSION_RETURN(); } char* input = _strdup(function); @@ -256,8 +258,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) velocity = strtod(strtok_s(NULL, ":", &next_token), NULL); retard = calculateRetard(dragModel, ballisticCoefficient, velocity); - int n = sprintf_s(output, outputSize, "%f", retard); - return; + int n = sprintf(output, "%f", retard); + EXTENSION_RETURN(); } else if (!strcmp(mode, "atmosphericCorrection")) { double ballisticCoefficient = 1.0; double temperature = 15.0; @@ -272,8 +274,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) atmosphereModel = strtok_s(NULL, ":", &next_token); ballisticCoefficient = calculateAtmosphericCorrection(ballisticCoefficient, temperature, pressure, humidity, atmosphereModel); - int n = sprintf_s(output, outputSize, "%f", ballisticCoefficient); - return; + int n = sprintf(output, "%f", ballisticCoefficient); + EXTENSION_RETURN(); } else if (!strcmp(mode, "new")) { unsigned int index = 0; double airFriction = 0.0; @@ -339,8 +341,10 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) tickTime = strtod(strtok_s(NULL, ":", &next_token), NULL); tickTime += strtod(strtok_s(NULL, ":", &next_token), NULL); - if (index >= bulletDatabase.size()) - bulletDatabase.resize(index+1); + while (index >= bulletDatabase.size()) { + Bullet bullet; + bulletDatabase.push_back(bullet); + } bulletDatabase[index].airFriction = airFriction; bulletDatabase[index].ballisticCoefficients = ballisticCoefficients; @@ -365,8 +369,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) bulletDatabase[index].frames = 0.0; bulletDatabase[index].randSeed = 0; - int n = sprintf_s(output, outputSize, "%s", ""); - return; + int n = sprintf(output, "%s", ""); + EXTENSION_RETURN(); } else if (!strcmp(mode, "simulate")) { // simulate:0:[-0.109985,542.529,-3.98301]:[3751.57,5332.23,214.252]:[0.598153,2.38829,0]:28.6:0:0.481542:0:215.16 unsigned int index = 0; @@ -582,8 +586,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) velocityOffset[2] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef; }; - int n = sprintf_s(output, outputSize, "_bullet setVelocity (_bulletVelocity vectorAdd [%f, %f, %f]); _bullet setPosASL (_bulletPosition vectorAdd [%f, %f, %f]);", velocityOffset[0], velocityOffset[1], velocityOffset[2], positionOffset[0], positionOffset[1], positionOffset[2]); - return; + int n = sprintf(output, "_bullet setVelocity (_bulletVelocity vectorAdd [%f, %f, %f]); _bullet setPosASL (_bulletPosition vectorAdd [%f, %f, %f]);", velocityOffset[0], velocityOffset[1], velocityOffset[2], positionOffset[0], positionOffset[1], positionOffset[2]); + EXTENSION_RETURN(); } else if (!strcmp(mode, "set")) { int height = 0; int numObjects = 0; @@ -597,8 +601,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) map->gridBuildingNums.push_back(numObjects); map->gridSurfaceIsWater.push_back(surfaceIsWater); - int n = sprintf_s(output, outputSize, "%s", ""); - return; + int n = sprintf(output, "%s", ""); + EXTENSION_RETURN(); } else if (!strcmp(mode, "init")) { int mapSize = 0; int mapGrids = 0; @@ -609,15 +613,11 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) mapGrids = (int)ceil((double)mapSize / 50.0) + 1; gridCells = mapGrids * mapGrids; - - auto map_iter = mapDatabase.find(worldName); - if (map_iter == mapDatabase.end()) - return; - map = &map_iter->second; + map = &mapDatabase[worldName]; if (map->gridHeights.size() == gridCells) { - int n = sprintf_s(output, outputSize, "%s", "Terrain already initialized"); - return; + int n = sprintf(output, "%s", "Terrain already initialized"); + EXTENSION_RETURN(); } map->mapSize = mapSize; @@ -629,10 +629,10 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) map->gridBuildingNums.reserve(gridCells); map->gridSurfaceIsWater.reserve(gridCells); - int n = sprintf_s(output, outputSize, "%s", ""); - return; + int n = sprintf(output, "%s", ""); + EXTENSION_RETURN(); } - int n = sprintf_s(output, outputSize, "%s", ""); - return; + int n = sprintf(output, "%s", ""); + EXTENSION_RETURN(); } diff --git a/extensions/advanced_ballistics/CMakeLists.txt b/extensions/advanced_ballistics/CMakeLists.txt index 19b9fc41d9..51e709f6d2 100644 --- a/extensions/advanced_ballistics/CMakeLists.txt +++ b/extensions/advanced_ballistics/CMakeLists.txt @@ -1,9 +1,10 @@ set(ACE_EXTENSION_NAME "ace_advanced_ballistics") file(GLOB SOURCES *.h *.hpp *.c *.cpp) -add_library( ${ACE_EXTENSION_NAME} SHARED ${GLOBAL_SOURCES} ${SOURCES}) -add_dependencies(${ACE_EXTENSION_NAME} ace_common) -SET_TARGET_PROPERTIES(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "") +add_library( ${ACE_EXTENSION_NAME} SHARED ${SOURCES} ${GLOBAL_SOURCES}) +target_link_libraries(${ACE_EXTENSION_NAME} ace_common) +set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "") +set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions) if(CMAKE_COMPILER_IS_GNUCXX) set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1) diff --git a/extensions/break_line/CMakeLists.txt b/extensions/break_line/CMakeLists.txt index 00a74d4c3a..5d29d295c8 100644 --- a/extensions/break_line/CMakeLists.txt +++ b/extensions/break_line/CMakeLists.txt @@ -1,9 +1,10 @@ set(ACE_EXTENSION_NAME "ace_break_line") file(GLOB SOURCES *.h *.hpp *.c *.cpp) -add_library( ${ACE_EXTENSION_NAME} SHARED ${GLOBAL_SOURCES} ${SOURCES}) -add_dependencies(${ACE_EXTENSION_NAME} ace_common) -SET_TARGET_PROPERTIES(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "") +add_library( ${ACE_EXTENSION_NAME} SHARED ${SOURCES} ${GLOBAL_SOURCES}) +target_link_libraries(${ACE_EXTENSION_NAME} ace_common) +set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "") +set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions) if(CMAKE_COMPILER_IS_GNUCXX) set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1) diff --git a/extensions/break_line/ace_break_line.cpp b/extensions/break_line/ace_break_line.cpp index 2b253c05bc..440566b744 100644 --- a/extensions/break_line/ace_break_line.cpp +++ b/extensions/break_line/ace_break_line.cpp @@ -11,7 +11,7 @@ * String with line breaks */ -#include "ace_common.h" +#include "shared.hpp" #include #include @@ -65,12 +65,14 @@ std::string addLineBreaks(const std::vector &words) { #pragma warning( disable : 4996 ) void __stdcall RVExtension(char *output, int outputSize, const char *function) { + ZERO_OUTPUT(); if (!strcmp(function, "version")) { strncpy(output, ACE_FULL_VERSION_STR, outputSize); } else { strncpy(output, addLineBreaks(splitString(function)).c_str(), outputSize); output[outputSize - 1] = '\0'; } + EXTENSION_RETURN(); } #pragma warning( pop ) diff --git a/extensions/clipboard/ace_clipboard.cpp b/extensions/clipboard/ace_clipboard.cpp index 4809a14acf..41e3a5721f 100644 --- a/extensions/clipboard/ace_clipboard.cpp +++ b/extensions/clipboard/ace_clipboard.cpp @@ -9,7 +9,7 @@ * Returns: * None */ -#include "ace_common.h" +#include "shared.hpp" #include #include @@ -23,12 +23,15 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { std::string cur_input(function); std::string result; - if (cur_input.length() < 1) - return; + ZERO_OUTPUT(); + + if (cur_input.length() < 1) { + EXTENSION_RETURN(); + } if (!strcmp(function, "version")) { strncpy(output, ACE_FULL_VERSION_STR, outputSize); - return; + EXTENSION_RETURN(); } #ifdef _WIN32 @@ -38,14 +41,14 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { if (!hClipboardData) { result = "GlobalAlloc() failed, GetLastError=" + GetLastError(); gClipboardData = ""; - return; + EXTENSION_RETURN(); } char *pClipboardData = (char *)GlobalLock(hClipboardData); if (!pClipboardData) { result = "GlobalLock() failed, GetLastError=" + GetLastError(); gClipboardData = ""; - return; + EXTENSION_RETURN(); } memcpy(pClipboardData, gClipboardData.c_str(), gClipboardData.length()); pClipboardData[gClipboardData.length() + 1] = 0x00; @@ -82,6 +85,6 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { #endif - + EXTENSION_RETURN(); } diff --git a/extensions/cmake/FindDirectX.cmake b/extensions/cmake/FindDirectX.cmake new file mode 100644 index 0000000000..69bf1d62e8 --- /dev/null +++ b/extensions/cmake/FindDirectX.cmake @@ -0,0 +1,215 @@ +# - try to find DirectX include directories and libraries +# +# Once done this will define: +# +# DirectX_XYZ_FOUND - system has the XYZ API +# DirectX_XYZ_INCLUDE_FOUND - system has the include for the XYZ API +# DirectX_XYZ_INCLUDE_DIR - include directory for the XYZ API +# DirectX_XYZ_LIBRARY - path/name for the XYZ library +# +# Where XYZ can be any of: +# +# DDRAW +# D3D +# D3DX +# D3D8 +# D3DX8 +# D3D9 +# D3DX9 +# D3D10 +# D3D10_1 +# D3DX10 +# D3D11 +# D3D11_1 +# D3D11_2 +# D3DX11 +# D2D1 +# + + +include (CheckIncludeFileCXX) +include (FindPackageMessage) + + +if (WIN32) + + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (DirectX_ARCHITECTURE x64) + else () + set (DirectX_ARCHITECTURE x86) + endif () + + # Can't use "$ENV{ProgramFiles(x86)}" to avoid violating CMP0053. See + # http://public.kitware.com/pipermail/cmake-developers/2014-October/023190.html + set (ProgramFiles_x86 "ProgramFiles(x86)") + if ("$ENV{${ProgramFiles_x86}}") + set (ProgramFiles "$ENV{${ProgramFiles_x86}}") + else () + set (ProgramFiles "$ENV{ProgramFiles}") + endif () + + find_path (DirectX_ROOT_DIR + Include/d3d9.h + PATHS + "$ENV{DXSDK_DIR}" + "${ProgramFiles}/Microsoft DirectX SDK (June 2010)" + "${ProgramFiles}/Microsoft DirectX SDK (February 2010)" + "${ProgramFiles}/Microsoft DirectX SDK (March 2009)" + "${ProgramFiles}/Microsoft DirectX SDK (August 2008)" + "${ProgramFiles}/Microsoft DirectX SDK (June 2008)" + "${ProgramFiles}/Microsoft DirectX SDK (March 2008)" + "${ProgramFiles}/Microsoft DirectX SDK (November 2007)" + "${ProgramFiles}/Microsoft DirectX SDK (August 2007)" + "${ProgramFiles}/Microsoft DirectX SDK" + DOC "DirectX SDK root directory" + ) + if (DirectX_ROOT_DIR) + set (DirectX_INC_SEARCH_PATH "${DirectX_ROOT_DIR}/Include") + set (DirectX_LIB_SEARCH_PATH "${DirectX_ROOT_DIR}/Lib/${DirectX_ARCHITECTURE}") + set (DirectX_BIN_SEARCH_PATH "${DirectX_ROOT_DIR}/Utilities/bin/x86") + endif () + + # With VS 2011 and Windows 8 SDK, the DirectX SDK is included as part of + # the Windows SDK. + # + # See also: + # - http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx + if (DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) + set (USE_WINSDK_HEADERS TRUE) + endif () + + # Find a header in the DirectX SDK + macro (find_dxsdk_header var_name header) + set (include_dir_var "DirectX_${var_name}_INCLUDE_DIR") + set (include_found_var "DirectX_${var_name}_INCLUDE_FOUND") + find_path (${include_dir_var} ${header} + HINTS ${DirectX_INC_SEARCH_PATH} + DOC "The directory where ${header} resides" + CMAKE_FIND_ROOT_PATH_BOTH + ) + if (${include_dir_var}) + set (${include_found_var} TRUE) + find_package_message (${var_name}_INC "Found ${header} header: ${${include_dir_var}}/${header}" "[${${include_dir_var}}]") + endif () + mark_as_advanced (${include_found_var}) + endmacro () + + # Find a library in the DirectX SDK + macro (find_dxsdk_library var_name library) + # DirectX SDK + set (library_var "DirectX_${var_name}_LIBRARY") + find_library (${library_var} ${library} + HINTS ${DirectX_LIB_SEARCH_PATH} + DOC "The directory where ${library} resides" + CMAKE_FIND_ROOT_PATH_BOTH + ) + if (${library_var}) + find_package_message (${var_name}_LIB "Found ${library} library: ${${library_var}}" "[${${library_var}}]") + endif () + mark_as_advanced (${library_var}) + endmacro () + + # Find a header in the Windows SDK + macro (find_winsdk_header var_name header) + if (USE_WINSDK_HEADERS) + # Windows SDK + set (include_dir_var "DirectX_${var_name}_INCLUDE_DIR") + set (include_found_var "DirectX_${var_name}_INCLUDE_FOUND") + check_include_file_cxx (${header} ${include_found_var}) + set (${include_dir_var}) + mark_as_advanced (${include_found_var}) + else () + find_dxsdk_header (${var_name} ${header}) + endif () + endmacro () + + # Find a library in the Windows SDK + macro (find_winsdk_library var_name library) + if (USE_WINSDK_HEADERS) + # XXX: We currently just assume the library exists + set (library_var "DirectX_${var_name}_LIBRARY") + set (${library_var} ${library}) + mark_as_advanced (${library_var}) + else () + find_dxsdk_library (${var_name} ${library}) + endif () + endmacro () + + # Combine header and library variables into an API found variable + macro (find_combined var_name inc_var_name lib_var_name) + if (DirectX_${inc_var_name}_INCLUDE_FOUND AND DirectX_${lib_var_name}_LIBRARY) + set (DirectX_${var_name}_FOUND 1) + find_package_message (${var_name} "Found ${var_name} API" "[${DirectX_${lib_var_name}_LIBRARY}][${DirectX_${inc_var_name}_INCLUDE_DIR}]") + endif () + endmacro () + + find_winsdk_header (DDRAW ddraw.h) + find_winsdk_library (DDRAW ddraw) + find_combined (DDRAW DDRAW DDRAW) + + if (CMAKE_GENERATOR_TOOLSET MATCHES "_xp$") + # Windows 7 SDKs, used by XP toolset, do not include d3d.h + find_dxsdk_header (D3D d3d.h) + else () + find_winsdk_header (D3D d3d.h) + endif () + find_combined (D3D D3D DDRAW) + + find_dxsdk_header (D3DX d3dx.h) + find_combined (D3DX D3DX D3DX) + + find_dxsdk_header (D3D8 d3d8.h) + find_dxsdk_library (D3D8 d3d8) + find_combined (D3D8 D3D8 D3D8) + + find_dxsdk_header (D3DX8 d3dx8.h) + find_dxsdk_library (D3DX8 d3dx8) + find_combined (D3DX8 D3DX8 D3DX8) + + find_winsdk_header (D3D9 d3d9.h) + find_winsdk_library (D3D9 d3d9) + find_combined (D3D9 D3D9 D3D9) + + find_dxsdk_header (D3DX9 d3dx9.h) + find_dxsdk_library (D3DX9 d3dx9) + find_combined (D3DX9 D3DX9 D3DX9) + + find_winsdk_header (DXGI dxgi.h) + find_winsdk_header (DXGI1_2 dxgi1_2.h) + find_winsdk_header (DXGI1_3 dxgi1_3.h) + find_winsdk_library (DXGI dxgi) + + find_winsdk_header (D3D10 d3d10.h) + find_winsdk_library (D3D10 d3d10) + find_combined (D3D10 D3D10 D3D10) + + find_winsdk_header (D3D10_1 d3d10_1.h) + find_winsdk_library (D3D10_1 d3d10_1) + find_combined (D3D10_1 D3D10_1 D3D10_1) + + find_dxsdk_header (D3DX10 d3dx10.h) + find_dxsdk_library (D3DX10 d3dx10) + find_combined (D3DX10 D3DX10 D3DX10) + + find_winsdk_header (D3D11 d3d11.h) + find_winsdk_library (D3D11 d3d11) + find_combined (D3D11 D3D11 D3D11) + find_winsdk_header (D3D11_1 d3d11_1.h) + find_combined (D3D11_1 D3D11_1 D3D11) + find_winsdk_header (D3D11_2 d3d11_2.h) + find_combined (D3D11_2 D3D11_2 D3D11) + + find_dxsdk_header (D3DX11 d3dx11.h) + find_dxsdk_library (D3DX11 d3dx11) + find_combined (D3DX11 D3DX11 D3DX11) + + find_winsdk_header (D2D1 d2d1.h) + find_winsdk_library (D2D1 d2d1) + find_combined (D2D1 D2D1 D2D1) + + find_program (DirectX_FXC_EXECUTABLE fxc + HINTS ${DirectX_BIN_SEARCH_PATH} + DOC "Path to fxc.exe executable." + ) + +endif () \ No newline at end of file diff --git a/extensions/common/CMakeLists.txt b/extensions/common/CMakeLists.txt new file mode 100644 index 0000000000..620023ceb1 --- /dev/null +++ b/extensions/common/CMakeLists.txt @@ -0,0 +1,18 @@ +file(GLOB_RECURSE ACE_COMMON_SOURCES *.h *.hpp *.c *.cpp) + + +file(GLOB ACE_BASE_COMMON_SOURCES *.h *.hpp *.c *.cpp) +file(GLOB ACE_P3D_SOURCES p3d/*.h p3d/*.hpp p3d/*.c p3d/*.cpp) +file(GLOB ACE_PBO_SOURCES pbo/*.h pbo/*.hpp pbo/*.c pbo/*.cpp) +file(GLOB ACE_SIMULATION_SOURCES simulation/*.h simulation/*.hpp simulation/*.c simulation/*.cpp) +file(GLOB ACE_DIRECTX_SOURCES directx/*.h directx/*.hpp directx/*.c directx/*.cpp) +file(GLOB ACE_GLM_SOURCES glm/*.h glm/*.hpp glm/*.c glm/*.cpp) + +SOURCE_GROUP("common" FILES ${ACE_BASE_COMMON_SOURCES}) +SOURCE_GROUP("p3d" FILES ${ACE_P3D_SOURCES}) +SOURCE_GROUP("pbo" FILES ${ACE_PBO_SOURCES}) +SOURCE_GROUP("simulation" FILES ${ACE_SIMULATION_SOURCES}) +SOURCE_GROUP("directx" FILES ${ACE_DIRECTX_SOURCES}) +SOURCE_GROUP("glm" FILES ${ACE_GLM_SOURCES}) + +add_library(ace_common STATIC ${ACE_GLM_SOURCES} ${ACE_BASE_COMMON_SOURCES} ${ACE_P3D_SOURCES} ${ACE_PBO_SOURCES} ${ACE_SIMULATION_SOURCES} ${ACE_DIRECTX_SOURCES}) diff --git a/extensions/common/arguments.hpp b/extensions/common/arguments.hpp new file mode 100644 index 0000000000..70e942a241 --- /dev/null +++ b/extensions/common/arguments.hpp @@ -0,0 +1,90 @@ +#pragma once + +#include "shared.hpp" +#include "vector.hpp" + +#include +#include + +namespace ace { + class argument_accessor { + public: + argument_accessor(const uint32_t index, const std::vector & ar) : _index(index), _args(ar) { } + + const std::string & as_string() const { return _args[_index]; } + operator const std::string &() const { return as_string(); } + + float as_float() const { return atof(_args[_index].c_str()); } + operator float() const { return as_float(); } + + int as_int() const { return atoi(_args[_index].c_str()); } + operator int() const { return as_int(); } + + int as_uint32() const { return (uint32_t)atoi(_args[_index].c_str()); } + operator uint32_t() const { return as_uint32(); } + + ace::vector3 as_vector() const { + std::vector t = ace::split(_args[_index], ';'); + return ace::vector3(atof(t[0].c_str()), + atof(t[1].c_str()), + atof(t[2].c_str())); + } + operator ace::vector3() const { return as_vector(); } + + protected: + const uint32_t _index; + const std::vector & _args; + }; + + class arguments { + public: + arguments(const std::string & str) : _original(str) { + _args = ace::split(str, ','); + for (int i = 0; i < _args.size(); i++) { + _args[i] = trim(_args[i]); + } + } + + size_t size() const { return _args.size(); } + + const argument_accessor operator[] (int index) const { return argument_accessor(index, _args); } + + const std::string & as_string(uint32_t _index) const { return _args[_index]; } + float as_float(uint32_t _index) const { return atof(_args[_index].c_str()); } + int as_int(uint32_t _index) const { return atoi(_args[_index].c_str()); } + int as_uint32(uint32_t _index) const { return (uint32_t)atoi(_args[_index].c_str()); } + ace::vector3 as_vector(uint32_t _index) const { + std::vector t = ace::split(_args[_index], ';'); + return ace::vector3(atof(t[0].c_str()), + atof(t[1].c_str()), + atof(t[2].c_str())); + } + + const std::string & get() const { + return _original; + } + + std::string create(const std::string & command) const { + std::stringstream ss; + ss << command << ":"; + + for (auto & v : _args) { + ss << v << ","; + } + + // Remove the trailing , + std::string result = ss.str(); + result.erase(result.length()); + + return result; + } + static std::string create(const std::string & command, const arguments & args) { + return args.create(command); + } + + + protected: + std::vector _args; + const std::string _original; + }; +} \ No newline at end of file diff --git a/extensions/common/directx/d3d_display.cpp b/extensions/common/directx/d3d_display.cpp new file mode 100644 index 0000000000..bfc7a0e013 --- /dev/null +++ b/extensions/common/directx/d3d_display.cpp @@ -0,0 +1,439 @@ +#ifdef USE_DIRECTX + +#include "shared.hpp" +#include "d3d_display.hpp" + +#include + +#include + +using namespace DirectX; + +namespace ace { + namespace debug { + + DWORD GetMainThreadId() { + const std::shared_ptr hThreadSnapshot( + CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0), CloseHandle); + if (hThreadSnapshot.get() == INVALID_HANDLE_VALUE) { + throw std::runtime_error("GetMainThreadId failed"); + } + THREADENTRY32 tEntry; + tEntry.dwSize = sizeof(THREADENTRY32); + DWORD result = 0; + DWORD currentPID = GetCurrentProcessId(); + for (BOOL success = Thread32First(hThreadSnapshot.get(), &tEntry); + !result && success && GetLastError() != ERROR_NO_MORE_FILES; + success = Thread32Next(hThreadSnapshot.get(), &tEntry)) + { + if (tEntry.th32OwnerProcessID == currentPID) { + result = tEntry.th32ThreadID; + } + } + return result; + } + + d3d_display::d3d_display() : _fullscreen(false) {} + d3d_display::~d3d_display() {} + + bool d3d_display::render_thread(uint32_t w, uint32_t h, bool f) { + _render_thread = std::make_unique(this, d3d_display_worker_args(w, h, f) ); + return true; + } + + void d3d_display::render_worker(d3d_display_worker_args args) { + { + create(args.width, args.height, args.fullscreen); + init(); + } + run(); + } + + bool d3d_display::run() { + MSG msg = { 0 }; + + while (WM_QUIT != msg.message) { + if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else { + render(); + } + } + + return true; + } + + bool d3d_display::init() { + + std::lock_guard _lock(_render_lock); + + HRESULT hr = S_OK; + RECT rc; + + GetClientRect(_hWnd, &rc); + UINT width = rc.right - rc.left; + UINT height = rc.bottom - rc.top; + UINT createDeviceFlags = 0; +#ifdef _DEBUG + createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; +#endif + + D3D_DRIVER_TYPE driverTypes[] = + { + D3D_DRIVER_TYPE_HARDWARE, + D3D_DRIVER_TYPE_WARP, + D3D_DRIVER_TYPE_REFERENCE, + }; + UINT numDriverTypes = ARRAYSIZE(driverTypes); + + D3D_FEATURE_LEVEL featureLevels[] = + { + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + }; + UINT numFeatureLevels = ARRAYSIZE(featureLevels); + + DXGI_SWAP_CHAIN_DESC sd; + ZeroMemory(&sd, sizeof(sd)); + sd.BufferCount = 1; + sd.BufferDesc.Width = width; + sd.BufferDesc.Height = height; + sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + sd.BufferDesc.RefreshRate.Numerator = 60; + sd.BufferDesc.RefreshRate.Denominator = 1; + sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + sd.OutputWindow = _hWnd; + sd.SampleDesc.Count = 1; + sd.SampleDesc.Quality = 0; + sd.Windowed = _fullscreen ? FALSE : TRUE; + + for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++) + { + _driverType = driverTypes[driverTypeIndex]; + hr = D3D11CreateDeviceAndSwapChain(nullptr, _driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, + D3D11_SDK_VERSION, &sd, &_pSwapChain, &_pd3dDevice, &_featureLevel, &_pImmediateContext); + if (SUCCEEDED(hr)) + break; + } + if (FAILED(hr)) + return false; + + // Create a render target view + ID3D11Texture2D* pBackBuffer = nullptr; + hr = _pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer); + if (FAILED(hr)) + return false; + + hr = _pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &_pRenderTargetView); + pBackBuffer->Release(); + if (FAILED(hr)) + return false; + + // Create depth stencil texture + D3D11_TEXTURE2D_DESC descDepth; + ZeroMemory(&descDepth, sizeof(descDepth)); + descDepth.Width = width; + descDepth.Height = height; + descDepth.MipLevels = 1; + descDepth.ArraySize = 1; + descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + descDepth.SampleDesc.Count = 1; + descDepth.SampleDesc.Quality = 0; + descDepth.Usage = D3D11_USAGE_DEFAULT; + descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; + descDepth.CPUAccessFlags = 0; + descDepth.MiscFlags = 0; + hr = _pd3dDevice->CreateTexture2D(&descDepth, nullptr, &_pDepthStencil); + if (FAILED(hr)) + return false; + + // Create the depth stencil view + D3D11_DEPTH_STENCIL_VIEW_DESC descDSV; + ZeroMemory(&descDSV, sizeof(descDSV)); + descDSV.Format = descDepth.Format; + descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + descDSV.Texture2D.MipSlice = 0; + hr = _pd3dDevice->CreateDepthStencilView(_pDepthStencil, &descDSV, &_pDepthStencilView); + if (FAILED(hr)) + return false; + + _pImmediateContext->OMSetRenderTargets(1, &_pRenderTargetView, _pDepthStencilView); + + // Setup the viewport + D3D11_VIEWPORT vp; + vp.Width = (FLOAT)width; + vp.Height = (FLOAT)height; + vp.MinDepth = 0.0f; + vp.MaxDepth = 1.0f; + vp.TopLeftX = 0; + vp.TopLeftY = 0; + _pImmediateContext->RSSetViewports(1, &vp); + + XMStoreFloat4x4(&_World, XMMatrixIdentity()); + XMStoreFloat4x4(&_View, XMMatrixLookAtLH(XMLoadFloat4(&_camera.camPosition), XMLoadFloat4(&_camera.camTarget), XMLoadFloat4(&_camera.camUp))); + XMStoreFloat4x4(&_Projection, XMMatrixPerspectiveFovLH(XM_PIDIV4, width / (FLOAT)height, 0.01f, 100.0f)); + + init_input(); + + return true; + } + + bool d3d_display::init_input() { + RAWINPUTDEVICE Rid[2]; + + Rid[0].usUsagePage = 0x01; // magic numbers + Rid[0].usUsage = 0x02; // magically means mouse + Rid[0].dwFlags = 0; // (use this if you DO NOT WANT to capture mouse) + //Rid[0].dwFlags = RIDEV_CAPTUREMOUSE | RIDEV_NOLEGACY ; // (use this to CAPTURE MOUSE) + Rid[0].hwndTarget = _hWnd; + + Rid[1].usUsagePage = 0x01; // magic numbers + Rid[1].usUsage = 0x06; // magically means keyboard + Rid[1].dwFlags = 0; // use RIDEV_NOHOTKEYS for no winkey + Rid[1].hwndTarget = _hWnd; + + if (!RegisterRawInputDevices(Rid, 2, sizeof(Rid[0]))) { + LOG(ERROR) << "Could not register raw input devices. "; + exit(1); + } + } + + bool d3d_display::create(uint32_t width = 1024, uint32_t height = 768, bool fullscreen = false) { + std::lock_guard _lock(_render_lock); + + _fullscreen = fullscreen; + + WNDCLASSEXW wcex; + wcex.cbSize = sizeof(WNDCLASSEXW); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = (WNDPROC)&ace::debug::d3d_display::wndproc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = (HINSTANCE)GetCurrentProcess(); + //wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SAMPLE1); + //wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.lpszMenuName = nullptr; + wcex.lpszClassName = L"ACE3BaseDisplayClass"; + //wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SAMPLE1); + if (!RegisterClassExW(&wcex)) { + return false; + } + + // Create window + _hInst = (HINSTANCE)GetCurrentProcess(); + RECT rc = { 0, 0, width, height }; + AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); + _hWnd = CreateWindowW(L"ACE3BaseDisplayClass", L"ACE3 D3D Render", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, _hInst, + nullptr); + + if (!_hWnd) { + return false; + } + + // Attach our input to the master input + //AttachThreadInput(GetCurrentThreadId(), GetMainThraedId()); + + SetWindowLongPtr(_hWnd, GWLP_USERDATA, (LONG)this); + + ShowWindow(_hWnd, 5); + + return true; + } + + bool d3d_display::destroy() { + if (_pImmediateContext) _pImmediateContext->ClearState(); + + if (_pBatchInputLayout) _pBatchInputLayout->Release(); + + if (_pTextureRV1) _pTextureRV1->Release(); + if (_pTextureRV2) _pTextureRV2->Release(); + + if (_pDepthStencilView) _pDepthStencilView->Release(); + if (_pDepthStencil) _pDepthStencil->Release(); + if (_pRenderTargetView) _pRenderTargetView->Release(); + if (_pSwapChain) _pSwapChain->Release(); + if (_pImmediateContext) _pImmediateContext->Release(); + if (_pd3dDevice) _pd3dDevice->Release(); + + return true; + } + + bool d3d_display::render() { + // Update our time + static float t = 0.0f; + static float dt = 0.f; + if (_driverType == D3D_DRIVER_TYPE_REFERENCE) { + t += (float)XM_PI * 0.0125f; + } else { + static uint64_t dwTimeStart = 0; + static uint64_t dwTimeLast = 0; + uint64_t dwTimeCur = GetTickCount64(); + if (dwTimeStart == 0) + dwTimeStart = dwTimeCur; + t = (dwTimeCur - dwTimeStart) / 1000.0f; + dt = (dwTimeCur - dwTimeLast) / 1000.0f; + dwTimeLast = dwTimeCur; + } + + { + std::lock_guard _lock(_render_lock); + + _pImmediateContext->ClearRenderTargetView(_pRenderTargetView, Colors::MidnightBlue); + _pImmediateContext->ClearDepthStencilView(_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); + + update_camera(); + step(); + + _pSwapChain->Present(0, 0); + } + + return true; + } + + bool d3d_display::step() { + return true; + } + + void d3d_display::_move_camera(ace::vector3 direction) { + + } + void d3d_display::_rotate_camera(ace::vector3 direction) { + + } + void d3d_display::update_camera() { + XMVECTOR DefaultForward, DefaultRight, camPosition; + + DefaultForward = XMLoadFloat4(&_camera.DefaultForward); + DefaultRight = XMLoadFloat4(&_camera.DefaultRight); + camPosition = XMLoadFloat4(&_camera.camPosition); + + XMMATRIX camRotationMatrix = XMMatrixRotationRollPitchYaw(_camera.camPitch, _camera.camYaw, 0); + XMVECTOR camTarget = XMVector3TransformCoord(DefaultForward, camRotationMatrix); + camTarget = XMVector3Normalize(camTarget); + + XMVECTOR camRight = XMVector3TransformCoord(DefaultRight, camRotationMatrix); + XMVECTOR camForward = XMVector3TransformCoord(DefaultForward, camRotationMatrix); + XMVECTOR camUp = XMVector3Cross(camForward, camRight); + + camPosition += _camera.moveLeftRight * camRight; + camPosition += _camera.moveBackForward * camForward; + XMStoreFloat4(&_camera.camPosition, camPosition); + + _camera.moveLeftRight = 0.0f; + _camera.moveBackForward = 0.0f; + + camTarget = camPosition + camTarget; + + XMStoreFloat4x4(&_View, XMMatrixLookAtLH(camPosition, camTarget, camUp)); + } + + LRESULT CALLBACK d3d_display::_wndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + PAINTSTRUCT ps; + HDC hdc; + + switch (message) { + case WM_INPUT: { + UINT dwSize; + if (GetActiveWindow() != _hWnd) { + return DefWindowProc(hWnd, message, wParam, lParam); + } + GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, + sizeof(RAWINPUTHEADER)); + LPBYTE lpb = new BYTE[dwSize]; + if (lpb == NULL) { + return 0; + } + + int readSize = GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)); + + if (readSize != dwSize) + break; + + RAWINPUT* raw = (RAWINPUT*)lpb; + + float speed = 0.5f; + + if (raw->header.dwType == RIM_TYPEKEYBOARD) { + switch (raw->data.keyboard.VKey) { + case VK_SPACE: { + XMStoreFloat4(&_camera.camPosition, XMVectorSet(0, 0, 0, 0)); + break; + } + // Camera Movement + case 0x57: case VK_NUMPAD8: + case VK_UP: { + _camera.moveBackForward += speed; + break; + } + case 0x53: case VK_NUMPAD2: + case VK_DOWN: { + _camera.moveBackForward -= speed; + break; + } + case 0x41: case VK_NUMPAD4: + case VK_LEFT: { + _camera.moveLeftRight -= speed; + break; + } + case 0x44: case VK_NUMPAD6: + case VK_RIGHT: { + _camera.moveLeftRight += speed; + break; + } + // Numpad Movement + case VK_NUMPAD5: { + XMStoreFloat4(&_camera.camPosition, XMVectorSet(0, 0, 0, 0)); + break; + } + } + } + else if (raw->header.dwType == RIM_TYPEMOUSE) { + RAWMOUSE mouseCurrState = raw->data.mouse; + + if ((mouseCurrState.lLastX != _last_mouse_state.lLastY) || (mouseCurrState.lLastX != _last_mouse_state.lLastY)) + { + _camera.camYaw += mouseCurrState.lLastX * 0.005f; + _camera.camPitch += mouseCurrState.lLastY * 0.005f; + _last_mouse_state = mouseCurrState; + } + + } + + delete[] lpb; + return 0; + } + + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + break; + + case WM_DESTROY: + PostQuitMessage(0); + + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + + return 0; + } + LRESULT CALLBACK d3d_display::wndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + LONG data; + data = GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (data) { + return ((d3d_display*)data)->_wndproc(hWnd, message, wParam, lParam); + } else { + return DefWindowProc(hWnd, message, wParam, lParam); + } + } + }; + + +}; + +#endif \ No newline at end of file diff --git a/extensions/common/directx/d3d_display.hpp b/extensions/common/directx/d3d_display.hpp new file mode 100644 index 0000000000..b10e8ef070 --- /dev/null +++ b/extensions/common/directx/d3d_display.hpp @@ -0,0 +1,130 @@ +#pragma once + +#ifdef USE_DIRECTX + +#include +#include +#include +#include + +#include +#include +#include + +#include "singleton.hpp" +#include "vector.hpp" + +#define IDI_ACE_DEBUG 666 + +namespace ace { + namespace debug { + + __declspec(align(16)) + struct camera_movement { + camera_movement() { + XMStoreFloat4(&DefaultForward, DirectX::XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f)); + XMStoreFloat4(&DefaultRight, DirectX::XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f)); + XMStoreFloat4(&camForward, DirectX::XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f)); + XMStoreFloat4(&camRight, DirectX::XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f)); + + camYaw = 0.0f; + camPitch = 0.0f; + + moveLeftRight = 0.0f; + moveBackForward = 0.0f; + + XMStoreFloat4(&camPosition, DirectX::XMVectorSet(0.0f, 12.0f, 6.0f, 0.0f)); + XMStoreFloat4(&camTarget, DirectX::XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f)); + XMStoreFloat4(&camUp, DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f)); + } + + DirectX::XMFLOAT4 DefaultForward; + DirectX::XMFLOAT4 DefaultRight; + DirectX::XMFLOAT4 camForward; + DirectX::XMFLOAT4 camRight; + + DirectX::XMFLOAT4X4 camRotationMatrix; + DirectX::XMFLOAT4X4 groundWorld; + + float moveLeftRight; + float moveBackForward; + + float camYaw; + float camPitch; + + DirectX::XMFLOAT4 camPosition; + DirectX::XMFLOAT4 camTarget; + DirectX::XMFLOAT4 camUp; + }; + + struct d3d_display_worker; + struct d3d_display_worker_args; + __declspec(align(16)) + class d3d_display { + public: + d3d_display(); + ~d3d_display(); + + virtual bool run(); + virtual bool render(); + virtual bool render_thread(uint32_t, uint32_t, bool); + + virtual void update_camera(); + virtual bool step(); + + virtual bool create(uint32_t, uint32_t, bool); + virtual bool init(); + virtual bool init_input(); + + virtual bool destroy(); + + void render_worker(d3d_display_worker_args); + + static LRESULT CALLBACK wndproc(HWND, UINT, WPARAM, LPARAM); + LRESULT CALLBACK _wndproc(HWND, UINT, WPARAM, LPARAM); + protected: + void _move_camera(ace::vector3); + void _rotate_camera(ace::vector3); + + std::unique_ptr _render_thread; + std::mutex _render_lock; + + bool _fullscreen; + HINSTANCE _hInst = nullptr; + HWND _hWnd = nullptr; + D3D_DRIVER_TYPE _driverType = D3D_DRIVER_TYPE_NULL; + D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_11_0; + ID3D11Device* _pd3dDevice = nullptr; + ID3D11DeviceContext* _pImmediateContext = nullptr; + IDXGISwapChain* _pSwapChain = nullptr; + ID3D11RenderTargetView* _pRenderTargetView = nullptr; + ID3D11Texture2D* _pDepthStencil = nullptr; + ID3D11DepthStencilView* _pDepthStencilView = nullptr; + + ID3D11ShaderResourceView* _pTextureRV1 = nullptr; + ID3D11ShaderResourceView* _pTextureRV2 = nullptr; + ID3D11InputLayout* _pBatchInputLayout = nullptr; + + DirectX::XMFLOAT4X4 _World; + DirectX::XMFLOAT4X4 _View; + DirectX::XMFLOAT4X4 _Projection; + + RAWMOUSE _last_mouse_state; + camera_movement _camera; + + }; + struct d3d_display_worker_args { + d3d_display_worker_args(uint32_t w, uint32_t h, bool f) : width(w), height(h), fullscreen(f) {} + uint32_t width; + uint32_t height; + bool fullscreen; + }; + struct d3d_display_worker { + d3d_display_worker(d3d_display * obj, d3d_display_worker_args args) : thread(&ace::debug::d3d_display::render_worker, obj, args) {} + ~d3d_display_worker() { thread.join(); } + std::thread thread; + }; + }; +}; + +#endif \ No newline at end of file diff --git a/extensions/common/dispatch.hpp b/extensions/common/dispatch.hpp new file mode 100644 index 0000000000..0a37824b83 --- /dev/null +++ b/extensions/common/dispatch.hpp @@ -0,0 +1,153 @@ +#pragma once + +#include +#include +#include +#include + +#include "shared.hpp" +#include "arguments.hpp" +#include "singleton.hpp" + +namespace ace { + class dispatcher { + public: + dispatcher() : _ready(true) {} + + virtual bool call(const std::string & name_, const arguments & args_, std::string & result_) { + if (_methods.find(name_) == _methods.end()) { + // @TODO: Exceptions + return false; + } + return _methods[name_](args_, result_); + } + + bool add(const std::string & name_, std::function func_) { + if (_methods.find(name_) != _methods.end()) { + // @TODO: Exceptions + return false; + } + _methods[name_] = func_; + + return true; + } + + bool ready() const { return _ready; } + void ready(bool r) { _ready.exchange(r); } + protected: + std::unordered_map < std::string, std::function > _methods; + std::atomic_bool _ready; + }; + class dispatch : public dispatcher, public singleton { }; + + struct dispatch_message { + dispatch_message(const std::string & command_, const arguments & args_, const uint64_t id_) : command(command_), args(args_), id(id_) {} + std::string command; + arguments args; + uint64_t id; + }; + struct dispatch_result { + dispatch_result() {} + dispatch_result(const std::string &res, const uint64_t id_) : message(res), id(id_) {} + std::string message; + uint64_t id; + }; + + class threaded_dispatcher : public dispatcher { + public: + threaded_dispatcher() : _stop(false), _worker(&ace::threaded_dispatcher::monitor, this) { + + } + ~threaded_dispatcher() {} + + bool call(const std::string & name_, const arguments & args_, std::string & result_, bool threaded) { + if (_methods.find(name_) == _methods.end()) { + // @TODO: Exceptions + return false; + } + if (threaded) { + std::lock_guard lock(_messages_lock); + _messages.push(dispatch_message(name_, args_, _message_id)); + + // @TODO: We should provide an interface for this serialization. + std::stringstream ss; + ss << "[\"result_id\", \"" << _message_id << "\" ]"; + result_ = ss.str(); + + _message_id = _message_id + 1; + } else { +#ifdef _DEBUG + if (name_ != "fetch_result") { + LOG(TRACE) << "dispatch[immediate]:\t[" << name_ << "] { " << args_.get() << " }"; + } +#endif + return dispatcher::call(name_, args_, result_); + } + + return true; + } + bool call(const std::string & name_, const arguments & args_, std::string & result_) override { + return call(name_, args_, result_, false); + } + + void push_result(const dispatch_result & result) { + { + std::lock_guard lock(_results_lock); + _results.push(result); + } + } + void push_result(const std::string & result) { + push_result(dispatch_result(result, -1)); + } + void stop() { + std::lock_guard lock(_messages_lock); + _stop = true; + } + protected: + void monitor() { + _ready = false; + while (!_stop) { + { + std::lock_guard lock(_messages_lock); + while (!_messages.empty()) { + if (_ready) { + dispatch_result result; + dispatch_message _message = std::move(_messages.front()); + _messages.pop(); + + result.id = _message.id; + result.message.resize(4096); +#ifdef _DEBUG + if (_message.command != "fetch_result") { + LOG(TRACE) << "dispatch[threaded]:\t[" << _message.command << "]"; + if (_message.args.size() > 0) { + // LOG(TRACE) << "\t{ " << _messages.front().args.get() << " }"; + } + } +#endif + dispatcher::call(_message.command, _message.args, result.message); + { + std::lock_guard lock(_results_lock); + _results.push(result); + } + + + } + } + } + sleep(5); + } + } + std::atomic_bool _stop; + std::queue _results; + std::mutex _results_lock; + + std::queue _messages; + std::mutex _messages_lock; + + std::thread _worker; + + uint64_t _message_id; + }; + class threaded_dispatch : public threaded_dispatcher, public singleton { }; +}; \ No newline at end of file diff --git a/extensions/common/easyloggingc++.hpp b/extensions/common/easyloggingc++.hpp new file mode 100644 index 0000000000..3a5455c4d0 --- /dev/null +++ b/extensions/common/easyloggingc++.hpp @@ -0,0 +1,6718 @@ +// +// Easylogging++ v9.80 +// Single-header only, cross-platform logging library for C++ applications +// +// Copyright (c) 2015 muflihun.com +// +// This library is released under the MIT Licence. +// http://easylogging.muflihun.com/licence.php +// +// easylogging@muflihun.com +// +// https://github.com/easylogging/easyloggingpp +// http://easylogging.muflihun.com +// http://muflihun.com +// +#ifndef EASYLOGGINGPP_H +#define EASYLOGGINGPP_H +// Compilers and C++0x/C++11 Evaluation +#if defined(__GNUC__) +# define ELPP_COMPILER_GCC 1 +# define ELPP_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +# if defined(__GXX_EXPERIMENTAL_CXX0X__) +# define ELPP_CXX0X 1 +# elif(ELPP_GCC_VERSION >= 40801) +# define ELPP_CXX11 1 +# endif // defined(__GXX_EXPERIMENTAL_CXX0X__) +#endif // defined(__GNUC__) +// Visual C++ +#if defined(_MSC_VER) +# define ELPP_COMPILER_MSVC 1 +# define ELPP_CRT_DBG_WARNINGS 1 +# if (_MSC_VER == 1600) +# define ELPP_CXX0X 1 +# elif(_MSC_VER >= 1700) +# define ELPP_CXX11 1 +# endif // (_MSC_VER == 1600) +#endif // defined(_MSC_VER) +// Clang++ +#if defined(__clang__) && (__clang__ == 1) +# define ELPP_COMPILER_CLANG 1 +# define ELPP_CLANG_VERSION (__clang_major__ * 10000 \ + + __clang_minor__ * 100 \ + + __clang_patchlevel__) +# if (ELPP_CLANG_VERSION >= 30300) +# define ELPP_CXX11 1 +# endif // (ELPP_CLANG_VERSION >= 30300) +#endif // defined(__clang__) && (__clang__ == 1) +// MinGW +#if defined(__MINGW32__) || defined(__MINGW64__) +# define ELPP_MINGW 1 +#endif // defined(__MINGW32__) || defined(__MINGW64__) +// Cygwin +#if defined(__CYGWIN__) && (__CYGWIN__ == 1) +# define ELPP_CYGWIN 1 +#endif // defined(__CYGWIN__) && (__CYGWIN__ == 1) +// Intel C++ +#if defined(__INTEL_COMPILER) +# define ELPP_COMPILER_INTEL 1 +#endif +// Operating System Evaluation +// Windows +#if defined(_WIN32) || defined(_WIN64) +# define ELPP_OS_WINDOWS 1 +#endif // defined(_WIN32) || defined(_WIN64) +// Linux +#if (defined(__linux) || defined(__linux__)) +# define ELPP_OS_LINUX 1 +#endif // (defined(__linux) || defined(__linux__)) +// Mac +#if defined(__APPLE__) +# define ELPP_OS_MAC 1 +#endif // defined(__APPLE__) +// FreeBSD +#if defined(__FreeBSD__) +# define ELPP_OS_FREEBSD 1 +#endif +// Solaris +#if defined(__sun) +# define ELPP_OS_SOLARIS 1 +#endif +// Unix +#if ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_SOLARIS) && (!ELPP_OS_WINDOWS)) +# define ELPP_OS_UNIX 1 +#endif // ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_SOLARIS) && (!ELPP_OS_WINDOWS)) +// Android +#if defined(__ANDROID__) +# define ELPP_OS_ANDROID 1 +#endif // defined(__ANDROID__) +// Evaluating Cygwin as *nix OS +#if !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN +# undef ELPP_OS_UNIX +# undef ELPP_OS_LINUX +# define ELPP_OS_UNIX 1 +# define ELPP_OS_LINUX 1 +#endif // !ELPP_OS_UNIX && !ELPP_OS_WINDOWS && ELPP_CYGWIN +#if !defined(ELPP_INTERNAL_DEBUGGING_OUT_INFO) +# define ELPP_INTERNAL_DEBUGGING_OUT_INFO std::cout +#endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) +#if !defined(ELPP_INTERNAL_DEBUGGING_OUT_ERROR) +# define ELPP_INTERNAL_DEBUGGING_OUT_ERROR std::cerr +#endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) +#if !defined(ELPP_INTERNAL_DEBUGGING_ENDL) +# define ELPP_INTERNAL_DEBUGGING_ENDL std::endl +#endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) +#if !defined(ELPP_INTERNAL_DEBUGGING_MSG) +# define ELPP_INTERNAL_DEBUGGING_MSG(msg) msg +#endif // !defined(ELPP_INTERNAL_DEBUGGING_OUT) +// Internal Assertions and errors +#if !defined(ELPP_DISABLE_ASSERT) +# if (defined(ELPP_DEBUG_ASSERT_FAILURE)) +# define ELPP_ASSERT(expr, msg) if (!(expr)) { \ + std::stringstream internalInfoStream; internalInfoStream << msg; \ + ELPP_INTERNAL_DEBUGGING_OUT_ERROR \ + << "EASYLOGGING++ ASSERTION FAILED (LINE: " << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" \ + << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" << ELPP_INTERNAL_DEBUGGING_ENDL; base::utils::abort(1, \ + "ELPP Assertion failure, please define ELPP_DEBUG_ASSERT_FAILURE"); } +# else +# define ELPP_ASSERT(expr, msg) if (!(expr)) { \ + std::stringstream internalInfoStream; internalInfoStream << msg; \ + ELPP_INTERNAL_DEBUGGING_OUT_ERROR\ + << "ASSERTION FAILURE FROM EASYLOGGING++ (LINE: " \ + << __LINE__ << ") [" #expr << "] WITH MESSAGE \"" << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << "\"" \ + << ELPP_INTERNAL_DEBUGGING_ENDL; } +# endif // (defined(ELPP_DEBUG_ASSERT_FAILURE)) +#else +# define ELPP_ASSERT(x, y) +#endif //(!defined(ELPP_DISABLE_ASSERT) +#if ELPP_COMPILER_MSVC +# define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \ + { char buff[256]; strerror_s(buff, 256, errno); \ + ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << buff << " [" << errno << "]";} (void)0 +#else +# define ELPP_INTERNAL_DEBUGGING_WRITE_PERROR \ + ELPP_INTERNAL_DEBUGGING_OUT_ERROR << ": " << strerror(errno) << " [" << errno << "]"; (void)0 +#endif // ELPP_COMPILER_MSVC +#if defined(ELPP_DEBUG_ERRORS) +# if !defined(ELPP_INTERNAL_ERROR) +# define ELPP_INTERNAL_ERROR(msg, pe) { \ + std::stringstream internalInfoStream; internalInfoStream << " " << msg; \ + ELPP_INTERNAL_DEBUGGING_OUT_ERROR \ + << "ERROR FROM EASYLOGGING++ (LINE: " << __LINE__ << ") " \ + << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) << ELPP_INTERNAL_DEBUGGING_ENDL; \ + if (pe) { ELPP_INTERNAL_DEBUGGING_OUT_ERROR << " "; ELPP_INTERNAL_DEBUGGING_WRITE_PERROR; }} (void)0 +# endif +#else +# undef ELPP_INTERNAL_INFO +# define ELPP_INTERNAL_ERROR(msg, pe) +#endif // defined(ELPP_DEBUG_ERRORS) +#if (defined(ELPP_DEBUG_INFO)) +# if !(defined(ELPP_INTERNAL_INFO_LEVEL)) +# define ELPP_INTERNAL_INFO_LEVEL 9 +# endif // !(defined(ELPP_INTERNAL_INFO_LEVEL)) +# if !defined(ELPP_INTERNAL_INFO) +# define ELPP_INTERNAL_INFO(lvl, msg) { if (lvl <= ELPP_INTERNAL_INFO_LEVEL) { \ + std::stringstream internalInfoStream; internalInfoStream << " " << msg; \ + ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStream.str()) \ + << ELPP_INTERNAL_DEBUGGING_ENDL; }} +# endif +#else +# undef ELPP_INTERNAL_INFO +# define ELPP_INTERNAL_INFO(lvl, msg) +#endif // (defined(ELPP_DEBUG_INFO)) +#if defined(ELPP_STACKTRACE_ON_CRASH) +# if (ELPP_COMPILER_GCC && !ELPP_MINGW) +# define ELPP_STACKTRACE 1 +# else +# if ELPP_COMPILER_MSVC +# pragma message("Stack trace not available for this compiler") +# else +# warning "Stack trace not available for this compiler"; +# endif // ELPP_COMPILER_MSVC +# endif // ELPP_COMPILER_GCC +#endif // (defined(ELPP_STACKTRACE_ON_CRASH)) +// Miscellaneous macros +#define ELPP_UNUSED(x) (void)x +#if ELPP_OS_UNIX +// Log file permissions for unix-based systems +# define ELPP_LOG_PERMS S_IRUSR | S_IWUSR | S_IXUSR | S_IWGRP | S_IRGRP | S_IXGRP | S_IWOTH | S_IXOTH +#endif // ELPP_OS_UNIX +#if defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC +# if defined(ELPP_EXPORT_SYMBOLS) +# define ELPP_EXPORT __declspec(dllexport) +# else +# define ELPP_EXPORT __declspec(dllimport) +# endif // defined(ELPP_EXPORT_SYMBOLS) +#else +# define ELPP_EXPORT +#endif // defined(ELPP_AS_DLL) && ELPP_COMPILER_MSVC +// Some special functions that are VC++ specific +#undef STRTOK +#undef STRERROR +#undef STRCAT +#undef STRCPY +#if ELPP_CRT_DBG_WARNINGS +# define STRTOK(a, b, c) strtok_s(a, b, c) +# define STRERROR(a, b, c) strerror_s(a, b, c) +# define STRCAT(a, b, len) strcat_s(a, len, b) +# define STRCPY(a, b, len) strcpy_s(a, len, b) +#else +# define STRTOK(a, b, c) strtok(a, b) +# define STRERROR(a, b, c) strerror(c) +# define STRCAT(a, b, len) strcat(a, b) +# define STRCPY(a, b, len) strcpy(a, b) +#endif +// Compiler specific support evaluations +#if (!ELPP_MINGW && !ELPP_COMPILER_CLANG) || defined(ELPP_FORCE_USE_STD_THREAD) +# define ELPP_USE_STD_THREADING 1 +#endif // (!ELPP_MINGW && !ELPP_COMPILER_CLANG) || defined(ELPP_FORCE_USE_STD_THREAD) +#undef ELPP_FINAL +#if ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702) +# define ELPP_FINAL +#else +# define ELPP_FINAL final +#endif // ELPP_COMPILER_INTEL || (ELPP_GCC_VERSION < 40702) +#if defined(ELPP_EXPERIMENTAL_ASYNC) +# define ELPP_ASYNC_LOGGING 1 +#else +# define ELPP_ASYNC_LOGGING 0 +#endif // defined(ELPP_EXPERIMENTAL_ASYNC) +#if defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING +# define ELPP_THREADING_ENABLED 1 +#endif // defined(ELPP_THREAD_SAFE) || ELPP_ASYNC_LOGGING +// Function macro ELPP_FUNC +#undef ELPP_FUNC +#if ELPP_COMPILER_MSVC // Visual C++ +# define ELPP_FUNC __FUNCSIG__ +#elif ELPP_COMPILER_GCC // GCC +# define ELPP_FUNC __PRETTY_FUNCTION__ +#elif ELPP_COMPILER_INTEL // Intel C++ +# define ELPP_FUNC __PRETTY_FUNCTION__ +#elif ELPP_COMPILER_CLANG // Clang++ +# define ELPP_FUNC __PRETTY_FUNCTION__ +#else +# if defined(__func__) +# define ELPP_FUNC __func__ +# else +# define ELPP_FUNC "" +# endif // defined(__func__) +#endif // defined(_MSC_VER) +#undef ELPP_VARIADIC_TEMPLATES_SUPPORTED +// Keep following line commented until features are fixed +#if ELPP_COMPILER_GCC || ELPP_COMPILER_CLANG || ELPP_COMPILER_INTEL || (ELPP_COMPILER_MSVC && _MSC_VER >= 1800) +# define ELPP_VARIADIC_TEMPLATES_SUPPORTED 1 +#endif // ELPP_COMPILER_GCC || ELPP_COMPILER_CLANG || ELPP_COMPILER_INTEL || (ELPP_COMPILER_MSVC && _MSC_VER >= 1800) +// Logging Enable/Disable macros +#if (!defined(ELPP_DISABLE_LOGS)) +# define ELPP_LOGGING_ENABLED 1 +#endif // (!defined(ELPP_DISABLE_LOGS)) +#if (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED) && ((defined(_DEBUG)) || (!defined(NDEBUG)))) +# define ELPP_DEBUG_LOG 1 +#else +# define ELPP_DEBUG_LOG 0 +#endif // (!defined(ELPP_DISABLE_DEBUG_LOGS) && (ELPP_LOGGING_ENABLED) && ((defined(_DEBUG)) || (!defined(NDEBUG)))) +#if (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED)) +# define ELPP_INFO_LOG 1 +#else +# define ELPP_INFO_LOG 0 +#endif // (!defined(ELPP_DISABLE_INFO_LOGS) && (ELPP_LOGGING_ENABLED)) +#if (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED)) +# define ELPP_WARNING_LOG 1 +#else +# define ELPP_WARNING_LOG 0 +#endif // (!defined(ELPP_DISABLE_WARNING_LOGS) && (ELPP_LOGGING_ENABLED)) +#if (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED)) +# define ELPP_ERROR_LOG 1 +#else +# define ELPP_ERROR_LOG 0 +#endif // (!defined(ELPP_DISABLE_ERROR_LOGS) && (ELPP_LOGGING_ENABLED)) +#if (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED)) +# define ELPP_FATAL_LOG 1 +#else +# define ELPP_FATAL_LOG 0 +#endif // (!defined(ELPP_DISABLE_FATAL_LOGS) && (ELPP_LOGGING_ENABLED)) +#if (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED)) +# define ELPP_TRACE_LOG 1 +#else +# define ELPP_TRACE_LOG 0 +#endif // (!defined(ELPP_DISABLE_TRACE_LOGS) && (ELPP_LOGGING_ENABLED)) +#if (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED)) +# define ELPP_VERBOSE_LOG 1 +#else +# define ELPP_VERBOSE_LOG 0 +#endif // (!defined(ELPP_DISABLE_VERBOSE_LOGS) && (ELPP_LOGGING_ENABLED)) +#if (!(ELPP_CXX0X || ELPP_CXX11)) +# error "Easylogging++ 9.0+ is only compatible with C++0x (or higher) compliant compiler" +#endif // (!(ELPP_CXX0X || ELPP_CXX11)) +// Headers +#if defined(ELPP_SYSLOG) +# include +#endif // defined(ELPP_SYSLOG) +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(ELPP_UNICODE) +# include +# if ELPP_OS_WINDOWS +# include +# endif // ELPP_OS_WINDOWS +#endif // defined(ELPP_UNICODE) +#if ELPP_STACKTRACE +# include +# include +#endif // ELPP_STACKTRACE +#if ELPP_OS_ANDROID +# include +#endif // ELPP_OS_ANDROID +#if ELPP_OS_UNIX +# include +# include +#elif ELPP_OS_WINDOWS +# include +# include +# if defined(WIN32_LEAN_AND_MEAN) +# if defined(ELPP_WINSOCK2) +# include +# else +# include +# endif // defined(ELPP_WINSOCK2) +# endif // defined(WIN32_LEAN_AND_MEAN) +#endif // ELPP_OS_UNIX +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if ELPP_THREADING_ENABLED +# if ELPP_USE_STD_THREADING +# include +# include +# else +# if ELPP_OS_UNIX +# include +# endif // ELPP_OS_UNIX +# endif // ELPP_USE_STD_THREADING +#endif // ELPP_THREADING_ENABLED +#if ELPP_ASYNC_LOGGING +# include +# include +# include +#endif // ELPP_ASYNC_LOGGING +#if defined(ELPP_STL_LOGGING) +// For logging STL based templates +# include +# include +# include +# include +# include +# include +# if defined(ELPP_LOG_STD_ARRAY) +# include +# endif // defined(ELPP_LOG_STD_ARRAY) +# if defined(ELPP_LOG_UNORDERED_MAP) +# include +# endif // defined(ELPP_LOG_UNORDERED_MAP) +# if defined(ELPP_LOG_UNORDERED_SET) +# include +# endif // defined(ELPP_UNORDERED_SET) +#endif // defined(ELPP_STL_LOGGING) +#if defined(ELPP_QT_LOGGING) +// For logging Qt based classes & templates +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif // defined(ELPP_QT_LOGGING) +#if defined(ELPP_BOOST_LOGGING) +// For logging boost based classes & templates +# include +# include +# include +# include +# include +# include +# include +# include +#endif // defined(ELPP_BOOST_LOGGING) +#if defined(ELPP_WXWIDGETS_LOGGING) +// For logging wxWidgets based classes & templates +# include +#endif // defined(ELPP_WXWIDGETS_LOGGING) +// Forward declarations +namespace el { + class Logger; + class LogMessage; + class PerformanceTrackingData; + class Loggers; + class Helpers; + template class Callback; + class LogDispatchCallback; + class PerformanceTrackingCallback; + class LogDispatchData; + namespace base { + class Storage; + class RegisteredLoggers; + class PerformanceTracker; + class MessageBuilder; + class Writer; + class PErrorWriter; + class LogDispatcher; + class DefaultLogBuilder; + class DefaultLogDispatchCallback; +#if ELPP_ASYNC_LOGGING + class AsyncLogDispatchCallback; + class AsyncDispatchWorker; +#endif // ELPP_ASYNC_LOGGING + class DefaultPerformanceTrackingCallback; + } // namespace base +} // namespace el + /// @brief Easylogging++ entry namespace +namespace el { + /// @brief Namespace containing base/internal functionality used by Easylogging++ + namespace base { + /// @brief Data types used by Easylogging++ + namespace type { +#undef ELPP_LITERAL +#undef ELPP_STRLEN +#undef ELPP_COUT +#if defined(ELPP_UNICODE) +# define ELPP_LITERAL(txt) L##txt +# define ELPP_STRLEN wcslen +# if defined ELPP_CUSTOM_COUT +# define ELPP_COUT ELPP_CUSTOM_COUT +# else +# define ELPP_COUT std::wcout +# endif // defined ELPP_CUSTOM_COUT + typedef wchar_t char_t; + typedef std::wstring string_t; + typedef std::wstringstream stringstream_t; + typedef std::wfstream fstream_t; + typedef std::wostream ostream_t; +#else +# define ELPP_LITERAL(txt) txt +# define ELPP_STRLEN strlen +# if defined ELPP_CUSTOM_COUT +# define ELPP_COUT ELPP_CUSTOM_COUT +# else +# define ELPP_COUT std::cout +# endif // defined ELPP_CUSTOM_COUT + typedef char char_t; + typedef std::string string_t; + typedef std::stringstream stringstream_t; + typedef std::fstream fstream_t; + typedef std::ostream ostream_t; +#endif // defined(ELPP_UNICODE) +#if defined(ELPP_CUSTOM_COUT_LINE) +# define ELPP_COUT_LINE(logLine) ELPP_CUSTOM_COUT_LINE(logLine) +#else +# define ELPP_COUT_LINE(logLine) logLine << std::flush +#endif // defined(ELPP_CUSTOM_COUT_LINE) + typedef unsigned short EnumType; + typedef std::shared_ptr StoragePointer; + typedef int VerboseLevel; + typedef std::shared_ptr LogDispatchCallbackPtr; + typedef std::shared_ptr PerformanceTrackingCallbackPtr; + } // namespace type + /// @brief Internal helper class that prevent copy constructor for class + /// + /// @detail When using this class simply inherit it privately + class NoCopy { + protected: + NoCopy(void) {} + private: + NoCopy(const NoCopy&); + NoCopy& operator=(const NoCopy&); + }; + /// @brief Internal helper class that makes all default constructors private. + /// + /// @detail This prevents initializing class making it static unless an explicit constructor is declared. + /// When using this class simply inherit it privately + class StaticClass { + private: + StaticClass(void); + StaticClass(const StaticClass&); + StaticClass& operator=(const StaticClass&); + }; + } // namespace base + /// @brief Represents enumeration for severity level used to determine level of logging + /// + /// @detail With Easylogging++, developers may disable or enable any level regardless of + /// what the severity is. Or they can choose to log using hierarchical logging flag + enum class Level : base::type::EnumType { + /// @brief Generic level that represents all the levels. Useful when setting global configuration for all levels + Global = 1, + /// @brief Information that can be useful to back-trace certain events - mostly useful than debug logs. + Trace = 2, + /// @brief Informational events most useful for developers to debug application + Debug = 4, + /// @brief Severe error information that will presumably abort application + Fatal = 8, + /// @brief Information representing errors in application but application will keep running + Error = 16, + /// @brief Useful when application has potentially harmful situtaions + Warning = 32, + /// @brief Information that can be highly useful and vary with verbose logging level. + Verbose = 64, + /// @brief Mainly useful to represent current progress of application + Info = 128, + /// @brief Represents unknown level + Unknown = 1010 + }; + /// @brief Static class that contains helper functions for el::Level + class LevelHelper : base::StaticClass { + public: + /// @brief Represents minimum valid level. Useful when iterating through enum. + static const base::type::EnumType kMinValid = static_cast(Level::Trace); + /// @brief Represents maximum valid level. This is used internally and you should not need it. + static const base::type::EnumType kMaxValid = static_cast(Level::Info); + /// @brief Casts level to int, useful for iterating through enum. + static base::type::EnumType castToInt(Level level) { + return static_cast(level); + } + /// @brief Casts int(ushort) to level, useful for iterating through enum. + static Level castFromInt(base::type::EnumType l) { + return static_cast(l); + } + /// @brief Converts level to associated const char* + /// @return Upper case string based level. + static const char* convertToString(Level level) { + // Do not use switch over strongly typed enums because Intel C++ compilers dont support them yet. + if (level == Level::Global) return "GLOBAL"; + if (level == Level::Debug) return "DEBUG"; + if (level == Level::Info) return "INFO"; + if (level == Level::Warning) return "WARNING"; + if (level == Level::Error) return "ERROR"; + if (level == Level::Fatal) return "FATAL"; + if (level == Level::Verbose) return "VERBOSE"; + if (level == Level::Trace) return "TRACE"; + return "UNKNOWN"; + } + /// @brief Converts from levelStr to Level + /// @param levelStr Upper case string based level. + /// Lower case is also valid but providing upper case is recommended. + static Level convertFromString(const char* levelStr) { + if ((strcmp(levelStr, "GLOBAL") == 0) || (strcmp(levelStr, "global") == 0)) + return Level::Global; + if ((strcmp(levelStr, "DEBUG") == 0) || (strcmp(levelStr, "debug") == 0)) + return Level::Debug; + if ((strcmp(levelStr, "INFO") == 0) || (strcmp(levelStr, "info") == 0)) + return Level::Info; + if ((strcmp(levelStr, "WARNING") == 0) || (strcmp(levelStr, "warning") == 0)) + return Level::Warning; + if ((strcmp(levelStr, "ERROR") == 0) || (strcmp(levelStr, "error") == 0)) + return Level::Error; + if ((strcmp(levelStr, "FATAL") == 0) || (strcmp(levelStr, "fatal") == 0)) + return Level::Fatal; + if ((strcmp(levelStr, "VERBOSE") == 0) || (strcmp(levelStr, "verbose") == 0)) + return Level::Verbose; + if ((strcmp(levelStr, "TRACE") == 0) || (strcmp(levelStr, "trace") == 0)) + return Level::Trace; + return Level::Unknown; + } + /// @brief Applies specified function to each level starting from startIndex + /// @param startIndex initial value to start the iteration from. This is passed as pointer and + /// is left-shifted so this can be used inside function (fn) to represent current level. + /// @param fn function to apply with each level. This bool represent whether or not to stop iterating through levels. + static inline void forEachLevel(base::type::EnumType* startIndex, const std::function& fn) { + base::type::EnumType lIndexMax = LevelHelper::kMaxValid; + do { + if (fn()) { + break; + } + *startIndex = static_cast(*startIndex << 1); + } while (*startIndex <= lIndexMax); + } + }; + /// @brief Represents enumeration of ConfigurationType used to configure or access certain aspect + /// of logging + enum class ConfigurationType : base::type::EnumType { + /// @brief Determines whether or not corresponding level and logger of logging is enabled + /// You may disable all logs by using el::Level::Global + Enabled = 1, + /// @brief Whether or not to write corresponding log to log file + ToFile = 2, + /// @brief Whether or not to write corresponding level and logger log to standard output. + /// By standard output meaning termnal, command prompt etc + ToStandardOutput = 4, + /// @brief Determines format of logging corresponding level and logger. + Format = 8, + /// @brief Determines log file (full path) to write logs to for correponding level and logger + Filename = 16, + /// @brief Specifies milliseconds width. Width can be within range (1-6) + MillisecondsWidth = 32, + /// @brief Determines whether or not performance tracking is enabled. + /// + /// @detail This does not depend on logger or level. Performance tracking always uses 'performance' logger + PerformanceTracking = 64, + /// @brief Specifies log file max size. + /// + /// @detail If file size of corresponding log file (for corresponding level) is >= specified size, log file will + /// be truncated and re-initiated. + MaxLogFileSize = 128, + /// @brief Specifies number of log entries to hold until we flush pending log data + LogFlushThreshold = 256, + /// @brief Represents unknown configuration + Unknown = 1010 + }; + /// @brief Static class that contains helper functions for el::ConfigurationType + class ConfigurationTypeHelper : base::StaticClass { + public: + /// @brief Represents minimum valid configuration type. Useful when iterating through enum. + static const base::type::EnumType kMinValid = static_cast(ConfigurationType::Enabled); + /// @brief Represents maximum valid configuration type. This is used internally and you should not need it. + static const base::type::EnumType kMaxValid = static_cast(ConfigurationType::MaxLogFileSize); + /// @brief Casts configuration type to int, useful for iterating through enum. + static base::type::EnumType castToInt(ConfigurationType configurationType) { + return static_cast(configurationType); + } + /// @brief Casts int(ushort) to configurationt type, useful for iterating through enum. + static ConfigurationType castFromInt(base::type::EnumType c) { + return static_cast(c); + } + /// @brief Converts configuration type to associated const char* + /// @returns Upper case string based configuration type. + static const char* convertToString(ConfigurationType configurationType) { + // Do not use switch over strongly typed enums because Intel C++ compilers dont support them yet. + if (configurationType == ConfigurationType::Enabled) return "ENABLED"; + if (configurationType == ConfigurationType::Filename) return "FILENAME"; + if (configurationType == ConfigurationType::Format) return "FORMAT"; + if (configurationType == ConfigurationType::ToFile) return "TO_FILE"; + if (configurationType == ConfigurationType::ToStandardOutput) return "TO_STANDARD_OUTPUT"; + if (configurationType == ConfigurationType::MillisecondsWidth) return "MILLISECONDS_WIDTH"; + if (configurationType == ConfigurationType::PerformanceTracking) return "PERFORMANCE_TRACKING"; + if (configurationType == ConfigurationType::MaxLogFileSize) return "MAX_LOG_FILE_SIZE"; + if (configurationType == ConfigurationType::LogFlushThreshold) return "LOG_FLUSH_THRESHOLD"; + return "UNKNOWN"; + } + /// @brief Converts from configStr to ConfigurationType + /// @param configStr Upper case string based configuration type. + /// Lower case is also valid but providing upper case is recommended. + static ConfigurationType convertFromString(const char* configStr) { + if ((strcmp(configStr, "ENABLED") == 0) || (strcmp(configStr, "enabled") == 0)) + return ConfigurationType::Enabled; + if ((strcmp(configStr, "TO_FILE") == 0) || (strcmp(configStr, "to_file") == 0)) + return ConfigurationType::ToFile; + if ((strcmp(configStr, "TO_STANDARD_OUTPUT") == 0) || (strcmp(configStr, "to_standard_output") == 0)) + return ConfigurationType::ToStandardOutput; + if ((strcmp(configStr, "FORMAT") == 0) || (strcmp(configStr, "format") == 0)) + return ConfigurationType::Format; + if ((strcmp(configStr, "FILENAME") == 0) || (strcmp(configStr, "filename") == 0)) + return ConfigurationType::Filename; + if ((strcmp(configStr, "MILLISECONDS_WIDTH") == 0) || (strcmp(configStr, "milliseconds_width") == 0)) + return ConfigurationType::MillisecondsWidth; + if ((strcmp(configStr, "PERFORMANCE_TRACKING") == 0) || (strcmp(configStr, "performance_tracking") == 0)) + return ConfigurationType::PerformanceTracking; + if ((strcmp(configStr, "MAX_LOG_FILE_SIZE") == 0) || (strcmp(configStr, "max_log_file_size") == 0)) + return ConfigurationType::MaxLogFileSize; + if ((strcmp(configStr, "LOG_FLUSH_THRESHOLD") == 0) || (strcmp(configStr, "log_flush_threshold") == 0)) + return ConfigurationType::LogFlushThreshold; + return ConfigurationType::Unknown; + } + /// @brief Applies specified function to each configuration type starting from startIndex + /// @param startIndex initial value to start the iteration from. This is passed by pointer and is left-shifted + /// so this can be used inside function (fn) to represent current configuration type. + /// @param fn function to apply with each configuration type. + /// This bool represent whether or not to stop iterating through configurations. + static inline void forEachConfigType(base::type::EnumType* startIndex, const std::function& fn) { + base::type::EnumType cIndexMax = ConfigurationTypeHelper::kMaxValid; + do { + if (fn()) { + break; + } + *startIndex = static_cast(*startIndex << 1); + } while (*startIndex <= cIndexMax); + } + }; + /// @brief Flags used while writing logs. This flags are set by user + enum class LoggingFlag : base::type::EnumType { + /// @brief Makes sure we have new line for each container log entry + NewLineForContainer = 1, + /// @brief Makes sure if -vmodule is used and does not specifies a module, then verbose + /// logging is allowed via that module. + AllowVerboseIfModuleNotSpecified = 2, + /// @brief When handling crashes by default, detailed crash reason will be logged as well + LogDetailedCrashReason = 4, + /// @brief Allows to disable application abortion when logged using FATAL level + DisableApplicationAbortOnFatalLog = 8, + /// @brief Flushes log with every log-entry (performance sensative) - Disabled by default + ImmediateFlush = 16, + /// @brief Enables strict file rolling + StrictLogFileSizeCheck = 32, + /// @brief Make terminal output colorful for supported terminals + ColoredTerminalOutput = 64, + /// @brief Supports use of multiple logging in same macro, e.g, CLOG(INFO, "default", "network") + MultiLoggerSupport = 128, + /// @brief Disables comparing performance tracker's checkpoints + DisablePerformanceTrackingCheckpointComparison = 256, + /// @brief Disable VModules + DisableVModules = 512, + /// @brief Disable VModules extensions + DisableVModulesExtensions = 1024, + /// @brief Enables hierarchical logging + HierarchicalLogging = 2048, + /// @brief Creates logger automatically when not available + CreateLoggerAutomatically = 4096, + /// @brief Adds spaces b/w logs that separated by left-shift operator + AutoSpacing = 8192, + /// @brief Preserves time format and does not convert it to sec, hour etc (performance tracking only) + FixedTimeFormat = 16384 + }; + namespace base { + /// @brief Namespace containing constants used internally. + namespace consts { + // Level log values - These are values that are replaced in place of %level format specifier + static const base::type::char_t* kInfoLevelLogValue = ELPP_LITERAL("INFO "); + static const base::type::char_t* kDebugLevelLogValue = ELPP_LITERAL("DEBUG"); + static const base::type::char_t* kWarningLevelLogValue = ELPP_LITERAL("WARN "); + static const base::type::char_t* kErrorLevelLogValue = ELPP_LITERAL("ERROR"); + static const base::type::char_t* kFatalLevelLogValue = ELPP_LITERAL("FATAL"); + static const base::type::char_t* kVerboseLevelLogValue = ELPP_LITERAL("VER"); + static const base::type::char_t* kTraceLevelLogValue = ELPP_LITERAL("TRACE"); + static const base::type::char_t* kInfoLevelShortLogValue = ELPP_LITERAL("I"); + static const base::type::char_t* kDebugLevelShortLogValue = ELPP_LITERAL("D"); + static const base::type::char_t* kWarningLevelShortLogValue = ELPP_LITERAL("W"); + static const base::type::char_t* kErrorLevelShortLogValue = ELPP_LITERAL("E"); + static const base::type::char_t* kFatalLevelShortLogValue = ELPP_LITERAL("F"); + static const base::type::char_t* kVerboseLevelShortLogValue = ELPP_LITERAL("V"); + static const base::type::char_t* kTraceLevelShortLogValue = ELPP_LITERAL("T"); + // Format specifiers - These are used to define log format + static const base::type::char_t* kAppNameFormatSpecifier = ELPP_LITERAL("%app"); + static const base::type::char_t* kLoggerIdFormatSpecifier = ELPP_LITERAL("%logger"); + static const base::type::char_t* kThreadIdFormatSpecifier = ELPP_LITERAL("%thread"); + static const base::type::char_t* kSeverityLevelFormatSpecifier = ELPP_LITERAL("%level"); + static const base::type::char_t* kSeverityLevelShortFormatSpecifier = ELPP_LITERAL("%levshort"); + static const base::type::char_t* kDateTimeFormatSpecifier = ELPP_LITERAL("%datetime"); + static const base::type::char_t* kLogFileFormatSpecifier = ELPP_LITERAL("%file"); + static const base::type::char_t* kLogFileBaseFormatSpecifier = ELPP_LITERAL("%fbase"); + static const base::type::char_t* kLogLineFormatSpecifier = ELPP_LITERAL("%line"); + static const base::type::char_t* kLogLocationFormatSpecifier = ELPP_LITERAL("%loc"); + static const base::type::char_t* kLogFunctionFormatSpecifier = ELPP_LITERAL("%func"); + static const base::type::char_t* kCurrentUserFormatSpecifier = ELPP_LITERAL("%user"); + static const base::type::char_t* kCurrentHostFormatSpecifier = ELPP_LITERAL("%host"); + static const base::type::char_t* kMessageFormatSpecifier = ELPP_LITERAL("%msg"); + static const base::type::char_t* kVerboseLevelFormatSpecifier = ELPP_LITERAL("%vlevel"); + static const char* kDateTimeFormatSpecifierForFilename = "%datetime"; + // Date/time + static const char* kDays[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; + static const char* kDaysAbbrev[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + static const char* kMonths[12] = { "January", "February", "March", "Apri", "May", "June", "July", "August", + "September", "October", "November", "December" }; + static const char* kMonthsAbbrev[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + static const char* kDefaultDateTimeFormat = "%Y-%M-%d %H:%m:%s,%g"; + static const char* kDefaultDateTimeFormatInFilename = "%Y-%M-%d_%H-%m"; + static const int kYearBase = 1900; + static const char* kAm = "AM"; + static const char* kPm = "PM"; + // Miscellaneous constants + static const char* kDefaultLoggerId = "default"; + static const char* kPerformanceLoggerId = "performance"; + static const char* kSysLogLoggerId = "syslog"; + static const char* kNullPointer = "nullptr"; + static const char kFormatSpecifierChar = '%'; +#if ELPP_VARIADIC_TEMPLATES_SUPPORTED + static const char kFormatSpecifierCharValue = 'v'; +#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED + static const unsigned int kMaxLogPerContainer = 100; + static const unsigned int kMaxLogPerCounter = 100000; + static const unsigned int kDefaultMillisecondsWidth = 3; + static const base::type::VerboseLevel kMaxVerboseLevel = 9; + static const char* kUnknownUser = "user"; + static const char* kUnknownHost = "unknown-host"; +#if defined(ELPP_DEFAULT_LOG_FILE) + static const char* kDefaultLogFile = ELPP_DEFAULT_LOG_FILE; +#else +# if ELPP_OS_UNIX +# if ELPP_OS_ANDROID + static const char* kDefaultLogFile = "logs/ace.log"; +# else + static const char* kDefaultLogFile = "logs/ace.log"; +# endif // ELPP_OS_ANDROID +# elif ELPP_OS_WINDOWS + static const char* kDefaultLogFile = "logs\\ace.log"; +# endif // ELPP_OS_UNIX +#endif // defined(ELPP_DEFAULT_LOG_FILE) +#if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG) + static const char* kDefaultLogFileParam = "--default-log-file"; +#endif // !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG) +#if defined(ELPP_LOGGING_FLAGS_FROM_ARG) + static const char* kLoggingFlagsParam = "--logging-flags"; +#endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG) +#if ELPP_OS_WINDOWS + static const char* kFilePathSeperator = "\\"; +#else + static const char* kFilePathSeperator = "/"; +#endif // ELPP_OS_WINDOWS + static const char* kValidLoggerIdSymbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._"; + static const char* kConfigurationComment = "##"; + static const char* kConfigurationLevel = "*"; + static const char* kConfigurationLoggerId = "--"; + static const std::size_t kSourceFilenameMaxLength = 100; + static const std::size_t kSourceLineMaxLength = 10; + static const Level kPerformanceTrackerDefaultLevel = Level::Info; + const struct { + double value; + const base::type::char_t* unit; + } kTimeFormats[] = { + { 1000.0f, ELPP_LITERAL("mis") }, + { 1000.0f, ELPP_LITERAL("ms") }, + { 60.0f, ELPP_LITERAL("seconds") }, + { 60.0f, ELPP_LITERAL("minutes") }, + { 24.0f, ELPP_LITERAL("hours") }, + { 7.0f, ELPP_LITERAL("days") } + }; + static const int kTimeFormatsCount = sizeof(kTimeFormats) / sizeof(kTimeFormats[0]); + const struct { + int numb; + const char* name; + const char* brief; + const char* detail; + } kCrashSignals[] = { + // NOTE: Do not re-order, if you do please check CrashHandler(bool) constructor and CrashHandler::setHandler(..) + { SIGABRT, "SIGABRT", "Abnormal termination", + "Program was abnormally terminated." }, + { SIGFPE, "SIGFPE", "Erroneous arithmetic operation", + "Arithemetic operation issue such as division by zero or operation resulting in overflow." }, + { SIGILL, "SIGILL", "Illegal instruction", + "Generally due to a corruption in the code or to an attempt to execute data." }, + { SIGSEGV, "SIGSEGV", "Invalid access to memory", + "Program is trying to read an invalid (unallocated, deleted or corrupted) or inaccessible memory." }, + { SIGINT, "SIGINT", "Interactive attention signal", + "Interruption generated (generally) by user or operating system." }, + }; + static const int kCrashSignalsCount = sizeof(kCrashSignals) / sizeof(kCrashSignals[0]); + } // namespace consts + } // namespace base + typedef std::function PreRollOutCallback; + namespace base { + static inline void defaultPreRollOutCallback(const char*, std::size_t) {} + /// @brief Enum to represent timestamp unit + enum class TimestampUnit : base::type::EnumType { + Microsecond = 0, Millisecond = 1, Second = 2, Minute = 3, Hour = 4, Day = 5 + }; + /// @brief Format flags used to determine specifiers that are active for performance improvements. + enum class FormatFlags : base::type::EnumType { + DateTime = 1 << 1, LoggerId = 1 << 2, File = 1 << 3, Line = 1 << 4, Location = 1 << 5, Function = 1 << 6, + User = 1 << 7, Host = 1 << 8, LogMessage = 1 << 9, VerboseLevel = 1 << 10, AppName = 1 << 11, ThreadId = 1 << 12, + Level = 1 << 13, FileBase = 1 << 14, LevelShort = 1 << 15 + }; + /// @brief A milliseconds width class containing actual width and offset for date/time + class MillisecondsWidth { + public: + MillisecondsWidth(void) { init(base::consts::kDefaultMillisecondsWidth); } + explicit MillisecondsWidth(int width) { init(width); } + bool operator==(const MillisecondsWidth& msWidth) { return m_width == msWidth.m_width && m_offset == msWidth.m_offset; } + int m_width; unsigned int m_offset; + private: + void init(int width) { + if (width < 1 || width > 6) { + width = base::consts::kDefaultMillisecondsWidth; + } + m_width = width; + switch (m_width) { + case 3: m_offset = 1000; break; + case 4: m_offset = 100; break; + case 5: m_offset = 10; break; + case 6: m_offset = 1; break; + default: m_offset = 1000; break; + } + } + }; + /// @brief Namespace containing utility functions/static classes used internally + namespace utils { + /// @brief Deletes memory safely and points to null + template + static inline + typename std::enable_if::value, void>::type + safeDelete(T*& pointer) { + if (pointer == nullptr) + return; + delete pointer; + pointer = nullptr; + } + /// @brief Gets value of const char* but if it is nullptr, a string nullptr is returned + static inline const char* charPtrVal(const char* pointer) { + return pointer == nullptr ? base::consts::kNullPointer : pointer; + } + /// @brief Aborts application due with user-defined status + static inline void abort(int status, const std::string& reason = std::string()) { + // Both status and reason params are there for debugging with tools like gdb etc + ELPP_UNUSED(status); + ELPP_UNUSED(reason); +#if defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG) + // Ignore msvc critical error dialog - break instead (on debug mode) + _asm int 3 +#else + ::abort(); +#endif // defined(ELPP_COMPILER_MSVC) && defined(_M_IX86) && defined(_DEBUG) + } + /// @brief Bitwise operations for C++11 strong enum class. This casts e into Flag_T and returns value after bitwise operation + /// Use these function as
flag = bitwise::Or(MyEnum::val1, flag);
+ namespace bitwise { + template + static inline base::type::EnumType And(Enum e, base::type::EnumType flag) { + return static_cast(flag) & static_cast(e); + } + template + static inline base::type::EnumType Not(Enum e, base::type::EnumType flag) { + return static_cast(flag) & ~(static_cast(e)); + } + template + static inline base::type::EnumType Or(Enum e, base::type::EnumType flag) { + return static_cast(flag) | static_cast(e); + } + } // namespace bitwise + template + static inline void addFlag(Enum e, base::type::EnumType* flag) { + *flag = base::utils::bitwise::Or(e, *flag); + } + template + static inline void removeFlag(Enum e, base::type::EnumType* flag) { + *flag = base::utils::bitwise::Not(e, *flag); + } + template + static inline bool hasFlag(Enum e, base::type::EnumType flag) { + return base::utils::bitwise::And(e, flag) > 0x0; + } + } // namespace utils + namespace threading { +#if ELPP_THREADING_ENABLED +# if !ELPP_USE_STD_THREADING + namespace internal { + /// @brief A mutex wrapper for compiler that dont yet support std::mutex + class Mutex : base::NoCopy { + public: + Mutex(void) { +# if ELPP_OS_UNIX + pthread_mutex_init(&m_underlyingMutex, nullptr); +# elif ELPP_OS_WINDOWS + InitializeCriticalSection(&m_underlyingMutex); +# endif // ELPP_OS_UNIX + } + + virtual ~Mutex(void) { +# if ELPP_OS_UNIX + pthread_mutex_destroy(&m_underlyingMutex); +# elif ELPP_OS_WINDOWS + DeleteCriticalSection(&m_underlyingMutex); +# endif // ELPP_OS_UNIX + } + + inline void lock(void) { +# if ELPP_OS_UNIX + pthread_mutex_lock(&m_underlyingMutex); +# elif ELPP_OS_WINDOWS + EnterCriticalSection(&m_underlyingMutex); +# endif // ELPP_OS_UNIX + } + + inline bool try_lock(void) { +# if ELPP_OS_UNIX + return (pthread_mutex_trylock(&m_underlyingMutex) == 0); +# elif ELPP_OS_WINDOWS + return TryEnterCriticalSection(&m_underlyingMutex); +# endif // ELPP_OS_UNIX + } + + inline void unlock(void) { +# if ELPP_OS_UNIX + pthread_mutex_unlock(&m_underlyingMutex); +# elif ELPP_OS_WINDOWS + LeaveCriticalSection(&m_underlyingMutex); +# endif // ELPP_OS_UNIX + } + + private: +# if ELPP_OS_UNIX + pthread_mutex_t m_underlyingMutex; +# elif ELPP_OS_WINDOWS + CRITICAL_SECTION m_underlyingMutex; +# endif // ELPP_OS_UNIX + }; + /// @brief Scoped lock for compiler that dont yet support std::lock_guard + template + class ScopedLock : base::NoCopy { + public: + explicit ScopedLock(M& mutex) { + m_mutex = &mutex; + m_mutex->lock(); + } + + virtual ~ScopedLock(void) { + m_mutex->unlock(); + } + private: + M* m_mutex; + ScopedLock(void); + }; + } // namespace internal + /// @brief Gets ID of currently running threading in windows systems. On unix, nothing is returned. + static inline std::string getCurrentThreadId(void) { + std::stringstream ss; +# if (ELPP_OS_WINDOWS) + ss << GetCurrentThreadId(); +# endif // (ELPP_OS_WINDOWS) + return ss.str(); + } + static inline void msleep(int) { + // No implementation for non std::thread version + } + typedef base::threading::internal::Mutex Mutex; + typedef base::threading::internal::ScopedLock ScopedLock; +# else + /// @brief Gets ID of currently running threading using std::this_thread::get_id() + static inline std::string getCurrentThreadId(void) { + std::stringstream ss; + ss << std::this_thread::get_id(); + return ss.str(); + } + static inline void msleep(int ms) { + // Only when async logging enabled - this is because async is strict on compiler +#if ELPP_ASYNC_LOGGING + std::this_thread::sleep_for(std::chrono::milliseconds(ms)); +#endif // ELPP_ASYNC_LOGGING + } + typedef std::mutex Mutex; + typedef std::lock_guard ScopedLock; +# endif // !ELPP_USE_STD_THREADING +#else + namespace internal { + /// @brief Mutex wrapper used when multi-threading is disabled. + class NoMutex : base::NoCopy { + public: + NoMutex(void) {} + inline void lock(void) {} + inline bool try_lock(void) { return true; } + inline void unlock(void) {} + }; + /// @brief Lock guard wrapper used when multi-threading is disabled. + template + class NoScopedLock : base::NoCopy { + public: + explicit NoScopedLock(Mutex&) { + } + virtual ~NoScopedLock(void) { + } + private: + NoScopedLock(void); + }; + } // namespace internal + static inline std::string getCurrentThreadId(void) { + return std::string(); + } + static inline void msleep(int) { + // No custom implementation + } + typedef base::threading::internal::NoMutex Mutex; + typedef base::threading::internal::NoScopedLock ScopedLock; +#endif // ELPP_THREADING_ENABLED + /// @brief Base of thread safe class, this class is inheritable-only + class ThreadSafe { + public: + virtual inline void acquireLock(void) ELPP_FINAL { m_mutex.lock(); } + virtual inline void releaseLock(void) ELPP_FINAL { m_mutex.unlock(); } + virtual inline base::threading::Mutex& lock(void) ELPP_FINAL { return m_mutex; } + protected: + ThreadSafe(void) {} + virtual ~ThreadSafe(void) {} + private: + base::threading::Mutex m_mutex; + }; + } // namespace threading + namespace utils { + class File : base::StaticClass { + public: + /// @brief Creates new out file stream for specified filename. + /// @return Pointer to newly created fstream or nullptr + static base::type::fstream_t* newFileStream(const std::string& filename) { + base::type::fstream_t *fs = new base::type::fstream_t(filename.c_str(), + base::type::fstream_t::out | base::type::fstream_t::app); +#if defined(ELPP_UNICODE) + std::locale elppUnicodeLocale(""); +#if ELPP_OS_WINDOWS + std::locale elppUnicodeLocaleWindows(elppUnicodeLocale, new std::codecvt_utf8_utf16); + elppUnicodeLocale = elppUnicodeLocaleWindows; +#endif + fs->imbue(elppUnicodeLocale); +#endif // defined(ELPP_UNICODE) + if (fs->is_open()) { + fs->flush(); + } + else { + base::utils::safeDelete(fs); + ELPP_INTERNAL_ERROR("Bad file [" << filename << "]", true); + } + return fs; + } + + /// @brief Gets size of file provided in stream + static std::size_t getSizeOfFile(base::type::fstream_t* fs) { + if (fs == nullptr) { + return 0; + } + std::streampos currPos = fs->tellg(); + fs->seekg(0, fs->end); + std::size_t size = static_cast(fs->tellg()); + fs->seekg(currPos); + return size; + } + + /// @brief Determines whether or not provided path exist in current file system + static inline bool pathExists(const char* path, bool considerFile = false) { + if (path == nullptr) { + return false; + } +#if ELPP_OS_UNIX + ELPP_UNUSED(considerFile); + struct stat st; + return (stat(path, &st) == 0); +#elif ELPP_OS_WINDOWS + DWORD fileType = GetFileAttributesA(path); + if (fileType == INVALID_FILE_ATTRIBUTES) { + return false; + } + return considerFile ? true : ((fileType & FILE_ATTRIBUTE_DIRECTORY) == 0 ? false : true); +#endif // ELPP_OS_UNIX + } + + /// @brief Creates specified path on file system + /// @param path Path to create. + static bool createPath(const std::string& path) { + if (path.empty()) { + return false; + } + if (base::utils::File::pathExists(path.c_str())) { + return true; + } + int status = -1; + + char* currPath = const_cast(path.c_str()); + std::string builtPath = std::string(); +#if ELPP_OS_UNIX + if (path[0] == '/') { + builtPath = "/"; + } + currPath = STRTOK(currPath, base::consts::kFilePathSeperator, 0); +#elif ELPP_OS_WINDOWS + // Use secure functions API + char* nextTok_ = nullptr; + currPath = STRTOK(currPath, base::consts::kFilePathSeperator, &nextTok_); + ELPP_UNUSED(nextTok_); +#endif // ELPP_OS_UNIX + while (currPath != nullptr) { + builtPath.append(currPath); + builtPath.append(base::consts::kFilePathSeperator); +#if ELPP_OS_UNIX + status = mkdir(builtPath.c_str(), ELPP_LOG_PERMS); + currPath = STRTOK(nullptr, base::consts::kFilePathSeperator, 0); +#elif ELPP_OS_WINDOWS + status = _mkdir(builtPath.c_str()); + currPath = STRTOK(nullptr, base::consts::kFilePathSeperator, &nextTok_); +#endif // ELPP_OS_UNIX + } + if (status == -1) { + ELPP_INTERNAL_ERROR("Error while creating path [" << path << "]", true); + return false; + } + return true; + } + /// @brief Extracts path of filename with leading slash + static std::string extractPathFromFilename(const std::string& fullPath, + const char* seperator = base::consts::kFilePathSeperator) { + if ((fullPath == "") || (fullPath.find(seperator) == std::string::npos)) { + return fullPath; + } + std::size_t lastSlashAt = fullPath.find_last_of(seperator); + if (lastSlashAt == 0) { + return std::string(seperator); + } + return fullPath.substr(0, lastSlashAt + 1); + } + /// @brief builds stripped filename and puts it in buff + static void buildStrippedFilename(const char* filename, char buff[], + std::size_t limit = base::consts::kSourceFilenameMaxLength) { + std::size_t sizeOfFilename = strlen(filename); + if (sizeOfFilename >= limit) { + filename += (sizeOfFilename - limit); + if (filename[0] != '.' && filename[1] != '.') { // prepend if not already + filename += 3; // 3 = '..' + STRCAT(buff, "..", limit); + } + } + STRCAT(buff, filename, limit); + } + /// @brief builds base filename and puts it in buff + static void buildBaseFilename(const std::string& fullPath, char buff[], + std::size_t limit = base::consts::kSourceFilenameMaxLength, + const char* seperator = base::consts::kFilePathSeperator) { + const char *filename = fullPath.c_str(); + std::size_t lastSlashAt = fullPath.find_last_of(seperator); + filename += lastSlashAt ? lastSlashAt + 1 : 0; + std::size_t sizeOfFilename = strlen(filename); + if (sizeOfFilename >= limit) { + filename += (sizeOfFilename - limit); + if (filename[0] != '.' && filename[1] != '.') { // prepend if not already + filename += 3; // 3 = '..' + STRCAT(buff, "..", limit); + } + } + STRCAT(buff, filename, limit); + } + }; + /// @brief String utilities helper class used internally. You should not use it. + class Str : base::StaticClass { + public: + /// @brief Checks if character is digit. Dont use libc implementation of it to prevent locale issues. + static inline bool isDigit(char c) { + return c >= '0' && c <= '9'; + } + + /// @brief Matches wildcards, '*' and '?' only supported. + static bool wildCardMatch(const char* str, const char* pattern) { + while (*pattern) { + switch (*pattern) { + case '?': + if (!*str) + return false; + ++str; + ++pattern; + break; + case '*': + if (wildCardMatch(str, pattern + 1)) + return true; + if (*str && wildCardMatch(str + 1, pattern)) + return true; + return false; + break; + default: + if (*str++ != *pattern++) + return false; + break; + } + } + return !*str && !*pattern; + } + + /// @brief Trims string from start + /// @param [in,out] str String to trim + static inline std::string& ltrim(std::string& str) { + str.erase(str.begin(), std::find_if(str.begin(), str.end(), std::not1(std::ptr_fun(&std::isspace)))); + return str; + } + + /// @brief Trim string from end + /// @param [in,out] str String to trim + static inline std::string& rtrim(std::string& str) { + str.erase(std::find_if(str.rbegin(), str.rend(), std::not1(std::ptr_fun(&std::isspace))).base(), str.end()); + return str; + } + + /// @brief Trims string from left and right + /// @param [in,out] str String to trim + static inline std::string& trim(std::string& str) { + return ltrim(rtrim(str)); + } + + /// @brief Determines whether or not str starts with specified string + /// @param str String to check + /// @param start String to check against + /// @return Returns true if starts with specified string, false otherwise + static inline bool startsWith(const std::string& str, const std::string& start) { + return (str.length() >= start.length()) && (str.compare(0, start.length(), start) == 0); + } + + /// @brief Determines whether or not str ends with specified string + /// @param str String to check + /// @param end String to check against + /// @return Returns true if ends with specified string, false otherwise + static inline bool endsWith(const std::string& str, const std::string& end) { + return (str.length() >= end.length()) && (str.compare(str.length() - end.length(), end.length(), end) == 0); + } + + /// @brief Replaces all instances of replaceWhat with 'replaceWith'. Original variable is changed for performance. + /// @param [in,out] str String to replace from + /// @param replaceWhat Character to replace + /// @param replaceWith Character to replace with + /// @return Modified version of str + static inline std::string& replaceAll(std::string& str, char replaceWhat, char replaceWith) { + std::replace(str.begin(), str.end(), replaceWhat, replaceWith); + return str; + } + + /// @brief Replaces all instances of 'replaceWhat' with 'replaceWith'. (String version) Replaces in place + /// @param str String to replace from + /// @param replaceWhat Character to replace + /// @param replaceWith Character to replace with + /// @return Modified (original) str + static inline std::string& replaceAll(std::string& str, const std::string& replaceWhat, // NOLINT + const std::string& replaceWith) { + if (replaceWhat == replaceWith) + return str; + std::size_t foundAt = std::string::npos; + while ((foundAt = str.find(replaceWhat, foundAt + 1)) != std::string::npos) { + str.replace(foundAt, replaceWhat.length(), replaceWith); + } + return str; + } + + static void replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat, // NOLINT + const base::type::string_t& replaceWith) { + std::size_t foundAt = base::type::string_t::npos; + while ((foundAt = str.find(replaceWhat, foundAt + 1)) != base::type::string_t::npos) { + if (foundAt > 0 && str[foundAt - 1] == base::consts::kFormatSpecifierChar) { + str.erase(foundAt > 0 ? foundAt - 1 : 0, 1); + ++foundAt; + } + else { + str.replace(foundAt, replaceWhat.length(), replaceWith); + return; + } + } + } +#if defined(ELPP_UNICODE) + static void replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat, // NOLINT + const std::string& replaceWith) { + replaceFirstWithEscape(str, replaceWhat, base::type::string_t(replaceWith.begin(), replaceWith.end())); + } +#endif // defined(ELPP_UNICODE) + /// @brief Converts string to uppercase + /// @param str String to convert + /// @return Uppercase string + static inline std::string& toUpper(std::string& str) { + std::transform(str.begin(), str.end(), str.begin(), ::toupper); + return str; + } + + /// @brief Compares cstring equality - uses strcmp + static inline bool cStringEq(const char* s1, const char* s2) { + if (s1 == nullptr && s2 == nullptr) return true; + if (s1 == nullptr || s2 == nullptr) return false; + return strcmp(s1, s2) == 0; + } + + /// @brief Compares cstring equality (case-insensitive) - uses toupper(char) + /// Dont use strcasecmp because of CRT (VC++) + static bool cStringCaseEq(const char* s1, const char* s2) { + if (s1 == nullptr && s2 == nullptr) return true; + if (s1 == nullptr || s2 == nullptr) return false; + if (strlen(s1) != strlen(s2)) return false; + while (*s1 != '\0' && *s2 != '\0') { + if (::toupper(*s1) != ::toupper(*s2)) return false; + ++s1; + ++s2; + } + return true; + } + + /// @brief Returns true if c exist in str + static inline bool contains(const char* str, char c) { + for (; *str; ++str) { + if (*str == c) + return true; + } + return false; + } + + static inline char* convertAndAddToBuff(std::size_t n, int len, char* buf, const char* bufLim, bool zeroPadded = true) { + char localBuff[10] = ""; + char* p = localBuff + sizeof(localBuff) - 2; + if (n > 0) { + for (; n > 0 && p > localBuff && len > 0; n /= 10, --len) + *--p = static_cast(n % 10 + '0'); + } + else { + *--p = '0'; + --len; + } + if (zeroPadded) + while (p > localBuff && len-- > 0) *--p = static_cast('0'); + return addToBuff(p, buf, bufLim); + } + + static inline char* addToBuff(const char* str, char* buf, const char* bufLim) { + while ((buf < bufLim) && ((*buf = *str++) != '\0')) + ++buf; + return buf; + } + + static inline char* clearBuff(char buff[], std::size_t lim) { + STRCPY(buff, "", lim); + ELPP_UNUSED(lim); // For *nix we dont have anything using lim in above STRCPY macro + return buff; + } + + /// @brief Converst wchar* to char* + /// NOTE: Need to free return value after use! + static char* wcharPtrToCharPtr(const wchar_t* line) { + std::size_t len_ = wcslen(line) + 1; + char* buff_ = static_cast(malloc(len_ + 1)); +# if ELPP_OS_UNIX || (ELPP_OS_WINDOWS && !ELPP_CRT_DBG_WARNINGS) + std::wcstombs(buff_, line, len_); +# elif ELPP_OS_WINDOWS + std::size_t convCount_ = 0; + mbstate_t mbState_; + ::memset(static_cast(&mbState_), 0, sizeof(mbState_)); + wcsrtombs_s(&convCount_, buff_, len_, &line, len_, &mbState_); +# endif // ELPP_OS_UNIX || (ELPP_OS_WINDOWS && !ELPP_CRT_DBG_WARNINGS) + return buff_; + } + }; + /// @brief Operating System helper static class used internally. You should not use it. + class OS : base::StaticClass { + public: +#if ELPP_OS_WINDOWS + /// @brief Gets environment variables for Windows based OS. + /// We are not using getenv(const char*) because of CRT deprecation + /// @param varname Variable name to get environment variable value for + /// @return If variable exist the value of it otherwise nullptr + static const char* getWindowsEnvironmentVariable(const char* varname) { + const DWORD bufferLen = 50; + static char buffer[bufferLen]; + if (GetEnvironmentVariableA(varname, buffer, bufferLen)) { + return buffer; + } + return nullptr; + } +#endif // ELPP_OS_WINDOWS +#if ELPP_OS_ANDROID + /// @brief Reads android property value + static inline std::string getProperty(const char* prop) { + char propVal[PROP_VALUE_MAX + 1]; + int ret = __system_property_get(prop, propVal); + return ret == 0 ? std::string() : std::string(propVal); + } + + /// @brief Reads android device name + static std::string getDeviceName(void) { + std::stringstream ss; + std::string manufacturer = getProperty("ro.product.manufacturer"); + std::string model = getProperty("ro.product.model"); + if (manufacturer.empty() || model.empty()) { + return std::string(); + } + ss << manufacturer << "-" << model; + return ss.str(); + } +#endif // ELPP_OS_ANDROID + + /// @brief Runs command on terminal and returns the output. + /// + /// @detail This is applicable only on unix based systems, for all other OS, an empty string is returned. + /// @param command Bash command + /// @return Result of bash output or empty string if no result found. + static const std::string getBashOutput(const char* command) { +#if (ELPP_OS_UNIX && !ELPP_OS_ANDROID && !ELPP_CYGWIN) + if (command == nullptr) { + return std::string(); + } + FILE* proc = nullptr; + if ((proc = popen(command, "r")) == nullptr) { + ELPP_INTERNAL_ERROR("\nUnable to run command [" << command << "]", true); + return std::string(); + } + char hBuff[4096]; + if (fgets(hBuff, sizeof(hBuff), proc) != nullptr) { + pclose(proc); + if (hBuff[strlen(hBuff) - 1] == '\n') { + hBuff[strlen(hBuff) - 1] = '\0'; + } + return std::string(hBuff); + } + return std::string(); +#else + ELPP_UNUSED(command); + return std::string(); +#endif // (ELPP_OS_UNIX && !ELPP_OS_ANDROID && !ELPP_CYGWIN) + } + + /// @brief Gets environment variable. This is cross-platform and CRT safe (for VC++) + /// @param variableName Environment variable name + /// @param defaultVal If no environment variable or value found the value to return by default + /// @param alternativeBashCommand If environment variable not found what would be alternative bash command + /// in order to look for value user is looking for. E.g, for 'user' alternative command will 'whoami' + static std::string getEnvironmentVariable(const char* variableName, const char* defaultVal, const char* alternativeBashCommand = nullptr) { +#if ELPP_OS_UNIX + const char* val = getenv(variableName); +#elif ELPP_OS_WINDOWS + const char* val = getWindowsEnvironmentVariable(variableName); +#endif // ELPP_OS_UNIX + if ((val == nullptr) || ((strcmp(val, "") == 0))) { +#if ELPP_OS_UNIX && defined(ELPP_FORCE_ENV_VAR_FROM_BASH) + // Try harder on unix-based systems + std::string valBash = base::utils::OS::getBashOutput(alternativeBashCommand); + if (valBash.empty()) { + return std::string(defaultVal); + } + else { + return valBash; + } +#elif ELPP_OS_WINDOWS || ELPP_OS_UNIX + ELPP_UNUSED(alternativeBashCommand); + return std::string(defaultVal); +#endif // ELPP_OS_UNIX && defined(ELPP_FORCE_ENV_VAR_FROM_BASH) + } + return std::string(val); + } + /// @brief Gets current username. + static inline std::string currentUser(void) { +#if ELPP_OS_UNIX && !ELPP_OS_ANDROID + return getEnvironmentVariable("USER", base::consts::kUnknownUser, "whoami"); +#elif ELPP_OS_WINDOWS + return getEnvironmentVariable("USERNAME", base::consts::kUnknownUser); +#elif ELPP_OS_ANDROID + ELPP_UNUSED(base::consts::kUnknownUser); + return std::string("android"); +#else + return std::string(); +#endif // ELPP_OS_UNIX && !ELPP_OS_ANDROID + } + + /// @brief Gets current host name or computer name. + /// + /// @detail For android systems this is device name with its manufacturer and model seperated by hyphen + static inline std::string currentHost(void) { +#if ELPP_OS_UNIX && !ELPP_OS_ANDROID + return getEnvironmentVariable("HOSTNAME", base::consts::kUnknownHost, "hostname"); +#elif ELPP_OS_WINDOWS + return getEnvironmentVariable("COMPUTERNAME", base::consts::kUnknownHost); +#elif ELPP_OS_ANDROID + ELPP_UNUSED(base::consts::kUnknownHost); + return getDeviceName(); +#else + return std::string(); +#endif // ELPP_OS_UNIX && !ELPP_OS_ANDROID + } + /// @brief Whether or not terminal supports colors + static inline bool termSupportsColor(void) { + std::string term = getEnvironmentVariable("TERM", ""); + return term == "xterm" || term == "xterm-color" || term == "xterm-256color" || + term == "screen" || term == "linux" || term == "cygwin"; + } + }; + extern std::string s_currentUser; + extern std::string s_currentHost; + extern bool s_termSupportsColor; +#define ELPP_INITI_BASIC_DECLR \ + namespace el {\ + namespace base {\ + namespace utils {\ + std::string s_currentUser = el::base::utils::OS::currentUser(); \ + std::string s_currentHost = el::base::utils::OS::currentHost(); \ + bool s_termSupportsColor = el::base::utils::OS::termSupportsColor(); \ + }\ + }\ + } + /// @brief Contains utilities for cross-platform date/time. This class make use of el::base::utils::Str + class DateTime : base::StaticClass { + public: + /// @brief Cross platform gettimeofday for Windows and unix platform. This can be used to determine current millisecond. + /// + /// @detail For unix system it uses gettimeofday(timeval*, timezone*) and for Windows, a seperate implementation is provided + /// @param [in,out] tv Pointer that gets updated + static void gettimeofday(struct timeval* tv) { +#if ELPP_OS_WINDOWS + if (tv != nullptr) { +# if ELPP_COMPILER_MSVC || defined(_MSC_EXTENSIONS) + const unsigned __int64 delta_ = 11644473600000000Ui64; +# else + const unsigned __int64 delta_ = 11644473600000000ULL; +# endif // ELPP_COMPILER_MSVC || defined(_MSC_EXTENSIONS) + const double secOffSet = 0.000001; + const unsigned long usecOffSet = 1000000; + FILETIME fileTime; + GetSystemTimeAsFileTime(&fileTime); + unsigned __int64 present = 0; + present |= fileTime.dwHighDateTime; + present = present << 32; + present |= fileTime.dwLowDateTime; + present /= 10; // mic-sec + // Subtract the difference + present -= delta_; + tv->tv_sec = static_cast(present * secOffSet); + tv->tv_usec = static_cast(present % usecOffSet); + } +#else + ::gettimeofday(tv, nullptr); +#endif // ELPP_OS_WINDOWS + } + + /// @brief Gets current date and time with milliseconds. + /// @param format User provided date/time format + /// @param msWidth A pointer to base::MillisecondsWidth from configuration (non-null) + /// @returns string based date time in specified format. + static inline std::string getDateTime(const char* format, const base::MillisecondsWidth* msWidth) { + struct timeval currTime; + gettimeofday(&currTime); + struct ::tm timeInfo; + buildTimeInfo(&currTime, &timeInfo); + const int kBuffSize = 30; + char buff_[kBuffSize] = ""; + parseFormat(buff_, kBuffSize, format, &timeInfo, static_cast(currTime.tv_usec / msWidth->m_offset), msWidth); + return std::string(buff_); + } + + /// @brief Formats time to get unit accordingly, units like second if > 1000 or minutes if > 60000 etc + static base::type::string_t formatTime(unsigned long long time, base::TimestampUnit timestampUnit) { + double result = static_cast(time); + base::type::EnumType start = static_cast(timestampUnit); + const base::type::char_t* unit = base::consts::kTimeFormats[start].unit; + for (base::type::EnumType i = start; i < base::consts::kTimeFormatsCount - 1; ++i) { + if (result <= base::consts::kTimeFormats[i].value) { + break; + } + result /= base::consts::kTimeFormats[i].value; + unit = base::consts::kTimeFormats[i + 1].unit; + } + base::type::stringstream_t ss; + ss << result << " " << unit; + return ss.str(); + } + + /// @brief Gets time difference in milli/micro second depending on timestampUnit + static inline unsigned long long getTimeDifference(const struct timeval& endTime, const struct timeval& startTime, base::TimestampUnit timestampUnit) { + if (timestampUnit == base::TimestampUnit::Microsecond) { + return static_cast(static_cast(1000000 * endTime.tv_sec + endTime.tv_usec) - + static_cast(1000000 * startTime.tv_sec + startTime.tv_usec)); + } + else { + return static_cast((((endTime.tv_sec - startTime.tv_sec) * 1000000) + (endTime.tv_usec - startTime.tv_usec)) / 1000); + } + } + + private: + static inline struct ::tm* buildTimeInfo(struct timeval* currTime, struct ::tm* timeInfo) { +#if ELPP_OS_UNIX + time_t rawTime = currTime->tv_sec; + ::localtime_r(&rawTime, timeInfo); + return timeInfo; +#else +# if ELPP_COMPILER_MSVC + ELPP_UNUSED(currTime); + time_t t; + _time64(&t); + localtime_s(timeInfo, &t); + return timeInfo; +# else + // For any other compilers that don't have CRT warnings issue e.g, MinGW or TDM GCC- we use different method + time_t rawTime = currTime->tv_sec; + struct tm* tmInf = localtime(&rawTime); + *timeInfo = *tmInf; + return timeInfo; +# endif // ELPP_COMPILER_MSVC +#endif // ELPP_OS_UNIX + } + static char* parseFormat(char* buf, std::size_t bufSz, const char* format, const struct tm* tInfo, + std::size_t msec, const base::MillisecondsWidth* msWidth) { + const char* bufLim = buf + bufSz; + for (; *format; ++format) { + if (*format == base::consts::kFormatSpecifierChar) { + switch (*++format) { + case base::consts::kFormatSpecifierChar: // Escape + break; + case '\0': // End + --format; + break; + case 'd': // Day + buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_mday, 2, buf, bufLim); + continue; + case 'a': // Day of week (short) + buf = base::utils::Str::addToBuff(base::consts::kDaysAbbrev[tInfo->tm_wday], buf, bufLim); + continue; + case 'A': // Day of week (long) + buf = base::utils::Str::addToBuff(base::consts::kDays[tInfo->tm_wday], buf, bufLim); + continue; + case 'M': // month + buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_mon + 1, 2, buf, bufLim); + continue; + case 'b': // month (short) + buf = base::utils::Str::addToBuff(base::consts::kMonthsAbbrev[tInfo->tm_mon], buf, bufLim); + continue; + case 'B': // month (long) + buf = base::utils::Str::addToBuff(base::consts::kMonths[tInfo->tm_mon], buf, bufLim); + continue; + case 'y': // year (two digits) + buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_year + base::consts::kYearBase, 2, buf, bufLim); + continue; + case 'Y': // year (four digits) + buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_year + base::consts::kYearBase, 4, buf, bufLim); + continue; + case 'h': // hour (12-hour) + buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_hour % 12, 2, buf, bufLim); + continue; + case 'H': // hour (24-hour) + buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_hour, 2, buf, bufLim); + continue; + case 'm': // minute + buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_min, 2, buf, bufLim); + continue; + case 's': // second + buf = base::utils::Str::convertAndAddToBuff(tInfo->tm_sec, 2, buf, bufLim); + continue; + case 'z': // milliseconds + case 'g': + buf = base::utils::Str::convertAndAddToBuff(msec, msWidth->m_width, buf, bufLim); + continue; + case 'F': // AM/PM + buf = base::utils::Str::addToBuff((tInfo->tm_hour >= 12) ? base::consts::kPm : base::consts::kAm, buf, bufLim); + continue; + default: + continue; + } + } + if (buf == bufLim) break; + *buf++ = *format; + } + return buf; + } + }; + /// @brief Command line arguments for application if specified using el::Helpers::setArgs(..) or START_EASYLOGGINGPP(..) + class CommandLineArgs { + public: + CommandLineArgs(void) { + setArgs(0, static_cast(nullptr)); + } + CommandLineArgs(int argc, const char** argv) { + setArgs(argc, argv); + } + CommandLineArgs(int argc, char** argv) { + setArgs(argc, argv); + } + virtual ~CommandLineArgs(void) {} + /// @brief Sets arguments and parses them + inline void setArgs(int argc, const char** argv) { + setArgs(argc, const_cast(argv)); + } + /// @brief Sets arguments and parses them + inline void setArgs(int argc, char** argv) { + m_params.clear(); + m_paramsWithValue.clear(); + if (argc == 0 || argv == nullptr) { + return; + } + m_argc = argc; + m_argv = argv; + for (int i = 1; i < m_argc; ++i) { + const char* v = (strstr(m_argv[i], "=")); + if (v != nullptr && strlen(v) > 0) { + std::string key = std::string(m_argv[i]); + key = key.substr(0, key.find_first_of('=')); + if (hasParamWithValue(key.c_str())) { + ELPP_INTERNAL_INFO(1, "Skipping [" << key << "] arg since it already has value [" + << getParamValue(key.c_str()) << "]"); + } + else { + m_paramsWithValue.insert(std::make_pair(key, std::string(v + 1))); + } + } + if (v == nullptr) { + if (hasParam(m_argv[i])) { + ELPP_INTERNAL_INFO(1, "Skipping [" << m_argv[i] << "] arg since it already exists"); + } + else { + m_params.push_back(std::string(m_argv[i])); + } + } + } + } + /// @brief Returns true if arguments contain paramKey with a value (seperated by '=') + inline bool hasParamWithValue(const char* paramKey) const { + return m_paramsWithValue.find(std::string(paramKey)) != m_paramsWithValue.end(); + } + /// @brief Returns value of arguments + /// @see hasParamWithValue(const char*) + inline const char* getParamValue(const char* paramKey) const { + return m_paramsWithValue.find(std::string(paramKey))->second.c_str(); + } + /// @brief Return true if arguments has a param (not having a value) i,e without '=' + inline bool hasParam(const char* paramKey) const { + return std::find(m_params.begin(), m_params.end(), std::string(paramKey)) != m_params.end(); + } + /// @brief Returns true if no params available. This exclude argv[0] + inline bool empty(void) const { + return m_params.empty() && m_paramsWithValue.empty(); + } + /// @brief Returns total number of arguments. This exclude argv[0] + inline std::size_t size(void) const { + return m_params.size() + m_paramsWithValue.size(); + } + inline friend base::type::ostream_t& operator<<(base::type::ostream_t& os, const CommandLineArgs& c) { + for (int i = 1; i < c.m_argc; ++i) { + os << ELPP_LITERAL("[") << c.m_argv[i] << ELPP_LITERAL("]"); + if (i < c.m_argc - 1) { + os << ELPP_LITERAL(" "); + } + } + return os; + } + + private: + int m_argc; + char** m_argv; + std::map m_paramsWithValue; + std::vector m_params; + }; + /// @brief Abstract registry (aka repository) that provides basic interface for pointer repository specified by T_Ptr type. + /// + /// @detail Most of the functions are virtual final methods but anything implementing this abstract class should implement + /// unregisterAll() and deepCopy(const AbstractRegistry&) and write registerNew() method according to container + /// and few more methods; get() to find element, unregister() to unregister single entry. + /// Please note that this is thread-unsafe and should also implement thread-safety mechanisms in implementation. + template + class AbstractRegistry : public base::threading::ThreadSafe { + public: + typedef typename Container::iterator iterator; + typedef typename Container::const_iterator const_iterator; + + /// @brief Default constructor + AbstractRegistry(void) {} + + /// @brief Move constructor that is useful for base classes + AbstractRegistry(AbstractRegistry&& sr) { + if (this == &sr) { + return; + } + unregisterAll(); + m_list = std::move(sr.m_list); + } + + bool operator==(const AbstractRegistry& other) { + if (size() != other.size()) { + return false; + } + for (std::size_t i = 0; i < m_list.size(); ++i) { + if (m_list.at(i) != other.m_list.at(i)) { + return false; + } + } + return true; + } + + bool operator!=(const AbstractRegistry& other) { + if (size() != other.size()) { + return true; + } + for (std::size_t i = 0; i < m_list.size(); ++i) { + if (m_list.at(i) != other.m_list.at(i)) { + return true; + } + } + return false; + } + + /// @brief Assignment move operator + AbstractRegistry& operator=(AbstractRegistry&& sr) { + if (this == &sr) { + return *this; + } + unregisterAll(); + m_list = std::move(sr.m_list); + return *this; + } + + virtual ~AbstractRegistry(void) { + } + + /// @return Iterator pointer from start of repository + virtual inline iterator begin(void) ELPP_FINAL { + return m_list.begin(); + } + + /// @return Iterator pointer from end of repository + virtual inline iterator end(void) ELPP_FINAL { + return m_list.end(); + } + + + /// @return Constant iterator pointer from start of repository + virtual inline const_iterator cbegin(void) const ELPP_FINAL { + return m_list.cbegin(); + } + + /// @return End of repository + virtual inline const_iterator cend(void) const ELPP_FINAL { + return m_list.cend(); + } + + /// @return Whether or not repository is empty + virtual inline bool empty(void) const ELPP_FINAL { + return m_list.empty(); + } + + /// @return Size of repository + virtual inline std::size_t size(void) const ELPP_FINAL { + return m_list.size(); + } + + /// @brief Returns underlying container by reference + virtual inline Container& list(void) ELPP_FINAL { + return m_list; + } + + /// @brief Returns underlying container by constant reference. + virtual inline const Container& list(void) const ELPP_FINAL { + return m_list; + } + + /// @brief Unregisters all the pointers from current repository. + virtual void unregisterAll(void) = 0; + + protected: + virtual void deepCopy(const AbstractRegistry&) = 0; + void reinitDeepCopy(const AbstractRegistry& sr) { + unregisterAll(); + deepCopy(sr); + } + + private: + Container m_list; + }; + + /// @brief A pointer registry mechanism to manage memory and provide search functionalities. (non-predicate version) + /// + /// @detail NOTE: This is thread-unsafe implementation (although it contains lock function, it does not use these functions) + /// of AbstractRegistry. Any implementation of this class should be + /// explicitly (by using lock functions) + template + class Registry : public AbstractRegistry> { + public: + typedef typename Registry::iterator iterator; + typedef typename Registry::const_iterator const_iterator; + + Registry(void) {} + + /// @brief Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor. + Registry(const Registry& sr) : AbstractRegistry>() { + if (this == &sr) { + return; + } + this->reinitDeepCopy(sr); + } + + /// @brief Assignment operator that unregisters all the existing registeries and deeply copies each of repo element + /// @see unregisterAll() + /// @see deepCopy(const AbstractRegistry&) + Registry& operator=(const Registry& sr) { + if (this == &sr) { + return *this; + } + this->reinitDeepCopy(sr); + return *this; + } + + virtual ~Registry(void) { + unregisterAll(); + } + + protected: + virtual inline void unregisterAll(void) ELPP_FINAL { + if (!this->empty()) { + for (auto&& curr : this->list()) { + base::utils::safeDelete(curr.second); + } + this->list().clear(); + } + } + + /// @brief Registers new registry to repository. + virtual inline void registerNew(const T_Key& uniqKey, T_Ptr* ptr) ELPP_FINAL { + unregister(uniqKey); + this->list().insert(std::make_pair(uniqKey, ptr)); + } + + /// @brief Unregisters single entry mapped to specified unique key + inline void unregister(const T_Key& uniqKey) { + T_Ptr* existing = get(uniqKey); + if (existing != nullptr) { + base::utils::safeDelete(existing); + this->list().erase(uniqKey); + } + } + + /// @brief Gets pointer from repository. If none found, nullptr is returned. + inline T_Ptr* get(const T_Key& uniqKey) { + iterator it = this->list().find(uniqKey); + return it == this->list().end() + ? nullptr + : it->second; + } + + private: + virtual inline void deepCopy(const AbstractRegistry>& sr) ELPP_FINAL { + for (const_iterator it = sr.cbegin(); it != sr.cend(); ++it) { + registerNew(it->first, new T_Ptr(*it->second)); + } + } + }; + + /// @brief A pointer registry mechanism to manage memory and provide search functionalities. (predicate version) + /// + /// @detail NOTE: This is thread-unsafe implementation of AbstractRegistry. Any implementation of this class + /// should be made thread-safe explicitly + template + class RegistryWithPred : public AbstractRegistry> { + public: + typedef typename RegistryWithPred::iterator iterator; + typedef typename RegistryWithPred::const_iterator const_iterator; + + RegistryWithPred(void) { + } + + virtual ~RegistryWithPred(void) { + unregisterAll(); + } + + /// @brief Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor. + RegistryWithPred(const RegistryWithPred& sr) : AbstractRegistry>() { + if (this == &sr) { + return; + } + this->reinitDeepCopy(sr); + } + + /// @brief Assignment operator that unregisters all the existing registeries and deeply copies each of repo element + /// @see unregisterAll() + /// @see deepCopy(const AbstractRegistry&) + RegistryWithPred& operator=(const RegistryWithPred& sr) { + if (this == &sr) { + return *this; + } + this->reinitDeepCopy(sr); + return *this; + } + + friend inline base::type::ostream_t& operator<<(base::type::ostream_t& os, const RegistryWithPred& sr) { + for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) { + os << ELPP_LITERAL(" ") << **it << ELPP_LITERAL("\n"); + } + return os; + } + + protected: + virtual inline void unregisterAll(void) ELPP_FINAL { + if (!this->empty()) { + for (auto&& curr : this->list()) { + base::utils::safeDelete(curr); + } + this->list().clear(); + } + } + + virtual void unregister(T_Ptr*& ptr) ELPP_FINAL { + if (ptr) { + iterator iter = this->begin(); + for (; iter != this->end(); ++iter) { + if (ptr == *iter) { + break; + } + } + if (iter != this->end() && *iter != nullptr) { + this->list().erase(iter); + base::utils::safeDelete(*iter); + } + } + } + + virtual inline void registerNew(T_Ptr* ptr) ELPP_FINAL { + this->list().push_back(ptr); + } + + /// @brief Gets pointer from repository with speicifed arguments. Arguments are passed to predicate + /// in order to validate pointer. + template + inline T_Ptr* get(const T& arg1, const T2 arg2) { + iterator iter = std::find_if(this->list().begin(), this->list().end(), Pred(arg1, arg2)); + if (iter != this->list().end() && *iter != nullptr) { + return *iter; + } + return nullptr; + } + + private: + virtual inline void deepCopy(const AbstractRegistry>& sr) { + for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) { + registerNew(new T_Ptr(**it)); + } + } + }; + + } // namespace utils + } // namespace base + /// @brief Base of Easylogging++ friendly class + /// + /// @detail After inheriting this class publicly, implement pure-virtual function `void log(std::ostream&) const` + class Loggable { + public: + virtual ~Loggable(void) {} + virtual void log(el::base::type::ostream_t&) const = 0; + private: + friend inline el::base::type::ostream_t& operator<<(el::base::type::ostream_t& os, const Loggable& loggable) { + loggable.log(os); + return os; + } + }; + namespace base { + /// @brief Represents log format containing flags and date format. This is used internally to start initial log + class LogFormat : public Loggable { + public: + LogFormat(void) : + m_level(Level::Unknown), + m_userFormat(base::type::string_t()), + m_format(base::type::string_t()), + m_dateTimeFormat(std::string()), + m_flags(0x0) { + } + + LogFormat(Level level, const base::type::string_t& format) + : m_level(level), m_userFormat(format) { + parseFromFormat(m_userFormat); + } + + LogFormat(const LogFormat& logFormat) { + m_level = logFormat.m_level; + m_userFormat = logFormat.m_userFormat; + m_format = logFormat.m_format; + m_dateTimeFormat = logFormat.m_dateTimeFormat; + m_flags = logFormat.m_flags; + } + + LogFormat(LogFormat&& logFormat) { + m_level = std::move(logFormat.m_level); + m_userFormat = std::move(logFormat.m_userFormat); + m_format = std::move(logFormat.m_format); + m_dateTimeFormat = std::move(logFormat.m_dateTimeFormat); + m_flags = std::move(logFormat.m_flags); + } + + LogFormat& operator=(const LogFormat& logFormat) { + m_level = logFormat.m_level; + m_userFormat = logFormat.m_userFormat; + m_dateTimeFormat = logFormat.m_dateTimeFormat; + m_flags = logFormat.m_flags; + return *this; + } + + virtual ~LogFormat(void) { + } + + inline bool operator==(const LogFormat& other) { + return m_level == other.m_level && m_userFormat == other.m_userFormat && m_format == other.m_format && + m_dateTimeFormat == other.m_dateTimeFormat && m_flags == other.m_flags; + } + + /// @brief Updates format to be used while logging. + /// @param userFormat User provided format + void parseFromFormat(const base::type::string_t& userFormat) { + // We make copy because we will be changing the format + // i.e, removing user provided date format from original format + // and then storing it. + base::type::string_t formatCopy = userFormat; + m_flags = 0x0; + auto conditionalAddFlag = [&](const base::type::char_t* specifier, base::FormatFlags flag) { + std::size_t foundAt = base::type::string_t::npos; + while ((foundAt = formatCopy.find(specifier, foundAt + 1)) != base::type::string_t::npos) { + if (foundAt > 0 && formatCopy[foundAt - 1] == base::consts::kFormatSpecifierChar) { + if (hasFlag(flag)) { + // If we already have flag we remove the escape chars so that '%%' is turned to '%' + // even after specifier resolution - this is because we only replaceFirst specifier + formatCopy.erase(foundAt > 0 ? foundAt - 1 : 0, 1); + ++foundAt; + } + } + else { + if (!hasFlag(flag)) addFlag(flag); + } + } + }; + conditionalAddFlag(base::consts::kAppNameFormatSpecifier, base::FormatFlags::AppName); + conditionalAddFlag(base::consts::kSeverityLevelFormatSpecifier, base::FormatFlags::Level); + conditionalAddFlag(base::consts::kSeverityLevelShortFormatSpecifier, base::FormatFlags::LevelShort); + conditionalAddFlag(base::consts::kLoggerIdFormatSpecifier, base::FormatFlags::LoggerId); + conditionalAddFlag(base::consts::kThreadIdFormatSpecifier, base::FormatFlags::ThreadId); + conditionalAddFlag(base::consts::kLogFileFormatSpecifier, base::FormatFlags::File); + conditionalAddFlag(base::consts::kLogFileBaseFormatSpecifier, base::FormatFlags::FileBase); + conditionalAddFlag(base::consts::kLogLineFormatSpecifier, base::FormatFlags::Line); + conditionalAddFlag(base::consts::kLogLocationFormatSpecifier, base::FormatFlags::Location); + conditionalAddFlag(base::consts::kLogFunctionFormatSpecifier, base::FormatFlags::Function); + conditionalAddFlag(base::consts::kCurrentUserFormatSpecifier, base::FormatFlags::User); + conditionalAddFlag(base::consts::kCurrentHostFormatSpecifier, base::FormatFlags::Host); + conditionalAddFlag(base::consts::kMessageFormatSpecifier, base::FormatFlags::LogMessage); + conditionalAddFlag(base::consts::kVerboseLevelFormatSpecifier, base::FormatFlags::VerboseLevel); + // For date/time we need to extract user's date format first + std::size_t dateIndex = std::string::npos; + if ((dateIndex = formatCopy.find(base::consts::kDateTimeFormatSpecifier)) != std::string::npos) { + while (dateIndex > 0 && formatCopy[dateIndex - 1] == base::consts::kFormatSpecifierChar) { + dateIndex = formatCopy.find(base::consts::kDateTimeFormatSpecifier, dateIndex + 1); + } + if (dateIndex != std::string::npos) { + addFlag(base::FormatFlags::DateTime); + updateDateFormat(dateIndex, formatCopy); + } + } + m_format = formatCopy; + updateFormatSpec(); + } + + inline Level level(void) const { + return m_level; + } + + inline const base::type::string_t& userFormat(void) const { + return m_userFormat; + } + + inline const base::type::string_t& format(void) const { + return m_format; + } + + inline const std::string& dateTimeFormat(void) const { + return m_dateTimeFormat; + } + + inline base::type::EnumType flags(void) const { + return m_flags; + } + + inline bool hasFlag(base::FormatFlags flag) const { + return base::utils::hasFlag(flag, m_flags); + } + + virtual void log(el::base::type::ostream_t& os) const { + os << m_format; + } + + protected: + /// @brief Updates date time format if available in currFormat. + /// @param index Index where %datetime, %date or %time was found + /// @param [in,out] currFormat current format that is being used to format + virtual void updateDateFormat(std::size_t index, base::type::string_t& currFormat) ELPP_FINAL { + if (hasFlag(base::FormatFlags::DateTime)) { + index += ELPP_STRLEN(base::consts::kDateTimeFormatSpecifier); + } + const base::type::char_t* ptr = currFormat.c_str() + index; + if ((currFormat.size() > index) && (ptr[0] == '{')) { + // User has provided format for date/time + ++ptr; + int count = 1; // Start by 1 in order to remove starting brace + std::stringstream ss; + for (; *ptr; ++ptr, ++count) { + if (*ptr == '}') { + ++count; // In order to remove ending brace + break; + } + ss << *ptr; + } + currFormat.erase(index, count); + m_dateTimeFormat = ss.str(); + } + else { + // No format provided, use default + if (hasFlag(base::FormatFlags::DateTime)) { + m_dateTimeFormat = std::string(base::consts::kDefaultDateTimeFormat); + } + } + } + + /// @brief Updates %level from format. This is so that we dont have to do it at log-writing-time. It uses m_format and m_level + virtual void updateFormatSpec(void) ELPP_FINAL { + // Do not use switch over strongly typed enums because Intel C++ compilers dont support them yet. + if (m_level == Level::Debug) { + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, + base::consts::kDebugLevelLogValue); + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, + base::consts::kDebugLevelShortLogValue); + } + else if (m_level == Level::Info) { + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, + base::consts::kInfoLevelLogValue); + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, + base::consts::kInfoLevelShortLogValue); + } + else if (m_level == Level::Warning) { + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, + base::consts::kWarningLevelLogValue); + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, + base::consts::kWarningLevelShortLogValue); + } + else if (m_level == Level::Error) { + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, + base::consts::kErrorLevelLogValue); + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, + base::consts::kErrorLevelShortLogValue); + } + else if (m_level == Level::Fatal) { + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, + base::consts::kFatalLevelLogValue); + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, + base::consts::kFatalLevelShortLogValue); + } + else if (m_level == Level::Verbose) { + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, + base::consts::kVerboseLevelLogValue); + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, + base::consts::kVerboseLevelShortLogValue); + } + else if (m_level == Level::Trace) { + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelFormatSpecifier, + base::consts::kTraceLevelLogValue); + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kSeverityLevelShortFormatSpecifier, + base::consts::kTraceLevelShortLogValue); + } + if (hasFlag(base::FormatFlags::User)) { + std::string s = base::utils::s_currentUser; + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kCurrentUserFormatSpecifier, + base::utils::s_currentUser); + } + if (hasFlag(base::FormatFlags::Host)) { + base::utils::Str::replaceFirstWithEscape(m_format, base::consts::kCurrentHostFormatSpecifier, + base::utils::s_currentHost); + } + // Ignore Level::Global and Level::Unknown + } + + inline void addFlag(base::FormatFlags flag) { + base::utils::addFlag(flag, &m_flags); + } + + private: + Level m_level; + base::type::string_t m_userFormat; + base::type::string_t m_format; + std::string m_dateTimeFormat; + base::type::EnumType m_flags; + friend class el::Logger; // To resolve loggerId format specifier easily + }; + } // namespace base + /// @brief Resolving function for format specifier + typedef std::function FormatSpecifierValueResolver; + /// @brief User-provided custom format specifier + /// @see el::Helpers::installCustomFormatSpecifier + /// @see FormatSpecifierValueResolver + class CustomFormatSpecifier { + public: + CustomFormatSpecifier(const char* formatSpecifier, const FormatSpecifierValueResolver& resolver) : + m_formatSpecifier(formatSpecifier), m_resolver(resolver) {} + inline const char* formatSpecifier(void) const { return m_formatSpecifier; } + inline const FormatSpecifierValueResolver& resolver(void) const { return m_resolver; } + inline bool operator==(const char* formatSpecifier) { + return strcmp(m_formatSpecifier, formatSpecifier) == 0; + } + + private: + const char* m_formatSpecifier; + FormatSpecifierValueResolver m_resolver; + }; + /// @brief Represents single configuration that has representing level, configuration type and a string based value. + /// + /// @detail String based value means any value either its boolean, integer or string itself, it will be embedded inside quotes + /// and will be parsed later. + /// + /// Consider some examples below: + /// * el::Configuration confEnabledInfo(el::Level::Info, el::ConfigurationType::Enabled, "true"); + /// * el::Configuration confMaxLogFileSizeInfo(el::Level::Info, el::ConfigurationType::MaxLogFileSize, "2048"); + /// * el::Configuration confFilenameInfo(el::Level::Info, el::ConfigurationType::Filename, "/var/log/my.log"); + class Configuration : public Loggable { + public: + Configuration(const Configuration& c) : + m_level(c.m_level), + m_configurationType(c.m_configurationType), + m_value(c.m_value) { + } + + Configuration& operator=(const Configuration& c) { + m_level = c.m_level; + m_configurationType = c.m_configurationType; + m_value = c.m_value; + return *this; + } + + virtual ~Configuration(void) { + } + + /// @brief Full constructor used to sets value of configuration + Configuration(Level level, ConfigurationType configurationType, const std::string& value) : + m_level(level), + m_configurationType(configurationType), + m_value(value) { + } + + /// @brief Gets level of current configuration + inline Level level(void) const { + return m_level; + } + + /// @brief Gets configuration type of current configuration + inline ConfigurationType configurationType(void) const { + return m_configurationType; + } + + /// @brief Gets string based configuration value + inline const std::string& value(void) const { + return m_value; + } + + /// @brief Set string based configuration value + /// @param value Value to set. Values have to be std::string; For boolean values use "true", "false", for any integral values + /// use them in quotes. They will be parsed when configuring + inline void setValue(const std::string& value) { + m_value = value; + } + + virtual inline void log(el::base::type::ostream_t& os) const { + os << LevelHelper::convertToString(m_level) + << ELPP_LITERAL(" ") << ConfigurationTypeHelper::convertToString(m_configurationType) + << ELPP_LITERAL(" = ") << m_value.c_str(); + } + + /// @brief Used to find configuration from configuration (pointers) repository. Avoid using it. + class Predicate { + public: + Predicate(Level level, ConfigurationType configurationType) : + m_level(level), + m_configurationType(configurationType) { + } + + inline bool operator()(const Configuration* conf) const { + return ((conf != nullptr) && (conf->level() == m_level) && (conf->configurationType() == m_configurationType)); + } + + private: + Level m_level; + ConfigurationType m_configurationType; + }; + + private: + Level m_level; + ConfigurationType m_configurationType; + std::string m_value; + }; + + /// @brief Thread-safe Configuration repository + /// + /// @detail This repository represents configurations for all the levels and configuration type mapped to a value. + class Configurations : public base::utils::RegistryWithPred { + public: + /// @brief Default constructor with empty repository + Configurations(void) : + m_configurationFile(std::string()), + m_isFromFile(false) { + } + + /// @brief Constructor used to set configurations using configuration file. + /// @param configurationFile Full path to configuration file + /// @param useDefaultsForRemaining Lets you set the remaining configurations to default. + /// @param base If provided, this configuration will be based off existing repository that this argument is pointing to. + /// @see parseFromFile(const std::string&, Configurations* base) + /// @see setRemainingToDefault() + Configurations(const std::string& configurationFile, bool useDefaultsForRemaining = true, Configurations* base = nullptr) : + m_configurationFile(configurationFile), + m_isFromFile(false) { + parseFromFile(configurationFile, base); + if (useDefaultsForRemaining) { + setRemainingToDefault(); + } + } + + virtual ~Configurations(void) { + } + + /// @brief Parses configuration from file. + /// @param configurationFile Full path to configuration file + /// @param base Configurations to base new configuration repository off. This value is used when you want to use + /// existing Configurations to base all the values and then set rest of configuration via configuration file. + /// @return True if successfully parsed, false otherwise. You may define 'ELPP_DEBUG_ASSERT_FAILURE' to make sure you + /// do not proceed without successful parse. + inline bool parseFromFile(const std::string& configurationFile, Configurations* base = nullptr) { + // We initial assertion with true because if we have assertion diabled, we want to pass this + // check and if assertion is enabled we will have values re-assigned any way. + bool assertionPassed = true; + ELPP_ASSERT((assertionPassed = base::utils::File::pathExists(configurationFile.c_str(), true)), + "Configuration file [" << configurationFile << "] does not exist!"); + if (!assertionPassed) { + return false; + } + bool success = Parser::parseFromFile(configurationFile, this, base); + m_isFromFile = success; + return success; + } + + /// @brief Parse configurations from configuration string. + /// + /// @detail This configuration string has same syntax as configuration file contents. Make sure all the necessary + /// new line characters are provided. + /// @param base Configurations to base new configuration repository off. This value is used when you want to use + /// existing Configurations to base all the values and then set rest of configuration via configuration text. + /// @return True if successfully parsed, false otherwise. You may define 'ELPP_DEBUG_ASSERT_FAILURE' to make sure you + /// do not proceed without successful parse. + inline bool parseFromText(const std::string& configurationsString, Configurations* base = nullptr) { + bool success = Parser::parseFromText(configurationsString, this, base); + if (success) { + m_isFromFile = false; + } + return success; + } + + /// @brief Sets configuration based-off an existing configurations. + /// @param base Pointer to existing configurations. + inline void setFromBase(Configurations* base) { + if (base == nullptr || base == this) { + return; + } + base::threading::ScopedLock scopedLock(base->lock()); + for (Configuration*& conf : base->list()) { + set(conf); + } + } + + /// @brief Determines whether or not specified configuration type exists in the repository. + /// + /// @detail Returns as soon as first level is found. + /// @param configurationType Type of configuration to check existence for. + bool hasConfiguration(ConfigurationType configurationType) { + base::type::EnumType lIndex = LevelHelper::kMinValid; + bool result = false; + LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { + if (hasConfiguration(LevelHelper::castFromInt(lIndex), configurationType)) { + result = true; + } + return result; + }); + return result; + } + + /// @brief Determines whether or not specified configuration type exists for specified level + /// @param level Level to check + /// @param configurationType Type of configuration to check existence for. + inline bool hasConfiguration(Level level, ConfigurationType configurationType) { + base::threading::ScopedLock scopedLock(lock()); +#if ELPP_COMPILER_INTEL + // We cant specify template types here, Intel C++ throws compilation error + // "error: type name is not allowed" + return RegistryWithPred::get(level, configurationType) != nullptr; +#else + return RegistryWithPred::get(level, configurationType) != nullptr; +#endif // ELPP_COMPILER_INTEL + } + + /// @brief Sets value of configuration for specified level. + /// + /// @detail Any existing configuration for specified level will be replaced. Also note that configuration types + /// ConfigurationType::MillisecondsWidth and ConfigurationType::PerformanceTracking will be ignored if not set for + /// Level::Global because these configurations are not dependant on level. + /// @param level Level to set configuration for (el::Level). + /// @param configurationType Type of configuration (el::ConfigurationType) + /// @param value A string based value. Regardless of what the data type of configuration is, it will always be string + /// from users' point of view. This is then parsed later to be used internally. + /// @see Configuration::setValue(const std::string& value) + /// @see el::Level + /// @see el::ConfigurationType + inline void set(Level level, ConfigurationType configurationType, const std::string& value) { + base::threading::ScopedLock scopedLock(lock()); + unsafeSet(level, configurationType, value); // This is not unsafe anymore as we have locked mutex + if (level == Level::Global) { + unsafeSetGlobally(configurationType, value, false); // Again this is not unsafe either + } + } + + /// @brief Sets single configuration based on other single configuration. + /// @see set(Level level, ConfigurationType configurationType, const std::string& value) + inline void set(Configuration* conf) { + if (conf == nullptr) { + return; + } + set(conf->level(), conf->configurationType(), conf->value()); + } + + inline Configuration* get(Level level, ConfigurationType configurationType) { + base::threading::ScopedLock scopedLock(lock()); + return RegistryWithPred::get(level, configurationType); + } + + /// @brief Sets configuration for all levels. + /// @param configurationType Type of configuration + /// @param value String based value + /// @see Configurations::set(Level level, ConfigurationType configurationType, const std::string& value) + inline void setGlobally(ConfigurationType configurationType, const std::string& value) { + setGlobally(configurationType, value, false); + } + + /// @brief Clears repository so that all the configurations are unset + inline void clear(void) { + base::threading::ScopedLock scopedLock(lock()); + unregisterAll(); + } + + /// @brief Gets configuration file used in parsing this configurations. + /// + /// @detail If this repository was set manually or by text this returns empty string. + inline const std::string& configurationFile(void) const { + return m_configurationFile; + } + + /// @brief Sets configurations to "factory based" configurations. + void setToDefault(void) { + setGlobally(ConfigurationType::Enabled, std::string("true"), true); +#if !defined(ELPP_NO_DEFAULT_LOG_FILE) + setGlobally(ConfigurationType::Filename, std::string(base::consts::kDefaultLogFile), true); +#else + ELPP_UNUSED(base::consts::kDefaultLogFile); +#endif // !defined(ELPP_NO_DEFAULT_LOG_FILE) + setGlobally(ConfigurationType::ToFile, std::string("true"), true); + setGlobally(ConfigurationType::ToStandardOutput, std::string("true"), true); + setGlobally(ConfigurationType::MillisecondsWidth, std::string("3"), true); + setGlobally(ConfigurationType::PerformanceTracking, std::string("true"), true); + setGlobally(ConfigurationType::MaxLogFileSize, std::string("0"), true); + setGlobally(ConfigurationType::LogFlushThreshold, std::string("0"), true); + + setGlobally(ConfigurationType::Format, std::string("%datetime %level [%logger] %msg"), true); + set(Level::Debug, ConfigurationType::Format, std::string("%datetime %level [%logger] [%user@%host] [%func] [%loc] %msg")); + // INFO and WARNING are set to default by Level::Global + set(Level::Error, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); + set(Level::Fatal, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); + set(Level::Verbose, ConfigurationType::Format, std::string("%datetime %level-%vlevel [%logger] %msg")); + set(Level::Trace, ConfigurationType::Format, std::string("%datetime %level [%logger] [%func] [%loc] %msg")); + } + + /// @brief Lets you set the remaining configurations to default. + /// + /// @detail By remaining, it means that the level/type a configuration does not exist for. + /// This function is useful when you want to minimize chances of failures, e.g, if you have a configuration file that sets + /// configuration for all the configurations except for Enabled or not, we use this so that ENABLED is set to default i.e, + /// true. If you dont do this explicitley (either by calling this function or by using second param in Constructor + /// and try to access a value, an error is thrown + void setRemainingToDefault(void) { + base::threading::ScopedLock scopedLock(lock()); + unsafeSetIfNotExist(Level::Global, ConfigurationType::Enabled, std::string("true")); +#if !defined(ELPP_NO_DEFAULT_LOG_FILE) + unsafeSetIfNotExist(Level::Global, ConfigurationType::Filename, std::string(base::consts::kDefaultLogFile)); +#endif // !defined(ELPP_NO_DEFAULT_LOG_FILE) + unsafeSetIfNotExist(Level::Global, ConfigurationType::ToFile, std::string("true")); + unsafeSetIfNotExist(Level::Global, ConfigurationType::ToStandardOutput, std::string("true")); + unsafeSetIfNotExist(Level::Global, ConfigurationType::MillisecondsWidth, std::string("3")); + unsafeSetIfNotExist(Level::Global, ConfigurationType::PerformanceTracking, std::string("true")); + unsafeSetIfNotExist(Level::Global, ConfigurationType::MaxLogFileSize, std::string("0")); + unsafeSetIfNotExist(Level::Global, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); + unsafeSetIfNotExist(Level::Debug, ConfigurationType::Format, + std::string("%datetime %level [%logger] [%user@%host] [%func] [%loc] %msg")); + // INFO and WARNING are set to default by Level::Global + unsafeSetIfNotExist(Level::Error, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); + unsafeSetIfNotExist(Level::Fatal, ConfigurationType::Format, std::string("%datetime %level [%logger] %msg")); + unsafeSetIfNotExist(Level::Verbose, ConfigurationType::Format, std::string("%datetime %level-%vlevel [%logger] %msg")); + unsafeSetIfNotExist(Level::Trace, ConfigurationType::Format, std::string("%datetime %level [%logger] [%func] [%loc] %msg")); + } + + /// @brief Parser used internally to parse configurations from file or text. + /// + /// @detail This class makes use of base::utils::Str. + /// You should not need this unless you are working on some tool for Easylogging++ + class Parser : base::StaticClass { + public: + /// @brief Parses configuration from file. + /// @param configurationFile Full path to configuration file + /// @param sender Sender configurations pointer. Usually 'this' is used from calling class + /// @param base Configurations to base new configuration repository off. This value is used when you want to use + /// existing Configurations to base all the values and then set rest of configuration via configuration file. + /// @return True if successfully parsed, false otherwise. You may define '_STOP_ON_FIRSTELPP_ASSERTION' to make sure you + /// do not proceed without successful parse. + static bool parseFromFile(const std::string& configurationFile, Configurations* sender, Configurations* base = nullptr) { + sender->setFromBase(base); + std::ifstream fileStream_(configurationFile.c_str(), std::ifstream::in); + ELPP_ASSERT(fileStream_.is_open(), "Unable to open configuration file [" << configurationFile << "] for parsing."); + bool parsedSuccessfully = false; + std::string line = std::string(); + Level currLevel = Level::Unknown; + std::string currConfigStr = std::string(); + std::string currLevelStr = std::string(); + while (fileStream_.good()) { + std::getline(fileStream_, line); + parsedSuccessfully = parseLine(&line, &currConfigStr, &currLevelStr, &currLevel, sender); + ELPP_ASSERT(parsedSuccessfully, "Unable to parse configuration line: " << line); + } + return parsedSuccessfully; + } + + /// @brief Parse configurations from configuration string. + /// + /// @detail This configuration string has same syntax as configuration file contents. Make sure all the necessary + /// new line characters are provided. You may define '_STOP_ON_FIRSTELPP_ASSERTION' to make sure you + /// do not proceed without successful parse (This is recommended) + /// @param configurationsString + /// @param sender Sender configurations pointer. Usually 'this' is used from calling class + /// @param base Configurations to base new configuration repository off. This value is used when you want to use + /// existing Configurations to base all the values and then set rest of configuration via configuration text. + /// @return True if successfully parsed, false otherwise. + static bool parseFromText(const std::string& configurationsString, Configurations* sender, Configurations* base = nullptr) { + sender->setFromBase(base); + bool parsedSuccessfully = false; + std::stringstream ss(configurationsString); + std::string line = std::string(); + Level currLevel = Level::Unknown; + std::string currConfigStr = std::string(); + std::string currLevelStr = std::string(); + while (std::getline(ss, line)) { + parsedSuccessfully = parseLine(&line, &currConfigStr, &currLevelStr, &currLevel, sender); + ELPP_ASSERT(parsedSuccessfully, "Unable to parse configuration line: " << line); + } + return parsedSuccessfully; + } + + private: + friend class el::Loggers; + static void ignoreComments(std::string* line) { + std::size_t foundAt = 0; + std::size_t quotesStart = line->find("\""); + std::size_t quotesEnd = std::string::npos; + if (quotesStart != std::string::npos) { + quotesEnd = line->find("\"", quotesStart + 1); + while (quotesEnd != std::string::npos && line->at(quotesEnd - 1) == '\\') { + // Do not erase slash yet - we will erase it in parseLine(..) while loop + quotesEnd = line->find("\"", quotesEnd + 2); + } + } + if ((foundAt = line->find(base::consts::kConfigurationComment)) != std::string::npos) { + if (foundAt < quotesEnd) { + foundAt = line->find(base::consts::kConfigurationComment, quotesEnd + 1); + } + *line = line->substr(0, foundAt); + } + } + static inline bool isLevel(const std::string& line) { + return base::utils::Str::startsWith(line, std::string(base::consts::kConfigurationLevel)); + } + + static inline bool isComment(const std::string& line) { + return base::utils::Str::startsWith(line, std::string(base::consts::kConfigurationComment)); + } + + static inline bool isConfig(const std::string& line) { + std::size_t assignment = line.find('='); + return line != "" && + (line[0] >= 65 || line[0] <= 90 || line[0] >= 97 || line[0] <= 122) && + (assignment != std::string::npos) && + (line.size() > assignment); + } + + static bool parseLine(std::string* line, std::string* currConfigStr, std::string* currLevelStr, Level* currLevel, Configurations* conf) { + ConfigurationType currConfig = ConfigurationType::Unknown; + std::string currValue = std::string(); + *line = base::utils::Str::trim(*line); + if (isComment(*line)) return true; + ignoreComments(line); + *line = base::utils::Str::trim(*line); + if (line->empty()) { + // Comment ignored + return true; + } + if (isLevel(*line)) { + if (line->size() <= 2) { + return true; + } + *currLevelStr = line->substr(1, line->size() - 2); + *currLevelStr = base::utils::Str::toUpper(*currLevelStr); + *currLevelStr = base::utils::Str::trim(*currLevelStr); + *currLevel = LevelHelper::convertFromString(currLevelStr->c_str()); + return true; + } + if (isConfig(*line)) { + std::size_t assignment = line->find('='); + *currConfigStr = line->substr(0, assignment); + *currConfigStr = base::utils::Str::toUpper(*currConfigStr); + *currConfigStr = base::utils::Str::trim(*currConfigStr); + currConfig = ConfigurationTypeHelper::convertFromString(currConfigStr->c_str()); + currValue = line->substr(assignment + 1); + currValue = base::utils::Str::trim(currValue); + std::size_t quotesStart = currValue.find("\"", 0); + std::size_t quotesEnd = std::string::npos; + if (quotesStart != std::string::npos) { + quotesEnd = currValue.find("\"", quotesStart + 1); + while (quotesEnd != std::string::npos && currValue.at(quotesEnd - 1) == '\\') { + currValue = currValue.erase(quotesEnd - 1, 1); + quotesEnd = currValue.find("\"", quotesEnd + 2); + } + } + if (quotesStart != std::string::npos && quotesEnd != std::string::npos) { + // Quote provided - check and strip if valid + ELPP_ASSERT((quotesStart < quotesEnd), "Configuration error - No ending quote found in [" + << currConfigStr << "]"); + ELPP_ASSERT((quotesStart + 1 != quotesEnd), "Empty configuration value for [" << currConfigStr << "]"); + if ((quotesStart != quotesEnd) && (quotesStart + 1 != quotesEnd)) { + // Explicit check in case if assertion is disabled + currValue = currValue.substr(quotesStart + 1, quotesEnd - 1); + } + } + } + ELPP_ASSERT(*currLevel != Level::Unknown, "Unrecognized severity level [" << *currLevelStr << "]"); + ELPP_ASSERT(currConfig != ConfigurationType::Unknown, "Unrecognized configuration [" << *currConfigStr << "]"); + if (*currLevel == Level::Unknown || currConfig == ConfigurationType::Unknown) { + return false; // unrecognizable level or config + } + conf->set(*currLevel, currConfig, currValue); + return true; + } + }; + + private: + std::string m_configurationFile; + bool m_isFromFile; + friend class el::Loggers; + + /// @brief Unsafely sets configuration if does not already exist + void unsafeSetIfNotExist(Level level, ConfigurationType configurationType, const std::string& value) { + Configuration* conf = RegistryWithPred::get(level, configurationType); + if (conf == nullptr) { + unsafeSet(level, configurationType, value); + } + } + + /// @brief Thread unsafe set + void unsafeSet(Level level, ConfigurationType configurationType, const std::string& value) { + Configuration* conf = RegistryWithPred::get(level, configurationType); + if (conf == nullptr) { + registerNew(new Configuration(level, configurationType, value)); + } + else { + conf->setValue(value); + } + if (level == Level::Global) { + unsafeSetGlobally(configurationType, value, false); + } + } + + /// @brief Sets configurations for all levels including Level::Global if includeGlobalLevel is true + /// @see Configurations::setGlobally(ConfigurationType configurationType, const std::string& value) + void setGlobally(ConfigurationType configurationType, const std::string& value, bool includeGlobalLevel) { + if (includeGlobalLevel) { + set(Level::Global, configurationType, value); + } + base::type::EnumType lIndex = LevelHelper::kMinValid; + LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { + set(LevelHelper::castFromInt(lIndex), configurationType, value); + return false; // Do not break lambda function yet as we need to set all levels regardless + }); + } + + /// @brief Sets configurations (Unsafely) for all levels including Level::Global if includeGlobalLevel is true + /// @see Configurations::setGlobally(ConfigurationType configurationType, const std::string& value) + void unsafeSetGlobally(ConfigurationType configurationType, const std::string& value, bool includeGlobalLevel) { + if (includeGlobalLevel) { + unsafeSet(Level::Global, configurationType, value); + } + base::type::EnumType lIndex = LevelHelper::kMinValid; + LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { + unsafeSet(LevelHelper::castFromInt(lIndex), configurationType, value); + return false; // Do not break lambda function yet as we need to set all levels regardless + }); + } + }; + + namespace base { + typedef std::shared_ptr FileStreamPtr; + typedef std::map LogStreamsReferenceMap; + /// @brief Configurations with data types. + /// + /// @detail el::Configurations have string based values. This is whats used internally in order to read correct configurations. + /// This is to perform faster while writing logs using correct configurations. + /// + /// This is thread safe and final class containing non-virtual destructor (means nothing should inherit this class) + class TypedConfigurations : public base::threading::ThreadSafe { + public: + /// @brief Constructor to initialize (construct) the object off el::Configurations + /// @param configurations Configurations pointer/reference to base this typed configurations off. + /// @param logStreamsReference Use ELPP->registeredLoggers()->logStreamsReference() + TypedConfigurations(Configurations* configurations, base::LogStreamsReferenceMap* logStreamsReference) { + m_configurations = configurations; + m_logStreamsReference = logStreamsReference; + build(m_configurations); + } + + TypedConfigurations(const TypedConfigurations& other) { + this->m_configurations = other.m_configurations; + this->m_logStreamsReference = other.m_logStreamsReference; + build(m_configurations); + } + + virtual ~TypedConfigurations(void) { + } + + const Configurations* configurations(void) const { + return m_configurations; + } + + inline bool enabled(Level level) { + return getConfigByVal(level, &m_enabledMap, "enabled"); + } + + inline bool toFile(Level level) { + return getConfigByVal(level, &m_toFileMap, "toFile"); + } + + inline const std::string& filename(Level level) { + return getConfigByRef(level, &m_filenameMap, "filename"); + } + + inline bool toStandardOutput(Level level) { + return getConfigByVal(level, &m_toStandardOutputMap, "toStandardOutput"); + } + + inline const base::LogFormat& logFormat(Level level) { + return getConfigByRef(level, &m_logFormatMap, "logFormat"); + } + + inline const base::MillisecondsWidth& millisecondsWidth(Level level = Level::Global) { + return getConfigByRef(level, &m_millisecondsWidthMap, "millisecondsWidth"); + } + + inline bool performanceTracking(Level level = Level::Global) { + return getConfigByVal(level, &m_performanceTrackingMap, "performanceTracking"); + } + + inline base::type::fstream_t* fileStream(Level level) { + return getConfigByRef(level, &m_fileStreamMap, "fileStream").get(); + } + + inline std::size_t maxLogFileSize(Level level) { + return getConfigByVal(level, &m_maxLogFileSizeMap, "maxLogFileSize"); + } + + inline std::size_t logFlushThreshold(Level level) { + return getConfigByVal(level, &m_logFlushThresholdMap, "logFlushThreshold"); + } + + private: + Configurations* m_configurations; + std::map m_enabledMap; + std::map m_toFileMap; + std::map m_filenameMap; + std::map m_toStandardOutputMap; + std::map m_logFormatMap; + std::map m_millisecondsWidthMap; + std::map m_performanceTrackingMap; + std::map m_fileStreamMap; + std::map m_maxLogFileSizeMap; + std::map m_logFlushThresholdMap; + base::LogStreamsReferenceMap* m_logStreamsReference; + + friend class el::Helpers; + friend class el::base::MessageBuilder; + friend class el::base::Writer; + friend class el::base::DefaultLogDispatchCallback; + friend class el::base::LogDispatcher; + + template + inline Conf_T getConfigByVal(Level level, const std::map* confMap, const char* confName) { + base::threading::ScopedLock scopedLock(lock()); + return unsafeGetConfigByVal(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope + } + + template + inline Conf_T& getConfigByRef(Level level, std::map* confMap, const char* confName) { + base::threading::ScopedLock scopedLock(lock()); + return unsafeGetConfigByRef(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope + } + + template + inline Conf_T unsafeGetConfigByVal(Level level, const std::map* confMap, const char* confName) { + ELPP_UNUSED(confName); + typename std::map::const_iterator it = confMap->find(level); + if (it == confMap->end()) { + try { + return confMap->at(Level::Global); + } + catch (...) { + ELPP_INTERNAL_ERROR("Unable to get configuration [" << confName << "] for level [" + << LevelHelper::convertToString(level) << "]" + << std::endl << "Please ensure you have properly configured logger.", false); + return Conf_T(); + } + } + return it->second; + } + + template + inline Conf_T& unsafeGetConfigByRef(Level level, std::map* confMap, const char* confName) { + ELPP_UNUSED(confName); + typename std::map::iterator it = confMap->find(level); + if (it == confMap->end()) { + try { + return confMap->at(Level::Global); + } + catch (...) { + ELPP_INTERNAL_ERROR("Unable to get configuration [" << confName << "] for level [" + << LevelHelper::convertToString(level) << "]" + << std::endl << "Please ensure you have properly configured logger.", false); + } + } + return it->second; + } + + template + void setValue(Level level, const Conf_T& value, std::map* confMap, bool includeGlobalLevel = true) { + // If map is empty and we are allowed to add into generic level (Level::Global), do it! + if (confMap->empty() && includeGlobalLevel) { + confMap->insert(std::make_pair(Level::Global, value)); + return; + } + // If same value exist in generic level already, dont add it to explicit level + typename std::map::iterator it = confMap->find(Level::Global); + if (it != confMap->end() && it->second == value) { + return; + } + // Now make sure we dont double up values if we really need to add it to explicit level + it = confMap->find(level); + if (it == confMap->end()) { + // Value not found for level, add new + confMap->insert(std::make_pair(level, value)); + } + else { + // Value found, just update value + confMap->at(level) = value; + } + } + + void build(Configurations* configurations) { + base::threading::ScopedLock scopedLock(lock()); + auto getBool = [](std::string boolStr) -> bool { // Pass by value for trimming + base::utils::Str::trim(boolStr); + return (boolStr == "TRUE" || boolStr == "true" || boolStr == "1"); + }; + std::vector withFileSizeLimit; + for (Configurations::const_iterator it = configurations->begin(); it != configurations->end(); ++it) { + Configuration* conf = *it; + // We cannot use switch on strong enums because Intel C++ dont support them yet + if (conf->configurationType() == ConfigurationType::Enabled) { + setValue(conf->level(), getBool(conf->value()), &m_enabledMap); + } + else if (conf->configurationType() == ConfigurationType::ToFile) { + setValue(conf->level(), getBool(conf->value()), &m_toFileMap); + } + else if (conf->configurationType() == ConfigurationType::ToStandardOutput) { + setValue(conf->level(), getBool(conf->value()), &m_toStandardOutputMap); + } + else if (conf->configurationType() == ConfigurationType::Filename) { + // We do not yet configure filename but we will configure in another + // loop. This is because if file cannot be created, we will force ToFile + // to be false. Because configuring logger is not necessarily performance + // sensative operation, we can live with another loop; (by the way this loop + // is not very heavy either) + } + else if (conf->configurationType() == ConfigurationType::Format) { + setValue(conf->level(), base::LogFormat(conf->level(), + base::type::string_t(conf->value().begin(), conf->value().end())), &m_logFormatMap); + } + else if (conf->configurationType() == ConfigurationType::MillisecondsWidth) { + setValue(Level::Global, + base::MillisecondsWidth(static_cast(getULong(conf->value()))), &m_millisecondsWidthMap); + } + else if (conf->configurationType() == ConfigurationType::PerformanceTracking) { + setValue(Level::Global, getBool(conf->value()), &m_performanceTrackingMap); + } + else if (conf->configurationType() == ConfigurationType::MaxLogFileSize) { + setValue(conf->level(), static_cast(getULong(conf->value())), &m_maxLogFileSizeMap); +#if !defined(ELPP_NO_DEFAULT_LOG_FILE) + withFileSizeLimit.push_back(conf); +#endif // !defined(ELPP_NO_DEFAULT_LOG_FILE) + } + else if (conf->configurationType() == ConfigurationType::LogFlushThreshold) { + setValue(conf->level(), static_cast(getULong(conf->value())), &m_logFlushThresholdMap); + } + } + // As mentioned early, we will now set filename configuration in separate loop to deal with non-existent files + for (Configurations::const_iterator it = configurations->begin(); it != configurations->end(); ++it) { + Configuration* conf = *it; + if (conf->configurationType() == ConfigurationType::Filename) { + insertFile(conf->level(), conf->value()); + } + } + for (std::vector::iterator conf = withFileSizeLimit.begin(); + conf != withFileSizeLimit.end(); ++conf) { + // This is not unsafe as mutex is locked in currect scope + unsafeValidateFileRolling((*conf)->level(), base::defaultPreRollOutCallback); + } + } + + unsigned long getULong(std::string confVal) { + bool valid = true; + base::utils::Str::trim(confVal); + valid = !confVal.empty() && std::find_if(confVal.begin(), confVal.end(), + [](char c) { return !base::utils::Str::isDigit(c); }) == confVal.end(); + if (!valid) { + valid = false; + ELPP_ASSERT(valid, "Configuration value not a valid integer [" << confVal << "]"); + return 0; + } + return atol(confVal.c_str()); + } + + std::string resolveFilename(const std::string& filename) { + std::string resultingFilename = filename; + std::size_t dateIndex = std::string::npos; + std::string dateTimeFormatSpecifierStr = std::string(base::consts::kDateTimeFormatSpecifierForFilename); + if ((dateIndex = resultingFilename.find(dateTimeFormatSpecifierStr.c_str())) != std::string::npos) { + while (dateIndex > 0 && resultingFilename[dateIndex - 1] == base::consts::kFormatSpecifierChar) { + dateIndex = resultingFilename.find(dateTimeFormatSpecifierStr.c_str(), dateIndex + 1); + } + if (dateIndex != std::string::npos) { + const char* ptr = resultingFilename.c_str() + dateIndex; + // Goto end of specifier + ptr += dateTimeFormatSpecifierStr.size(); + std::string fmt; + if ((resultingFilename.size() > dateIndex) && (ptr[0] == '{')) { + // User has provided format for date/time + ++ptr; + int count = 1; // Start by 1 in order to remove starting brace + std::stringstream ss; + for (; *ptr; ++ptr, ++count) { + if (*ptr == '}') { + ++count; // In order to remove ending brace + break; + } + ss << *ptr; + } + resultingFilename.erase(dateIndex + dateTimeFormatSpecifierStr.size(), count); + fmt = ss.str(); + } + else { + fmt = std::string(base::consts::kDefaultDateTimeFormatInFilename); + } + base::MillisecondsWidth msWidth(3); + std::string now = base::utils::DateTime::getDateTime(fmt.c_str(), &msWidth); + base::utils::Str::replaceAll(now, '/', '-'); // Replace path element since we are dealing with filename + base::utils::Str::replaceAll(resultingFilename, dateTimeFormatSpecifierStr, now); + } + } + return resultingFilename; + } + + void insertFile(Level level, const std::string& fullFilename) { + std::string resolvedFilename = resolveFilename(fullFilename); + if (resolvedFilename.empty()) { + std::cerr << "Could not load empty file for logging, please re-check your configurations for level [" + << LevelHelper::convertToString(level) << "]"; + } + std::string filePath = base::utils::File::extractPathFromFilename(resolvedFilename, base::consts::kFilePathSeperator); + if (filePath.size() < resolvedFilename.size()) { + base::utils::File::createPath(filePath); + } + auto create = [&](Level level) { + base::LogStreamsReferenceMap::iterator filestreamIter = m_logStreamsReference->find(resolvedFilename); + base::type::fstream_t* fs = nullptr; + if (filestreamIter == m_logStreamsReference->end()) { + // We need a completely new stream, nothing to share with + fs = base::utils::File::newFileStream(resolvedFilename); + m_filenameMap.insert(std::make_pair(level, resolvedFilename)); + m_fileStreamMap.insert(std::make_pair(level, base::FileStreamPtr(fs))); + m_logStreamsReference->insert(std::make_pair(resolvedFilename, base::FileStreamPtr(m_fileStreamMap.at(level)))); + } + else { + // Woops! we have an existing one, share it! + m_filenameMap.insert(std::make_pair(level, filestreamIter->first)); + m_fileStreamMap.insert(std::make_pair(level, base::FileStreamPtr(filestreamIter->second))); + fs = filestreamIter->second.get(); + } + if (fs == nullptr) { + // We display bad file error from newFileStream() + ELPP_INTERNAL_ERROR("Setting [TO_FILE] of [" + << LevelHelper::convertToString(level) << "] to FALSE", false); + setValue(level, false, &m_toFileMap); + } + }; + // If we dont have file conf for any level, create it for Level::Global first + // otherwise create for specified level + create(m_filenameMap.empty() && m_fileStreamMap.empty() ? Level::Global : level); + } + + bool unsafeValidateFileRolling(Level level, const PreRollOutCallback& PreRollOutCallback) { + base::type::fstream_t* fs = unsafeGetConfigByRef(level, &m_fileStreamMap, "fileStream").get(); + if (fs == nullptr) { + return true; + } + std::size_t maxLogFileSize = unsafeGetConfigByVal(level, &m_maxLogFileSizeMap, "maxLogFileSize"); + std::size_t currFileSize = base::utils::File::getSizeOfFile(fs); + if (maxLogFileSize != 0 && currFileSize >= maxLogFileSize) { + std::string fname = unsafeGetConfigByRef(level, &m_filenameMap, "filename"); + ELPP_INTERNAL_INFO(1, "Truncating log file [" << fname << "] as a result of configurations for level [" + << LevelHelper::convertToString(level) << "]"); + fs->close(); + PreRollOutCallback(fname.c_str(), currFileSize); + fs->open(fname, std::fstream::out | std::fstream::trunc); + return true; + } + return false; + } + + bool validateFileRolling(Level level, const PreRollOutCallback& PreRollOutCallback) { + base::threading::ScopedLock scopedLock(lock()); + return unsafeValidateFileRolling(level, PreRollOutCallback); + } + }; + /// @brief Class that keeps record of current line hit for occasional logging + class HitCounter { + public: + HitCounter(void) : + m_filename(""), + m_lineNumber(0), + m_hitCounts(0) { + } + + HitCounter(const char* filename, unsigned long int lineNumber) : + m_filename(filename), + m_lineNumber(lineNumber), + m_hitCounts(0) { + } + + HitCounter(const HitCounter& hitCounter) : + m_filename(hitCounter.m_filename), + m_lineNumber(hitCounter.m_lineNumber), + m_hitCounts(hitCounter.m_hitCounts) { + } + + HitCounter& operator=(const HitCounter& hitCounter) { + m_filename = hitCounter.m_filename; + m_lineNumber = hitCounter.m_lineNumber; + m_hitCounts = hitCounter.m_hitCounts; + return *this; + } + + virtual ~HitCounter(void) { + } + + /// @brief Resets location of current hit counter + inline void resetLocation(const char* filename, unsigned long int lineNumber) { + m_filename = filename; + m_lineNumber = lineNumber; + } + + /// @brief Validates hit counts and resets it if necessary + inline void validateHitCounts(std::size_t n) { + if (m_hitCounts >= base::consts::kMaxLogPerCounter) { + m_hitCounts = (n >= 1 ? base::consts::kMaxLogPerCounter % n : 0); + } + ++m_hitCounts; + } + + inline const char* filename(void) const { + return m_filename; + } + + inline unsigned long int lineNumber(void) const { + return m_lineNumber; + } + + inline std::size_t hitCounts(void) const { + return m_hitCounts; + } + + inline void increment(void) { + ++m_hitCounts; + } + + class Predicate { + public: + Predicate(const char* filename, unsigned long int lineNumber) + : m_filename(filename), + m_lineNumber(lineNumber) { + } + inline bool operator()(const HitCounter* counter) { + return ((counter != nullptr) && + (strcmp(counter->m_filename, m_filename) == 0) && + (counter->m_lineNumber == m_lineNumber)); + } + + private: + const char* m_filename; + unsigned long int m_lineNumber; + }; + + private: + const char* m_filename; + unsigned long int m_lineNumber; + std::size_t m_hitCounts; + }; + /// @brief Repository for hit counters used across the application + class RegisteredHitCounters : public base::utils::RegistryWithPred { + public: + /// @brief Validates counter for every N, i.e, registers new if does not exist otherwise updates original one + /// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned + bool validateEveryN(const char* filename, unsigned long int lineNumber, std::size_t n) { + base::threading::ScopedLock scopedLock(lock()); + base::HitCounter* counter = get(filename, lineNumber); + if (counter == nullptr) { + registerNew(counter = new base::HitCounter(filename, lineNumber)); + } + counter->validateHitCounts(n); + bool result = (n >= 1 && counter->hitCounts() != 0 && counter->hitCounts() % n == 0); + return result; + } + + /// @brief Validates counter for hits >= N, i.e, registers new if does not exist otherwise updates original one + /// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned + bool validateAfterN(const char* filename, unsigned long int lineNumber, std::size_t n) { + base::threading::ScopedLock scopedLock(lock()); + base::HitCounter* counter = get(filename, lineNumber); + if (counter == nullptr) { + registerNew(counter = new base::HitCounter(filename, lineNumber)); + } + // Do not use validateHitCounts here since we do not want to reset counter here + // Note the >= instead of > because we are incrementing + // after this check + if (counter->hitCounts() >= n) + return true; + counter->increment(); + return false; + } + + /// @brief Validates counter for hits are <= n, i.e, registers new if does not exist otherwise updates original one + /// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned + bool validateNTimes(const char* filename, unsigned long int lineNumber, std::size_t n) { + base::threading::ScopedLock scopedLock(lock()); + base::HitCounter* counter = get(filename, lineNumber); + if (counter == nullptr) { + registerNew(counter = new base::HitCounter(filename, lineNumber)); + } + counter->increment(); + // Do not use validateHitCounts here since we do not want to reset counter here + if (counter->hitCounts() <= n) + return true; + return false; + } + + /// @brief Gets hit counter registered at specified position + inline const base::HitCounter* getCounter(const char* filename, unsigned long int lineNumber) { + base::threading::ScopedLock scopedLock(lock()); + return get(filename, lineNumber); + } + }; + /// @brief Action to be taken for dispatching + enum class DispatchAction : base::type::EnumType { + None = 1, NormalLog = 2, SysLog = 4 + }; + } // namespace base + template + class Callback : protected base::threading::ThreadSafe { + public: + Callback(void) : m_enabled(true) {} + inline bool enabled(void) const { return m_enabled; } + inline void setEnabled(bool enabled) { + base::threading::ScopedLock scopedLock(lock()); + m_enabled = enabled; + } + protected: + virtual void handle(const T* handlePtr) = 0; + private: + bool m_enabled; + }; + class LogDispatchData { + public: + LogDispatchData() : m_logMessage(nullptr), m_dispatchAction(base::DispatchAction::None) {} + inline const LogMessage* logMessage(void) const { return m_logMessage; } + inline base::DispatchAction dispatchAction(void) const { return m_dispatchAction; } + private: + LogMessage* m_logMessage; + base::DispatchAction m_dispatchAction; + friend class base::LogDispatcher; + + inline void setLogMessage(LogMessage* logMessage) { m_logMessage = logMessage; } + inline void setDispatchAction(base::DispatchAction dispatchAction) { m_dispatchAction = dispatchAction; } + }; + class LogDispatchCallback : public Callback { + private: + friend class base::LogDispatcher; + }; + class PerformanceTrackingCallback : public Callback { + private: + friend class base::PerformanceTracker; + }; + class LogBuilder : base::NoCopy { + public: + virtual ~LogBuilder(void) { ELPP_INTERNAL_INFO(3, "Destroying log builder...") } + virtual base::type::string_t build(const LogMessage* logMessage, bool appendNewLine) const = 0; + void convertToColoredOutput(base::type::string_t* logLine, Level level) { + if (!base::utils::s_termSupportsColor) return; + const base::type::char_t* resetColor = ELPP_LITERAL("\x1b[0m"); + if (level == Level::Error || level == Level::Fatal) + *logLine = ELPP_LITERAL("\x1b[31m") + *logLine + resetColor; + else if (level == Level::Warning) + *logLine = ELPP_LITERAL("\x1b[33m") + *logLine + resetColor; + } + private: + friend class el::base::DefaultLogDispatchCallback; + }; + typedef std::shared_ptr LogBuilderPtr; + /// @brief Represents a logger holding ID and configurations we need to write logs + /// + /// @detail This class does not write logs itself instead its used by writer to read configuations from. + class Logger : public base::threading::ThreadSafe, public Loggable { + public: + Logger(const std::string& id, base::LogStreamsReferenceMap* logStreamsReference) : + m_id(id), + m_typedConfigurations(nullptr), + m_parentApplicationName(std::string()), + m_isConfigured(false), + m_logStreamsReference(logStreamsReference) { + initUnflushedCount(); + } + + Logger(const std::string& id, const Configurations& configurations, base::LogStreamsReferenceMap* logStreamsReference) : + m_id(id), + m_typedConfigurations(nullptr), + m_parentApplicationName(std::string()), + m_isConfigured(false), + m_logStreamsReference(logStreamsReference) { + initUnflushedCount(); + configure(configurations); + } + + Logger(const Logger& logger) { + base::utils::safeDelete(m_typedConfigurations); + m_id = logger.m_id; + m_typedConfigurations = logger.m_typedConfigurations; + m_parentApplicationName = logger.m_parentApplicationName; + m_isConfigured = logger.m_isConfigured; + m_configurations = logger.m_configurations; + m_unflushedCount = logger.m_unflushedCount; + m_logStreamsReference = logger.m_logStreamsReference; + } + + Logger& operator=(const Logger& logger) { + base::utils::safeDelete(m_typedConfigurations); + m_id = logger.m_id; + m_typedConfigurations = logger.m_typedConfigurations; + m_parentApplicationName = logger.m_parentApplicationName; + m_isConfigured = logger.m_isConfigured; + m_configurations = logger.m_configurations; + m_unflushedCount = logger.m_unflushedCount; + m_logStreamsReference = logger.m_logStreamsReference; + return *this; + } + + virtual ~Logger(void) { + base::utils::safeDelete(m_typedConfigurations); + } + + virtual inline void log(el::base::type::ostream_t& os) const { + os << m_id.c_str(); + } + + /// @brief Configures the logger using specified configurations. + void configure(const Configurations& configurations) { + m_isConfigured = false; // we set it to false in case if we fail + initUnflushedCount(); + if (m_typedConfigurations != nullptr) { + Configurations* c = const_cast(m_typedConfigurations->configurations()); + if (c->hasConfiguration(Level::Global, ConfigurationType::Filename)) { + // This check is definitely needed for cases like ELPP_NO_DEFAULT_LOG_FILE + flush(); + } + } + base::threading::ScopedLock scopedLock(lock()); + if (m_configurations != configurations) { + m_configurations.setFromBase(const_cast(&configurations)); + } + base::utils::safeDelete(m_typedConfigurations); + m_typedConfigurations = new base::TypedConfigurations(&m_configurations, m_logStreamsReference); + resolveLoggerFormatSpec(); + m_isConfigured = true; + } + + /// @brief Reconfigures logger using existing configurations + inline void reconfigure(void) { + ELPP_INTERNAL_INFO(1, "Reconfiguring logger [" << m_id << "]"); + configure(m_configurations); + } + + inline const std::string& id(void) const { + return m_id; + } + + inline const std::string& parentApplicationName(void) const { + return m_parentApplicationName; + } + + inline void setParentApplicationName(const std::string& parentApplicationName) { + m_parentApplicationName = parentApplicationName; + } + + inline Configurations* configurations(void) { + return &m_configurations; + } + + inline base::TypedConfigurations* typedConfigurations(void) { + return m_typedConfigurations; + } + + static inline bool isValidId(const std::string& id) { + for (std::string::const_iterator it = id.begin(); it != id.end(); ++it) { + if (!base::utils::Str::contains(base::consts::kValidLoggerIdSymbols, *it)) { + return false; + } + } + return true; + } + /// @brief Flushes logger to sync all log files for all levels + inline void flush(void) { + ELPP_INTERNAL_INFO(3, "Flushing logger [" << m_id << "] all levels"); + base::threading::ScopedLock scopedLock(lock()); + base::type::EnumType lIndex = LevelHelper::kMinValid; + LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { + flush(LevelHelper::castFromInt(lIndex), nullptr); + return false; + }); + } + + inline void flush(Level level, base::type::fstream_t* fs) { + if (fs == nullptr && m_typedConfigurations->toFile(level)) { + fs = m_typedConfigurations->fileStream(level); + } + if (fs != nullptr) { + fs->flush(); + m_unflushedCount.find(level)->second = 0; + } + } + + inline bool isFlushNeeded(Level level) { + return ++m_unflushedCount.find(level)->second >= m_typedConfigurations->logFlushThreshold(level); + } + + inline LogBuilder* logBuilder(void) const { + return m_logBuilder.get(); + } + + inline void setLogBuilder(const LogBuilderPtr& logBuilder) { + m_logBuilder = logBuilder; + } + + inline bool enabled(Level level) const { + return m_typedConfigurations->enabled(level); + } + +#if ELPP_VARIADIC_TEMPLATES_SUPPORTED +# define LOGGER_LEVEL_WRITERS_SIGNATURES(FUNCTION_NAME)\ + template \ + inline void FUNCTION_NAME(const char*, const T&, const Args&...);\ + template \ + inline void FUNCTION_NAME(const T&); + + template + inline void verbose(int, const char*, const T&, const Args&...); + + template + inline void verbose(int, const T&); + + LOGGER_LEVEL_WRITERS_SIGNATURES(info) + LOGGER_LEVEL_WRITERS_SIGNATURES(debug) + LOGGER_LEVEL_WRITERS_SIGNATURES(warn) + LOGGER_LEVEL_WRITERS_SIGNATURES(error) + LOGGER_LEVEL_WRITERS_SIGNATURES(fatal) + LOGGER_LEVEL_WRITERS_SIGNATURES(trace) +# undef LOGGER_LEVEL_WRITERS_SIGNATURES +#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED + private: + std::string m_id; + base::TypedConfigurations* m_typedConfigurations; + base::type::stringstream_t m_stream; + std::string m_parentApplicationName; + bool m_isConfigured; + Configurations m_configurations; + std::map m_unflushedCount; + base::LogStreamsReferenceMap* m_logStreamsReference; + LogBuilderPtr m_logBuilder; + + friend class el::LogMessage; + friend class el::Loggers; + friend class el::Helpers; + friend class el::base::RegisteredLoggers; + friend class el::base::DefaultLogDispatchCallback; + friend class el::base::MessageBuilder; + friend class el::base::Writer; + friend class el::base::PErrorWriter; + friend class el::base::Storage; + friend class el::base::PerformanceTracker; + friend class el::base::LogDispatcher; + + Logger(void); + +#if ELPP_VARIADIC_TEMPLATES_SUPPORTED + template + void log_(Level, int, const char*, const T&, const Args&...); + + template + inline void log_(Level, int, const T&); + + template + void log(Level, const char*, const T&, const Args&...); + + template + inline void log(Level, const T&); +#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED + + void initUnflushedCount(void) { + m_unflushedCount.clear(); + base::type::EnumType lIndex = LevelHelper::kMinValid; + LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { + m_unflushedCount.insert(std::make_pair(LevelHelper::castFromInt(lIndex), 0)); + return false; + }); + } + + inline base::type::stringstream_t& stream(void) { + return m_stream; + } + + void resolveLoggerFormatSpec(void) const { + base::type::EnumType lIndex = LevelHelper::kMinValid; + LevelHelper::forEachLevel(&lIndex, [&](void) -> bool { + base::LogFormat* logFormat = + const_cast(&m_typedConfigurations->logFormat(LevelHelper::castFromInt(lIndex))); + base::utils::Str::replaceFirstWithEscape(logFormat->m_format, base::consts::kLoggerIdFormatSpecifier, m_id); + return false; + }); + } + }; + namespace base { + /// @brief Loggers repository + class RegisteredLoggers : public base::utils::Registry { + public: + explicit RegisteredLoggers(const LogBuilderPtr& defaultLogBuilder) : + m_defaultLogBuilder(defaultLogBuilder) { + m_defaultConfigurations.setToDefault(); + } + + virtual ~RegisteredLoggers(void) { + flushAll(); + } + + inline void setDefaultConfigurations(const Configurations& configurations) { + base::threading::ScopedLock scopedLock(lock()); + m_defaultConfigurations.setFromBase(const_cast(&configurations)); + } + + inline Configurations* defaultConfigurations(void) { + return &m_defaultConfigurations; + } + + Logger* get(const std::string& id, bool forceCreation = true) { + base::threading::ScopedLock scopedLock(lock()); + Logger* logger_ = base::utils::Registry::get(id); + if (logger_ == nullptr && forceCreation) { + bool validId = Logger::isValidId(id); + if (!validId) { + ELPP_ASSERT(validId, "Invalid logger ID [" << id << "]. Not registering this logger."); + return nullptr; + } + logger_ = new Logger(id, m_defaultConfigurations, &m_logStreamsReference); + logger_->m_logBuilder = m_defaultLogBuilder; + registerNew(id, logger_); + } + return logger_; + } + + bool remove(const std::string& id) { + if (id == "default") { + return false; + } + Logger* logger = base::utils::Registry::get(id); + if (logger != nullptr) { + unregister(logger); + } + return true; + } + + inline bool has(const std::string& id) { + return get(id, false) != nullptr; + } + + inline void unregister(Logger*& logger) { + base::threading::ScopedLock scopedLock(lock()); + base::utils::Registry::unregister(logger->id()); + } + + inline base::LogStreamsReferenceMap* logStreamsReference(void) { + return &m_logStreamsReference; + } + + inline void flushAll(void) { + ELPP_INTERNAL_INFO(1, "Flushing all log files"); + base::threading::ScopedLock scopedLock(lock()); + for (base::LogStreamsReferenceMap::iterator it = m_logStreamsReference.begin(); + it != m_logStreamsReference.end(); ++it) { + if (it->second.get() == nullptr) continue; + it->second->flush(); + } + } + + private: + LogBuilderPtr m_defaultLogBuilder; + Configurations m_defaultConfigurations; + base::LogStreamsReferenceMap m_logStreamsReference; + friend class el::base::Storage; + }; + /// @brief Represents registries for verbose logging + class VRegistry : base::NoCopy, public base::threading::ThreadSafe { + public: + explicit VRegistry(base::type::VerboseLevel level, base::type::EnumType* pFlags) : m_level(level), m_pFlags(pFlags) { + } + + /// @brief Sets verbose level. Accepted range is 0-9 + inline void setLevel(base::type::VerboseLevel level) { + base::threading::ScopedLock scopedLock(lock()); + if (level < 0) + m_level = 0; + else if (level > 9) + m_level = base::consts::kMaxVerboseLevel; + else + m_level = level; + } + + inline base::type::VerboseLevel level(void) const { + return m_level; + } + + inline void clearModules(void) { + base::threading::ScopedLock scopedLock(lock()); + m_modules.clear(); + } + + void setModules(const char* modules) { + base::threading::ScopedLock scopedLock(lock()); + auto addSuffix = [](std::stringstream& ss, const char* sfx, const char* prev) { + if (prev != nullptr && base::utils::Str::endsWith(ss.str(), std::string(prev))) { + std::string chr(ss.str().substr(0, ss.str().size() - strlen(prev))); + ss.str(std::string("")); + ss << chr; + } + if (base::utils::Str::endsWith(ss.str(), std::string(sfx))) { + std::string chr(ss.str().substr(0, ss.str().size() - strlen(sfx))); + ss.str(std::string("")); + ss << chr; + } + ss << sfx; + }; + auto insert = [&](std::stringstream& ss, base::type::VerboseLevel level) { + if (!base::utils::hasFlag(LoggingFlag::DisableVModulesExtensions, *m_pFlags)) { + addSuffix(ss, ".h", nullptr); + m_modules.insert(std::make_pair(ss.str(), level)); + addSuffix(ss, ".c", ".h"); + m_modules.insert(std::make_pair(ss.str(), level)); + addSuffix(ss, ".cpp", ".c"); + m_modules.insert(std::make_pair(ss.str(), level)); + addSuffix(ss, ".cc", ".cpp"); + m_modules.insert(std::make_pair(ss.str(), level)); + addSuffix(ss, ".cxx", ".cc"); + m_modules.insert(std::make_pair(ss.str(), level)); + addSuffix(ss, ".-inl.h", ".cxx"); + m_modules.insert(std::make_pair(ss.str(), level)); + addSuffix(ss, ".hxx", ".-inl.h"); + m_modules.insert(std::make_pair(ss.str(), level)); + addSuffix(ss, ".hpp", ".hxx"); + m_modules.insert(std::make_pair(ss.str(), level)); + addSuffix(ss, ".hh", ".hpp"); + } + m_modules.insert(std::make_pair(ss.str(), level)); + }; + bool isMod = true; + bool isLevel = false; + std::stringstream ss; + int level = -1; + for (; *modules; ++modules) { + switch (*modules) { + case '=': + isLevel = true; + isMod = false; + break; + case ',': + isLevel = false; + isMod = true; + if (!ss.str().empty() && level != -1) { + insert(ss, level); + ss.str(std::string("")); + level = -1; + } + break; + default: + if (isMod) { + ss << *modules; + } + else if (isLevel) { + if (isdigit(*modules)) { + level = static_cast(*modules) - 48; + } + } + break; + } + } + if (!ss.str().empty() && level != -1) { + insert(ss, level); + } + } + + bool allowed(base::type::VerboseLevel vlevel, const char* file) { + base::threading::ScopedLock scopedLock(lock()); + if (m_modules.empty() || file == nullptr) { + return vlevel <= m_level; + } + else { + std::map::iterator it = m_modules.begin(); + for (; it != m_modules.end(); ++it) { + if (base::utils::Str::wildCardMatch(file, it->first.c_str())) { + return vlevel <= it->second; + } + } + if (base::utils::hasFlag(LoggingFlag::AllowVerboseIfModuleNotSpecified, *m_pFlags)) { + return true; + } + return false; + } + } + + inline const std::map& modules(void) const { + return m_modules; + } + + void setFromArgs(const base::utils::CommandLineArgs* commandLineArgs) { + if (commandLineArgs->hasParam("-v") || commandLineArgs->hasParam("--verbose") || + commandLineArgs->hasParam("-V") || commandLineArgs->hasParam("--VERBOSE")) { + setLevel(base::consts::kMaxVerboseLevel); + } + else if (commandLineArgs->hasParamWithValue("--v")) { + setLevel(atoi(commandLineArgs->getParamValue("--v"))); + } + else if (commandLineArgs->hasParamWithValue("--V")) { + setLevel(atoi(commandLineArgs->getParamValue("--V"))); + } + else if ((commandLineArgs->hasParamWithValue("-vmodule")) && vModulesEnabled()) { + setModules(commandLineArgs->getParamValue("-vmodule")); + } + else if (commandLineArgs->hasParamWithValue("-VMODULE") && vModulesEnabled()) { + setModules(commandLineArgs->getParamValue("-VMODULE")); + } + } + + /// @brief Whether or not vModules enabled + inline bool vModulesEnabled(void) { + return !base::utils::hasFlag(LoggingFlag::DisableVModules, *m_pFlags); + } + + private: + base::type::VerboseLevel m_level; + base::type::EnumType* m_pFlags; + std::map m_modules; + }; + } // namespace base + class LogMessage { + public: + LogMessage(Level level, const std::string& file, unsigned long int line, const std::string& func, + base::type::VerboseLevel verboseLevel, Logger* logger) : + m_level(level), m_file(file), m_line(line), m_func(func), + m_verboseLevel(verboseLevel), m_logger(logger), m_message(std::move(logger->stream().str())) { + } + inline Level level(void) const { return m_level; } + inline const std::string& file(void) const { return m_file; } + inline unsigned long int line(void) const { return m_line; } // NOLINT + inline const std::string& func(void) const { return m_func; } + inline base::type::VerboseLevel verboseLevel(void) const { return m_verboseLevel; } + inline Logger* logger(void) const { return m_logger; } + inline const base::type::string_t& message(void) const { return m_message; } + private: + Level m_level; + std::string m_file; + unsigned long int m_line; + std::string m_func; + base::type::VerboseLevel m_verboseLevel; + Logger* m_logger; + base::type::string_t m_message; + }; + namespace base { +#if ELPP_ASYNC_LOGGING + class AsyncLogItem { + public: + explicit AsyncLogItem(const LogMessage& logMessage, const LogDispatchData& data, const base::type::string_t& logLine) + : m_logMessage(logMessage), m_dispatchData(data), m_logLine(logLine) {} + virtual ~AsyncLogItem() {} + inline LogMessage* logMessage(void) { return &m_logMessage; } + inline LogDispatchData* data(void) { return &m_dispatchData; } + inline base::type::string_t logLine(void) { return m_logLine; } + private: + LogMessage m_logMessage; + LogDispatchData m_dispatchData; + base::type::string_t m_logLine; + }; + class AsyncLogQueue : public base::threading::ThreadSafe { + public: + virtual ~AsyncLogQueue() { + ELPP_INTERNAL_INFO(6, "~AsyncLogQueue"); + } + + inline AsyncLogItem next(void) { + base::threading::ScopedLock scopedLock(lock()); + AsyncLogItem result = m_queue.front(); + m_queue.pop(); + return result; + } + + inline void push(const AsyncLogItem& item) { + base::threading::ScopedLock scopedLock(lock()); + m_queue.push(item); + } + inline void pop(void) { + base::threading::ScopedLock scopedLock(lock()); + m_queue.pop(); + } + inline AsyncLogItem front(void) { + base::threading::ScopedLock scopedLock(lock()); + return m_queue.front(); + } + inline bool empty(void) { + base::threading::ScopedLock scopedLock(lock()); + return m_queue.empty(); + } + private: + std::queue m_queue; + }; + class IWorker { + public: + virtual ~IWorker() {} + virtual void start() = 0; + }; +#endif // ELPP_ASYNC_LOGGING + /// @brief Easylogging++ management storage + class Storage : base::NoCopy, public base::threading::ThreadSafe { + public: +#if ELPP_ASYNC_LOGGING + Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker) : +#else + explicit Storage(const LogBuilderPtr& defaultLogBuilder) : +#endif // ELPP_ASYNC_LOGGING + m_registeredHitCounters(new base::RegisteredHitCounters()), + m_registeredLoggers(new base::RegisteredLoggers(defaultLogBuilder)), + m_flags(0x0), + m_vRegistry(new base::VRegistry(0, &m_flags)), +#if ELPP_ASYNC_LOGGING + m_asyncLogQueue(new base::AsyncLogQueue()), + m_asyncDispatchWorker(asyncDispatchWorker), +#endif // ELPP_ASYNC_LOGGING + m_preRollOutCallback(base::defaultPreRollOutCallback) { + // Register default logger + m_registeredLoggers->get(std::string(base::consts::kDefaultLoggerId)); + // Register performance logger and reconfigure format + Logger* performanceLogger = m_registeredLoggers->get(std::string(base::consts::kPerformanceLoggerId)); + performanceLogger->configurations()->setGlobally(ConfigurationType::Format, std::string("%datetime %level %msg")); + performanceLogger->reconfigure(); +#if defined(ELPP_SYSLOG) + // Register syslog logger and reconfigure format + Logger* sysLogLogger = m_registeredLoggers->get(std::string(base::consts::kSysLogLoggerId)); + sysLogLogger->configurations()->setGlobally(ConfigurationType::Format, std::string("%level: %msg")); + sysLogLogger->reconfigure(); +#else + ELPP_UNUSED(base::consts::kSysLogLoggerId); +#endif // defined(ELPP_SYSLOG) + addFlag(LoggingFlag::AllowVerboseIfModuleNotSpecified); +#if ELPP_ASYNC_LOGGING + installLogDispatchCallback(std::string("AsyncLogDispatchCallback")); +#else + installLogDispatchCallback(std::string("DefaultLogDispatchCallback")); +#endif // ELPP_ASYNC_LOGGING + installPerformanceTrackingCallback(std::string("DefaultPerformanceTrackingCallback")); + ELPP_INTERNAL_INFO(1, "Easylogging++ has been initialized"); +#if ELPP_ASYNC_LOGGING + m_asyncDispatchWorker->start(); +#endif // ELPP_ASYNC_LOGGING + } + + virtual ~Storage(void) { + ELPP_INTERNAL_INFO(4, "Destroying storage"); +#if ELPP_ASYNC_LOGGING + ELPP_INTERNAL_INFO(5, "Replacing log dispatch callback to synchronous"); + uninstallLogDispatchCallback(std::string("AsyncLogDispatchCallback")); + installLogDispatchCallback(std::string("DefaultLogDispatchCallback")); + ELPP_INTERNAL_INFO(5, "Destroying asyncDispatchWorker"); + base::utils::safeDelete(m_asyncDispatchWorker); + ELPP_INTERNAL_INFO(5, "Destroying asyncLogQueue"); + base::utils::safeDelete(m_asyncLogQueue); +#endif // ELPP_ASYNC_LOGGING + ELPP_INTERNAL_INFO(5, "Destroying registeredHitCounters"); + base::utils::safeDelete(m_registeredHitCounters); + ELPP_INTERNAL_INFO(5, "Destroying registeredLoggers"); + base::utils::safeDelete(m_registeredLoggers); + ELPP_INTERNAL_INFO(5, "Destroying vRegistry"); + base::utils::safeDelete(m_vRegistry); + } + + inline bool validateEveryNCounter(const char* filename, unsigned long int lineNumber, std::size_t occasion) { + return hitCounters()->validateEveryN(filename, lineNumber, occasion); + } + + inline bool validateAfterNCounter(const char* filename, unsigned long int lineNumber, std::size_t n) { // NOLINT + return hitCounters()->validateAfterN(filename, lineNumber, n); + } + + inline bool validateNTimesCounter(const char* filename, unsigned long int lineNumber, std::size_t n) { // NOLINT + return hitCounters()->validateNTimes(filename, lineNumber, n); + } + + inline base::RegisteredHitCounters* hitCounters(void) const { + return m_registeredHitCounters; + } + + inline base::RegisteredLoggers* registeredLoggers(void) const { + return m_registeredLoggers; + } + + inline base::VRegistry* vRegistry(void) const { + return m_vRegistry; + } + +#if ELPP_ASYNC_LOGGING + inline base::AsyncLogQueue* asyncLogQueue(void) const { + return m_asyncLogQueue; + } +#endif // ELPP_ASYNC_LOGGING + + inline const base::utils::CommandLineArgs* commandLineArgs(void) const { + return &m_commandLineArgs; + } + + inline void addFlag(LoggingFlag flag) { + base::utils::addFlag(flag, &m_flags); + } + + inline void removeFlag(LoggingFlag flag) { + base::utils::removeFlag(flag, &m_flags); + } + + inline bool hasFlag(LoggingFlag flag) const { + return base::utils::hasFlag(flag, m_flags); + } + + inline base::type::EnumType flags(void) const { + return m_flags; + } + + inline void setFlags(base::type::EnumType flags) { + m_flags = flags; + } + + inline void setPreRollOutCallback(const PreRollOutCallback& callback) { + m_preRollOutCallback = callback; + } + + inline void unsetPreRollOutCallback(void) { + m_preRollOutCallback = base::defaultPreRollOutCallback; + } + + inline PreRollOutCallback& preRollOutCallback(void) { + return m_preRollOutCallback; + } + + inline bool hasCustomFormatSpecifier(const char* formatSpecifier) { + base::threading::ScopedLock scopedLock(lock()); + return std::find(m_customFormatSpecifiers.begin(), m_customFormatSpecifiers.end(), + formatSpecifier) != m_customFormatSpecifiers.end(); + } + + inline void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier) { + if (hasCustomFormatSpecifier(customFormatSpecifier.formatSpecifier())) { + return; + } + base::threading::ScopedLock scopedLock(lock()); + m_customFormatSpecifiers.push_back(customFormatSpecifier); + } + + inline bool uninstallCustomFormatSpecifier(const char* formatSpecifier) { + base::threading::ScopedLock scopedLock(lock()); + std::vector::iterator it = std::find(m_customFormatSpecifiers.begin(), + m_customFormatSpecifiers.end(), formatSpecifier); + if (it != m_customFormatSpecifiers.end() && strcmp(formatSpecifier, it->formatSpecifier()) == 0) { + m_customFormatSpecifiers.erase(it); + return true; + } + return false; + } + + const std::vector* customFormatSpecifiers(void) const { + return &m_customFormatSpecifiers; + } + + inline void setLoggingLevel(Level level) { + m_loggingLevel = level; + } + + template + inline bool installLogDispatchCallback(const std::string& id) { + return installCallback(id, &m_logDispatchCallbacks); + } + + template + inline void uninstallLogDispatchCallback(const std::string& id) { + uninstallCallback(id, &m_logDispatchCallbacks); + } + template + inline T* logDispatchCallback(const std::string& id) { + return callback(id, &m_logDispatchCallbacks); + } + + template + inline bool installPerformanceTrackingCallback(const std::string& id) { + return installCallback(id, &m_performanceTrackingCallbacks); + } + + template + inline void uninstallPerformanceTrackingCallback(const std::string& id) { + uninstallCallback(id, &m_performanceTrackingCallbacks); + } + + template + inline T* performanceTrackingCallback(const std::string& id) { + return callback(id, &m_performanceTrackingCallbacks); + } + private: + base::RegisteredHitCounters* m_registeredHitCounters; + base::RegisteredLoggers* m_registeredLoggers; + base::type::EnumType m_flags; + base::VRegistry* m_vRegistry; +#if ELPP_ASYNC_LOGGING + base::AsyncLogQueue* m_asyncLogQueue; + base::IWorker* m_asyncDispatchWorker; +#endif // ELPP_ASYNC_LOGGING + base::utils::CommandLineArgs m_commandLineArgs; + PreRollOutCallback m_preRollOutCallback; + std::map m_logDispatchCallbacks; + std::map m_performanceTrackingCallbacks; + std::vector m_customFormatSpecifiers; + Level m_loggingLevel; + + friend class el::Helpers; + friend class el::base::DefaultLogDispatchCallback; + friend class el::LogBuilder; + friend class el::base::MessageBuilder; + friend class el::base::Writer; + friend class el::base::PerformanceTracker; + friend class el::base::LogDispatcher; + + void setApplicationArguments(int argc, char** argv) { + m_commandLineArgs.setArgs(argc, argv); + m_vRegistry->setFromArgs(commandLineArgs()); + // default log file +#if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG) + if (m_commandLineArgs.hasParamWithValue(base::consts::kDefaultLogFileParam)) { + Configurations c; + c.setGlobally(ConfigurationType::Filename, std::string(m_commandLineArgs.getParamValue(base::consts::kDefaultLogFileParam))); + registeredLoggers()->setDefaultConfigurations(c); + for (base::RegisteredLoggers::iterator it = registeredLoggers()->begin(); + it != registeredLoggers()->end(); ++it) { + it->second->configure(c); + } + } +#endif // !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG) +#if defined(ELPP_LOGGING_FLAGS_FROM_ARG) + if (m_commandLineArgs.hasParamWithValue(base::consts::kLoggingFlagsParam)) { + m_flags = atoi(m_commandLineArgs.getParamValue(base::consts::kLoggingFlagsParam)); + } +#endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG) + } + + inline void setApplicationArguments(int argc, const char** argv) { + setApplicationArguments(argc, const_cast(argv)); + } + + template + inline bool installCallback(const std::string& id, std::map* mapT) { + if (mapT->find(id) == mapT->end()) { + mapT->insert(std::make_pair(id, TPtr(new T()))); + return true; + } + return false; + } + + template + inline void uninstallCallback(const std::string& id, std::map* mapT) { + if (mapT->find(id) != mapT->end()) { + mapT->erase(id); + } + } + + template + inline T* callback(const std::string& id, std::map* mapT) { + typename std::map::iterator iter = mapT->find(id); + if (iter != mapT->end()) { + return static_cast(iter->second.get()); + } + return nullptr; + } + }; + extern ELPP_EXPORT base::type::StoragePointer elStorage; +#define ELPP el::base::elStorage + class DefaultLogDispatchCallback : public LogDispatchCallback { + protected: + void handle(const LogDispatchData* data) { + m_data = data; + dispatch(std::move(m_data->logMessage()->logger()->logBuilder()->build(m_data->logMessage(), + m_data->dispatchAction() == base::DispatchAction::NormalLog))); + } + private: + const LogDispatchData* m_data; + void dispatch(base::type::string_t&& logLine) { + if (m_data->dispatchAction() == base::DispatchAction::NormalLog) { + if (m_data->logMessage()->logger()->m_typedConfigurations->toFile(m_data->logMessage()->level())) { + base::type::fstream_t* fs = m_data->logMessage()->logger()->m_typedConfigurations->fileStream(m_data->logMessage()->level()); + if (fs != nullptr) { + fs->write(logLine.c_str(), logLine.size()); + if (fs->fail()) { + ELPP_INTERNAL_ERROR("Unable to write log to file [" + << m_data->logMessage()->logger()->m_typedConfigurations->filename(m_data->logMessage()->level()) << "].\n" + << "Few possible reasons (could be something else):\n" << " * Permission denied\n" + << " * Disk full\n" << " * Disk is not writable", true); + } + else { + if (ELPP->hasFlag(LoggingFlag::ImmediateFlush) || (m_data->logMessage()->logger()->isFlushNeeded(m_data->logMessage()->level()))) { + m_data->logMessage()->logger()->flush(m_data->logMessage()->level(), fs); + } + } + } + else { + ELPP_INTERNAL_ERROR("Log file for [" << LevelHelper::convertToString(m_data->logMessage()->level()) << "] " + << "has not been configured but [TO_FILE] is configured to TRUE. [Logger ID: " + << m_data->logMessage()->logger()->id() << "]", false); + } + } + if (m_data->logMessage()->logger()->m_typedConfigurations->toStandardOutput(m_data->logMessage()->level())) { + if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput)) + m_data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, m_data->logMessage()->level()); + ELPP_COUT << ELPP_COUT_LINE(logLine); + } + } +#if defined(ELPP_SYSLOG) + else if (m_data->dispatchAction() == base::DispatchAction::SysLog) { + // Determine syslog priority + int sysLogPriority = 0; + if (m_data->logMessage()->level() == Level::Fatal) + sysLogPriority = LOG_EMERG; + else if (m_data->logMessage()->level() == Level::Error) + sysLogPriority = LOG_ERR; + else if (m_data->logMessage()->level() == Level::Warning) + sysLogPriority = LOG_WARNING; + else if (m_data->logMessage()->level() == Level::Info) + sysLogPriority = LOG_INFO; + else if (m_data->logMessage()->level() == Level::Debug) + sysLogPriority = LOG_DEBUG; + else + sysLogPriority = LOG_NOTICE; +# if defined(ELPP_UNICODE) + char* line = base::utils::Str::wcharPtrToCharPtr(logLine.c_str()); + syslog(sysLogPriority, "%s", line); + free(line); +# else + syslog(sysLogPriority, "%s", logLine.c_str()); +# endif + } +#endif // defined(ELPP_SYSLOG) + } + }; +#if ELPP_ASYNC_LOGGING + class AsyncLogDispatchCallback : public LogDispatchCallback { + protected: + void handle(const LogDispatchData* data) { + base::type::string_t logLine = data->logMessage()->logger()->logBuilder()->build(data->logMessage(), data->dispatchAction() == base::DispatchAction::NormalLog); + if (data->dispatchAction() == base::DispatchAction::NormalLog && data->logMessage()->logger()->typedConfigurations()->toStandardOutput(data->logMessage()->level())) { + if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput)) + data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, data->logMessage()->level()); + ELPP_COUT << ELPP_COUT_LINE(logLine); + } + // Save resources and only queue if we want to write to file otherwise just ignore handler + if (data->logMessage()->logger()->typedConfigurations()->toFile(data->logMessage()->level())) { + ELPP->asyncLogQueue()->push(AsyncLogItem(*(data->logMessage()), *data, logLine)); + } + } + }; + class AsyncDispatchWorker : public base::IWorker, public base::threading::ThreadSafe { + public: + AsyncDispatchWorker() { + setContinueRunning(false); + } + + virtual ~AsyncDispatchWorker() { + setContinueRunning(false); + ELPP_INTERNAL_INFO(6, "Stopping dispatch worker - Cleaning log queue"); + clean(); + ELPP_INTERNAL_INFO(6, "Log queue cleaned"); + } + + inline bool clean() { + std::mutex m; + std::unique_lock lk(m); + cv.wait(lk, [] { return !ELPP->asyncLogQueue()->empty(); }); + emptyQueue(); + lk.unlock(); + cv.notify_one(); + return ELPP->asyncLogQueue()->empty(); + } + + inline void emptyQueue() { + while (!ELPP->asyncLogQueue()->empty()) { + AsyncLogItem data = ELPP->asyncLogQueue()->next(); + handle(&data); + base::threading::msleep(100); + } + } + + virtual inline void start() { + base::threading::msleep(5000); // Wait extra few seconds + setContinueRunning(true); + std::thread t1(&AsyncDispatchWorker::runner, this); + t1.join(); + } + + void handle(AsyncLogItem* logItem) { + LogDispatchData* data = logItem->data(); + LogMessage* logMessage = logItem->logMessage(); + Logger* logger = logMessage->logger(); + base::TypedConfigurations* conf = logger->typedConfigurations(); + base::type::string_t logLine = logItem->logLine(); + if (data->dispatchAction() == base::DispatchAction::NormalLog) { + if (conf->toFile(logMessage->level())) { + base::type::fstream_t* fs = conf->fileStream(logMessage->level()); + if (fs != nullptr) { + fs->write(logLine.c_str(), logLine.size()); + if (fs->fail()) { + ELPP_INTERNAL_ERROR("Unable to write log to file [" + << conf->filename(logMessage->level()) << "].\n" + << "Few possible reasons (could be something else):\n" << " * Permission denied\n" + << " * Disk full\n" << " * Disk is not writable", true); + } + else { + if (ELPP->hasFlag(LoggingFlag::ImmediateFlush) || (logger->isFlushNeeded(logMessage->level()))) { + logger->flush(logMessage->level(), fs); + } + } + } + else { + ELPP_INTERNAL_ERROR("Log file for [" << LevelHelper::convertToString(logMessage->level()) << "] " + << "has not been configured but [TO_FILE] is configured to TRUE. [Logger ID: " << logger->id() << "]", false); + } + } + } +# if defined(ELPP_SYSLOG) + else if (data->dispatchAction() == base::DispatchAction::SysLog) { + // Determine syslog priority + int sysLogPriority = 0; + if (logMessage->level() == Level::Fatal) + sysLogPriority = LOG_EMERG; + else if (logMessage->level() == Level::Error) + sysLogPriority = LOG_ERR; + else if (logMessage->level() == Level::Warning) + sysLogPriority = LOG_WARNING; + else if (logMessage->level() == Level::Info) + sysLogPriority = LOG_INFO; + else if (logMessage->level() == Level::Debug) + sysLogPriority = LOG_DEBUG; + else + sysLogPriority = LOG_NOTICE; +# if defined(ELPP_UNICODE) + char* line = base::utils::Str::wcharPtrToCharPtr(logLine.c_str()); + syslog(sysLogPriority, "%s", line); + free(line); +# else + syslog(sysLogPriority, "%s", logLine.c_str()); +# endif + } +# endif // defined(ELPP_SYSLOG) + } + + void run() { + while (continueRunning()) { + emptyQueue(); + base::threading::msleep(10); // 10ms + } + } + + static void* runner(void *context) { + static_cast(context)->run(); + return NULL; + } + + void setContinueRunning(bool value) { + base::threading::ScopedLock scopedLock(m_continueRunningMutex); + m_continueRunning = value; + } + bool continueRunning(void) { + return m_continueRunning; + } + private: + std::condition_variable cv; + bool m_continueRunning; + base::threading::Mutex m_continueRunningMutex; + }; +#endif // ELPP_ASYNC_LOGGING + } // namespace base + namespace base { + class DefaultLogBuilder : public LogBuilder { + public: + base::type::string_t build(const LogMessage* logMessage, bool appendNewLine) const { + base::TypedConfigurations* tc = logMessage->logger()->typedConfigurations(); + const base::LogFormat* logFormat = &tc->logFormat(logMessage->level()); + base::type::string_t logLine = logFormat->format(); + char buff[base::consts::kSourceFilenameMaxLength + base::consts::kSourceLineMaxLength] = ""; + const char* bufLim = buff + sizeof(buff); + if (logFormat->hasFlag(base::FormatFlags::AppName)) { + // App name + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kAppNameFormatSpecifier, + logMessage->logger()->parentApplicationName()); + } + if (logFormat->hasFlag(base::FormatFlags::ThreadId)) { + // Thread ID + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kThreadIdFormatSpecifier, + base::threading::getCurrentThreadId()); + } + if (logFormat->hasFlag(base::FormatFlags::DateTime)) { + // DateTime + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kDateTimeFormatSpecifier, + base::utils::DateTime::getDateTime(logFormat->dateTimeFormat().c_str(), + &tc->millisecondsWidth(logMessage->level()))); + } + if (logFormat->hasFlag(base::FormatFlags::Function)) { + // Function + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogFunctionFormatSpecifier, logMessage->func()); + } + if (logFormat->hasFlag(base::FormatFlags::File)) { + // File + char* buf = base::utils::Str::clearBuff(buff, base::consts::kSourceFilenameMaxLength); + base::utils::File::buildStrippedFilename(logMessage->file().c_str(), buff); + buf = base::utils::Str::addToBuff(buff, buf, bufLim); + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogFileFormatSpecifier, std::string(buff)); + } + if (logFormat->hasFlag(base::FormatFlags::FileBase)) { + // FileBase + char* buf = base::utils::Str::clearBuff(buff, base::consts::kSourceFilenameMaxLength); + base::utils::File::buildBaseFilename(logMessage->file(), buff); + buf = base::utils::Str::addToBuff(buff, buf, bufLim); + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogFileBaseFormatSpecifier, std::string(buff)); + } + if (logFormat->hasFlag(base::FormatFlags::Line)) { + // Line + char* buf = base::utils::Str::clearBuff(buff, base::consts::kSourceLineMaxLength); + buf = base::utils::Str::convertAndAddToBuff(logMessage->line(), + base::consts::kSourceLineMaxLength, buf, bufLim, false); + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogLineFormatSpecifier, std::string(buff)); + } + if (logFormat->hasFlag(base::FormatFlags::Location)) { + // Location + char* buf = base::utils::Str::clearBuff(buff, + base::consts::kSourceFilenameMaxLength + base::consts::kSourceLineMaxLength); + base::utils::File::buildStrippedFilename(logMessage->file().c_str(), buff); + buf = base::utils::Str::addToBuff(buff, buf, bufLim); + buf = base::utils::Str::addToBuff(":", buf, bufLim); + buf = base::utils::Str::convertAndAddToBuff(logMessage->line(), + base::consts::kSourceLineMaxLength, buf, bufLim, false); + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kLogLocationFormatSpecifier, std::string(buff)); + } + if (logMessage->level() == Level::Verbose && logFormat->hasFlag(base::FormatFlags::VerboseLevel)) { + // Verbose level + char* buf = base::utils::Str::clearBuff(buff, 1); + buf = base::utils::Str::convertAndAddToBuff(logMessage->verboseLevel(), 1, buf, bufLim, false); + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kVerboseLevelFormatSpecifier, std::string(buff)); + } + if (logFormat->hasFlag(base::FormatFlags::LogMessage)) { + // Log message + base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kMessageFormatSpecifier, logMessage->message()); + } +#if !defined(ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS) + for (std::vector::const_iterator it = ELPP->customFormatSpecifiers()->begin(); + it != ELPP->customFormatSpecifiers()->end(); ++it) { + std::string fs(it->formatSpecifier()); + base::type::string_t wcsFormatSpecifier(fs.begin(), fs.end()); + base::utils::Str::replaceFirstWithEscape(logLine, wcsFormatSpecifier, std::string(it->resolver()())); + } +#endif // !defined(ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS) + if (appendNewLine) logLine += ELPP_LITERAL("\n"); + return logLine; + } + }; + /// @brief Dispatches log messages + class LogDispatcher : base::NoCopy { + public: + LogDispatcher(bool proceed, LogMessage&& logMessage, base::DispatchAction dispatchAction) : + m_proceed(proceed), + m_logMessage(std::move(logMessage)), + m_dispatchAction(std::move(dispatchAction)) { + } + + void dispatch(void) { + if (m_proceed && m_dispatchAction == base::DispatchAction::None) { + m_proceed = false; + } + if (!m_proceed) { + return; + } + // We minimize the time of ELPP's lock - this lock is released after log is written + base::threading::ScopedLock scopedLock(ELPP->lock()); + base::TypedConfigurations* tc = m_logMessage.logger()->m_typedConfigurations; + if (ELPP->hasFlag(LoggingFlag::StrictLogFileSizeCheck)) { + tc->validateFileRolling(m_logMessage.level(), ELPP->preRollOutCallback()); + } + LogDispatchCallback* callback = nullptr; + LogDispatchData data; + for (const std::pair& h + : ELPP->m_logDispatchCallbacks) { + callback = h.second.get(); + if (callback != nullptr && callback->enabled()) { + data.setLogMessage(&m_logMessage); + data.setDispatchAction(m_dispatchAction); + callback->acquireLock(); + callback->handle(&data); + callback->releaseLock(); + } + } + } + + private: + bool m_proceed; + LogMessage m_logMessage; + base::DispatchAction m_dispatchAction; + }; +#if defined(ELPP_STL_LOGGING) + /// @brief Workarounds to write some STL logs + /// + /// @detail There is workaround needed to loop through some stl containers. In order to do that, we need iterable containers + /// of same type and provide iterator interface and pass it on to writeIterator(). + /// Remember, this is passed by value in constructor so that we dont change original containers. + /// This operation is as expensive as Big-O(std::min(class_.size(), base::consts::kMaxLogPerContainer)) + namespace workarounds { + /// @brief Abstract IterableContainer template that provides interface for iterable classes of type T + template + class IterableContainer { + public: + typedef typename Container::iterator iterator; + typedef typename Container::const_iterator const_iterator; + IterableContainer(void) {} + virtual ~IterableContainer(void) {} + iterator begin(void) { return getContainer().begin(); } + iterator end(void) { return getContainer().end(); } + private: + virtual Container& getContainer(void) = 0; + }; + /// @brief Implements IterableContainer and provides iterable std::priority_queue class + template, typename Comparator = std::less> + class IterablePriorityQueue : public IterableContainer, public std::priority_queue { + public: + IterablePriorityQueue(std::priority_queue queue_) { + std::size_t count_ = 0; + while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) { + this->push(queue_.top()); + queue_.pop(); + } + } + private: + inline Container& getContainer(void) { + return this->c; + } + }; + /// @brief Implements IterableContainer and provides iterable std::queue class + template> + class IterableQueue : public IterableContainer, public std::queue { + public: + IterableQueue(std::queue queue_) { + std::size_t count_ = 0; + while (++count_ < base::consts::kMaxLogPerContainer && !queue_.empty()) { + this->push(queue_.front()); + queue_.pop(); + } + } + private: + inline Container& getContainer(void) { + return this->c; + } + }; + /// @brief Implements IterableContainer and provides iterable std::stack class + template> + class IterableStack : public IterableContainer, public std::stack { + public: + IterableStack(std::stack stack_) { + std::size_t count_ = 0; + while (++count_ < base::consts::kMaxLogPerContainer && !stack_.empty()) { + this->push(stack_.top()); + stack_.pop(); + } + } + private: + inline Container& getContainer(void) { + return this->c; + } + }; + } // namespace workarounds +#endif // defined(ELPP_STL_LOGGING) + // Log message builder + class MessageBuilder { + public: + MessageBuilder(void) : m_logger(nullptr), m_containerLogSeperator(ELPP_LITERAL("")) {} + void initialize(Logger* logger) { + m_logger = logger; + m_containerLogSeperator = ELPP->hasFlag(LoggingFlag::NewLineForContainer) ? + ELPP_LITERAL("\n ") : ELPP_LITERAL(", "); + } + +# define ELPP_SIMPLE_LOG(LOG_TYPE)\ + inline MessageBuilder& operator<<(LOG_TYPE msg) {\ + m_logger->stream() << msg;\ + if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) {\ + m_logger->stream() << " ";\ + }\ + return *this;\ + } + + inline MessageBuilder& operator<<(const std::string& msg) { + return operator<<(msg.c_str()); + } + ELPP_SIMPLE_LOG(char) + ELPP_SIMPLE_LOG(bool) + ELPP_SIMPLE_LOG(signed short) + ELPP_SIMPLE_LOG(unsigned short) + ELPP_SIMPLE_LOG(signed int) + ELPP_SIMPLE_LOG(unsigned int) + ELPP_SIMPLE_LOG(signed long) + ELPP_SIMPLE_LOG(unsigned long) + ELPP_SIMPLE_LOG(float) + ELPP_SIMPLE_LOG(double) + ELPP_SIMPLE_LOG(char*) + ELPP_SIMPLE_LOG(const char*) + ELPP_SIMPLE_LOG(const void*) + ELPP_SIMPLE_LOG(long double) + inline MessageBuilder& operator<<(const std::wstring& msg) { + return operator<<(msg.c_str()); + } + inline MessageBuilder& operator<<(const wchar_t* msg) { + if (msg == nullptr) { + m_logger->stream() << base::consts::kNullPointer; + return *this; + } +# if defined(ELPP_UNICODE) + m_logger->stream() << msg; +# else + char* buff_ = base::utils::Str::wcharPtrToCharPtr(msg); + m_logger->stream() << buff_; + free(buff_); +# endif + if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) { + m_logger->stream() << " "; + } + return *this; + } + // ostream manipulators + inline MessageBuilder& operator<<(std::ostream& (*OStreamMani)(std::ostream&)) { + m_logger->stream() << OStreamMani; + return *this; + } +#define ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(temp) \ + template \ + inline MessageBuilder& operator<<(const temp& template_inst) { \ + return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ + } +#define ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(temp) \ + template \ + inline MessageBuilder& operator<<(const temp& template_inst) { \ + return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ + } +#define ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(temp) \ + template \ + inline MessageBuilder& operator<<(const temp& template_inst) { \ + return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ + } +#define ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(temp) \ + template \ + inline MessageBuilder& operator<<(const temp& template_inst) { \ + return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ + } +#define ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(temp) \ + template \ + inline MessageBuilder& operator<<(const temp& template_inst) { \ + return writeIterator(template_inst.begin(), template_inst.end(), template_inst.size()); \ + } + +#if defined(ELPP_STL_LOGGING) + ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(std::vector) + ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(std::list) + ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(std::deque) + ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(std::set) + ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(std::multiset) + ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::map) + ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::multimap) + template + inline MessageBuilder& operator<<(const std::queue& queue_) { + base::workarounds::IterableQueue iterableQueue_ = + static_cast >(queue_); + return writeIterator(iterableQueue_.begin(), iterableQueue_.end(), iterableQueue_.size()); + } + template + inline MessageBuilder& operator<<(const std::stack& stack_) { + base::workarounds::IterableStack iterableStack_ = + static_cast >(stack_); + return writeIterator(iterableStack_.begin(), iterableStack_.end(), iterableStack_.size()); + } + template + inline MessageBuilder& operator<<(const std::priority_queue& priorityQueue_) { + base::workarounds::IterablePriorityQueue iterablePriorityQueue_ = + static_cast >(priorityQueue_); + return writeIterator(iterablePriorityQueue_.begin(), iterablePriorityQueue_.end(), iterablePriorityQueue_.size()); + } + template + inline MessageBuilder& operator<<(const std::pair& pair_) { + m_logger->stream() << ELPP_LITERAL("("); + operator << (static_cast(pair_.first)); + m_logger->stream() << ELPP_LITERAL(", "); + operator << (static_cast(pair_.second)); + m_logger->stream() << ELPP_LITERAL(")"); + return *this; + } + template + inline MessageBuilder& operator<<(const std::bitset& bitset_) { + m_logger->stream() << ELPP_LITERAL("["); + operator << (bitset_.to_string()); + m_logger->stream() << ELPP_LITERAL("]"); + return *this; + } +# if defined(ELPP_LOG_STD_ARRAY) + template + inline MessageBuilder& operator<<(const std::array& array) { + return writeIterator(array.begin(), array.end(), array.size()); + } +# endif // defined(ELPP_LOG_STD_ARRAY) +# if defined(ELPP_LOG_UNORDERED_MAP) + ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(std::unordered_map) + ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG(std::unordered_multimap) +# endif // defined(ELPP_LOG_UNORDERED_MAP) +# if defined(ELPP_LOG_UNORDERED_SET) + ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::unordered_set) + ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(std::unordered_multiset) +# endif // defined(ELPP_LOG_UNORDERED_SET) +#endif // defined(ELPP_STL_LOGGING) +#if defined(ELPP_QT_LOGGING) + inline MessageBuilder& operator<<(const QString& msg) { +# if defined(ELPP_UNICODE) + m_logger->stream() << msg.toStdWString(); +# else + m_logger->stream() << msg.toStdString(); +# endif // defined(ELPP_UNICODE) + return *this; + } + inline MessageBuilder& operator<<(const QByteArray& msg) { + return operator << (QString(msg)); + } + inline MessageBuilder& operator<<(const QStringRef& msg) { + return operator<<(msg.toString()); + } + inline MessageBuilder& operator<<(qint64 msg) { +# if defined(ELPP_UNICODE) + m_logger->stream() << QString::number(msg).toStdWString(); +# else + m_logger->stream() << QString::number(msg).toStdString(); +# endif // defined(ELPP_UNICODE) + return *this; + } + inline MessageBuilder& operator<<(quint64 msg) { +# if defined(ELPP_UNICODE) + m_logger->stream() << QString::number(msg).toStdWString(); +# else + m_logger->stream() << QString::number(msg).toStdString(); +# endif // defined(ELPP_UNICODE) + return *this; + } + inline MessageBuilder& operator<<(QChar msg) { + m_logger->stream() << msg.toLatin1(); + return *this; + } + inline MessageBuilder& operator<<(const QLatin1String& msg) { + m_logger->stream() << msg.latin1(); + return *this; + } + ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QList) + ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QVector) + ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QQueue) + ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QSet) + ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QLinkedList) + ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(QStack) + template + inline MessageBuilder& operator<<(const QPair& pair_) { + m_logger->stream() << ELPP_LITERAL("("); + operator << (static_cast(pair_.first)); + m_logger->stream() << ELPP_LITERAL(", "); + operator << (static_cast(pair_.second)); + m_logger->stream() << ELPP_LITERAL(")"); + return *this; + } + template + inline MessageBuilder& operator<<(const QMap& map_) { + m_logger->stream() << ELPP_LITERAL("["); + QList keys = map_.keys(); + typename QList::const_iterator begin = keys.begin(); + typename QList::const_iterator end = keys.end(); + int max_ = static_cast(base::consts::kMaxLogPerContainer); // to prevent warning + for (int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) { + m_logger->stream() << ELPP_LITERAL("("); + operator << (static_cast(*begin)); + m_logger->stream() << ELPP_LITERAL(", "); + operator << (static_cast(map_.value(*begin))); + m_logger->stream() << ELPP_LITERAL(")"); + m_logger->stream() << ((index_ < keys.size() - 1) ? m_containerLogSeperator : ELPP_LITERAL("")); + } + if (begin != end) { + m_logger->stream() << ELPP_LITERAL("..."); + } + m_logger->stream() << ELPP_LITERAL("]"); + return *this; + } + template + inline MessageBuilder& operator<<(const QMultiMap& map_) { + operator << (static_cast>(map_)); + return *this; + } + template + inline MessageBuilder& operator<<(const QHash& hash_) { + m_logger->stream() << ELPP_LITERAL("["); + QList keys = hash_.keys(); + typename QList::const_iterator begin = keys.begin(); + typename QList::const_iterator end = keys.end(); + int max_ = static_cast(base::consts::kMaxLogPerContainer); // prevent type warning + for (int index_ = 0; begin != end && index_ < max_; ++index_, ++begin) { + m_logger->stream() << ELPP_LITERAL("("); + operator << (static_cast(*begin)); + m_logger->stream() << ELPP_LITERAL(", "); + operator << (static_cast(hash_.value(*begin))); + m_logger->stream() << ELPP_LITERAL(")"); + m_logger->stream() << ((index_ < keys.size() - 1) ? m_containerLogSeperator : ELPP_LITERAL("")); + } + if (begin != end) { + m_logger->stream() << ELPP_LITERAL("..."); + } + m_logger->stream() << ELPP_LITERAL("]"); + return *this; + } + template + inline MessageBuilder& operator<<(const QMultiHash& multiHash_) { + operator << (static_cast>(multiHash_)); + return *this; + } +#endif // defined(ELPP_QT_LOGGING) +#if defined(ELPP_BOOST_LOGGING) + ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::vector) + ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::stable_vector) + ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::list) + ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG(boost::container::deque) + ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(boost::container::map) + ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG(boost::container::flat_map) + ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(boost::container::set) + ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG(boost::container::flat_set) +#endif // defined(ELPP_BOOST_LOGGING) + + /// @brief Macro used internally that can be used externally to make containers easylogging++ friendly + /// + /// @detail This macro expands to write an ostream& operator<< for container. This container is expected to + /// have begin() and end() methods that return respective iterators + /// @param ContainerType Type of container e.g, MyList from WX_DECLARE_LIST(int, MyList); in wxwidgets + /// @param SizeMethod Method used to get size of container. + /// @param ElementInstance Instance of element to be fed out. Insance name is "elem". See WXELPP_ENABLED macro + /// for an example usage +#define MAKE_CONTAINERELPP_FRIENDLY(ContainerType, SizeMethod, ElementInstance) \ + el::base::type::ostream_t& operator<<(el::base::type::ostream_t& ss, const ContainerType& container) {\ + const el::base::type::char_t* sep = ELPP->hasFlag(el::LoggingFlag::NewLineForContainer) ? \ + ELPP_LITERAL("\n ") : ELPP_LITERAL(", ");\ + ContainerType::const_iterator elem = container.begin();\ + ContainerType::const_iterator endElem = container.end();\ + std::size_t size_ = container.SizeMethod; \ + ss << ELPP_LITERAL("[");\ + for (std::size_t i = 0; elem != endElem && i < el::base::consts::kMaxLogPerContainer; ++i, ++elem) { \ + ss << ElementInstance;\ + ss << ((i < size_ - 1) ? sep : ELPP_LITERAL(""));\ + }\ + if (elem != endElem) {\ + ss << ELPP_LITERAL("...");\ + }\ + ss << ELPP_LITERAL("]");\ + return ss;\ + } +#if defined(ELPP_WXWIDGETS_LOGGING) + ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG(wxVector) +# define ELPP_WX_PTR_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), *(*elem)) +# define ELPP_WX_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), (*elem)) +# define ELPP_WX_HASH_MAP_ENABLED(ContainerType) MAKE_CONTAINERELPP_FRIENDLY(ContainerType, size(), \ + ELPP_LITERAL("(") << elem->first << ELPP_LITERAL(", ") << elem->second << ELPP_LITERAL(")") +#else +# define ELPP_WX_PTR_ENABLED(ContainerType) +# define ELPP_WX_ENABLED(ContainerType) +# define ELPP_WX_HASH_MAP_ENABLED(ContainerType) +#endif // defined(ELPP_WXWIDGETS_LOGGING) + // Other classes + template + ELPP_SIMPLE_LOG(const Class&) +#undef ELPP_SIMPLE_LOG +#undef ELPP_ITERATOR_CONTAINER_LOG_ONE_ARG +#undef ELPP_ITERATOR_CONTAINER_LOG_TWO_ARG +#undef ELPP_ITERATOR_CONTAINER_LOG_THREE_ARG +#undef ELPP_ITERATOR_CONTAINER_LOG_FOUR_ARG +#undef ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG + private: + Logger* m_logger; + const base::type::char_t* m_containerLogSeperator; + + template + inline MessageBuilder& writeIterator(Iterator begin_, Iterator end_, std::size_t size_) { + m_logger->stream() << ELPP_LITERAL("["); + for (std::size_t i = 0; begin_ != end_ && i < base::consts::kMaxLogPerContainer; ++i, ++begin_) { + operator << (*begin_); + m_logger->stream() << ((i < size_ - 1) ? m_containerLogSeperator : ELPP_LITERAL("")); + } + if (begin_ != end_) { + m_logger->stream() << ELPP_LITERAL("..."); + } + m_logger->stream() << ELPP_LITERAL("]"); + if (ELPP->hasFlag(LoggingFlag::AutoSpacing)) { + m_logger->stream() << " "; + } + return *this; + } + }; + /// @brief Writes nothing - Used when certain log is disabled + class NullWriter : base::NoCopy { + public: + NullWriter(void) {} + + // Null manipulator + inline NullWriter& operator<<(std::ostream& (*)(std::ostream&)) { + return *this; + } + + template + inline NullWriter& operator<<(const T&) { + return *this; + } + }; + /// @brief Main entry point of each logging + class Writer : base::NoCopy { + public: + Writer(Level level, const char* file, unsigned long int line, + const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog, + base::type::VerboseLevel verboseLevel = 0) : + m_level(level), m_file(file), m_line(line), m_func(func), m_verboseLevel(verboseLevel), + m_proceed(false), m_dispatchAction(dispatchAction) { + } + + virtual ~Writer(void) { + processDispatch(); + } + + template + inline Writer& operator<<(const T& log) { +#if ELPP_LOGGING_ENABLED + if (m_proceed) { + m_messageBuilder << log; + } +#endif // ELPP_LOGGING_ENABLED + return *this; + } + + inline Writer& operator<<(std::ostream& (*log)(std::ostream&)) { +#if ELPP_LOGGING_ENABLED + if (m_proceed) { + m_messageBuilder << log; + } +#endif // ELPP_LOGGING_ENABLED + return *this; + } + + Writer& construct(Logger* logger, bool needLock = true) { + m_logger = logger; + initializeLogger(logger->id(), false, needLock); + m_messageBuilder.initialize(m_logger); + return *this; + } + + Writer& construct(int count, const char* loggerIds, ...) { + if (ELPP->hasFlag(LoggingFlag::MultiLoggerSupport)) { + va_list loggersList; + va_start(loggersList, loggerIds); + const char* id = loggerIds; + for (int i = 0; i < count; ++i) { + m_loggerIds.push_back(std::string(id)); + id = va_arg(loggersList, const char*); + } + va_end(loggersList); + initializeLogger(m_loggerIds.at(0)); + } + else { + initializeLogger(std::string(loggerIds)); + } + m_messageBuilder.initialize(m_logger); + return *this; + } + protected: + Level m_level; + const char* m_file; + const unsigned long int m_line; + const char* m_func; + base::type::VerboseLevel m_verboseLevel; + Logger* m_logger; + bool m_proceed; + base::MessageBuilder m_messageBuilder; + base::DispatchAction m_dispatchAction; + std::vector m_loggerIds; + friend class el::Helpers; + + void initializeLogger(const std::string& loggerId, bool lookup = true, bool needLock = true) { + if (lookup) { + m_logger = ELPP->registeredLoggers()->get(loggerId, ELPP->hasFlag(LoggingFlag::CreateLoggerAutomatically)); + } + if (m_logger == nullptr) { + ELPP->acquireLock(); + if (!ELPP->registeredLoggers()->has(std::string(base::consts::kDefaultLoggerId))) { + // Somehow default logger has been unregistered. Not good! Register again + ELPP->registeredLoggers()->get(std::string(base::consts::kDefaultLoggerId)); + } + ELPP->releaseLock(); // Need to unlock it for next writer + Writer(Level::Debug, m_file, m_line, m_func).construct(1, base::consts::kDefaultLoggerId) + << "Logger [" << loggerId << "] is not registered yet!"; + m_proceed = false; + } + else { + if (needLock) { + m_logger->acquireLock(); // This should not be unlocked by checking m_proceed because + // m_proceed can be changed by lines below + } + if (ELPP->hasFlag(LoggingFlag::HierarchicalLogging)) { + m_proceed = m_level == Level::Verbose ? m_logger->enabled(m_level) : + LevelHelper::castToInt(m_level) >= LevelHelper::castToInt(ELPP->m_loggingLevel); + } + else { + m_proceed = m_logger->enabled(m_level); + } + } + } + + void processDispatch() { +#if ELPP_LOGGING_ENABLED + if (ELPP->hasFlag(LoggingFlag::MultiLoggerSupport)) { + bool firstDispatched = false; + base::type::string_t logMessage; + std::size_t i = 0; + do { + if (m_proceed) { + if (firstDispatched) { + m_logger->stream() << logMessage; + } + else { + firstDispatched = true; + if (m_loggerIds.size() > 1) { + logMessage = m_logger->stream().str(); + } + } + triggerDispatch(); + } + else if (m_logger != nullptr) { + m_logger->stream().str(ELPP_LITERAL("")); + m_logger->releaseLock(); + } + if (i + 1 < m_loggerIds.size()) { + initializeLogger(m_loggerIds.at(i + 1)); + } + } while (++i < m_loggerIds.size()); + } + else { + if (m_proceed) { + triggerDispatch(); + } + else if (m_logger != nullptr) { + m_logger->stream().str(ELPP_LITERAL("")); + m_logger->releaseLock(); + } + } +#else + if (m_logger != nullptr) { + m_logger->stream().str(ELPP_LITERAL("")); + m_logger->releaseLock(); + } +#endif // ELPP_LOGGING_ENABLED + } + + void triggerDispatch(void) { + if (m_proceed) { + base::LogDispatcher(m_proceed, LogMessage(m_level, m_file, m_line, m_func, m_verboseLevel, + m_logger), m_dispatchAction).dispatch(); + } + if (m_logger != nullptr) { + m_logger->stream().str(ELPP_LITERAL("")); + m_logger->releaseLock(); + } + if (m_proceed && m_level == Level::Fatal + && !ELPP->hasFlag(LoggingFlag::DisableApplicationAbortOnFatalLog)) { + base::Writer(Level::Warning, m_file, m_line, m_func).construct(1, base::consts::kDefaultLoggerId) + << "Aborting application. Reason: Fatal log at [" << m_file << ":" << m_line << "]"; + std::stringstream reasonStream; + reasonStream << "Fatal log at [" << m_file << ":" << m_line << "]" + << " If you wish to disable 'abort on fatal log' please use " + << "el::Helpers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog)"; + base::utils::abort(1, reasonStream.str()); + } + m_proceed = false; + } + }; + class PErrorWriter : public base::Writer { + public: + PErrorWriter(Level level, const char* file, unsigned long int line, + const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog, + base::type::VerboseLevel verboseLevel = 0) : + base::Writer(level, file, line, func, dispatchAction, verboseLevel) { + } + + virtual ~PErrorWriter(void) { + if (m_proceed) { +#if ELPP_COMPILER_MSVC + char buff[256]; + strerror_s(buff, 256, errno); + m_logger->stream() << ": " << buff << " [" << errno << "]"; +#else + m_logger->stream() << ": " << strerror(errno) << " [" << errno << "]"; +#endif + } + } + }; + } // namespace base + // Logging from Logger class. Why this is here? Because we have Storage and Writer class available +#if ELPP_VARIADIC_TEMPLATES_SUPPORTED + template + void Logger::log_(Level level, int vlevel, const char* s, const T& value, const Args&... args) { + base::MessageBuilder b; + b.initialize(this); + while (*s) { + if (*s == base::consts::kFormatSpecifierChar) { + if (*(s + 1) == base::consts::kFormatSpecifierChar) { + ++s; + } + else { + if (*(s + 1) == base::consts::kFormatSpecifierCharValue) { + ++s; + b << value; + log_(level, vlevel, ++s, args...); + return; + } + } + } + b << *s++; + } + ELPP_INTERNAL_ERROR("Too many arguments provided. Unable to handle. Please provide more format specifiers", false); + } + template + inline void Logger::log_(Level level, int vlevel, const T& log) { + if (level == Level::Verbose) { + if (ELPP->vRegistry()->allowed(vlevel, __FILE__)) { + base::Writer(Level::Verbose, "FILE", 0, "FUNCTION", + base::DispatchAction::NormalLog, vlevel).construct(this, false) << log; + } + else { + stream().str(ELPP_LITERAL("")); + } + } + else { + base::Writer(level, "FILE", 0, "FUNCTION").construct(this, false) << log; + } + } + template + void Logger::log(Level level, const char* s, const T& value, const Args&... args) { + base::threading::ScopedLock scopedLock(lock()); + log_(level, 0, s, value, args...); + } + template + inline void Logger::log(Level level, const T& log) { + base::threading::ScopedLock scopedLock(lock()); + log_(level, 0, log); + } +# if ELPP_VERBOSE_LOG + template + inline void Logger::verbose(int vlevel, const char* s, const T& value, const Args&... args) { + base::threading::ScopedLock scopedLock(lock()); + log_(el::Level::Verbose, vlevel, s, value, args...); + } + template + inline void Logger::verbose(int vlevel, const T& log) { + base::threading::ScopedLock scopedLock(lock()); + log_(el::Level::Verbose, vlevel, log); + } +# else + template + inline void Logger::verbose(int, const char*, const T&, const Args&...) { + return; + } + template + inline void Logger::verbose(int, const T&) { + return; + } +# endif // ELPP_VERBOSE_LOG +# define LOGGER_LEVEL_WRITERS(FUNCTION_NAME, LOG_LEVEL)\ + template \ + inline void Logger::FUNCTION_NAME(const char* s, const T& value, const Args&... args) {\ + log(LOG_LEVEL, s, value, args...);\ + }\ + template \ + inline void Logger::FUNCTION_NAME(const T& value) {\ + log(LOG_LEVEL, value);\ + } +# define LOGGER_LEVEL_WRITERS_DISABLED(FUNCTION_NAME, LOG_LEVEL)\ + template \ + inline void Logger::FUNCTION_NAME(const char*, const T&, const Args&...) {\ + return;\ + }\ + template \ + inline void Logger::FUNCTION_NAME(const T&) {\ + return;\ + } + +# if ELPP_INFO_LOG + LOGGER_LEVEL_WRITERS(info, Level::Info) +# else + LOGGER_LEVEL_WRITERS_DISABLED(info, Level::Info) +# endif // ELPP_INFO_LOG +# if ELPP_DEBUG_LOG + LOGGER_LEVEL_WRITERS(debug, Level::Debug) +# else + LOGGER_LEVEL_WRITERS_DISABLED(debug, Level::Debug) +# endif // ELPP_DEBUG_LOG +# if ELPP_WARNING_LOG + LOGGER_LEVEL_WRITERS(warn, Level::Warning) +# else + LOGGER_LEVEL_WRITERS_DISABLED(warn, Level::Warning) +# endif // ELPP_WARNING_LOG +# if ELPP_ERROR_LOG + LOGGER_LEVEL_WRITERS(error, Level::Error) +# else + LOGGER_LEVEL_WRITERS_DISABLED(error, Level::Error) +# endif // ELPP_ERROR_LOG +# if ELPP_FATAL_LOG + LOGGER_LEVEL_WRITERS(fatal, Level::Fatal) +# else + LOGGER_LEVEL_WRITERS_DISABLED(fatal, Level::Fatal) +# endif // ELPP_FATAL_LOG +# if ELPP_TRACE_LOG + LOGGER_LEVEL_WRITERS(trace, Level::Trace) +# else + LOGGER_LEVEL_WRITERS_DISABLED(trace, Level::Trace) +# endif // ELPP_TRACE_LOG +# undef LOGGER_LEVEL_WRITERS +# undef LOGGER_LEVEL_WRITERS_DISABLED +#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED +#if ELPP_COMPILER_MSVC +# define ELPP_VARIADIC_FUNC_MSVC(variadicFunction, variadicArgs) variadicFunction variadicArgs +# define ELPP_VARIADIC_FUNC_MSVC_RUN(variadicFunction, ...) ELPP_VARIADIC_FUNC_MSVC(variadicFunction, (__VA_ARGS__)) +# define el_getVALength(...) ELPP_VARIADIC_FUNC_MSVC_RUN(el_resolveVALength, 0, ## __VA_ARGS__,\ + 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +#else +# if ELPP_COMPILER_CLANG +# define el_getVALength(...) el_resolveVALength(0, __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +# else +# define el_getVALength(...) el_resolveVALength(0, ## __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +# endif // ELPP_COMPILER_CLANG +#endif // ELPP_COMPILER_MSVC +#define el_resolveVALength(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N +#define ELPP_WRITE_LOG(writer, level, dispatchAction, ...) \ + writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) +#define ELPP_WRITE_LOG_IF(writer, condition, level, dispatchAction, ...) if (condition) \ + writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) +#define ELPP_WRITE_LOG_EVERY_N(writer, occasion, level, dispatchAction, ...) \ + if (ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion)) \ + writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) +#define ELPP_WRITE_LOG_AFTER_N(writer, n, level, dispatchAction, ...) \ + if (ELPP->validateAfterNCounter(__FILE__, __LINE__, n)) \ + writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) +#define ELPP_WRITE_LOG_N_TIMES(writer, n, level, dispatchAction, ...) \ + if (ELPP->validateNTimesCounter(__FILE__, __LINE__, n)) \ + writer(level, __FILE__, __LINE__, ELPP_FUNC, dispatchAction).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) +#undef ELPP_CURR_FILE_PERFORMANCE_LOGGER +#if defined(ELPP_PERFORMANCE_LOGGER) +# define ELPP_CURR_FILE_PERFORMANCE_LOGGER ELPP_PERFORMANCE_LOGGER +#else +# define ELPP_CURR_FILE_PERFORMANCE_LOGGER el::base::consts::kPerformanceLoggerId +#endif + class PerformanceTrackingData { + public: + enum class DataType : base::type::EnumType { + Checkpoint = 1, Complete = 2 + }; + // Do not use constructor, will run into multiple definition error, use init(PerformanceTracker*) + explicit PerformanceTrackingData(DataType dataType) : m_performanceTracker(nullptr), + m_dataType(dataType), m_file(""), m_line(0), m_func("") {} + inline const std::string* blockName(void) const; + inline const struct timeval* startTime(void) const; + inline const struct timeval* endTime(void) const; + inline const struct timeval* lastCheckpointTime(void) const; + inline const base::PerformanceTracker* performanceTracker(void) const { return m_performanceTracker; } + inline PerformanceTrackingData::DataType dataType(void) const { return m_dataType; } + inline bool firstCheckpoint(void) const { return m_firstCheckpoint; } + inline std::string checkpointId(void) const { return m_checkpointId; } + inline const char* file(void) const { return m_file; } + inline unsigned long int line(void) const { return m_line; } + inline const char* func(void) const { return m_func; } + inline const base::type::string_t* formattedTimeTaken() const { return &m_formattedTimeTaken; } + inline const std::string& loggerId(void) const; + private: + base::PerformanceTracker* m_performanceTracker; + base::type::string_t m_formattedTimeTaken; + PerformanceTrackingData::DataType m_dataType; + bool m_firstCheckpoint; + std::string m_checkpointId; + const char* m_file; + unsigned long int m_line; + const char* m_func; + inline void init(base::PerformanceTracker* performanceTracker, bool firstCheckpoint = false) { + m_performanceTracker = performanceTracker; + m_firstCheckpoint = firstCheckpoint; + } + + friend class el::base::PerformanceTracker; + }; + namespace base { + /// @brief Represents performanceTracker block of code that conditionally adds performance status to log + /// either when goes outside the scope of when checkpoint() is called + class PerformanceTracker : public base::threading::ThreadSafe, public Loggable { + public: + PerformanceTracker(const std::string& blockName, + base::TimestampUnit timestampUnit = base::TimestampUnit::Millisecond, + const std::string& loggerId = std::string(ELPP_CURR_FILE_PERFORMANCE_LOGGER), + bool scopedLog = true, Level level = base::consts::kPerformanceTrackerDefaultLevel) : + m_blockName(blockName), m_timestampUnit(timestampUnit), m_loggerId(loggerId), m_scopedLog(scopedLog), + m_level(level), m_hasChecked(false), m_lastCheckpointId(std::string()), m_enabled(false) { +#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED + // We store it locally so that if user happen to change configuration by the end of scope + // or before calling checkpoint, we still depend on state of configuraton at time of construction + el::Logger* loggerPtr = ELPP->registeredLoggers()->get(loggerId, false); + m_enabled = loggerPtr != nullptr && loggerPtr->m_typedConfigurations->performanceTracking(m_level); + if (m_enabled) { + base::utils::DateTime::gettimeofday(&m_startTime); + } +#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED + } + /// @brief Copy constructor + PerformanceTracker(const PerformanceTracker& t) : + m_blockName(t.m_blockName), m_timestampUnit(t.m_timestampUnit), m_loggerId(t.m_loggerId), m_scopedLog(t.m_scopedLog), + m_level(t.m_level), m_hasChecked(t.m_hasChecked), m_lastCheckpointId(t.m_lastCheckpointId), m_enabled(t.m_enabled), + m_startTime(t.m_startTime), m_endTime(t.m_endTime), m_lastCheckpointTime(t.m_lastCheckpointTime) { + } + virtual ~PerformanceTracker(void) { +#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED + if (m_enabled) { + base::threading::ScopedLock scopedLock(lock()); + if (m_scopedLog) { + base::utils::DateTime::gettimeofday(&m_endTime); + base::type::string_t formattedTime = getFormattedTimeTaken(); + PerformanceTrackingData data(PerformanceTrackingData::DataType::Complete); + data.init(this); + data.m_formattedTimeTaken = formattedTime; + PerformanceTrackingCallback* callback = nullptr; + for (const std::pair& h + : ELPP->m_performanceTrackingCallbacks) { + callback = h.second.get(); + if (callback != nullptr && callback->enabled()) { + callback->acquireLock(); + callback->handle(&data); + callback->releaseLock(); + } + } + } + } +#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) + } + /// @brief A checkpoint for current performanceTracker block. + void checkpoint(const std::string& id = std::string(), const char* file = __FILE__, unsigned long int line = __LINE__, const char* func = "") { +#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED + if (m_enabled) { + base::threading::ScopedLock scopedLock(lock()); + base::utils::DateTime::gettimeofday(&m_endTime); + base::type::string_t formattedTime = m_hasChecked ? getFormattedTimeTaken(m_lastCheckpointTime) : ELPP_LITERAL(""); + PerformanceTrackingData data(PerformanceTrackingData::DataType::Checkpoint); + data.init(this); + data.m_checkpointId = id; + data.m_file = file; + data.m_line = line; + data.m_func = func; + data.m_formattedTimeTaken = formattedTime; + PerformanceTrackingCallback* callback = nullptr; + for (const std::pair& h + : ELPP->m_performanceTrackingCallbacks) { + callback = h.second.get(); + if (callback != nullptr && callback->enabled()) { + callback->acquireLock(); + callback->handle(&data); + callback->releaseLock(); + } + } + base::utils::DateTime::gettimeofday(&m_lastCheckpointTime); + m_hasChecked = true; + m_lastCheckpointId = id; + } +#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED + ELPP_UNUSED(id); + ELPP_UNUSED(file); + ELPP_UNUSED(line); + ELPP_UNUSED(func); + } + inline Level level(void) const { return m_level; } + private: + std::string m_blockName; + base::TimestampUnit m_timestampUnit; + std::string m_loggerId; + bool m_scopedLog; + Level m_level; + bool m_hasChecked; + std::string m_lastCheckpointId; + bool m_enabled; + struct timeval m_startTime, m_endTime, m_lastCheckpointTime; + + PerformanceTracker(void); + + friend class el::PerformanceTrackingData; + friend class base::DefaultPerformanceTrackingCallback; + + const inline base::type::string_t getFormattedTimeTaken() const { + return getFormattedTimeTaken(m_startTime); + } + + const base::type::string_t getFormattedTimeTaken(struct timeval startTime) const { + if (ELPP->hasFlag(LoggingFlag::FixedTimeFormat)) { + base::type::stringstream_t ss; + ss << base::utils::DateTime::getTimeDifference(m_endTime, + startTime, m_timestampUnit) << " " << base::consts::kTimeFormats[static_cast(m_timestampUnit)].unit; + return ss.str(); + } + return base::utils::DateTime::formatTime(base::utils::DateTime::getTimeDifference(m_endTime, + startTime, m_timestampUnit), m_timestampUnit); + } + + virtual inline void log(el::base::type::ostream_t& os) const { + os << getFormattedTimeTaken(); + } + }; + class DefaultPerformanceTrackingCallback : public PerformanceTrackingCallback { + protected: + void handle(const PerformanceTrackingData* data) { + m_data = data; + base::type::stringstream_t ss; + if (m_data->dataType() == PerformanceTrackingData::DataType::Complete) { + ss << ELPP_LITERAL("Executed [") << m_data->blockName()->c_str() << ELPP_LITERAL("] in [") << *m_data->formattedTimeTaken() << ELPP_LITERAL("]"); + } + else { + ss << ELPP_LITERAL("Performance checkpoint"); + if (!m_data->checkpointId().empty()) { + ss << ELPP_LITERAL(" [") << m_data->checkpointId().c_str() << ELPP_LITERAL("]"); + } + ss << ELPP_LITERAL(" for block [") << m_data->blockName()->c_str() << ELPP_LITERAL("] : [") << *m_data->performanceTracker(); + if (!ELPP->hasFlag(LoggingFlag::DisablePerformanceTrackingCheckpointComparison) && m_data->performanceTracker()->m_hasChecked) { + ss << ELPP_LITERAL(" ([") << *m_data->formattedTimeTaken() << ELPP_LITERAL("] from "); + if (m_data->performanceTracker()->m_lastCheckpointId.empty()) { + ss << ELPP_LITERAL("last checkpoint"); + } + else { + ss << ELPP_LITERAL("checkpoint '") << m_data->performanceTracker()->m_lastCheckpointId.c_str() << ELPP_LITERAL("'"); + } + ss << ELPP_LITERAL(")]"); + } + else { + ss << ELPP_LITERAL("]"); + } + } + el::base::Writer(m_data->performanceTracker()->level(), m_data->file(), m_data->line(), m_data->func()).construct(1, m_data->loggerId().c_str()) << ss.str(); + } + private: + const PerformanceTrackingData* m_data; + }; + } // namespace base + inline const std::string* PerformanceTrackingData::blockName() const { + return const_cast(&m_performanceTracker->m_blockName); + } + inline const struct timeval* PerformanceTrackingData::startTime() const { + return const_cast(&m_performanceTracker->m_startTime); + } + inline const struct timeval* PerformanceTrackingData::endTime() const { + return const_cast(&m_performanceTracker->m_endTime); + } + inline const struct timeval* PerformanceTrackingData::lastCheckpointTime() const { + return const_cast(&m_performanceTracker->m_lastCheckpointTime); + } + inline const std::string& PerformanceTrackingData::loggerId(void) const { return m_performanceTracker->m_loggerId; } + namespace base { + /// @brief Contains some internal debugging tools like crash handler and stack tracer + namespace debug { + class StackTrace : base::NoCopy { + public: + static const std::size_t kMaxStack = 64; + static const std::size_t kStackStart = 2; // We want to skip c'tor and StackTrace::generateNew() + class StackTraceEntry { + public: + StackTraceEntry(std::size_t index, const char* loc, const char* demang, const char* hex, const char* addr) { + m_index = index; + m_location = std::string(loc); + m_demangled = std::string(demang); + m_hex = std::string(hex); + m_addr = std::string(addr); + } + StackTraceEntry(std::size_t index, char* loc) { + m_index = index; + m_location = std::string(loc); + } + std::size_t m_index; + std::string m_location; + std::string m_demangled; + std::string m_hex; + std::string m_addr; + friend std::ostream& operator<<(std::ostream& ss, const StackTraceEntry& si) { + ss << "[" << si.m_index << "] " << si.m_location << (si.m_demangled.empty() ? "" : ":") << si.m_demangled + << (si.m_hex.empty() ? "" : "+") << si.m_hex << si.m_addr; + return ss; + } + + private: + StackTraceEntry(void); + }; + + StackTrace(void) { + generateNew(); + } + + virtual ~StackTrace(void) { + } + + inline std::vector& getLatestStack(void) { + return m_stack; + } + + friend inline std::ostream& operator<<(std::ostream& os, const StackTrace& st) { + std::vector::const_iterator it = st.m_stack.begin(); + while (it != st.m_stack.end()) { + os << " " << *it++ << "\n"; + } + return os; + } + + private: + std::vector m_stack; + + void generateNew(void) { +#if ELPP_STACKTRACE + m_stack.clear(); + void* stack[kMaxStack]; + std::size_t size = backtrace(stack, kMaxStack); + char** strings = backtrace_symbols(stack, size); + if (size > kStackStart) { // Skip StackTrace c'tor and generateNew + for (std::size_t i = kStackStart; i < size; ++i) { + char* mangName = nullptr; + char* hex = nullptr; + char* addr = nullptr; + for (char* c = strings[i]; *c; ++c) { + switch (*c) { + case '(': + mangName = c; + break; + case '+': + hex = c; + break; + case ')': + addr = c; + break; + } + } + // Perform demangling if parsed properly + if (mangName != nullptr && hex != nullptr && addr != nullptr && mangName < hex) { + *mangName++ = '\0'; + *hex++ = '\0'; + *addr++ = '\0'; + int status = 0; + char* demangName = abi::__cxa_demangle(mangName, 0, 0, &status); + // if demangling is successful, output the demangled function name + if (status == 0) { + // Success (see http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.3/a01696.html) + StackTraceEntry entry(i - 1, strings[i], demangName, hex, addr); + m_stack.push_back(entry); + } + else { + // Not successful - we will use mangled name + StackTraceEntry entry(i - 1, strings[i], mangName, hex, addr); + m_stack.push_back(entry); + } + free(demangName); + } + else { + StackTraceEntry entry(i - 1, strings[i]); + m_stack.push_back(entry); + } + } + } + free(strings); +#else + ELPP_INTERNAL_INFO(1, "Stacktrace generation not supported for selected compiler"); +#endif // ELPP_STACKTRACE + } + }; + static std::string crashReason(int sig) { + std::stringstream ss; + bool foundReason = false; + for (int i = 0; i < base::consts::kCrashSignalsCount; ++i) { + if (base::consts::kCrashSignals[i].numb == sig) { + ss << "Application has crashed due to [" << base::consts::kCrashSignals[i].name << "] signal"; + if (ELPP->hasFlag(el::LoggingFlag::LogDetailedCrashReason)) { + ss << std::endl << + " " << base::consts::kCrashSignals[i].brief << std::endl << + " " << base::consts::kCrashSignals[i].detail; + } + foundReason = true; + } + } + if (!foundReason) { + ss << "Application has crashed due to unknown signal [" << sig << "]"; + } + return ss.str(); + } + /// @brief Logs reason of crash from sig + static void logCrashReason(int sig, bool stackTraceIfAvailable, Level level, const char* logger) { + std::stringstream ss; + ss << "CRASH HANDLED; "; + ss << crashReason(sig); +#if ELPP_STACKTRACE + if (stackTraceIfAvailable) { + ss << std::endl << " ======= Backtrace: =========" << std::endl << base::debug::StackTrace(); + } +#else + ELPP_UNUSED(stackTraceIfAvailable); +#endif // ELPP_STACKTRACE + ELPP_WRITE_LOG(el::base::Writer, level, base::DispatchAction::NormalLog, logger) << ss.str(); + } + static inline void crashAbort(int sig) { + base::utils::abort(sig); + } + /// @brief Default application crash handler + /// + /// @detail This function writes log using 'default' logger, prints stack trace for GCC based compilers and aborts program. + static inline void defaultCrashHandler(int sig) { + base::debug::logCrashReason(sig, true, Level::Fatal, base::consts::kDefaultLoggerId); + base::debug::crashAbort(sig); + } + /// @brief Handles unexpected crashes + class CrashHandler : base::NoCopy { + public: + typedef void(*Handler)(int); + + explicit CrashHandler(bool useDefault) { + if (useDefault) { + setHandler(defaultCrashHandler); + } + } + explicit CrashHandler(const Handler& cHandler) { + setHandler(cHandler); + } + void setHandler(const Handler& cHandler) { + m_handler = cHandler; +#if defined(ELPP_HANDLE_SIGABRT) + int i = 0; // SIGABRT is at base::consts::kCrashSignals[0] +#else + int i = 1; +#endif // defined(ELPP_HANDLE_SIGABRT) + for (; i < base::consts::kCrashSignalsCount; ++i) { + m_handler = signal(base::consts::kCrashSignals[i].numb, cHandler); + } + } + + private: + Handler m_handler; + }; + } // namespace debug + } // namespace base + extern base::debug::CrashHandler elCrashHandler; +#define MAKE_LOGGABLE(ClassType, ClassInstance, OutputStreamInstance) \ + el::base::type::ostream_t& operator<<(el::base::type::ostream_t& OutputStreamInstance, const ClassType& ClassInstance) + /// @brief Initializes syslog with process ID, options and facility. calls closelog() on d'tor + class SysLogInitializer { + public: + SysLogInitializer(const char* processIdent, int options = 0, int facility = 0) { +#if defined(ELPP_SYSLOG) + openlog(processIdent, options, facility); +#else + ELPP_UNUSED(processIdent); + ELPP_UNUSED(options); + ELPP_UNUSED(facility); +#endif // defined(ELPP_SYSLOG) + } + virtual ~SysLogInitializer(void) { +#if defined(ELPP_SYSLOG) + closelog(); +#endif // defined(ELPP_SYSLOG) + } + }; +#define ELPP_INITIALIZE_SYSLOG(id, opt, fac) el::SysLogInitializer elSyslogInit(id, opt, fac) + /// @brief Static helpers for developers + class Helpers : base::StaticClass { + public: + /// @brief Shares logging repository (base::Storage) + static inline void setStorage(base::type::StoragePointer storage) { + ELPP = storage; + } + /// @return Main storage repository + static inline base::type::StoragePointer storage() { + return ELPP; + } + /// @brief Sets application arguments and figures out whats active for logging and whats not. + static inline void setArgs(int argc, char** argv) { + ELPP->setApplicationArguments(argc, argv); + } + /// @copydoc setArgs(int argc, char** argv) + static inline void setArgs(int argc, const char** argv) { + ELPP->setApplicationArguments(argc, const_cast(argv)); + } + /// @brief Overrides default crash handler and installs custom handler. + /// @param crashHandler A functor with no return type that takes single int argument. + /// Handler is a typedef with specification: void (*Handler)(int) + static inline void setCrashHandler(const el::base::debug::CrashHandler::Handler& crashHandler) { + el::elCrashHandler.setHandler(crashHandler); + } + /// @brief Abort due to crash with signal in parameter + /// @param sig Crash signal + static inline void crashAbort(int sig, const char* sourceFile = "", unsigned int long line = 0) { + std::stringstream ss; + ss << base::debug::crashReason(sig).c_str(); + ss << " - [Called el::Helpers::crashAbort(" << sig << ")]"; + if (sourceFile != nullptr && strlen(sourceFile) > 0) { + ss << " - Source: " << sourceFile; + if (line > 0) + ss << ":" << line; + else + ss << " (line number not specified)"; + } + base::utils::abort(sig, ss.str()); + } + /// @brief Logs reason of crash as per sig + /// @param sig Crash signal + /// @param stackTraceIfAvailable Includes stack trace if available + /// @param level Logging level + /// @param logger Logger to use for logging + static inline void logCrashReason(int sig, bool stackTraceIfAvailable = false, + Level level = Level::Fatal, const char* logger = base::consts::kDefaultLoggerId) { + el::base::debug::logCrashReason(sig, stackTraceIfAvailable, level, logger); + } + /// @brief Installs pre rollout callback, this callback is triggered when log file is about to be rolled out + /// (can be useful for backing up) + static inline void installPreRollOutCallback(const PreRollOutCallback& callback) { + ELPP->setPreRollOutCallback(callback); + } + /// @brief Uninstalls pre rollout callback + static inline void uninstallPreRollOutCallback(void) { + ELPP->unsetPreRollOutCallback(); + } + /// @brief Installs post log dispatch callback, this callback is triggered when log is dispatched + template + static inline bool installLogDispatchCallback(const std::string& id) { + return ELPP->installLogDispatchCallback(id); + } + /// @brief Uninstalls log dispatch callback + template + static inline void uninstallLogDispatchCallback(const std::string& id) { + ELPP->uninstallLogDispatchCallback(id); + } + template + static inline T* logDispatchCallback(const std::string& id) { + return ELPP->logDispatchCallback(id); + } + /// @brief Installs post performance tracking callback, this callback is triggered when performance tracking is finished + template + static inline bool installPerformanceTrackingCallback(const std::string& id) { + return ELPP->installPerformanceTrackingCallback(id); + } + /// @brief Uninstalls post performance tracking handler + template + static inline void uninstallPerformanceTrackingCallback(const std::string& id) { + ELPP->uninstallPerformanceTrackingCallback(id); + } + template + static inline T* performanceTrackingCallback(const std::string& id) { + return ELPP->performanceTrackingCallback(id); + } + /// @brief Converts template to std::string - useful for loggable classes to log containers within log(std::ostream&) const + template + static std::string convertTemplateToStdString(const T& templ) { + el::Logger* logger = + ELPP->registeredLoggers()->get(el::base::consts::kDefaultLoggerId); + if (logger == nullptr) { + return std::string(); + } + base::MessageBuilder b; + b.initialize(logger); + logger->acquireLock(); + b << templ; +#if defined(ELPP_UNICODE) + std::string s = std::string(logger->stream().str().begin(), logger->stream().str().end()); +#else + std::string s = logger->stream().str(); +#endif // defined(ELPP_UNICODE) + logger->stream().str(ELPP_LITERAL("")); + logger->releaseLock(); + return s; + } + /// @brief Returns command line arguments (pointer) provided to easylogging++ + static inline const el::base::utils::CommandLineArgs* commandLineArgs(void) { + return ELPP->commandLineArgs(); + } + /// @brief Installs user defined format specifier and handler + static inline void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier) { + ELPP->installCustomFormatSpecifier(customFormatSpecifier); + } + /// @brief Uninstalls user defined format specifier and handler + static inline bool uninstallCustomFormatSpecifier(const char* formatSpecifier) { + return ELPP->uninstallCustomFormatSpecifier(formatSpecifier); + } + /// @brief Returns true if custom format specifier is installed + static inline bool hasCustomFormatSpecifier(const char* formatSpecifier) { + return ELPP->hasCustomFormatSpecifier(formatSpecifier); + } + static inline void validateFileRolling(Logger* logger, Level level) { + if (logger == nullptr) return; + logger->m_typedConfigurations->validateFileRolling(level, ELPP->preRollOutCallback()); + } + }; + /// @brief Static helpers to deal with loggers and their configurations + class Loggers : base::StaticClass { + public: + /// @brief Gets existing or registers new logger + static inline Logger* getLogger(const std::string& identity, bool registerIfNotAvailable = true) { + base::threading::ScopedLock scopedLock(ELPP->lock()); + return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable); + } + /// @brief Unregisters logger - use it only when you know what you are doing, you may unregister + /// loggers initialized / used by third-party libs. + static inline bool unregisterLogger(const std::string& identity) { + base::threading::ScopedLock scopedLock(ELPP->lock()); + return ELPP->registeredLoggers()->remove(identity); + } + /// @brief Whether or not logger with id is registered + static inline bool hasLogger(const std::string& identity) { + base::threading::ScopedLock scopedLock(ELPP->lock()); + return ELPP->registeredLoggers()->has(identity); + } + /// @brief Reconfigures specified logger with new configurations + static inline Logger* reconfigureLogger(Logger* logger, const Configurations& configurations) { + if (!logger) return nullptr; + logger->configure(configurations); + return logger; + } + /// @brief Reconfigures logger with new configurations after looking it up using identity + static inline Logger* reconfigureLogger(const std::string& identity, const Configurations& configurations) { + return Loggers::reconfigureLogger(Loggers::getLogger(identity), configurations); + } + /// @brief Reconfigures logger's single configuration + static inline Logger* reconfigureLogger(const std::string& identity, ConfigurationType configurationType, + const std::string& value) { + Logger* logger = Loggers::getLogger(identity); + if (logger == nullptr) { + return nullptr; + } + logger->configurations()->set(Level::Global, configurationType, value); + logger->reconfigure(); + return logger; + } + /// @brief Reconfigures all the existing loggers with new configurations + static inline void reconfigureAllLoggers(const Configurations& configurations) { + for (base::RegisteredLoggers::iterator it = ELPP->registeredLoggers()->begin(); + it != ELPP->registeredLoggers()->end(); ++it) { + Loggers::reconfigureLogger(it->second, configurations); + } + } + /// @brief Reconfigures single configuration for all the loggers + static inline void reconfigureAllLoggers(ConfigurationType configurationType, const std::string& value) { + reconfigureAllLoggers(Level::Global, configurationType, value); + } + /// @brief Reconfigures single configuration for all the loggers for specified level + static inline void reconfigureAllLoggers(Level level, ConfigurationType configurationType, + const std::string& value) { + for (base::RegisteredLoggers::iterator it = ELPP->registeredLoggers()->begin(); + it != ELPP->registeredLoggers()->end(); ++it) { + Logger* logger = it->second; + logger->configurations()->set(level, configurationType, value); + logger->reconfigure(); + } + } + /// @brief Sets default configurations. This configuration is used for future (and conditionally for existing) loggers + static inline void setDefaultConfigurations(const Configurations& configurations, bool reconfigureExistingLoggers = false) { + ELPP->registeredLoggers()->setDefaultConfigurations(configurations); + if (reconfigureExistingLoggers) { + Loggers::reconfigureAllLoggers(configurations); + } + } + /// @brief Returns current default + static inline const Configurations* defaultConfigurations(void) { + return ELPP->registeredLoggers()->defaultConfigurations(); + } + /// @brief Returns log stream reference pointer if needed by user + static inline const base::LogStreamsReferenceMap* logStreamsReference(void) { + return ELPP->registeredLoggers()->logStreamsReference(); + } + /// @brief Default typed configuration based on existing defaultConf + static base::TypedConfigurations defaultTypedConfigurations(void) { + return base::TypedConfigurations( + ELPP->registeredLoggers()->defaultConfigurations(), + ELPP->registeredLoggers()->logStreamsReference()); + } + /// @brief Populates all logger IDs in current repository. + /// @param [out] targetList List of fill up. + static inline std::vector* populateAllLoggerIds(std::vector* targetList) { + targetList->clear(); + for (base::RegisteredLoggers::iterator it = ELPP->registeredLoggers()->list().begin(); + it != ELPP->registeredLoggers()->list().end(); ++it) { + targetList->push_back(it->first); + } + return targetList; + } + /// @brief Sets configurations from global configuration file. + static void configureFromGlobal(const char* globalConfigurationFilePath) { + std::ifstream gcfStream(globalConfigurationFilePath, std::ifstream::in); + ELPP_ASSERT(gcfStream.is_open(), "Unable to open global configuration file [" << globalConfigurationFilePath + << "] for parsing."); + std::string line = std::string(); + std::stringstream ss; + Logger* logger = nullptr; + auto configure = [&](void) { + ELPP_INTERNAL_INFO(8, "Configuring logger: '" << logger->id() << "' with configurations \n" << ss.str() + << "\n--------------"); + Configurations c; + c.parseFromText(ss.str()); + logger->configure(c); + }; + while (gcfStream.good()) { + std::getline(gcfStream, line); + ELPP_INTERNAL_INFO(1, "Parsing line: " << line); + base::utils::Str::trim(line); + if (Configurations::Parser::isComment(line)) continue; + Configurations::Parser::ignoreComments(&line); + base::utils::Str::trim(line); + if (line.size() > 2 && base::utils::Str::startsWith(line, std::string(base::consts::kConfigurationLoggerId))) { + if (!ss.str().empty() && logger != nullptr) { + configure(); + } + ss.str(std::string("")); + line = line.substr(2); + base::utils::Str::trim(line); + if (line.size() > 1) { + ELPP_INTERNAL_INFO(1, "Getting logger: '" << line << "'"); + logger = getLogger(line); + } + } + else { + ss << line << "\n"; + } + } + if (!ss.str().empty() && logger != nullptr) { + configure(); + } + } + /// @brief Configures loggers using command line arg. Ensure you have already set command line args, + /// @return False if invalid argument or argument with no value provided, true if attempted to configure logger. + /// If true is returned that does not mean it has been configured successfully, it only means that it + /// has attempeted to configure logger using configuration file provided in argument + static inline bool configureFromArg(const char* argKey) { +#if defined(ELPP_DISABLE_CONFIGURATION_FROM_PROGRAM_ARGS) + ELPP_UNUSED(argKey); +#else + if (!Helpers::commandLineArgs()->hasParamWithValue(argKey)) { + return false; + } + configureFromGlobal(Helpers::commandLineArgs()->getParamValue(argKey)); +#endif // defined(ELPP_DISABLE_CONFIGURATION_FROM_PROGRAM_ARGS) + return true; + } + /// @brief Flushes all loggers for all levels - Be careful if you dont know how many loggers are registered + static inline void flushAll(void) { + ELPP->registeredLoggers()->flushAll(); + } + /// @brief Adds logging flag used internally. + static inline void addFlag(LoggingFlag flag) { + ELPP->addFlag(flag); + } + /// @brief Removes logging flag used internally. + static inline void removeFlag(LoggingFlag flag) { + ELPP->removeFlag(flag); + } + /// @brief Determines whether or not certain flag is active + static inline bool hasFlag(LoggingFlag flag) { + return ELPP->hasFlag(flag); + } + /// @brief Adds flag and removes it when scope goes out + class ScopedAddFlag { + public: + ScopedAddFlag(LoggingFlag flag) : m_flag(flag) { Loggers::addFlag(m_flag); } + ~ScopedAddFlag(void) { Loggers::removeFlag(m_flag); } + private: + LoggingFlag m_flag; + }; + /// @brief Removes flag and add it when scope goes out + class ScopedRemoveFlag { + public: + ScopedRemoveFlag(LoggingFlag flag) : m_flag(flag) { Loggers::removeFlag(m_flag); } + ~ScopedRemoveFlag(void) { Loggers::addFlag(m_flag); } + private: + LoggingFlag m_flag; + }; + /// @brief Sets hierarchy for logging. Needs to enable logging flag (HierarchicalLogging) + static inline void setLoggingLevel(Level level) { + ELPP->setLoggingLevel(level); + } + /// @brief Sets verbose level on the fly + static inline void setVerboseLevel(base::type::VerboseLevel level) { + ELPP->vRegistry()->setLevel(level); + } + /// @brief Gets current verbose level + static inline base::type::VerboseLevel verboseLevel(void) { + return ELPP->vRegistry()->level(); + } + /// @brief Sets vmodules as specified (on the fly) + static inline void setVModules(const char* modules) { + if (ELPP->vRegistry()->vModulesEnabled()) { + ELPP->vRegistry()->setModules(modules); + } + } + /// @brief Clears vmodules + static inline void clearVModules(void) { + ELPP->vRegistry()->clearModules(); + } + }; + class VersionInfo : base::StaticClass { + public: + /// @brief Current version number + static inline const std::string version(void) { return std::string("9.80"); } + /// @brief Release date of current version + static inline const std::string releaseDate(void) { return std::string("08-01-2015 0850hrs"); } + }; +} // namespace el +#undef VLOG_IS_ON + /// @brief Determines whether verbose logging is on for specified level current file. +#define VLOG_IS_ON(verboseLevel) (ELPP->vRegistry()->allowed(verboseLevel, __FILE__)) +#undef TIMED_BLOCK +#undef TIMED_SCOPE +#undef TIMED_FUNC +#undef ELPP_MIN_UNIT +#if defined(ELPP_PERFORMANCE_MICROSECONDS) +# define ELPP_MIN_UNIT el::base::TimestampUnit::Microsecond +#else +# define ELPP_MIN_UNIT el::base::TimestampUnit::Millisecond +#endif // (defined(ELPP_PERFORMANCE_MICROSECONDS)) + /// @brief Performance tracked scope. Performance gets written when goes out of scope using + /// 'performance' logger. + /// + /// @detail Please note in order to check the performance at a certain time you can use obj.checkpoint(); + /// @see el::base::PerformanceTracker + /// @see el::base::PerformanceTracker::checkpoint + // Note: Do not surround this definition with null macro because of obj instance +#define TIMED_SCOPE(obj, blockname) el::base::PerformanceTracker obj(blockname, ELPP_MIN_UNIT) +#define TIMED_BLOCK(obj, blockName) for (struct { int i; el::base::PerformanceTracker timer; } obj = { 0, \ + el::base::PerformanceTracker(blockName, ELPP_MIN_UNIT) }; obj.i < 1; ++obj.i) + /// @brief Performance tracked function. Performance gets written when goes out of scope using + /// 'performance' logger. + /// + /// @detail Please note in order to check the performance at a certain time you can use obj.checkpoint(); + /// @see el::base::PerformanceTracker + /// @see el::base::PerformanceTracker::checkpoint +#define TIMED_FUNC(obj) TIMED_SCOPE(obj, ELPP_FUNC) +#undef PERFORMANCE_CHECKPOINT +#undef PERFORMANCE_CHECKPOINT_WITH_ID +#define PERFORMANCE_CHECKPOINT(obj) obj.checkpoint(std::string(), __FILE__, __LINE__, ELPP_FUNC) +#define PERFORMANCE_CHECKPOINT_WITH_ID(obj, id) obj.checkpoint(id, __FILE__, __LINE__, ELPP_FUNC) +#undef ELPP_COUNTER +#undef ELPP_COUNTER_POS + /// @brief Gets hit counter for file/line +#define ELPP_COUNTER (ELPP->hitCounters()->getCounter(__FILE__, __LINE__)) + /// @brief Gets hit counter position for file/line, -1 if not registered yet +#define ELPP_COUNTER_POS (ELPP_COUNTER == nullptr ? -1 : ELPP_COUNTER->hitCounts()) + // Undef levels to support LOG(LEVEL) +#undef INFO +#undef WARNING +#undef DEBUG +#undef ERROR +#undef FATAL +#undef TRACE +#undef VERBOSE + // Undef existing +#undef CINFO +#undef CWARNING +#undef CDEBUG +#undef CFATAL +#undef CERROR +#undef CTRACE +#undef CVERBOSE +#undef CINFO_IF +#undef CWARNING_IF +#undef CDEBUG_IF +#undef CERROR_IF +#undef CFATAL_IF +#undef CTRACE_IF +#undef CVERBOSE_IF +#undef CINFO_EVERY_N +#undef CWARNING_EVERY_N +#undef CDEBUG_EVERY_N +#undef CERROR_EVERY_N +#undef CFATAL_EVERY_N +#undef CTRACE_EVERY_N +#undef CVERBOSE_EVERY_N +#undef CINFO_AFTER_N +#undef CWARNING_AFTER_N +#undef CDEBUG_AFTER_N +#undef CERROR_AFTER_N +#undef CFATAL_AFTER_N +#undef CTRACE_AFTER_N +#undef CVERBOSE_AFTER_N +#undef CINFO_N_TIMES +#undef CWARNING_N_TIMES +#undef CDEBUG_N_TIMES +#undef CERROR_N_TIMES +#undef CFATAL_N_TIMES +#undef CTRACE_N_TIMES +#undef CVERBOSE_N_TIMES + // Normal logs +#if ELPP_INFO_LOG +# define CINFO(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Info, dispatchAction, __VA_ARGS__) +#else +# define CINFO(writer, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_INFO_LOG +#if ELPP_WARNING_LOG +# define CWARNING(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Warning, dispatchAction, __VA_ARGS__) +#else +# define CWARNING(writer, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_WARNING_LOG +#if ELPP_DEBUG_LOG +# define CDEBUG(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Debug, dispatchAction, __VA_ARGS__) +#else +# define CDEBUG(writer, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_DEBUG_LOG +#if ELPP_ERROR_LOG +# define CERROR(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Error, dispatchAction, __VA_ARGS__) +#else +# define CERROR(writer, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_ERROR_LOG +#if ELPP_FATAL_LOG +# define CFATAL(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Fatal, dispatchAction, __VA_ARGS__) +#else +# define CFATAL(writer, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_FATAL_LOG +#if ELPP_TRACE_LOG +# define CTRACE(writer, dispatchAction, ...) ELPP_WRITE_LOG(writer, el::Level::Trace, dispatchAction, __VA_ARGS__) +#else +# define CTRACE(writer, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_TRACE_LOG +#if ELPP_VERBOSE_LOG +# define CVERBOSE(writer, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel)) writer(\ + el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) +#else +# define CVERBOSE(writer, vlevel, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_VERBOSE_LOG + // Conditional logs +#if ELPP_INFO_LOG +# define CINFO_IF(writer, condition_, dispatchAction, ...) \ + ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Info, dispatchAction, __VA_ARGS__) +#else +# define CINFO_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_INFO_LOG +#if ELPP_WARNING_LOG +# define CWARNING_IF(writer, condition_, dispatchAction, ...)\ + ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Warning, dispatchAction, __VA_ARGS__) +#else +# define CWARNING_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_WARNING_LOG +#if ELPP_DEBUG_LOG +# define CDEBUG_IF(writer, condition_, dispatchAction, ...)\ + ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Debug, dispatchAction, __VA_ARGS__) +#else +# define CDEBUG_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_DEBUG_LOG +#if ELPP_ERROR_LOG +# define CERROR_IF(writer, condition_, dispatchAction, ...)\ + ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Error, dispatchAction, __VA_ARGS__) +#else +# define CERROR_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_ERROR_LOG +#if ELPP_FATAL_LOG +# define CFATAL_IF(writer, condition_, dispatchAction, ...)\ + ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Fatal, dispatchAction, __VA_ARGS__) +#else +# define CFATAL_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_FATAL_LOG +#if ELPP_TRACE_LOG +# define CTRACE_IF(writer, condition_, dispatchAction, ...)\ + ELPP_WRITE_LOG_IF(writer, (condition_), el::Level::Trace, dispatchAction, __VA_ARGS__) +#else +# define CTRACE_IF(writer, condition_, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_TRACE_LOG +#if ELPP_VERBOSE_LOG +# define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) if (VLOG_IS_ON(vlevel) && (condition_)) writer( \ + el::Level::Verbose, __FILE__, __LINE__, ELPP_FUNC, dispatchAction, vlevel).construct(el_getVALength(__VA_ARGS__), __VA_ARGS__) +#else +# define CVERBOSE_IF(writer, condition_, vlevel, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_VERBOSE_LOG + // Occasional logs +#if ELPP_INFO_LOG +# define CINFO_EVERY_N(writer, occasion, dispatchAction, ...)\ + ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Info, dispatchAction, __VA_ARGS__) +#else +# define CINFO_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_INFO_LOG +#if ELPP_WARNING_LOG +# define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...)\ + ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Warning, dispatchAction, __VA_ARGS__) +#else +# define CWARNING_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_WARNING_LOG +#if ELPP_DEBUG_LOG +# define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...)\ + ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Debug, dispatchAction, __VA_ARGS__) +#else +# define CDEBUG_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_DEBUG_LOG +#if ELPP_ERROR_LOG +# define CERROR_EVERY_N(writer, occasion, dispatchAction, ...)\ + ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Error, dispatchAction, __VA_ARGS__) +#else +# define CERROR_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_ERROR_LOG +#if ELPP_FATAL_LOG +# define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...)\ + ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Fatal, dispatchAction, __VA_ARGS__) +#else +# define CFATAL_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_FATAL_LOG +#if ELPP_TRACE_LOG +# define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...)\ + ELPP_WRITE_LOG_EVERY_N(writer, occasion, el::Level::Trace, dispatchAction, __VA_ARGS__) +#else +# define CTRACE_EVERY_N(writer, occasion, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_TRACE_LOG +#if ELPP_VERBOSE_LOG +# define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...)\ + CVERBOSE_IF(writer, ELPP->validateEveryNCounter(__FILE__, __LINE__, occasion), vlevel, dispatchAction, __VA_ARGS__) +#else +# define CVERBOSE_EVERY_N(writer, occasion, vlevel, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_VERBOSE_LOG + // After N logs +#if ELPP_INFO_LOG +# define CINFO_AFTER_N(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__) +#else +# define CINFO_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_INFO_LOG +#if ELPP_WARNING_LOG +# define CWARNING_AFTER_N(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__) +#else +# define CWARNING_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_WARNING_LOG +#if ELPP_DEBUG_LOG +# define CDEBUG_AFTER_N(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__) +#else +# define CDEBUG_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_DEBUG_LOG +#if ELPP_ERROR_LOG +# define CERROR_AFTER_N(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__) +#else +# define CERROR_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_ERROR_LOG +#if ELPP_FATAL_LOG +# define CFATAL_AFTER_N(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__) +#else +# define CFATAL_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_FATAL_LOG +#if ELPP_TRACE_LOG +# define CTRACE_AFTER_N(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_AFTER_N(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__) +#else +# define CTRACE_AFTER_N(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_TRACE_LOG +#if ELPP_VERBOSE_LOG +# define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...)\ + CVERBOSE_IF(writer, ELPP->validateAfterNCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__) +#else +# define CVERBOSE_AFTER_N(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_VERBOSE_LOG + // N Times logs +#if ELPP_INFO_LOG +# define CINFO_N_TIMES(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Info, dispatchAction, __VA_ARGS__) +#else +# define CINFO_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_INFO_LOG +#if ELPP_WARNING_LOG +# define CWARNING_N_TIMES(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Warning, dispatchAction, __VA_ARGS__) +#else +# define CWARNING_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_WARNING_LOG +#if ELPP_DEBUG_LOG +# define CDEBUG_N_TIMES(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Debug, dispatchAction, __VA_ARGS__) +#else +# define CDEBUG_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_DEBUG_LOG +#if ELPP_ERROR_LOG +# define CERROR_N_TIMES(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Error, dispatchAction, __VA_ARGS__) +#else +# define CERROR_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_ERROR_LOG +#if ELPP_FATAL_LOG +# define CFATAL_N_TIMES(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Fatal, dispatchAction, __VA_ARGS__) +#else +# define CFATAL_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_FATAL_LOG +#if ELPP_TRACE_LOG +# define CTRACE_N_TIMES(writer, n, dispatchAction, ...)\ + ELPP_WRITE_LOG_N_TIMES(writer, n, el::Level::Trace, dispatchAction, __VA_ARGS__) +#else +# define CTRACE_N_TIMES(writer, n, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_TRACE_LOG +#if ELPP_VERBOSE_LOG +# define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...)\ + CVERBOSE_IF(writer, ELPP->validateNTimesCounter(__FILE__, __LINE__, n), vlevel, dispatchAction, __VA_ARGS__) +#else +# define CVERBOSE_N_TIMES(writer, n, vlevel, dispatchAction, ...) el::base::NullWriter() +#endif // ELPP_VERBOSE_LOG + // + // Custom Loggers - Requires (level, dispatchAction, loggerId/s) + // + // undef existing +#undef CLOG +#undef CLOG_VERBOSE +#undef CVLOG +#undef CLOG_IF +#undef CLOG_VERBOSE_IF +#undef CVLOG_IF +#undef CLOG_EVERY_N +#undef CVLOG_EVERY_N +#undef CLOG_AFTER_N +#undef CVLOG_AFTER_N +#undef CLOG_N_TIMES +#undef CVLOG_N_TIMES + // Normal logs +#define CLOG(LEVEL, ...)\ + C##LEVEL(el::base::Writer, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define CVLOG(vlevel, ...) CVERBOSE(el::base::Writer, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) + // Conditional logs +#define CLOG_IF(condition, LEVEL, ...)\ + C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define CVLOG_IF(condition, vlevel, ...)\ + CVERBOSE_IF(el::base::Writer, condition, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) + // Hit counts based logs +#define CLOG_EVERY_N(n, LEVEL, ...)\ + C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define CVLOG_EVERY_N(n, vlevel, ...)\ + CVERBOSE_EVERY_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define CLOG_AFTER_N(n, LEVEL, ...)\ + C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define CVLOG_AFTER_N(n, vlevel, ...)\ + CVERBOSE_AFTER_N(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define CLOG_N_TIMES(n, LEVEL, ...)\ + C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define CVLOG_N_TIMES(n, vlevel, ...)\ + CVERBOSE_N_TIMES(el::base::Writer, n, vlevel, el::base::DispatchAction::NormalLog, __VA_ARGS__) + // + // Default Loggers macro using CLOG(), CLOG_VERBOSE() and CVLOG() macros + // + // undef existing +#undef LOG +#undef VLOG +#undef LOG_IF +#undef VLOG_IF +#undef LOG_EVERY_N +#undef VLOG_EVERY_N +#undef LOG_AFTER_N +#undef VLOG_AFTER_N +#undef LOG_N_TIMES +#undef VLOG_N_TIMES +#undef ELPP_CURR_FILE_LOGGER_ID +#if defined(ELPP_DEFAULT_LOGGER) +# define ELPP_CURR_FILE_LOGGER_ID ELPP_DEFAULT_LOGGER +#else +# define ELPP_CURR_FILE_LOGGER_ID el::base::consts::kDefaultLoggerId +#endif +#undef ELPP_TRACE +#define ELPP_TRACE CLOG(TRACE, ELPP_CURR_FILE_LOGGER_ID) + // Normal logs +#define LOG(LEVEL) CLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define VLOG(vlevel) CVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID) + // Conditional logs +#define LOG_IF(condition, LEVEL) CLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define VLOG_IF(condition, vlevel) CVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID) + // Hit counts based logs +#define LOG_EVERY_N(n, LEVEL) CLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define VLOG_EVERY_N(n, vlevel) CVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) +#define LOG_AFTER_N(n, LEVEL) CLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define VLOG_AFTER_N(n, vlevel) CVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) +#define LOG_N_TIMES(n, LEVEL) CLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define VLOG_N_TIMES(n, vlevel) CVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) + // Generic PLOG() +#undef CPLOG +#undef CPLOG_IF +#undef PLOG +#undef PLOG_IF +#undef DCPLOG +#undef DCPLOG_IF +#undef DPLOG +#undef DPLOG_IF +#define CPLOG(LEVEL, ...)\ + C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define CPLOG_IF(condition, LEVEL, ...)\ + C##LEVEL##_IF(el::base::PErrorWriter, condition, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define DCPLOG(LEVEL, ...)\ + if (ELPP_DEBUG_LOG) C##LEVEL(el::base::PErrorWriter, el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define DCPLOG_IF(condition, LEVEL, ...)\ + C##LEVEL##_IF(el::base::PErrorWriter, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::NormalLog, __VA_ARGS__) +#define PLOG(LEVEL) CPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define PLOG_IF(condition, LEVEL) CPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define DPLOG(LEVEL) DCPLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define DPLOG_IF(condition, LEVEL) DCPLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) + // Generic SYSLOG() +#undef CSYSLOG +#undef CSYSLOG_IF +#undef CSYSLOG_EVERY_N +#undef CSYSLOG_AFTER_N +#undef CSYSLOG_N_TIMES +#undef SYSLOG +#undef SYSLOG_IF +#undef SYSLOG_EVERY_N +#undef SYSLOG_AFTER_N +#undef SYSLOG_N_TIMES +#undef DCSYSLOG +#undef DCSYSLOG_IF +#undef DCSYSLOG_EVERY_N +#undef DCSYSLOG_AFTER_N +#undef DCSYSLOG_N_TIMES +#undef DSYSLOG +#undef DSYSLOG_IF +#undef DSYSLOG_EVERY_N +#undef DSYSLOG_AFTER_N +#undef DSYSLOG_N_TIMES +#if defined(ELPP_SYSLOG) +# define CSYSLOG(LEVEL, ...)\ + C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define CSYSLOG_IF(condition, LEVEL, ...)\ + C##LEVEL##_IF(el::base::Writer, condition, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define CSYSLOG_EVERY_N(n, LEVEL, ...) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define CSYSLOG_AFTER_N(n, LEVEL, ...) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define CSYSLOG_N_TIMES(n, LEVEL, ...) C##LEVEL##_N_TIMES(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define SYSLOG(LEVEL) CSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId) +# define SYSLOG_IF(condition, LEVEL) CSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId) +# define SYSLOG_EVERY_N(n, LEVEL) CSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId) +# define SYSLOG_AFTER_N(n, LEVEL) CSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId) +# define SYSLOG_N_TIMES(n, LEVEL) CSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId) +# define DCSYSLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) C##LEVEL(el::base::Writer, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define DCSYSLOG_IF(condition, LEVEL, ...)\ + C##LEVEL##_IF(el::base::Writer, (ELPP_DEBUG_LOG) && (condition), el::base::DispatchAction::SysLog, __VA_ARGS__) +# define DCSYSLOG_EVERY_N(n, LEVEL, ...)\ + if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define DCSYSLOG_AFTER_N(n, LEVEL, ...)\ + if (ELPP_DEBUG_LOG) C##LEVEL##_AFTER_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define DCSYSLOG_N_TIMES(n, LEVEL, ...)\ + if (ELPP_DEBUG_LOG) C##LEVEL##_EVERY_N(el::base::Writer, n, el::base::DispatchAction::SysLog, __VA_ARGS__) +# define DSYSLOG(LEVEL) DCSYSLOG(LEVEL, el::base::consts::kSysLogLoggerId) +# define DSYSLOG_IF(condition, LEVEL) DCSYSLOG_IF(condition, LEVEL, el::base::consts::kSysLogLoggerId) +# define DSYSLOG_EVERY_N(n, LEVEL) DCSYSLOG_EVERY_N(n, LEVEL, el::base::consts::kSysLogLoggerId) +# define DSYSLOG_AFTER_N(n, LEVEL) DCSYSLOG_AFTER_N(n, LEVEL, el::base::consts::kSysLogLoggerId) +# define DSYSLOG_N_TIMES(n, LEVEL) DCSYSLOG_N_TIMES(n, LEVEL, el::base::consts::kSysLogLoggerId) +#else +# define CSYSLOG(LEVEL, ...) el::base::NullWriter() +# define CSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter() +# define CSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter() +# define CSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter() +# define CSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter() +# define SYSLOG(LEVEL) el::base::NullWriter() +# define SYSLOG_IF(condition, LEVEL) el::base::NullWriter() +# define SYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter() +# define SYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter() +# define SYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter() +# define DCSYSLOG(LEVEL, ...) el::base::NullWriter() +# define DCSYSLOG_IF(condition, LEVEL, ...) el::base::NullWriter() +# define DCSYSLOG_EVERY_N(n, LEVEL, ...) el::base::NullWriter() +# define DCSYSLOG_AFTER_N(n, LEVEL, ...) el::base::NullWriter() +# define DCSYSLOG_N_TIMES(n, LEVEL, ...) el::base::NullWriter() +# define DSYSLOG(LEVEL) el::base::NullWriter() +# define DSYSLOG_IF(condition, LEVEL) el::base::NullWriter() +# define DSYSLOG_EVERY_N(n, LEVEL) el::base::NullWriter() +# define DSYSLOG_AFTER_N(n, LEVEL) el::base::NullWriter() +# define DSYSLOG_N_TIMES(n, LEVEL) el::base::NullWriter() +#endif // defined(ELPP_SYSLOG) + // + // Custom Debug Only Loggers - Requires (level, loggerId/s) + // + // undef existing +#undef DCLOG +#undef DCVLOG +#undef DCLOG_IF +#undef DCVLOG_IF +#undef DCLOG_EVERY_N +#undef DCVLOG_EVERY_N +#undef DCLOG_AFTER_N +#undef DCVLOG_AFTER_N +#undef DCLOG_N_TIMES +#undef DCVLOG_N_TIMES + // Normal logs +#define DCLOG(LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG(LEVEL, __VA_ARGS__) +#define DCLOG_VERBOSE(vlevel, ...) if (ELPP_DEBUG_LOG) CLOG_VERBOSE(vlevel, __VA_ARGS__) +#define DCVLOG(vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG(vlevel, __VA_ARGS__) + // Conditional logs +#define DCLOG_IF(condition, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_IF(condition, LEVEL, __VA_ARGS__) +#define DCVLOG_IF(condition, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_IF(condition, vlevel, __VA_ARGS__) + // Hit counts based logs +#define DCLOG_EVERY_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_EVERY_N(n, LEVEL, __VA_ARGS__) +#define DCVLOG_EVERY_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_EVERY_N(n, vlevel, __VA_ARGS__) +#define DCLOG_AFTER_N(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_AFTER_N(n, LEVEL, __VA_ARGS__) +#define DCVLOG_AFTER_N(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_AFTER_N(n, vlevel, __VA_ARGS__) +#define DCLOG_N_TIMES(n, LEVEL, ...) if (ELPP_DEBUG_LOG) CLOG_N_TIMES(n, LEVEL, __VA_ARGS__) +#define DCVLOG_N_TIMES(n, vlevel, ...) if (ELPP_DEBUG_LOG) CVLOG_N_TIMES(n, vlevel, __VA_ARGS__) + // + // Default Debug Only Loggers macro using CLOG(), CLOG_VERBOSE() and CVLOG() macros + // + // undef existing +#undef DLOG +#undef DVLOG +#undef DLOG_IF +#undef DVLOG_IF +#undef DLOG_EVERY_N +#undef DVLOG_EVERY_N +#undef DLOG_AFTER_N +#undef DVLOG_AFTER_N +#undef DLOG_N_TIMES +#undef DVLOG_N_TIMES + // Normal logs +#define DLOG(LEVEL) DCLOG(LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define DVLOG(vlevel) DCVLOG(vlevel, ELPP_CURR_FILE_LOGGER_ID) + // Conditional logs +#define DLOG_IF(condition, LEVEL) DCLOG_IF(condition, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define DVLOG_IF(condition, vlevel) DCVLOG_IF(condition, vlevel, ELPP_CURR_FILE_LOGGER_ID) + // Hit counts based logs +#define DLOG_EVERY_N(n, LEVEL) DCLOG_EVERY_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define DVLOG_EVERY_N(n, vlevel) DCVLOG_EVERY_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) +#define DLOG_AFTER_N(n, LEVEL) DCLOG_AFTER_N(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define DVLOG_AFTER_N(n, vlevel) DCVLOG_AFTER_N(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) +#define DLOG_N_TIMES(n, LEVEL) DCLOG_N_TIMES(n, LEVEL, ELPP_CURR_FILE_LOGGER_ID) +#define DVLOG_N_TIMES(n, vlevel) DCVLOG_N_TIMES(n, vlevel, ELPP_CURR_FILE_LOGGER_ID) + // Check macros +#undef CCHECK +#undef CPCHECK +#undef CCHECK_EQ +#undef CCHECK_NE +#undef CCHECK_LT +#undef CCHECK_GT +#undef CCHECK_LE +#undef CCHECK_GE +#undef CCHECK_BOUNDS +#undef CCHECK_NOTNULL +#undef CCHECK_STRCASEEQ +#undef CCHECK_STRCASENE +#undef CHECK +#undef PCHECK +#undef CHECK_EQ +#undef CHECK_NE +#undef CHECK_LT +#undef CHECK_GT +#undef CHECK_LE +#undef CHECK_GE +#undef CHECK_BOUNDS +#undef CHECK_NOTNULL +#undef CHECK_STRCASEEQ +#undef CHECK_STRCASENE +#define CCHECK(condition, ...) CLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] " +#define CPCHECK(condition, ...) CPLOG_IF(!(condition), FATAL, __VA_ARGS__) << "Check failed: [" << #condition << "] " +#define CHECK(condition) CCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) +#define PCHECK(condition) CPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) +#define CCHECK_EQ(a, b, ...) CCHECK(a == b, __VA_ARGS__) +#define CCHECK_NE(a, b, ...) CCHECK(a != b, __VA_ARGS__) +#define CCHECK_LT(a, b, ...) CCHECK(a < b, __VA_ARGS__) +#define CCHECK_GT(a, b, ...) CCHECK(a > b, __VA_ARGS__) +#define CCHECK_LE(a, b, ...) CCHECK(a <= b, __VA_ARGS__) +#define CCHECK_GE(a, b, ...) CCHECK(a >= b, __VA_ARGS__) +#define CCHECK_BOUNDS(val, min, max, ...) CCHECK(val >= min && val <= max, __VA_ARGS__) +#define CHECK_EQ(a, b) CCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_NE(a, b) CCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_LT(a, b) CCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_GT(a, b) CCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_LE(a, b) CCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_GE(a, b) CCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_BOUNDS(val, min, max) CCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID) +namespace el { + namespace base { + namespace utils { + template + static T* checkNotNull(T* ptr, const char* name, const char* loggers, ...) { + CLOG_IF(ptr == nullptr, FATAL, loggers) << "Check failed: [" << name << " != nullptr]"; + return ptr; + } + } // namespace utils + } // namespace base +} // namespace el +#define CCHECK_NOTNULL(ptr, ...) el::base::utils::checkNotNull(ptr, #ptr, __VA_ARGS__) +#define CCHECK_STREQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \ + << "Check failed: [" << #str1 << " == " << #str2 << "] " +#define CCHECK_STRNE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringEq(str1, str2), FATAL, __VA_ARGS__) \ + << "Check failed: [" << #str1 << " != " << #str2 << "] " +#define CCHECK_STRCASEEQ(str1, str2, ...) CLOG_IF(!el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \ + << "Check failed: [" << #str1 << " == " << #str2 << "] " +#define CCHECK_STRCASENE(str1, str2, ...) CLOG_IF(el::base::utils::Str::cStringCaseEq(str1, str2), FATAL, __VA_ARGS__) \ + << "Check failed: [" << #str1 << " != " << #str2 << "] " +#define CHECK_NOTNULL(ptr) CCHECK_NOTNULL(ptr, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_STREQ(str1, str2) CCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_STRNE(str1, str2) CCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_STRCASEEQ(str1, str2) CCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) +#define CHECK_STRCASENE(str1, str2) CCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) +#undef DCCHECK +#undef DCCHECK_EQ +#undef DCCHECK_NE +#undef DCCHECK_LT +#undef DCCHECK_GT +#undef DCCHECK_LE +#undef DCCHECK_GE +#undef DCCHECK_BOUNDS +#undef DCCHECK_NOTNULL +#undef DCCHECK_STRCASEEQ +#undef DCCHECK_STRCASENE +#undef DCPCHECK +#undef DCHECK +#undef DCHECK_EQ +#undef DCHECK_NE +#undef DCHECK_LT +#undef DCHECK_GT +#undef DCHECK_LE +#undef DCHECK_GE +#undef DCHECK_BOUNDS_ +#undef DCHECK_NOTNULL +#undef DCHECK_STRCASEEQ +#undef DCHECK_STRCASENE +#undef DPCHECK +#define DCCHECK(condition, ...) if (ELPP_DEBUG_LOG) CCHECK(condition, __VA_ARGS__) +#define DCCHECK_EQ(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_EQ(a, b, __VA_ARGS__) +#define DCCHECK_NE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_NE(a, b, __VA_ARGS__) +#define DCCHECK_LT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LT(a, b, __VA_ARGS__) +#define DCCHECK_GT(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GT(a, b, __VA_ARGS__) +#define DCCHECK_LE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_LE(a, b, __VA_ARGS__) +#define DCCHECK_GE(a, b, ...) if (ELPP_DEBUG_LOG) CCHECK_GE(a, b, __VA_ARGS__) +#define DCCHECK_BOUNDS(val, min, max, ...) if (ELPP_DEBUG_LOG) CCHECK_BOUNDS(val, min, max, __VA_ARGS__) +#define DCCHECK_NOTNULL(ptr, ...) if (ELPP_DEBUG_LOG) CCHECK_NOTNULL(ptr, __VA_ARGS__) +#define DCCHECK_STREQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STREQ(str1, str2, __VA_ARGS__) +#define DCCHECK_STRNE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRNE(str1, str2, __VA_ARGS__) +#define DCCHECK_STRCASEEQ(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASEEQ(str1, str2, __VA_ARGS__) +#define DCCHECK_STRCASENE(str1, str2, ...) if (ELPP_DEBUG_LOG) CCHECK_STRCASENE(str1, str2, __VA_ARGS__) +#define DCPCHECK(condition, ...) if (ELPP_DEBUG_LOG) CPCHECK(condition, __VA_ARGS__) +#define DCHECK(condition) DCCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_EQ(a, b) DCCHECK_EQ(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_NE(a, b) DCCHECK_NE(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_LT(a, b) DCCHECK_LT(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_GT(a, b) DCCHECK_GT(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_LE(a, b) DCCHECK_LE(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_GE(a, b) DCCHECK_GE(a, b, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_BOUNDS(val, min, max) DCCHECK_BOUNDS(val, min, max, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_NOTNULL(ptr) DCCHECK_NOTNULL(ptr, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_STREQ(str1, str2) DCCHECK_STREQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_STRNE(str1, str2) DCCHECK_STRNE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_STRCASEEQ(str1, str2) DCCHECK_STRCASEEQ(str1, str2, ELPP_CURR_FILE_LOGGER_ID) +#define DCHECK_STRCASENE(str1, str2) DCCHECK_STRCASENE(str1, str2, ELPP_CURR_FILE_LOGGER_ID) +#define DPCHECK(condition) DCPCHECK(condition, ELPP_CURR_FILE_LOGGER_ID) +#if defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING) +# define ELPP_USE_DEF_CRASH_HANDLER false +#else +# define ELPP_USE_DEF_CRASH_HANDLER true +#endif // defined(ELPP_DISABLE_DEFAULT_CRASH_HANDLING) +#define ELPP_CRASH_HANDLER_INIT +#define ELPP_INIT_EASYLOGGINGPP(val)\ + ELPP_INITI_BASIC_DECLR\ + namespace el {\ + namespace base {\ + el::base::type::StoragePointer elStorage(val);\ + }\ + el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\ + } + +#if ELPP_ASYNC_LOGGING +# define INITIALIZE_EASYLOGGINGPP\ + ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()),\ + new el::base::AsyncDispatchWorker()))\ + +#else +# define INITIALIZE_EASYLOGGINGPP\ + ELPP_INIT_EASYLOGGINGPP(new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()))) +#endif // ELPP_ASYNC_LOGGING +#define INITIALIZE_NULL_EASYLOGGINGPP\ + ELPP_INITI_BASIC_DECLR\ + namespace el {\ + namespace base {\ + el::base::type::StoragePointer elStorage;\ + }\ + el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\ + } + // NOTE: no ELPP_INITI_BASIC_DECLR when sharing - causes double free corruption on external symbols +#define SHARE_EASYLOGGINGPP(initializedStorage)\ + namespace el {\ + namespace base {\ + el::base::type::StoragePointer elStorage(initializedStorage);\ + }\ + el::base::debug::CrashHandler elCrashHandler(ELPP_USE_DEF_CRASH_HANDLER);\ + } + +#if defined(ELPP_UNICODE) +# define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv); std::locale::global(std::locale("")) +#else +# define START_EASYLOGGINGPP(argc, argv) el::Helpers::setArgs(argc, argv) +#endif // defined(ELPP_UNICODE) +#endif // EASYLOGGINGPP_H \ No newline at end of file diff --git a/extensions/common/glm/CMakeLists.txt b/extensions/common/glm/CMakeLists.txt new file mode 100644 index 0000000000..fe28b5d975 --- /dev/null +++ b/extensions/common/glm/CMakeLists.txt @@ -0,0 +1,43 @@ +set(NAME glm_dummy) + +file(GLOB ROOT_SOURCE *.cpp) +file(GLOB ROOT_INLINE *.inl) +file(GLOB ROOT_HEADER *.hpp) +file(GLOB ROOT_TEXT ../*.txt) +file(GLOB ROOT_NAT ../util/glm.natvis) + +file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp) +file(GLOB_RECURSE CORE_INLINE ./detail/*.inl) +file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp) + +file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp) +file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl) +file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp) + +file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) +file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) +file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) + +source_group("Text Files" FILES ${ROOT_TEXT}) +source_group("Core Files" FILES ${CORE_SOURCE}) +source_group("Core Files" FILES ${CORE_INLINE}) +source_group("Core Files" FILES ${CORE_HEADER}) +source_group("GTC Files" FILES ${GTC_SOURCE}) +source_group("GTC Files" FILES ${GTC_INLINE}) +source_group("GTC Files" FILES ${GTC_HEADER}) +source_group("GTX Files" FILES ${GTX_SOURCE}) +source_group("GTX Files" FILES ${GTX_INLINE}) +source_group("GTX Files" FILES ${GTX_HEADER}) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + +if(GLM_TEST_ENABLE) + add_executable(${NAME} ${ROOT_TEXT} ${ROOT_NAT} + ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} + ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} + ${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER} + ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}) +endif(GLM_TEST_ENABLE) + +#add_library(glm STATIC glm.cpp) +#add_library(glm_shared SHARED glm.cpp) diff --git a/extensions/common/glm/common.hpp b/extensions/common/glm/common.hpp new file mode 100644 index 0000000000..57beb106a9 --- /dev/null +++ b/extensions/common/glm/common.hpp @@ -0,0 +1,35 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/common.hpp +/// @date 2013-12-24 / 2013-12-24 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "detail/func_common.hpp" diff --git a/extensions/common/glm/detail/_features.hpp b/extensions/common/glm/detail/_features.hpp new file mode 100644 index 0000000000..ce2a35d9c1 --- /dev/null +++ b/extensions/common/glm/detail/_features.hpp @@ -0,0 +1,428 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/_features.hpp +/// @date 2013-02-20 / 2013-02-20 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +// #define GLM_CXX98_EXCEPTIONS +// #define GLM_CXX98_RTTI + +// #define GLM_CXX11_RVALUE_REFERENCES +// Rvalue references - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html + +// GLM_CXX11_TRAILING_RETURN +// Rvalue references for *this - GCC not supported +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm + +// GLM_CXX11_NONSTATIC_MEMBER_INIT +// Initialization of class objects by rvalues - GCC any +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1610.html + +// GLM_CXX11_NONSTATIC_MEMBER_INIT +// Non-static data member initializers - GCC 4.7 +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2756.htm + +// #define GLM_CXX11_VARIADIC_TEMPLATE +// Variadic templates - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf + +// +// Extending variadic template template parameters - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf + +// #define GLM_CXX11_GENERALIZED_INITIALIZERS +// Initializer lists - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm + +// #define GLM_CXX11_STATIC_ASSERT +// Static assertions - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html + +// #define GLM_CXX11_AUTO_TYPE +// auto-typed variables - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf + +// #define GLM_CXX11_AUTO_TYPE +// Multi-declarator auto - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1737.pdf + +// #define GLM_CXX11_AUTO_TYPE +// Removal of auto as a storage-class specifier - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2546.htm + +// #define GLM_CXX11_AUTO_TYPE +// New function declarator syntax - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm + +// #define GLM_CXX11_LAMBDAS +// New wording for C++0x lambdas - GCC 4.5 +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2927.pdf + +// #define GLM_CXX11_DECLTYPE +// Declared type of an expression - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf + +// +// Right angle brackets - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html + +// +// Default template arguments for function templates DR226 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226 + +// +// Solving the SFINAE problem for expressions DR339 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2634.html + +// #define GLM_CXX11_ALIAS_TEMPLATE +// Template aliases N2258 GCC 4.7 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf + +// +// Extern templates N1987 Yes +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm + +// #define GLM_CXX11_NULLPTR +// Null pointer constant N2431 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf + +// #define GLM_CXX11_STRONG_ENUMS +// Strongly-typed enums N2347 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf + +// +// Forward declarations for enums N2764 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf + +// +// Generalized attributes N2761 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf + +// +// Generalized constant expressions N2235 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf + +// +// Alignment support N2341 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf + +// #define GLM_CXX11_DELEGATING_CONSTRUCTORS +// Delegating constructors N1986 GCC 4.7 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf + +// +// Inheriting constructors N2540 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm + +// #define GLM_CXX11_EXPLICIT_CONVERSIONS +// Explicit conversion operators N2437 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf + +// +// New character types N2249 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2249.html + +// +// Unicode string literals N2442 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm + +// +// Raw string literals N2442 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm + +// +// Universal character name literals N2170 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2170.html + +// #define GLM_CXX11_USER_LITERALS +// User-defined literals N2765 GCC 4.7 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf + +// +// Standard Layout Types N2342 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm + +// #define GLM_CXX11_DEFAULTED_FUNCTIONS +// #define GLM_CXX11_DELETED_FUNCTIONS +// Defaulted and deleted functions N2346 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm + +// +// Extended friend declarations N1791 GCC 4.7 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf + +// +// Extending sizeof N2253 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html + +// #define GLM_CXX11_INLINE_NAMESPACES +// Inline namespaces N2535 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm + +// #define GLM_CXX11_UNRESTRICTED_UNIONS +// Unrestricted unions N2544 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf + +// #define GLM_CXX11_LOCAL_TYPE_TEMPLATE_ARGS +// Local and unnamed types as template arguments N2657 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm + +// #define GLM_CXX11_RANGE_FOR +// Range-based for N2930 GCC 4.6 +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2930.html + +// #define GLM_CXX11_OVERRIDE_CONTROL +// Explicit virtual overrides N2928 N3206 N3272 GCC 4.7 +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm + +// +// Minimal support for garbage collection and reachability-based leak detection N2670 No +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm + +// #define GLM_CXX11_NOEXCEPT +// Allowing move constructors to throw [noexcept] N3050 GCC 4.6 (core language only) +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html + +// +// Defining move special member functions N3053 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html + +// +// Sequence points N2239 Yes +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html + +// +// Atomic operations N2427 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html + +// +// Strong Compare and Exchange N2748 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html + +// +// Bidirectional Fences N2752 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2752.htm + +// +// Memory model N2429 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm + +// +// Data-dependency ordering: atomics and memory model N2664 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2664.htm + +// +// Propagating exceptions N2179 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html + +// +// Abandoning a process and at_quick_exit N2440 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2440.htm + +// +// Allow atomics use in signal handlers N2547 Yes +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2547.htm + +// +// Thread-local storage N2659 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm + +// +// Dynamic initialization and destruction with concurrency N2660 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm + +// +// __func__ predefined identifier N2340 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm + +// +// C99 preprocessor N1653 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm + +// +// long long N1811 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf + +// +// Extended integral types N1988 Yes +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1988.pdf + +#if(GLM_COMPILER & GLM_COMPILER_GCC) + +# if(GLM_COMPILER >= GLM_COMPILER_GCC43) +# define GLM_CXX11_STATIC_ASSERT +# endif + +#elif(GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM)) +# if(__has_feature(cxx_exceptions)) +# define GLM_CXX98_EXCEPTIONS +# endif + +# if(__has_feature(cxx_rtti)) +# define GLM_CXX98_RTTI +# endif + +# if(__has_feature(cxx_access_control_sfinae)) +# define GLM_CXX11_ACCESS_CONTROL_SFINAE +# endif + +# if(__has_feature(cxx_alias_templates)) +# define GLM_CXX11_ALIAS_TEMPLATE +# endif + +# if(__has_feature(cxx_alignas)) +# define GLM_CXX11_ALIGNAS +# endif + +# if(__has_feature(cxx_attributes)) +# define GLM_CXX11_ATTRIBUTES +# endif + +# if(__has_feature(cxx_constexpr)) +# define GLM_CXX11_CONSTEXPR +# endif + +# if(__has_feature(cxx_decltype)) +# define GLM_CXX11_DECLTYPE +# endif + +# if(__has_feature(cxx_default_function_template_args)) +# define GLM_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS +# endif + +# if(__has_feature(cxx_defaulted_functions)) +# define GLM_CXX11_DEFAULTED_FUNCTIONS +# endif + +# if(__has_feature(cxx_delegating_constructors)) +# define GLM_CXX11_DELEGATING_CONSTRUCTORS +# endif + +# if(__has_feature(cxx_deleted_functions)) +# define GLM_CXX11_DELETED_FUNCTIONS +# endif + +# if(__has_feature(cxx_explicit_conversions)) +# define GLM_CXX11_EXPLICIT_CONVERSIONS +# endif + +# if(__has_feature(cxx_generalized_initializers)) +# define GLM_CXX11_GENERALIZED_INITIALIZERS +# endif + +# if(__has_feature(cxx_implicit_moves)) +# define GLM_CXX11_IMPLICIT_MOVES +# endif + +# if(__has_feature(cxx_inheriting_constructors)) +# define GLM_CXX11_INHERITING_CONSTRUCTORS +# endif + +# if(__has_feature(cxx_inline_namespaces)) +# define GLM_CXX11_INLINE_NAMESPACES +# endif + +# if(__has_feature(cxx_lambdas)) +# define GLM_CXX11_LAMBDAS +# endif + +# if(__has_feature(cxx_local_type_template_args)) +# define GLM_CXX11_LOCAL_TYPE_TEMPLATE_ARGS +# endif + +# if(__has_feature(cxx_noexcept)) +# define GLM_CXX11_NOEXCEPT +# endif + +# if(__has_feature(cxx_nonstatic_member_init)) +# define GLM_CXX11_NONSTATIC_MEMBER_INIT +# endif + +# if(__has_feature(cxx_nullptr)) +# define GLM_CXX11_NULLPTR +# endif + +# if(__has_feature(cxx_override_control)) +# define GLM_CXX11_OVERRIDE_CONTROL +# endif + +# if(__has_feature(cxx_reference_qualified_functions)) +# define GLM_CXX11_REFERENCE_QUALIFIED_FUNCTIONS +# endif + +# if(__has_feature(cxx_range_for)) +# define GLM_CXX11_RANGE_FOR +# endif + +# if(__has_feature(cxx_raw_string_literals)) +# define GLM_CXX11_RAW_STRING_LITERALS +# endif + +# if(__has_feature(cxx_rvalue_references)) +# define GLM_CXX11_RVALUE_REFERENCES +# endif + +# if(__has_feature(cxx_static_assert)) +# define GLM_CXX11_STATIC_ASSERT +# endif + +# if(__has_feature(cxx_auto_type)) +# define GLM_CXX11_AUTO_TYPE +# endif + +# if(__has_feature(cxx_strong_enums)) +# define GLM_CXX11_STRONG_ENUMS +# endif + +# if(__has_feature(cxx_trailing_return)) +# define GLM_CXX11_TRAILING_RETURN +# endif + +# if(__has_feature(cxx_unicode_literals)) +# define GLM_CXX11_UNICODE_LITERALS +# endif + +# if(__has_feature(cxx_unrestricted_unions)) +# define GLM_CXX11_UNRESTRICTED_UNIONS +# endif + +# if(__has_feature(cxx_user_literals)) +# define GLM_CXX11_USER_LITERALS +# endif + +# if(__has_feature(cxx_variadic_templates)) +# define GLM_CXX11_VARIADIC_TEMPLATES +# endif + +#endif//(GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM)) diff --git a/extensions/common/glm/detail/_fixes.hpp b/extensions/common/glm/detail/_fixes.hpp new file mode 100644 index 0000000000..9728cafb73 --- /dev/null +++ b/extensions/common/glm/detail/_fixes.hpp @@ -0,0 +1,59 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/_fixes.hpp +/// @date 2011-02-21 / 2011-11-22 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#include + +//! Workaround for compatibility with other libraries +#ifdef max +#undef max +#endif + +//! Workaround for compatibility with other libraries +#ifdef min +#undef min +#endif + +//! Workaround for Android +#ifdef isnan +#undef isnan +#endif + +//! Workaround for Android +#ifdef isinf +#undef isinf +#endif + +//! Workaround for Chrone Native Client +#ifdef log2 +#undef log2 +#endif + diff --git a/extensions/common/glm/detail/_noise.hpp b/extensions/common/glm/detail/_noise.hpp new file mode 100644 index 0000000000..296709d4b9 --- /dev/null +++ b/extensions/common/glm/detail/_noise.hpp @@ -0,0 +1,136 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/_noise.hpp +/// @date 2013-12-24 / 2013-12-24 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "../vec2.hpp" +#include "../vec3.hpp" +#include "../vec4.hpp" +#include "../common.hpp" + +namespace glm{ +namespace detail +{ + template + GLM_FUNC_QUALIFIER T mod289(T const & x) + { + return x - floor(x * static_cast(1.0) / static_cast(289.0)) * static_cast(289.0); + } + + template + GLM_FUNC_QUALIFIER T permute(T const & x) + { + return mod289(((x * static_cast(34)) + static_cast(1)) * x); + } + + template + GLM_FUNC_QUALIFIER tvec2 permute(tvec2 const & x) + { + return mod289(((x * static_cast(34)) + static_cast(1)) * x); + } + + template + GLM_FUNC_QUALIFIER tvec3 permute(tvec3 const & x) + { + return mod289(((x * static_cast(34)) + static_cast(1)) * x); + } + + template + GLM_FUNC_QUALIFIER tvec4 permute(tvec4 const & x) + { + return mod289(((x * static_cast(34)) + static_cast(1)) * x); + } +/* + template class vecType> + GLM_FUNC_QUALIFIER vecType permute(vecType const & x) + { + return mod289(((x * T(34)) + T(1)) * x); + } +*/ + template + GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + + template + GLM_FUNC_QUALIFIER tvec2 taylorInvSqrt(tvec2 const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + + template + GLM_FUNC_QUALIFIER tvec3 taylorInvSqrt(tvec3 const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + + template + GLM_FUNC_QUALIFIER tvec4 taylorInvSqrt(tvec4 const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } +/* + template class vecType> + GLM_FUNC_QUALIFIER vecType taylorInvSqrt(vecType const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } +*/ + + template + GLM_FUNC_QUALIFIER tvec2 fade(tvec2 const & t) + { + return (t * t * t) * (t * (t * T(6) - T(15)) + T(10)); + } + + template + GLM_FUNC_QUALIFIER tvec3 fade(tvec3 const & t) + { + return (t * t * t) * (t * (t * T(6) - T(15)) + T(10)); + } + + template + GLM_FUNC_QUALIFIER tvec4 fade(tvec4 const & t) + { + return (t * t * t) * (t * (t * T(6) - T(15)) + T(10)); + } +/* + template class vecType> + GLM_FUNC_QUALIFIER vecType fade(vecType const & t) + { + return (t * t * t) * (t * (t * T(6) - T(15)) + T(10)); + } +*/ +}//namespace detail +}//namespace glm + diff --git a/extensions/common/glm/detail/_swizzle.hpp b/extensions/common/glm/detail/_swizzle.hpp new file mode 100644 index 0000000000..04ea55bcf2 --- /dev/null +++ b/extensions/common/glm/detail/_swizzle.hpp @@ -0,0 +1,833 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/_swizzle.hpp +/// @date 2006-04-20 / 2011-02-16 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +namespace glm{ +namespace detail +{ + // Internal class for implementing swizzle operators + template + struct _swizzle_base0 + { + typedef T value_type; + + protected: + GLM_FUNC_QUALIFIER value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } + GLM_FUNC_QUALIFIER const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } + + // Use an opaque buffer to *ensure* the compiler doesn't call a constructor. + // The size 1 buffer is assumed to aligned to the actual members so that the + // elem() + char _buffer[1]; + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER V operator ()() const { return V(this->elem(E0), this->elem(E1)); } + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2)); } + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } + }; + + // Internal class for implementing swizzle operators + /* + Template parameters: + + ValueType = type of scalar values (e.g. float, double) + VecType = class the swizzle is applies to (e.g. tvec3) + N = number of components in the vector (e.g. 3) + E0...3 = what index the n-th element of this swizzle refers to in the unswizzled vec + + DUPLICATE_ELEMENTS = 1 if there is a repeated element, 0 otherwise (used to specialize swizzles + containing duplicate elements so that they cannot be used as r-values). + */ + template + struct _swizzle_base2 : public _swizzle_base1 + { + typedef VecType vec_type; + typedef ValueType value_type; + + GLM_FUNC_QUALIFIER _swizzle_base2& operator= (const ValueType& t) + { + for (int i = 0; i < N; ++i) + (*this)[i] = t; + return *this; + } + + GLM_FUNC_QUALIFIER _swizzle_base2& operator= (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e = t; } + }; + _apply_op(that, op()); + return *this; + } + + GLM_FUNC_QUALIFIER void operator -= (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e -= t; } + }; + _apply_op(that, op()); + } + + GLM_FUNC_QUALIFIER void operator += (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e += t; } + }; + _apply_op(that, op()); + } + + GLM_FUNC_QUALIFIER void operator *= (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e *= t; } + }; + _apply_op(that, op()); + } + + GLM_FUNC_QUALIFIER void operator /= (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e /= t; } + }; + _apply_op(that, op()); + } + + GLM_FUNC_QUALIFIER value_type& operator[] (size_t i) + { + const int offset_dst[4] = { E0, E1, E2, E3 }; + return this->elem(offset_dst[i]); + } + GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const + { + const int offset_dst[4] = { E0, E1, E2, E3 }; + return this->elem(offset_dst[i]); + } + + protected: + template + GLM_FUNC_QUALIFIER void _apply_op(const VecType& that, T op) + { + // Make a copy of the data in this == &that. + // The copier should optimize out the copy in cases where the function is + // properly inlined and the copy is not necessary. + ValueType t[N]; + for (int i = 0; i < N; ++i) + t[i] = that[i]; + for (int i = 0; i < N; ++i) + op( (*this)[i], t[i] ); + } + }; + + // Specialization for swizzles containing duplicate elements. These cannot be modified. + template + struct _swizzle_base2 : public _swizzle_base1 + { + typedef VecType vec_type; + typedef ValueType value_type; + + struct Stub {}; + GLM_FUNC_QUALIFIER _swizzle_base2& operator= (Stub const &) { return *this; } + + GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const + { + const int offset_dst[4] = { E0, E1, E2, E3 }; + return this->elem(offset_dst[i]); + } + }; + + template + struct _swizzle : public _swizzle_base2 + { + typedef _swizzle_base2 base_type; + + using base_type::operator=; + + GLM_FUNC_QUALIFIER operator VecType () const { return (*this)(); } + }; + +// +// To prevent the C++ syntax from getting entirely overwhelming, define some alias macros +// +#define _GLM_SWIZZLE_TEMPLATE1 template +#define _GLM_SWIZZLE_TEMPLATE2 template +#define _GLM_SWIZZLE_TYPE1 _swizzle +#define _GLM_SWIZZLE_TYPE2 _swizzle + +// +// Wrapper for a binary operator (e.g. u.yy + v.zy) +// +#define _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND) \ + _GLM_SWIZZLE_TEMPLATE2 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ + { \ + return a() OPERAND b(); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const V& b) \ + { \ + return a() OPERAND b; \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const V& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return a OPERAND b(); \ + } + +// +// Wrapper for a operand between a swizzle and a binary (e.g. 1.0f - u.xyz) +// +#define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND) \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const T& b) \ + { \ + return a() OPERAND b; \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const T& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return a OPERAND b(); \ + } + +// +// Macro for wrapping a function taking one argument (e.g. abs()) +// +#define _GLM_SWIZZLE_FUNCTION_1_ARGS(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a) \ + { \ + return FUNCTION(a()); \ + } + +// +// Macro for wrapping a function taking two vector arguments (e.g. dot()). +// +#define _GLM_SWIZZLE_FUNCTION_2_ARGS(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE2 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ + { \ + return FUNCTION(a(), b()); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return FUNCTION(a(), b()); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename V& b) \ + { \ + return FUNCTION(a(), b); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const V& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return FUNCTION(a, b()); \ + } + +// +// Macro for wrapping a function take 2 vec arguments followed by a scalar (e.g. mix()). +// +#define _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE2 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b, const T& c) \ + { \ + return FUNCTION(a(), b(), c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE1& b, const T& c) \ + { \ + return FUNCTION(a(), b(), c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b, const T& c)\ + { \ + return FUNCTION(a(), b, c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const typename V& a, const _GLM_SWIZZLE_TYPE1& b, const T& c) \ + { \ + return FUNCTION(a, b(), c); \ + } + +}//namespace detail +}//namespace glm + +namespace glm +{ + namespace detail + { + _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(-) + _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(*) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(+) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(-) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(*) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(/) + } + + // + // Swizzles are distinct types from the unswizzled type. The below macros will + // provide template specializations for the swizzle types for the given functions + // so that the compiler does not have any ambiguity to choosing how to handle + // the function. + // + // The alternative is to use the operator()() when calling the function in order + // to explicitly convert the swizzled type to the unswizzled type. + // + + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, abs); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acos); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acosh); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, all); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, any); + + //_GLM_SWIZZLE_FUNCTION_2_ARGS(value_type, dot); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, cross); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, step); + //_GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(vec_type, mix); +} + +#define _GLM_SWIZZLE2_2_MEMBERS(T, P, V, E0,E1) \ + struct { detail::_swizzle<2, T, P, V, 0,0,-1,-2> E0 ## E0; }; \ + struct { detail::_swizzle<2, T, P, V, 0,1,-1,-2> E0 ## E1; }; \ + struct { detail::_swizzle<2, T, P, V, 1,0,-1,-2> E1 ## E0; }; \ + struct { detail::_swizzle<2, T, P, V, 1,1,-1,-2> E1 ## E1; }; + +#define _GLM_SWIZZLE2_3_MEMBERS(T, P, V, E0,E1) \ + struct { detail::_swizzle<3,T, P, V, 0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T, P, V, 0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T, P, V, 0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T, P, V, 0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<3,T, P, V, 1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T, P, V, 1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T, P, V, 1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T, P, V, 1,1,1,-1> E1 ## E1 ## E1; }; + +#define _GLM_SWIZZLE2_4_MEMBERS(T, P, V, E0,E1) \ + struct { detail::_swizzle<4,T, P, V, 0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,1,1> E1 ## E1 ## E1 ## E1; }; + +#define _GLM_SWIZZLE3_2_MEMBERS(T, P, V, E0,E1,E2) \ + struct { detail::_swizzle<2,T, P, V, 0,0,-1,-2> E0 ## E0; }; \ + struct { detail::_swizzle<2,T, P, V, 0,1,-1,-2> E0 ## E1; }; \ + struct { detail::_swizzle<2,T, P, V, 0,2,-1,-2> E0 ## E2; }; \ + struct { detail::_swizzle<2,T, P, V, 1,0,-1,-2> E1 ## E0; }; \ + struct { detail::_swizzle<2,T, P, V, 1,1,-1,-2> E1 ## E1; }; \ + struct { detail::_swizzle<2,T, P, V, 1,2,-1,-2> E1 ## E2; }; \ + struct { detail::_swizzle<2,T, P, V, 2,0,-1,-2> E2 ## E0; }; \ + struct { detail::_swizzle<2,T, P, V, 2,1,-1,-2> E2 ## E1; }; \ + struct { detail::_swizzle<2,T, P, V, 2,2,-1,-2> E2 ## E2; }; + +#define _GLM_SWIZZLE3_3_MEMBERS(T, P, V ,E0,E1,E2) \ + struct { detail::_swizzle<3,T,P, V, 0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 0,0,2,-1> E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 0,1,2,-1> E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 0,2,0,-1> E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 0,2,1,-1> E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 0,2,2,-1> E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 1,0,2,-1> E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 1,1,1,-1> E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 1,1,2,-1> E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 1,2,0,-1> E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 1,2,1,-1> E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 1,2,2,-1> E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 2,0,0,-1> E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 2,0,1,-1> E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 2,0,2,-1> E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 2,1,0,-1> E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 2,1,1,-1> E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 2,1,2,-1> E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 2,2,0,-1> E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 2,2,1,-1> E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 2,2,2,-1> E2 ## E2 ## E2; }; + +#define _GLM_SWIZZLE3_4_MEMBERS(T, P, V, E0,E1,E2) \ + struct { detail::_swizzle<4,T, P, V, 0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,0,2> E0 ## E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,1,2> E0 ## E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,2,0> E0 ## E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,2,1> E0 ## E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,0,2,2> E0 ## E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,0,2> E0 ## E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,1,2> E0 ## E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,2,0> E0 ## E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,2,1> E0 ## E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,1,2,2> E0 ## E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,0,0> E0 ## E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,0,1> E0 ## E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,0,2> E0 ## E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,1,0> E0 ## E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,1,1> E0 ## E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,1,2> E0 ## E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,2,0> E0 ## E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,2,1> E0 ## E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 0,2,2,2> E0 ## E2 ## E2 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,0,2> E1 ## E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,1,2> E1 ## E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,2,0> E1 ## E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,2,1> E1 ## E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,0,2,2> E1 ## E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,0,2> E1 ## E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,1,1> E1 ## E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,1,2> E1 ## E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,2,0> E1 ## E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,2,1> E1 ## E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,1,2,2> E1 ## E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,0,0> E1 ## E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,0,1> E1 ## E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,0,2> E1 ## E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,1,0> E1 ## E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,1,1> E1 ## E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,1,2> E1 ## E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,2,0> E1 ## E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,2,1> E1 ## E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 1,2,2,2> E1 ## E2 ## E2 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,0,0> E2 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,0,1> E2 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,0,2> E2 ## E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,1,0> E2 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,1,1> E2 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,1,2> E2 ## E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,2,0> E2 ## E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,2,1> E2 ## E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,0,2,2> E2 ## E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,0,0> E2 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,0,1> E2 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,0,2> E2 ## E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,1,0> E2 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,1,1> E2 ## E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,1,2> E2 ## E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,2,0> E2 ## E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,2,1> E2 ## E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,1,2,2> E2 ## E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,0,0> E2 ## E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,0,1> E2 ## E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,0,2> E2 ## E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,1,0> E2 ## E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,1,1> E2 ## E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,1,2> E2 ## E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,2,0> E2 ## E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,2,1> E2 ## E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<4,T, P, V, 2,2,2,2> E2 ## E2 ## E2 ## E2; }; + +#define _GLM_SWIZZLE4_2_MEMBERS(T, P, V, E0,E1,E2,E3) \ + struct { detail::_swizzle<2,T, P, V, 0,0,-1,-2> E0 ## E0; }; \ + struct { detail::_swizzle<2,T, P, V, 0,1,-1,-2> E0 ## E1; }; \ + struct { detail::_swizzle<2,T, P, V, 0,2,-1,-2> E0 ## E2; }; \ + struct { detail::_swizzle<2,T, P, V, 0,3,-1,-2> E0 ## E3; }; \ + struct { detail::_swizzle<2,T, P, V, 1,0,-1,-2> E1 ## E0; }; \ + struct { detail::_swizzle<2,T, P, V, 1,1,-1,-2> E1 ## E1; }; \ + struct { detail::_swizzle<2,T, P, V, 1,2,-1,-2> E1 ## E2; }; \ + struct { detail::_swizzle<2,T, P, V, 1,3,-1,-2> E1 ## E3; }; \ + struct { detail::_swizzle<2,T, P, V, 2,0,-1,-2> E2 ## E0; }; \ + struct { detail::_swizzle<2,T, P, V, 2,1,-1,-2> E2 ## E1; }; \ + struct { detail::_swizzle<2,T, P, V, 2,2,-1,-2> E2 ## E2; }; \ + struct { detail::_swizzle<2,T, P, V, 2,3,-1,-2> E2 ## E3; }; \ + struct { detail::_swizzle<2,T, P, V, 3,0,-1,-2> E3 ## E0; }; \ + struct { detail::_swizzle<2,T, P, V, 3,1,-1,-2> E3 ## E1; }; \ + struct { detail::_swizzle<2,T, P, V, 3,2,-1,-2> E3 ## E2; }; \ + struct { detail::_swizzle<2,T, P, V, 3,3,-1,-2> E3 ## E3; }; + +#define _GLM_SWIZZLE4_3_MEMBERS(T,P, V, E0,E1,E2,E3) \ + struct { detail::_swizzle<3,T,P, V, 0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 0,0,2,-1> E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 0,0,3,-1> E0 ## E0 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 0,1,2,-1> E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 0,1,3,-1> E0 ## E1 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 0,2,0,-1> E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 0,2,1,-1> E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 0,2,2,-1> E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 0,2,3,-1> E0 ## E2 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 0,3,0,-1> E0 ## E3 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 0,3,1,-1> E0 ## E3 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 0,3,2,-1> E0 ## E3 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 0,3,3,-1> E0 ## E3 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 1,0,2,-1> E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 1,0,3,-1> E1 ## E0 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 1,1,1,-1> E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 1,1,2,-1> E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 1,1,3,-1> E1 ## E1 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 1,2,0,-1> E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 1,2,1,-1> E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 1,2,2,-1> E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 1,2,3,-1> E1 ## E2 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 1,3,0,-1> E1 ## E3 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 1,3,1,-1> E1 ## E3 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 1,3,2,-1> E1 ## E3 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 1,3,3,-1> E1 ## E3 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 2,0,0,-1> E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 2,0,1,-1> E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 2,0,2,-1> E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 2,0,3,-1> E2 ## E0 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 2,1,0,-1> E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 2,1,1,-1> E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 2,1,2,-1> E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 2,1,3,-1> E2 ## E1 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 2,2,0,-1> E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 2,2,1,-1> E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 2,2,2,-1> E2 ## E2 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 2,2,3,-1> E2 ## E2 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 2,3,0,-1> E2 ## E3 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 2,3,1,-1> E2 ## E3 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 2,3,2,-1> E2 ## E3 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 2,3,3,-1> E2 ## E3 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 3,0,0,-1> E3 ## E0 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 3,0,1,-1> E3 ## E0 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 3,0,2,-1> E3 ## E0 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 3,0,3,-1> E3 ## E0 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 3,1,0,-1> E3 ## E1 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 3,1,1,-1> E3 ## E1 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 3,1,2,-1> E3 ## E1 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 3,1,3,-1> E3 ## E1 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 3,2,0,-1> E3 ## E2 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 3,2,1,-1> E3 ## E2 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 3,2,2,-1> E3 ## E2 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 3,2,3,-1> E3 ## E2 ## E3; }; \ + struct { detail::_swizzle<3,T,P, V, 3,3,0,-1> E3 ## E3 ## E0; }; \ + struct { detail::_swizzle<3,T,P, V, 3,3,1,-1> E3 ## E3 ## E1; }; \ + struct { detail::_swizzle<3,T,P, V, 3,3,2,-1> E3 ## E3 ## E2; }; \ + struct { detail::_swizzle<3,T,P, V, 3,3,3,-1> E3 ## E3 ## E3; }; + +#define _GLM_SWIZZLE4_4_MEMBERS(T, P, V, E0,E1,E2,E3) \ + struct { detail::_swizzle<4, T, P, V, 0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,0,2> E0 ## E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,0,3> E0 ## E0 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,1,2> E0 ## E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,1,3> E0 ## E0 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,2,0> E0 ## E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,2,1> E0 ## E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,2,2> E0 ## E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,2,3> E0 ## E0 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,3,0> E0 ## E0 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,3,1> E0 ## E0 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,3,2> E0 ## E0 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,0,3,3> E0 ## E0 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,0,2> E0 ## E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,0,3> E0 ## E1 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,1,2> E0 ## E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,1,3> E0 ## E1 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,2,0> E0 ## E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,2,1> E0 ## E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,2,2> E0 ## E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,2,3> E0 ## E1 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,3,0> E0 ## E1 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,3,1> E0 ## E1 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,3,2> E0 ## E1 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,1,3,3> E0 ## E1 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,0,0> E0 ## E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,0,1> E0 ## E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,0,2> E0 ## E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,0,3> E0 ## E2 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,1,0> E0 ## E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,1,1> E0 ## E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,1,2> E0 ## E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,1,3> E0 ## E2 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,2,0> E0 ## E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,2,1> E0 ## E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,2,2> E0 ## E2 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,2,3> E0 ## E2 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,3,0> E0 ## E2 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,3,1> E0 ## E2 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,3,2> E0 ## E2 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,2,3,3> E0 ## E2 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,0,0> E0 ## E3 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,0,1> E0 ## E3 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,0,2> E0 ## E3 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,0,3> E0 ## E3 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,1,0> E0 ## E3 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,1,1> E0 ## E3 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,1,2> E0 ## E3 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,1,3> E0 ## E3 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,2,0> E0 ## E3 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,2,1> E0 ## E3 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,2,2> E0 ## E3 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,2,3> E0 ## E3 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,3,0> E0 ## E3 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,3,1> E0 ## E3 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,3,2> E0 ## E3 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 0,3,3,3> E0 ## E3 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,0,2> E1 ## E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,0,3> E1 ## E0 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,1,2> E1 ## E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,1,3> E1 ## E0 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,2,0> E1 ## E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,2,1> E1 ## E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,2,2> E1 ## E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,2,3> E1 ## E0 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,3,0> E1 ## E0 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,3,1> E1 ## E0 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,3,2> E1 ## E0 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,0,3,3> E1 ## E0 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,0,2> E1 ## E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,0,3> E1 ## E1 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,1,1> E1 ## E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,1,2> E1 ## E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,1,3> E1 ## E1 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,2,0> E1 ## E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,2,1> E1 ## E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,2,2> E1 ## E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,2,3> E1 ## E1 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,3,0> E1 ## E1 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,3,1> E1 ## E1 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,3,2> E1 ## E1 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,1,3,3> E1 ## E1 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,0,0> E1 ## E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,0,1> E1 ## E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,0,2> E1 ## E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,0,3> E1 ## E2 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,1,0> E1 ## E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,1,1> E1 ## E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,1,2> E1 ## E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,1,3> E1 ## E2 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,2,0> E1 ## E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,2,1> E1 ## E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,2,2> E1 ## E2 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,2,3> E1 ## E2 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,3,0> E1 ## E2 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,3,1> E1 ## E2 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,3,2> E1 ## E2 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,2,3,3> E1 ## E2 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,0,0> E1 ## E3 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,0,1> E1 ## E3 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,0,2> E1 ## E3 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,0,3> E1 ## E3 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,1,0> E1 ## E3 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,1,1> E1 ## E3 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,1,2> E1 ## E3 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,1,3> E1 ## E3 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,2,0> E1 ## E3 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,2,1> E1 ## E3 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,2,2> E1 ## E3 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,2,3> E1 ## E3 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,3,0> E1 ## E3 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,3,1> E1 ## E3 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,3,2> E1 ## E3 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 1,3,3,3> E1 ## E3 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,0,0> E2 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,0,1> E2 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,0,2> E2 ## E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,0,3> E2 ## E0 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,1,0> E2 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,1,1> E2 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,1,2> E2 ## E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,1,3> E2 ## E0 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,2,0> E2 ## E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,2,1> E2 ## E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,2,2> E2 ## E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,2,3> E2 ## E0 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,3,0> E2 ## E0 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,3,1> E2 ## E0 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,3,2> E2 ## E0 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,0,3,3> E2 ## E0 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,0,0> E2 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,0,1> E2 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,0,2> E2 ## E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,0,3> E2 ## E1 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,1,0> E2 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,1,1> E2 ## E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,1,2> E2 ## E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,1,3> E2 ## E1 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,2,0> E2 ## E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,2,1> E2 ## E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,2,2> E2 ## E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,2,3> E2 ## E1 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,3,0> E2 ## E1 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,3,1> E2 ## E1 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,3,2> E2 ## E1 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,1,3,3> E2 ## E1 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,0,0> E2 ## E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,0,1> E2 ## E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,0,2> E2 ## E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,0,3> E2 ## E2 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,1,0> E2 ## E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,1,1> E2 ## E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,1,2> E2 ## E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,1,3> E2 ## E2 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,2,0> E2 ## E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,2,1> E2 ## E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,2,2> E2 ## E2 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,2,3> E2 ## E2 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,3,0> E2 ## E2 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,3,1> E2 ## E2 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,3,2> E2 ## E2 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,2,3,3> E2 ## E2 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,0,0> E2 ## E3 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,0,1> E2 ## E3 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,0,2> E2 ## E3 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,0,3> E2 ## E3 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,1,0> E2 ## E3 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,1,1> E2 ## E3 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,1,2> E2 ## E3 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,1,3> E2 ## E3 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,2,0> E2 ## E3 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,2,1> E2 ## E3 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,2,2> E2 ## E3 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,2,3> E2 ## E3 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,3,0> E2 ## E3 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,3,1> E2 ## E3 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,3,2> E2 ## E3 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 2,3,3,3> E2 ## E3 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,0,0> E3 ## E0 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,0,1> E3 ## E0 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,0,2> E3 ## E0 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,0,3> E3 ## E0 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,1,0> E3 ## E0 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,1,1> E3 ## E0 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,1,2> E3 ## E0 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,1,3> E3 ## E0 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,2,0> E3 ## E0 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,2,1> E3 ## E0 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,2,2> E3 ## E0 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,2,3> E3 ## E0 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,3,0> E3 ## E0 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,3,1> E3 ## E0 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,3,2> E3 ## E0 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,0,3,3> E3 ## E0 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,0,0> E3 ## E1 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,0,1> E3 ## E1 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,0,2> E3 ## E1 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,0,3> E3 ## E1 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,1,0> E3 ## E1 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,1,1> E3 ## E1 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,1,2> E3 ## E1 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,1,3> E3 ## E1 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,2,0> E3 ## E1 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,2,1> E3 ## E1 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,2,2> E3 ## E1 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,2,3> E3 ## E1 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,3,0> E3 ## E1 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,3,1> E3 ## E1 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,3,2> E3 ## E1 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,1,3,3> E3 ## E1 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,0,0> E3 ## E2 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,0,1> E3 ## E2 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,0,2> E3 ## E2 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,0,3> E3 ## E2 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,1,0> E3 ## E2 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,1,1> E3 ## E2 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,1,2> E3 ## E2 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,1,3> E3 ## E2 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,2,0> E3 ## E2 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,2,1> E3 ## E2 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,2,2> E3 ## E2 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,2,3> E3 ## E2 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,3,0> E3 ## E2 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,3,1> E3 ## E2 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,3,2> E3 ## E2 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,2,3,3> E3 ## E2 ## E3 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,0,0> E3 ## E3 ## E0 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,0,1> E3 ## E3 ## E0 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,0,2> E3 ## E3 ## E0 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,0,3> E3 ## E3 ## E0 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,1,0> E3 ## E3 ## E1 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,1,1> E3 ## E3 ## E1 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,1,2> E3 ## E3 ## E1 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,1,3> E3 ## E3 ## E1 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,2,0> E3 ## E3 ## E2 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,2,1> E3 ## E3 ## E2 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,2,2> E3 ## E3 ## E2 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,2,3> E3 ## E3 ## E2 ## E3; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,3,0> E3 ## E3 ## E3 ## E0; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,3,1> E3 ## E3 ## E3 ## E1; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,3,2> E3 ## E3 ## E3 ## E2; }; \ + struct { detail::_swizzle<4, T, P, V, 3,3,3,3> E3 ## E3 ## E3 ## E3; }; diff --git a/extensions/common/glm/detail/_swizzle_func.hpp b/extensions/common/glm/detail/_swizzle_func.hpp new file mode 100644 index 0000000000..4dbb783c5b --- /dev/null +++ b/extensions/common/glm/detail/_swizzle_func.hpp @@ -0,0 +1,725 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/_swizzle_func.hpp +/// @date 2011-10-16 / 2011-10-16 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#define GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B) \ + SWIZZLED_TYPE A ## B() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B); \ + } + +#define GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C) \ + SWIZZLED_TYPE A ## B ## C() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->C); \ + } + +#define GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C, D) \ + SWIZZLED_TYPE A ## B ## C ## D() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->C, this->D); \ + } + +#define GLM_SWIZZLE_GEN_VEC2_ENTRY_DEF(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B) \ + template \ + SWIZZLED_TYPE CLASS_TYPE::A ## B() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B); \ + } + +#define GLM_SWIZZLE_GEN_VEC3_ENTRY_DEF(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C) \ + template \ + SWIZZLED_TYPE CLASS_TYPE::A ## B ## C() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->C); \ + } + +#define GLM_SWIZZLE_GEN_VEC4_ENTRY_DEF(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C, D) \ + template \ + SWIZZLED_TYPE CLASS_TYPE::A ## B ## C ## D() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->C, this->D); \ + } + +#define GLM_MUTABLE + +#define GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC2(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, x, y) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, r, g) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, s, t) + +//GLM_SWIZZLE_GEN_REF_FROM_VEC2(valType, detail::vec2, detail::ref2) + +#define GLM_SWIZZLE_GEN_REF2_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B) + +#define GLM_SWIZZLE_GEN_REF3_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B, A) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_REF3_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC3(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, x, y, z) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, r, g, b) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, s, t, p) + +//GLM_SWIZZLE_GEN_REF_FROM_VEC3(valType, detail::vec3, detail::ref2, detail::ref3) + +#define GLM_SWIZZLE_GEN_REF2_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, C) + +#define GLM_SWIZZLE_GEN_REF3_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, C, B) + +#define GLM_SWIZZLE_GEN_REF4_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, B, C, A) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_REF3_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_REF4_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC4(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, x, y, z, w) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, r, g, b, a) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t, p, q) + +//GLM_SWIZZLE_GEN_REF_FROM_VEC4(valType, detail::vec4, detail::ref2, detail::ref3, detail::ref4) + +#define GLM_SWIZZLE_GEN_VEC2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B) + +#define GLM_SWIZZLE_GEN_VEC3_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B) + +#define GLM_SWIZZLE_GEN_VEC4_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, B) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC3_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC4_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC2(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, x, y) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, r, g) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t) + +//GLM_SWIZZLE_GEN_VEC_FROM_VEC2(valType, detail::vec2, detail::vec2, detail::vec3, detail::vec4) + +#define GLM_SWIZZLE_GEN_VEC2_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C) + +#define GLM_SWIZZLE_GEN_VEC3_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C) + +#define GLM_SWIZZLE_GEN_VEC4_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, C) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC2_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B, C) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC3(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, x, y, z) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, r, g, b) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t, p) + +//GLM_SWIZZLE_GEN_VEC_FROM_VEC3(valType, detail::vec3, detail::vec2, detail::vec3, detail::vec4) + +#define GLM_SWIZZLE_GEN_VEC2_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D) + +#define GLM_SWIZZLE_GEN_VEC3_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D) + +#define GLM_SWIZZLE_GEN_VEC4_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, D) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC2_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC4(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, x, y, z, w) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, r, g, b, a) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t, p, q) + +//GLM_SWIZZLE_GEN_VEC_FROM_VEC4(valType, detail::vec4, detail::vec2, detail::vec3, detail::vec4) diff --git a/extensions/common/glm/detail/_vectorize.hpp b/extensions/common/glm/detail/_vectorize.hpp new file mode 100644 index 0000000000..1deff1e080 --- /dev/null +++ b/extensions/common/glm/detail/_vectorize.hpp @@ -0,0 +1,160 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/_vectorize.hpp +/// @date 2011-10-14 / 2011-10-14 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "type_vec1.hpp" +#include "type_vec2.hpp" +#include "type_vec3.hpp" +#include "type_vec4.hpp" + +namespace glm{ +namespace detail +{ + template class vecType> + struct functor1{}; + + template + struct functor1 + { + GLM_FUNC_QUALIFIER static tvec1 call(R (*Func) (T x), tvec1 const & v) + { + return tvec1(Func(v.x)); + } + }; + + template + struct functor1 + { + GLM_FUNC_QUALIFIER static tvec2 call(R (*Func) (T x), tvec2 const & v) + { + return tvec2(Func(v.x), Func(v.y)); + } + }; + + template + struct functor1 + { + GLM_FUNC_QUALIFIER static tvec3 call(R (*Func) (T x), tvec3 const & v) + { + return tvec3(Func(v.x), Func(v.y), Func(v.z)); + } + }; + + template + struct functor1 + { + GLM_FUNC_QUALIFIER static tvec4 call(R (*Func) (T x), tvec4 const & v) + { + return tvec4(Func(v.x), Func(v.y), Func(v.z), Func(v.w)); + } + }; + + template class vecType> + struct functor2{}; + + template + struct functor2 + { + GLM_FUNC_QUALIFIER static tvec1 call(T (*Func) (T x, T y), tvec1 const & a, tvec1 const & b) + { + return tvec1(Func(a.x, b.x)); + } + }; + + template + struct functor2 + { + GLM_FUNC_QUALIFIER static tvec2 call(T (*Func) (T x, T y), tvec2 const & a, tvec2 const & b) + { + return tvec2(Func(a.x, b.x), Func(a.y, b.y)); + } + }; + + template + struct functor2 + { + GLM_FUNC_QUALIFIER static tvec3 call(T (*Func) (T x, T y), tvec3 const & a, tvec3 const & b) + { + return tvec3(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z)); + } + }; + + template + struct functor2 + { + GLM_FUNC_QUALIFIER static tvec4 call(T (*Func) (T x, T y), tvec4 const & a, tvec4 const & b) + { + return tvec4(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w)); + } + }; + + template class vecType> + struct functor2_vec_sca{}; + + template + struct functor2_vec_sca + { + GLM_FUNC_QUALIFIER static tvec1 call(T (*Func) (T x, T y), tvec1 const & a, T b) + { + return tvec1(Func(a.x, b)); + } + }; + + template + struct functor2_vec_sca + { + GLM_FUNC_QUALIFIER static tvec2 call(T (*Func) (T x, T y), tvec2 const & a, T b) + { + return tvec2(Func(a.x, b), Func(a.y, b)); + } + }; + + template + struct functor2_vec_sca + { + GLM_FUNC_QUALIFIER static tvec3 call(T (*Func) (T x, T y), tvec3 const & a, T b) + { + return tvec3(Func(a.x, b), Func(a.y, b), Func(a.z, b)); + } + }; + + template + struct functor2_vec_sca + { + GLM_FUNC_QUALIFIER static tvec4 call(T (*Func) (T x, T y), tvec4 const & a, T b) + { + return tvec4(Func(a.x, b), Func(a.y, b), Func(a.z, b), Func(a.w, b)); + } + }; +}//namespace detail +}//namespace glm diff --git a/extensions/common/glm/detail/dummy.cpp b/extensions/common/glm/detail/dummy.cpp new file mode 100644 index 0000000000..88d8f3b807 --- /dev/null +++ b/extensions/common/glm/detail/dummy.cpp @@ -0,0 +1,232 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/dummy.cpp +/// @date 2011-01-19 / 2011-06-15 +/// @author Christophe Riccio +/// +/// GLM is a header only library. There is nothing to compile. +/// dummy.cpp exist only a wordaround for CMake file. +/////////////////////////////////////////////////////////////////////////////////// + +#define GLM_MESSAGES +#include +#include +#include + +struct material +{ + glm::vec4 emission; // Ecm + glm::vec4 ambient; // Acm + glm::vec4 diffuse; // Dcm + glm::vec4 specular; // Scm + float shininess; // Srm +}; + +struct light +{ + glm::vec4 ambient; // Acli + glm::vec4 diffuse; // Dcli + glm::vec4 specular; // Scli + glm::vec4 position; // Ppli + glm::vec4 halfVector; // Derived: Hi + glm::vec3 spotDirection; // Sdli + float spotExponent; // Srli + float spotCutoff; // Crli + // (range: [0.0,90.0], 180.0) + float spotCosCutoff; // Derived: cos(Crli) + // (range: [1.0,0.0],-1.0) + float constantAttenuation; // K0 + float linearAttenuation; // K1 + float quadraticAttenuation;// K2 +}; + + +// Sample 1 +#include // glm::vec3 +#include // glm::cross, glm::normalize + +glm::vec3 computeNormal +( + glm::vec3 const & a, + glm::vec3 const & b, + glm::vec3 const & c +) +{ + return glm::normalize(glm::cross(c - a, b - a)); +} + +typedef unsigned int GLuint; +#define GL_FALSE 0 +void glUniformMatrix4fv(GLuint, int, int, float*){} + +// Sample 2 +#include // glm::vec3 +#include // glm::vec4, glm::ivec4 +#include // glm::mat4 +#include // glm::translate, glm::rotate, glm::scale, glm::perspective +#include // glm::value_ptr +void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate) +{ + glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f); + glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); + glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); + glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); + glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); + glm::mat4 MVP = Projection * View * Model; + glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP)); +} + +// Sample 3 +#include // glm::vec2 +#include // glm::packUnorm2x16 +#include // glm::uint +#include // glm::i8vec2, glm::i32vec2 +std::size_t const VertexCount = 4; +// Float quad geometry +std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2); +glm::vec2 const PositionDataF32[VertexCount] = +{ + glm::vec2(-1.0f,-1.0f), + glm::vec2( 1.0f,-1.0f), + glm::vec2( 1.0f, 1.0f), + glm::vec2(-1.0f, 1.0f) + }; +// Half-float quad geometry +std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint); +glm::uint const PositionDataF16[VertexCount] = +{ + glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f))) +}; +// 8 bits signed integer quad geometry +std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2); +glm::i8vec2 const PositionDataI8[VertexCount] = +{ + glm::i8vec2(-1,-1), + glm::i8vec2( 1,-1), + glm::i8vec2( 1, 1), + glm::i8vec2(-1, 1) +}; +// 32 bits signed integer quad geometry +std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2); +glm::i32vec2 const PositionDataI32[VertexCount] = +{ + glm::i32vec2 (-1,-1), + glm::i32vec2 ( 1,-1), + glm::i32vec2 ( 1, 1), + glm::i32vec2 (-1, 1) +}; + +struct intersection +{ + glm::vec4 position; + glm::vec3 normal; +}; + +/* +// Sample 4 +#include // glm::vec3 +#include // glm::normalize, glm::dot, glm::reflect +#include // glm::pow +#include // glm::vecRand3 +glm::vec3 lighting +( + intersection const & Intersection, + material const & Material, + light const & Light, + glm::vec3 const & View +) +{ + glm::vec3 Color(0.0f); + glm::vec3 LightVertor(glm::normalize( + Light.position - Intersection.position + + glm::vecRand3(0.0f, Light.inaccuracy)); + + if(!shadow(Intersection.position, Light.position, LightVertor)) + { + float Diffuse = glm::dot(Intersection.normal, LightVector); + if(Diffuse <= 0.0f) + return Color; + if(Material.isDiffuse()) + Color += Light.color() * Material.diffuse * Diffuse; + if(Material.isSpecular()) + { + glm::vec3 Reflect(glm::reflect( + glm::normalize(-LightVector), + glm::normalize(Intersection.normal))); + float Dot = glm::dot(Reflect, View); + float Base = Dot > 0.0f ? Dot : 0.0f; + float Specular = glm::pow(Base, Material.exponent); + Color += Material.specular * Specular; + } + } + return Color; +} +*/ + + +template class vecType> +T normalizeDotA(vecType const & x, vecType const & y) +{ + return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); +} + +#define GLM_TEMPLATE_GENTYPE typename T, glm::precision P, template class + +template +T normalizeDotB(vecType const & x, vecType const & y) +{ + return glm::dot(x, y) * glm::inversesqrt(glm::dot(x, x) * glm::dot(y, y)); +} + +template +typename vecType::value_type normalizeDotC(vecType const & a, vecType const & b) +{ + return glm::dot(a, b) * glm::inversesqrt(glm::dot(a, a) * glm::dot(b, b)); +} + +int main() +{ + glm::vec1 o(1); + glm::vec2 a(1); + glm::vec3 b(1); + glm::vec4 c(1); + + glm::quat q; + glm::dualquat p; + + glm::mat4 m(1); + + float a0 = normalizeDotA(a, a); + float b0 = normalizeDotB(b, b); + float c0 = normalizeDotC(c, c); + + return 0; +} diff --git a/extensions/common/glm/detail/func_common.hpp b/extensions/common/glm/detail/func_common.hpp new file mode 100644 index 0000000000..da28007b05 --- /dev/null +++ b/extensions/common/glm/detail/func_common.hpp @@ -0,0 +1,456 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// Restrictions: +/// By making use of the Software for military purposes, you choose to make +/// a Bunny unhappy. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/func_common.hpp +/// @date 2008-03-08 / 2010-01-26 +/// @author Christophe Riccio +/// +/// @see GLSL 4.20.8 specification, section 8.3 Common Functions +/// +/// @defgroup core_func_common Common functions +/// @ingroup core +/// +/// These all operate component-wise. The description is per component. +/////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "setup.hpp" +#include "precision.hpp" +#include "type_int.hpp" +#include "_fixes.hpp" + +namespace glm +{ + /// @addtogroup core_func_common + /// @{ + + /// Returns x if x >= 0; otherwise, it returns -x. + /// + /// @tparam genType floating-point or signed integer; scalar or vector types. + /// + /// @see GLSL abs man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType abs(genType x); + + template class vecType> + GLM_FUNC_DECL vecType abs(vecType const & x); + + /// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0. + /// + /// @tparam genType Floating-point or signed integer; scalar or vector types. + /// + /// @see GLSL sign man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template class vecType> + GLM_FUNC_DECL vecType sign(vecType const & x); + + /// Returns a value equal to the nearest integer that is less then or equal to x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL floor man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template class vecType> + GLM_FUNC_DECL vecType floor(vecType const & x); + + /// Returns a value equal to the nearest integer to x + /// whose absolute value is not larger than the absolute value of x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL trunc man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template class vecType> + GLM_FUNC_DECL vecType trunc(vecType const & x); + + /// Returns a value equal to the nearest integer to x. + /// The fraction 0.5 will round in a direction chosen by the + /// implementation, presumably the direction that is fastest. + /// This includes the possibility that round(x) returns the + /// same value as roundEven(x) for all values of x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL round man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template class vecType> + GLM_FUNC_DECL vecType round(vecType const & x); + + /// Returns a value equal to the nearest integer to x. + /// A fractional part of 0.5 will round toward the nearest even + /// integer. (Both 3.5 and 4.5 for x will return 4.0.) + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL roundEven man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see New round to even technique + template class vecType> + GLM_FUNC_DECL vecType roundEven(vecType const & x); + + /// Returns a value equal to the nearest integer + /// that is greater than or equal to x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL ceil man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template class vecType> + GLM_FUNC_DECL vecType ceil(vecType const & x); + + /// Return x - floor(x). + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL fract man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType fract(genType x); + + template class vecType> + GLM_FUNC_DECL vecType fract(vecType const & x); + + /// Modulus. Returns x - y * floor(x / y) + /// for each component in x using the floating point value y. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL mod man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType mod(genType x, genType y); + + template class vecType> + GLM_FUNC_DECL vecType mod(vecType const & x, T y); + + template class vecType> + GLM_FUNC_DECL vecType mod(vecType const & x, vecType const & y); + + /// Returns the fractional part of x and sets i to the integer + /// part (as a whole number floating point value). Both the + /// return value and the output parameter will have the same + /// sign as x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL modf man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType modf(genType x, genType & i); + + /// Returns y if y < x; otherwise, it returns x. + /// + /// @tparam genType Floating-point or integer; scalar or vector types. + /// + /// @see GLSL min man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType min(genType x, genType y); + + template class vecType> + GLM_FUNC_DECL vecType min(vecType const & x, T y); + + template class vecType> + GLM_FUNC_DECL vecType min(vecType const & x, vecType const & y); + + /// Returns y if x < y; otherwise, it returns x. + /// + /// @tparam genType Floating-point or integer; scalar or vector types. + /// + /// @see GLSL max man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType max(genType x, genType y); + + template class vecType> + GLM_FUNC_DECL vecType max(vecType const & x, T y); + + template class vecType> + GLM_FUNC_DECL vecType max(vecType const & x, vecType const & y); + + /// Returns min(max(x, minVal), maxVal) for each component in x + /// using the floating-point values minVal and maxVal. + /// + /// @tparam genType Floating-point or integer; scalar or vector types. + /// + /// @see GLSL clamp man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType clamp(genType x, genType minVal, genType maxVal); + + template class vecType> + GLM_FUNC_DECL vecType clamp(vecType const & x, T minVal, T maxVal); + + template class vecType> + GLM_FUNC_DECL vecType clamp(vecType const & x, vecType const & minVal, vecType const & maxVal); + + /// If genTypeU is a floating scalar or vector: + /// Returns x * (1.0 - a) + y * a, i.e., the linear blend of + /// x and y using the floating-point value a. + /// The value for a is not restricted to the range [0, 1]. + /// + /// If genTypeU is a boolean scalar or vector: + /// Selects which vector each returned component comes + /// from. For a component of that is false, the + /// corresponding component of x is returned. For a + /// component of a that is true, the corresponding + /// component of y is returned. Components of x and y that + /// are not selected are allowed to be invalid floating point + /// values and will have no effect on the results. Thus, this + /// provides different functionality than + /// genType mix(genType x, genType y, genType(a)) + /// where a is a Boolean vector. + /// + /// @see GLSL mix man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @param[in] x Value to interpolate. + /// @param[in] y Value to interpolate. + /// @param[in] a Interpolant. + /// + /// @tparam genTypeT Floating point scalar or vector. + /// @tparam genTypeU Floating point or boolean scalar or vector. It can't be a vector if it is the length of genTypeT. + /// + /// @code + /// #include + /// ... + /// float a; + /// bool b; + /// glm::dvec3 e; + /// glm::dvec3 f; + /// glm::vec4 g; + /// glm::vec4 h; + /// ... + /// glm::vec4 r = glm::mix(g, h, a); // Interpolate with a floating-point scalar two vectors. + /// glm::vec4 s = glm::mix(g, h, b); // Teturns g or h; + /// glm::dvec3 t = glm::mix(e, f, a); // Types of the third parameter is not required to match with the first and the second. + /// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter. + /// @endcode + template class vecType> + GLM_FUNC_DECL vecType mix(vecType const & x, vecType const & y, vecType const & a); + + template class vecType> + GLM_FUNC_DECL vecType mix(vecType const & x, vecType const & y, U a); + + template + GLM_FUNC_DECL genTypeT mix(genTypeT x, genTypeT y, genTypeU a); + + /// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType. + /// + /// @see GLSL step man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType step(genType edge, genType x); + + /// Returns 0.0 if x < edge, otherwise it returns 1.0. + /// + /// @see GLSL step man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template