diff --git a/.gitignore b/.gitignore index f312ddb55e..1e42404039 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ -release/* -*.cache -*.pbo -texHeaders.bin -*.swp -*.swo -*.biprivatekey -Thumbs.db +release/* +*.cache +*.pbo +texHeaders.bin +*.swp +*.swo +*.biprivatekey +Thumbs.db diff --git a/addons/aircraft/Heli_Attack_01_base_F.hpp b/addons/aircraft/Heli_Attack_01_base_F.hpp index a6868033e6..f56cda1fd8 100644 --- a/addons/aircraft/Heli_Attack_01_base_F.hpp +++ b/addons/aircraft/Heli_Attack_01_base_F.hpp @@ -1,997 +1,997 @@ -class Heli_Attack_01_base_F: Helicopter_Base_F { - lockDetectionSystem = 12; - incomingMissileDetectionSystem = 16; - driverCanEject = 1; - - class MFD - { - class AirplaneHUD - { - class Bones{}; - class Draw{}; - topLeft = "HUD_top_left"; - topRight = "HUD_top_right"; - bottomLeft = "HUD_bottom_left"; - borderLeft = 0; - borderRight = 0; - borderTop = 0; - borderBottom = 0; - color[] = {0.15,1,0.15,1}; - enableParallax = 0; - helmetMountedDisplay = 1; - helmetPosition[] = {0,0,0}; - helmetRight[] = {0,0,0}; - helmetDown[] = {0,0,0}; - }; - class ACE_HUD_1 - { - topLeft = "HUD_top_left"; - topRight = "HUD_top_right"; - bottomLeft = "HUD_bottom_left"; - borderLeft = 0; - borderRight = 0; - borderTop = 0; - borderBottom = 0; - color[] = {0.15,1,0.15,1}; - enableParallax = 0; - class Bones - { - class GunnerAim - { - type = "vector"; - source = "weapon"; - pos0[] = {0.5,"0.9 - 0.04 + 0.012"}; - pos10[] = {"0.5 + 0.0111","0.9 - 0.04 + 0.012 + 0.0133"}; - }; - class Target - { - source = "target"; - type = "vector"; - pos0[] = {0.5,0.5}; - pos10[] = {0.85,0.85}; - }; - class Velocity - { - type = "vector"; - source = "velocity"; - pos0[] = {0.5,0.5}; - pos10[] = {0.65,0.65}; - }; - class Velocity_slip - { - type = "vector"; - source = "velocity"; - pos0[] = {0.5,0.845}; - pos10[] = {0.53,0.845}; - }; - class VspeedBone - { - type = "linear"; - source = "vspeed"; - sourceScale = 1; - min = -10; - max = 10; - minPos[] = {0.93,0.2}; - maxPos[] = {0.93,0.8}; - }; - class RadarAltitudeBone - { - type = "linear"; - source = "altitudeAGL"; - sourceScale = 1; - min = 0; - max = 60; - minPos[] = {0.965,0.2}; - maxPos[] = {0.965,0.8}; - }; - class HorizonBankRot - { - type = "rotational"; - source = "horizonBank"; - center[] = {0.5,0.5}; - min = -3.1416; - max = 3.1416; - minAngle = -180; - maxAngle = 180; - aspectRatio = 1; - }; - class ForwardVec - { - type = "vector"; - source = "forward"; - pos0[] = {0,0}; - pos10[] = {0.25,0.25}; - }; - class WeaponAim - { - type = "vector"; - source = "weapon"; - pos0[] = {0.5,0.5}; - pos10[] = {0.75,0.75}; - }; - class Level0 - { - type = "horizon"; - pos0[] = {0.5,0.5}; - pos10[] = {0.78,0.78}; - angle = 0; - }; - class LevelP5: Level0 - { - angle = 5; - }; - class LevelM5: Level0 - { - angle = -5; - }; - class LevelP10: Level0 - { - angle = 10; - }; - class LevelM10: Level0 - { - angle = -10; - }; - class LevelP15: Level0 - { - angle = 15; - }; - class LevelM15: Level0 - { - angle = -15; - }; - class LevelP20: Level0 - { - angle = 20; - }; - class LevelM20: Level0 - { - angle = -20; - }; - class LevelP25: Level0 - { - angle = 25; - }; - class LevelM25: Level0 - { - angle = -25; - }; - class LevelP30: Level0 - { - angle = 30; - }; - class LevelM30: Level0 - { - angle = -30; - }; - class LevelP35: Level0 - { - angle = 35; - }; - class LevelM35: Level0 - { - angle = -35; - }; - class LevelP40: Level0 - { - angle = 40; - }; - class LevelM40: Level0 - { - angle = -40; - }; - class LevelP45: Level0 - { - angle = 45; - }; - class LevelM45: Level0 - { - angle = -45; - }; - class LevelP50: Level0 - { - angle = 50; - }; - class LevelM50: Level0 - { - angle = -50; - }; - }; - class Draw - { - color[] = {0.18,1,0.18}; - alpha = 1; - condition = "on"; - class Horizont - { - clipTL[] = {0.15,0.15}; - clipBR[] = {0.85,0.85}; - class Dimmed - { - class Level0 - { - type = "line"; - points[] = {{ "Level0",{ -0.42,0 },1 },{ "Level0",{ -0.38,0 },1 },{ },{ "Level0",{ -0.37,0 },1 },{ "Level0",{ -0.33,0 },1 },{ },{ "Level0",{ -0.32,0 },1 },{ "Level0",{ -0.28,0 },1 },{ },{ "Level0",{ -0.27,0 },1 },{ "Level0",{ -0.23,0 },1 },{ },{ "Level0",{ -0.22,0 },1 },{ "Level0",{ -0.18,0 },1 },{ },{ "Level0",{ -0.17,0 },1 },{ "Level0",{ -0.13,0 },1 },{ },{ "Level0",{ -0.12,0 },1 },{ "Level0",{ -0.08,0 },1 },{ },{ "Level0",{ 0.42,0 },1 },{ "Level0",{ 0.38,0 },1 },{ },{ "Level0",{ 0.37,0 },1 },{ "Level0",{ 0.33,0 },1 },{ },{ "Level0",{ 0.32,0 },1 },{ "Level0",{ 0.28,0 },1 },{ },{ "Level0",{ 0.27,0 },1 },{ "Level0",{ 0.23,0 },1 },{ },{ "Level0",{ 0.22,0 },1 },{ "Level0",{ 0.18,0 },1 },{ },{ "Level0",{ 0.17,0 },1 },{ "Level0",{ 0.13,0 },1 },{ },{ "Level0",{ 0.12,0 },1 },{ "Level0",{ 0.08,0 },1 }}; - }; - }; - }; - class HorizonBankRot - { - type = "line"; - width = 3; - points[] = {{ "HorizonBankRot",{ 0,0.25 },1 },{ "HorizonBankRot",{ -0.01,0.23 },1 },{ "HorizonBankRot",{ 0.01,0.23 },1 },{ "HorizonBankRot",{ 0,0.25 },1 }}; - }; - class Static_HAD_BOX - { - clipTL[] = {0,1}; - clipBR[] = {1,0}; - type = "line"; - width = 5; - points[] = {{ { "0.5-0.1","0.9-0.04" },1 },{ { "0.5-0.1","0.9+0.04" },1 },{ { "0.5+0.1","0.9+0.04" },1 },{ { "0.5+0.1","0.9-0.04" },1 },{ { "0.5-0.1","0.9-0.04" },1 },{ },{ { "0.5-0.1","0.9-0.04+0.012" },1 },{ { "0.5-0.092","0.9-0.04+0.012" },1 },{ },{ { "0.5+0.1","0.9-0.04+0.012" },1 },{ { "0.5+0.092","0.9-0.04+0.012" },1 },{ },{ { 0.5,"0.9-0.04" },1 },{ { 0.5,"0.9-0.032" },1 },{ },{ { 0.5,"0.9+0.04" },1 },{ { 0.5,"0.9+0.032" },1 },{ }}; - }; - class Gunner_HAD - { - type = "line"; - width = 6; - points[] = {{ "GunnerAim",{ -0.015,-0.008 },1 },{ "GunnerAim",{ -0.015,0.008 },1 },{ "GunnerAim",{ 0.015,0.008 },1 },{ "GunnerAim",{ 0.015,-0.008 },1 },{ "GunnerAim",{ -0.015,-0.008 },1 }}; - }; - class Slip_ball_group - { - class Slip_bars - { - type = "line"; - width = 4; - points[] = {{ { "0.5-0.018","0.9-0.04" },1 },{ { "0.5-0.018","0.9-0.075" },1 },{ },{ { "0.5+0.018","0.9-0.04" },1 },{ { "0.5+0.018","0.9-0.075" },1 }}; - }; - class Slip_ball - { - type = "line"; - width = 6; - points[] = {{ "Velocity_slip",1,{ "0 * 0.75","-0.02 * 0.75" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.75","-0.01732 * 0.75" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.75","-0.0099999998 * 0.75" },1 },{ "Velocity_slip",1,{ "0.02 * 0.75","0 * 0.75" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.75","0.0099999998 * 0.75" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.75","0.01732 * 0.75" },1 },{ "Velocity_slip",1,{ "0 * 0.75","0.02 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.75","0.01732 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.75","0.0099999998 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.75","0 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.75","-0.0099999998 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.75","-0.01732 * 0.75" },1 },{ "Velocity_slip",1,{ "0 * 0.75","-0.02 * 0.75" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.6","-0.02 * 0.6" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.6","-0.01732 * 0.6" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.6","-0.0099999998 * 0.6" },1 },{ "Velocity_slip",1,{ "0.02 * 0.6","0 * 0.6" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.6","0.0099999998 * 0.6" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.6","0.01732 * 0.6" },1 },{ "Velocity_slip",1,{ "0 * 0.6","0.02 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.6","0.01732 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.6","0.0099999998 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.6","0 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.6","-0.0099999998 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.6","-0.01732 * 0.6" },1 },{ "Velocity_slip",1,{ "0 * 0.6","-0.02 * 0.6" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.5","-0.02 * 0.5" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.5","-0.01732 * 0.5" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.5","-0.0099999998 * 0.5" },1 },{ "Velocity_slip",1,{ "0.02 * 0.5","0 * 0.5" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.5","0.0099999998 * 0.5" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.5","0.01732 * 0.5" },1 },{ "Velocity_slip",1,{ "0 * 0.5","0.02 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.5","0.01732 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.5","0.0099999998 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.5","0 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.5","-0.0099999998 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.5","-0.01732 * 0.5" },1 },{ "Velocity_slip",1,{ "0 * 0.5","-0.02 * 0.5" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.4","-0.02 * 0.4" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.4","-0.01732 * 0.4" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.4","-0.0099999998 * 0.4" },1 },{ "Velocity_slip",1,{ "0.02 * 0.4","0 * 0.4" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.4","0.0099999998 * 0.4" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.4","0.01732 * 0.4" },1 },{ "Velocity_slip",1,{ "0 * 0.4","0.02 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.4","0.01732 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.4","0.0099999998 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.4","0 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.4","-0.0099999998 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.4","-0.01732 * 0.4" },1 },{ "Velocity_slip",1,{ "0 * 0.4","-0.02 * 0.4" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.30","-0.02 * 0.30" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.30","-0.01732 * 0.30" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.30","-0.0099999998 * 0.30" },1 },{ "Velocity_slip",1,{ "0.02 * 0.30","0 * 0.30" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.30","0.0099999998 * 0.30" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.30","0.01732 * 0.30" },1 },{ "Velocity_slip",1,{ "0 * 0.30","0.02 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.30","0.01732 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.30","0.0099999998 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.30","0 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.30","-0.0099999998 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.30","-0.01732 * 0.30" },1 },{ "Velocity_slip",1,{ "0 * 0.30","-0.02 * 0.30" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.20","-0.02 * 0.20" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.20","-0.01732 * 0.20" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.20","-0.0099999998 * 0.20" },1 },{ "Velocity_slip",1,{ "0.02 * 0.20","0 * 0.20" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.20","0.0099999998 * 0.20" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.20","0.01732 * 0.20" },1 },{ "Velocity_slip",1,{ "0 * 0.20","0.02 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.20","0.01732 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.20","0.0099999998 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.20","0 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.20","-0.0099999998 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.20","-0.01732 * 0.20" },1 },{ "Velocity_slip",1,{ "0 * 0.20","-0.02 * 0.20" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.1","-0.02 * 0.1" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.1","-0.01732 * 0.1" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.1","-0.0099999998 * 0.1" },1 },{ "Velocity_slip",1,{ "0.02 * 0.1","0 * 0.1" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.1","0.0099999998 * 0.1" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.1","0.01732 * 0.1" },1 },{ "Velocity_slip",1,{ "0 * 0.1","0.02 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.1","0.01732 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.1","0.0099999998 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.1","0 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.1","-0.0099999998 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.1","-0.01732 * 0.1" },1 },{ "Velocity_slip",1,{ "0 * 0.1","-0.02 * 0.1" },1 }}; - }; - }; - class Centerline - { - type = "line"; - width = 5; - points[] = {{ { 0.5,0.48 },1 },{ { 0.5,0.45 },1 },{ },{ { 0.5,0.52 },1 },{ { 0.5,0.55 },1 },{ },{ { 0.48,0.5 },1 },{ { 0.45,0.5 },1 },{ },{ { 0.52,0.5 },1 },{ { 0.55,0.5 },1 },{ }}; - }; - class WeaponName - { - type = "text"; - source = "weapon"; - sourceScale = 1; - align = "right"; - scale = 1; - pos[] = {{ 0.61,0.86 },1}; - right[] = {{ 0.65,0.86 },1}; - down[] = {{ 0.61,0.9 },1}; - }; - class Ammo_GUN - { - type = "group"; - condition = "mgun"; - class Ammo_count_GUN - { - type = "text"; - source = "ammo"; - sourceScale = 1; - align = "right"; - scale = 1; - pos[] = {{ 0.61,0.89 },1}; - right[] = {{ 0.65,0.89 },1}; - down[] = {{ 0.61,0.93 },1}; - }; - }; - class Ammo_RKT - { - type = "group"; - condition = "rocket"; - class Ammo_count_RKT - { - type = "text"; - source = "ammo"; - sourceScale = 1; - align = "right"; - scale = 1; - pos[] = {{ 0.61,0.89 },1}; - right[] = {{ 0.65,0.89 },1}; - down[] = {{ 0.61,0.93 },1}; - }; - }; - class Ammo_AGM - { - type = "group"; - condition = "AAmissile"; - class Ammo_count_AGM - { - type = "text"; - source = "ammo"; - sourceScale = 1; - align = "right"; - scale = 1; - pos[] = {{ 0.61,0.89 },1}; - right[] = {{ 0.65,0.89 },1}; - down[] = {{ 0.61,0.93 },1}; - }; - }; - class Ammo_AAM - { - type = "group"; - condition = "ATmissile"; - class Ammo_count_AAM - { - type = "text"; - source = "ammo"; - sourceScale = 1; - align = "right"; - scale = 1; - pos[] = {{ 0.61,0.89 },1}; - right[] = {{ 0.65,0.89 },1}; - down[] = {{ 0.61,0.93 },1}; - }; - }; - class Ammo_Bomb - { - type = "group"; - condition = "Bomb"; - class Ammo_count_Bomb - { - type = "text"; - source = "ammo"; - sourceScale = 1; - align = "right"; - scale = 1; - pos[] = {{ 0.61,0.89 },1}; - right[] = {{ 0.65,0.89 },1}; - down[] = {{ 0.61,0.93 },1}; - }; - }; - class LightsGroup - { - type = "group"; - condition = "lights"; - class LightsText - { - type = "text"; - source = "static"; - text = "LIGHTS"; - align = "right"; - scale = 1; - pos[] = {{ 0.03,"0.53 + 0.055" },1}; - right[] = {{ 0.07,"0.53 + 0.055" },1}; - down[] = {{ 0.03,"0.53 + 0.095" },1}; - }; - }; - class CollisionLightsGroup - { - type = "group"; - condition = "collisionlights"; - class CollisionLightsText - { - type = "text"; - source = "static"; - text = "A-COL"; - align = "right"; - scale = 1; - pos[] = {{ 0.03,"0.53 + 0.105" },1}; - right[] = {{ 0.07,"0.53 + 0.105" },1}; - down[] = {{ 0.03,"0.53 + 0.145" },1}; - }; - }; - class GearGroup - { - type = "group"; - condition = "ils"; - class GearText - { - type = "text"; - source = "static"; - text = "GEAR"; - align = "right"; - scale = 1; - pos[] = {{ 0.03,"0.53 + 0.155" },1}; - right[] = {{ 0.07,"0.53 + 0.155" },1}; - down[] = {{ 0.03,"0.53 + 0.195" },1}; - }; - }; - class ATMissileTOFGroup - { - condition = "ATmissile"; - type = "group"; - class TOFtext - { - type = "text"; - align = "right"; - source = "static"; - text = "TOF="; - scale = 1; - pos[] = {{ 0.61,0.92 },1}; - right[] = {{ 0.65,0.92 },1}; - down[] = {{ 0.61,0.96 },1}; - }; - class TOFnumber - { - type = "text"; - source = "targetDist"; - sourcescale = 0.0025; - align = "right"; - scale = 1; - pos[] = {{ 0.69,0.92 },1}; - right[] = {{ 0.73,0.92 },1}; - down[] = {{ 0.69,0.96 },1}; - }; - }; - class LaserTOFGroup - { - condition = "Bomb"; - type = "group"; - class TOFtext - { - type = "text"; - align = "right"; - source = "static"; - text = "TOF="; - scale = 1; - pos[] = {{ 0.61,0.92 },1}; - right[] = {{ 0.65,0.92 },1}; - down[] = {{ 0.61,0.96 },1}; - }; - class TOFnumber - { - type = "text"; - source = "targetDist"; - sourcescale = 0.0025; - align = "right"; - scale = 1; - pos[] = {{ 0.69,0.92 },1}; - right[] = {{ 0.73,0.92 },1}; - down[] = {{ 0.69,0.96 },1}; - }; - }; - class RocketTOFGroup - { - condition = "Rocket"; - type = "group"; - class TOFtext - { - type = "text"; - align = "right"; - source = "static"; - text = "TOF="; - scale = 1; - pos[] = {{ 0.61,0.92 },1}; - right[] = {{ 0.65,0.92 },1}; - down[] = {{ 0.61,0.96 },1}; - }; - class TOFnumber - { - type = "text"; - source = "targetDist"; - sourcescale = 0.0025; - align = "right"; - scale = 1; - pos[] = {{ 0.69,0.92 },1}; - right[] = {{ 0.73,0.92 },1}; - down[] = {{ 0.69,0.96 },1}; - }; - }; - class RangeNumber - { - type = "text"; - source = "targetDist"; - sourceScale = 1; - align = "left"; - scale = 1; - pos[] = {{ 0.39,0.89 },1}; - right[] = {{ 0.43,0.89 },1}; - down[] = {{ 0.39,0.93 },1}; - }; - class RangeText - { - type = "text"; - source = "static"; - text = "RNG"; - align = "left"; - scale = 1; - pos[] = {{ 0.39,0.86 },1}; - right[] = {{ 0.43,0.86 },1}; - down[] = {{ 0.39,0.9 },1}; - }; - class SpeedNumber - { - type = "text"; - align = "right"; - scale = 1; - source = "speed"; - sourceScale = 3.6; - pos[] = {{ 0.03,0.475 },1}; - right[] = {{ 0.08,0.475 },1}; - down[] = {{ 0.03,0.525 },1}; - }; - class TorqueNumber - { - condition = "simulRTD"; - class Torque_number - { - type = "text"; - align = "left"; - scale = 1; - source = "rtdRotorTorque"; - sourceScale = 290; - pos[] = {{ 0.065,0.175 },1}; - right[] = {{ 0.115,0.175 },1}; - down[] = {{ 0.065,0.225 },1}; - }; - class Torquetext - { - type = "text"; - source = "static"; - text = "%"; - align = "right"; - scale = 1; - pos[] = {{ 0.07,0.175 },1}; - right[] = {{ 0.12,0.175 },1}; - down[] = {{ 0.07,0.225 },1}; - }; - }; - class AltNumber: SpeedNumber - { - align = "right"; - source = "altitudeAGL"; - sourceScale = 1; - pos[] = {{ 0.83,0.475 },1}; - right[] = {{ 0.88,0.475 },1}; - down[] = {{ 0.83,0.525 },1}; - }; - class ASLNumber - { - type = "text"; - source = "altitudeASL"; - sourceScale = 1; - align = "right"; - scale = 1; - pos[] = {{ 0.835,0.18 },1}; - right[] = {{ 0.875,0.18 },1}; - down[] = {{ 0.835,0.22 },1}; - }; - class VspeedScalePosta - { - type = "line"; - width = 5; - points[] = {{ { 0.98,0.2 },1 },{ { 1,0.2 },1 },{ },{ { 0.93,0.2 },1 },{ { 0.95,0.2 },1 },{ },{ { 0.98,0.35 },1 },{ { 1,0.35 },1 },{ },{ { 0.93,0.35 },1 },{ { 0.95,0.35 },1 },{ },{ { 0.94,0.38 },1 },{ { 0.95,0.38 },1 },{ },{ { 0.94,0.41 },1 },{ { 0.95,0.41 },1 },{ },{ { 0.94,0.44 },1 },{ { 0.95,0.44 },1 },{ },{ { 0.94,0.47 },1 },{ { 0.95,0.47 },1 },{ },{ { 0.98,0.5 },1 },{ { 1,0.5 },1 },{ },{ { 0.93,0.5 },1 },{ { 0.95,0.5 },1 },{ },{ { 0.94,0.53 },1 },{ { 0.95,0.53 },1 },{ },{ { 0.94,0.56 },1 },{ { 0.95,0.56 },1 },{ },{ { 0.94,0.59 },1 },{ { 0.95,0.59 },1 },{ },{ { 0.94,0.62 },1 },{ { 0.95,0.62 },1 },{ },{ { 0.98,0.65 },1 },{ { 1,0.65 },1 },{ },{ { 0.93,0.65 },1 },{ { 0.95,0.65 },1 },{ },{ { 0.99,0.68 },1 },{ { 0.98,0.68 },1 },{ },{ { 0.99,0.71 },1 },{ { 0.98,0.71 },1 },{ },{ { 0.99,0.74 },1 },{ { 0.98,0.74 },1 },{ },{ { 0.99,0.77 },1 },{ { 0.98,0.77 },1 },{ },{ { 0.98,0.8 },1 },{ { 1,0.8 },1 },{ },{ { 0.93,0.8 },1 },{ { 0.95,0.8 },1 },{ }}; - }; - class RadarAltitudeBand - { - clipTL[] = {0,0.2}; - clipBR[] = {1,0.8}; - hideValue = 201; - class radarbanda - { - type = "line"; - width = 17; - points[] = {{ "RadarAltitudeBone",{ 0,0 },1 },{ "RadarAltitudeBone",{ 0,0.6 },1 }}; - }; - }; - class VspeedBand - { - type = "line"; - width = 3; - points[] = {{ "VspeedBone",{ -0.01,0 },1 },{ "VspeedBone",{ -0.025,-0.015 },1 },{ "VspeedBone",{ -0.025,0.015 },1 },{ "VspeedBone",{ -0.01,0 },1 },{ }}; - }; - class HeadingNumber: SpeedNumber - { - source = "heading"; - sourceScale = 1; - align = "center"; - pos[] = {{ 0.5,0.045 },1}; - right[] = {{ 0.56,0.045 },1}; - down[] = {{ 0.5,"0.045 + 0.06" },1}; - }; - class Center_box - { - type = "line"; - width = 1.5; - points[] = {{ { 0.45,"0.02 + 0.085 - 0.06" },1 },{ { "0.45 + 0.10","0.02 + 0.085 - 0.06" },1 },{ { "0.45 + 0.10","0.02 + 0.085" },1 },{ { 0.45,"0.02 + 0.085" },1 },{ { 0.45,"0.02 + 0.085 - 0.06" },1 }}; - }; - class HeadingArrow - { - type = "line"; - width = 7; - points[] = {{ { "0.5","0.128 + 0.03" },1 },{ { 0.5,0.128 },1 }}; - }; - class HeadingScale_LEFT - { - clipTL[] = {0,0}; - clipBR[] = {0.45,1}; - class Heading_group - { - type = "scale"; - horizontal = 1; - source = "heading"; - sourceScale = 1; - width = 5; - top = 0.12; - center = 0.5; - bottom = 0.88; - lineXleft = "0.03 + 0.085"; - lineYright = "0.02 + 0.085"; - lineXleftMajor = "0.04 + 0.085"; - lineYrightMajor = "0.02 + 0.085"; - majorLineEach = 3; - numberEach = 3; - step = 10; - stepSize = "0.05"; - align = "center"; - scale = 1; - pos[] = {0.12,"0.0 + 0.065"}; - right[] = {0.16,"0.0 + 0.065"}; - down[] = {0.12,"0.04 + 0.065"}; - }; - }; - class HeadingScale_RIGHT - { - clipTL[] = {0.55,0}; - clipBR[] = {1,1}; - class Heading_group - { - type = "scale"; - horizontal = 1; - source = "heading"; - sourceScale = 1; - width = 5; - top = 0.12; - center = 0.5; - bottom = 0.88; - lineXleft = "0.03 + 0.085"; - lineYright = "0.02 + 0.085"; - lineXleftMajor = "0.04 + 0.085"; - lineYrightMajor = "0.02 + 0.085"; - majorLineEach = 3; - numberEach = 3; - step = 10; - stepSize = "0.05"; - align = "center"; - scale = 1; - pos[] = {0.12,"0.0 + 0.065"}; - right[] = {0.16,"0.0 + 0.065"}; - down[] = {0.12,"0.04 + 0.065"}; - }; - }; - class HeadingScale_BOTTOM - { - clipTL[] = {0.45,"0.02 + 0.085"}; - clipBR[] = {"0.45 + 0.10",1}; - class Heading_group - { - type = "scale"; - horizontal = 1; - source = "heading"; - sourceScale = 1; - width = 5; - top = 0.12; - center = 0.5; - bottom = 0.88; - lineXleft = "0.03 + 0.085"; - lineYright = "0.02 + 0.085"; - lineXleftMajor = "0.04 + 0.085"; - lineYrightMajor = "0.02 + 0.085"; - majorLineEach = 3; - numberEach = 3; - step = 10; - stepSize = "0.05"; - align = "center"; - scale = 1; - pos[] = {0.12,"0.0 + 0.065"}; - right[] = {0.16,"0.0 + 0.065"}; - down[] = {0.12,"0.04 + 0.065"}; - }; - }; - class Fuel_Text - { - type = "text"; - source = "static"; - text = "Fuel"; - align = "right"; - scale = 1; - pos[] = {{ 0.03,0.9 },1}; - right[] = {{ 0.07,0.9 },1}; - down[] = {{ 0.03,0.94 },1}; - }; - class Fuel_Number - { - type = "text"; - source = "fuel"; - sourceScale = 100; - align = "right"; - scale = 1; - pos[] = {{ 0.1,0.9 },1}; - right[] = {{ 0.14,0.9 },1}; - down[] = {{ 0.1,0.94 },1}; - }; - }; - helmetMountedDisplay = 1; - helmetPosition[] = {-0.04,0.04,0.1}; - helmetRight[] = {0.08,0,0}; - helmetDown[] = {0,-0.08,0}; - }; - class ACE_HUD_2 - { - topLeft = "HUD_top_left"; - topRight = "HUD_top_right"; - bottomLeft = "HUD_bottom_left"; - borderLeft = 0; - borderRight = 0; - borderTop = 0; - borderBottom = 0; - color[] = {0.15,1,0.15,1}; - enableParallax = 0; - class Bones - { - class Velocity - { - type = "vector"; - source = "velocity"; - pos0[] = {0.5,0.5}; - pos10[] = {0.75,0.75}; - }; - class ForwardVec1 - { - type = "vector"; - source = "forward"; - pos0[] = {0,0}; - pos10[] = {0.25,0.25}; - }; - class ForwardVec - { - type = "vector"; - source = "forward"; - pos0[] = {0,0}; - pos10[] = {0.253,0.253}; - }; - class WeaponAim - { - type = "vector"; - source = "weapon"; - pos0[] = {0.5,0.5}; - pos10[] = {0.753,0.753}; - }; - class WeaponAim1 - { - type = "vector"; - source = "weapon"; - pos0[] = {0,0}; - pos10[] = {0.253,0.23}; - }; - class Target - { - type = "vector"; - source = "target"; - pos0[] = {0.5,0.5}; - pos10[] = {0.753,0.753}; - }; - class RadarContact - { - type = "fixed"; - pos[] = {0,0}; - }; - }; - class Draw - { - color[] = {0.18,1,0.18}; - alpha = 1; - condition = "on"; - class PlaneMovementCrosshair - { - type = "line"; - width = 7; - points[] = {{ "ForwardVec1",1,"Velocity",1,{ 0,-0.02 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.01,-0.01732 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.01732,-0.01 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.02,0 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.01732,0.01 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.01,0.01732 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0,0.02 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.01,0.01732 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.01732,0.01 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.02,0 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.01732,-0.01 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.01,-0.01732 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0,-0.02 },1 },{ },{ "ForwardVec1",1,"Velocity",1,{ 0.04,0 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.02,0 },1 },{ },{ "ForwardVec1",1,"Velocity",1,{ -0.04,0 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.02,0 },1 },{ },{ "ForwardVec1",1,"Velocity",1,{ 0,-0.04 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0,-0.02 },1 }}; - }; - class Gunner_AIM - { - type = "group"; - class Circle - { - type = "line"; - width = 6; - points[] = {{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.015 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.03 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.0325 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.0475 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.015 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.03 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.0325 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.0475 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ -0.015,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.03,0 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ -0.0325,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.0475,0 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0.015,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.03,0 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0.0325,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.0475,0 },1 }}; - }; - }; - class GunCross - { - condition = "mgun"; - class Circle - { - type = "line"; - width = 9; - points[] = {{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.05 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.015 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.015 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.05 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ -0.05,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.015,0 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0.015,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.05,0 },1 },{ }}; - }; - }; - class RocketCross - { - condition = "rocket"; - width = 6; - class Circle - { - type = "line"; - width = 6; - points[] = {{ "ForwardVec",1,"WeaponAim",1,{ -0.05,-0.08 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.05,-0.08 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.08 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.08 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ -0.05,0.08 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.05,0.08 },1 },{ }}; - }; - }; - class AT_Aim - { - condition = "ATmissile"; - width = 2; - class Circle - { - type = "line"; - width = 2; - points[] = {{ "ForwardVec",1,"WeaponAim",1,{ -0.1,-0.1 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.1,-0.1 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.1,0.1 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.1,0.1 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.1,-0.1 },1 }}; - }; - }; - class AA_aim - { - condition = "AAmissile"; - class Circle - { - type = "line"; - width = 2.5; - points[] = {{ "ForwardVec",1,"WeaponAim",1,{ "0 / 4","-0.248559 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0434 / 4","-0.244781 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0855 / 4","-0.233571 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.125 / 4","-0.215252 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1607 / 4","-0.190396 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1915 / 4","-0.159774 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2165 / 4","-0.12428 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.234925 / 4","-0.0850072 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2462 / 4","-0.0431499 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.25 / 4","0 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2462 / 4","0.0431499 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.234925 / 4","0.0850072 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2165 / 4","0.12428 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1915 / 4","0.159774 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1607 / 4","0.190396 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.125 / 4","0.215252 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0855 / 4","0.233571 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0434 / 4","0.244781 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 4","0.248559 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0434 / 4","0.244781 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0855 / 4","0.233571 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.125 / 4","0.215252 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1607 / 4","0.190396 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1915 / 4","0.159774 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2165 / 4","0.12428 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.234925 / 4","0.0850072 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2462 / 4","0.0431499 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.25 / 4","0 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2462 / 4","-0.0431499 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.234925 / 4","-0.0850072 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2165 / 4","-0.12428 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1915 / 4","-0.159774 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1607 / 4","-0.190396 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.125 / 4","-0.215252 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0855 / 4","-0.233571 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0434 / 4","-0.244781 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 4","-0.248559 / 4" },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 2","-0.248559 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0434 / 2","-0.244781 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0855 / 2","-0.233571 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.125 / 2","-0.215252 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1607 / 2","-0.190396 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1915 / 2","-0.159774 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2165 / 2","-0.12428 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.234925 / 2","-0.0850072 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2462 / 2","-0.0431499 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.25 / 2","0 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2462 / 2","0.0431499 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.234925 / 2","0.0850072 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2165 / 2","0.12428 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1915 / 2","0.159774 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1607 / 2","0.190396 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.125 / 2","0.215252 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0855 / 2","0.233571 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0434 / 2","0.244781 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 2","0.248559 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0434 / 2","0.244781 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0855 / 2","0.233571 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.125 / 2","0.215252 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1607 / 2","0.190396 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1915 / 2","0.159774 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2165 / 2","0.12428 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.234925 / 2","0.0850072 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2462 / 2","0.0431499 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.25 / 2","0 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2462 / 2","-0.0431499 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.234925 / 2","-0.0850072 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2165 / 2","-0.12428 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1915 / 2","-0.159774 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1607 / 2","-0.190396 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.125 / 2","-0.215252 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0855 / 2","-0.233571 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0434 / 2","-0.244781 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 2","-0.248559 / 2" },1 }}; - }; - }; - class TargetACQ - { - type = "line"; - width = 2; - points[] = {{ "ForwardVec",1,"target",{ 0,-0.06 },1 },{ "ForwardVec",1,"target",{ 0,-0.055 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.05 },1 },{ "ForwardVec",1,"target",{ 0,-0.045 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.04 },1 },{ "ForwardVec",1,"target",{ 0,-0.035 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.03 },1 },{ "ForwardVec",1,"target",{ 0,-0.025 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.02 },1 },{ "ForwardVec",1,"target",{ 0,-0.015 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.01 },1 },{ "ForwardVec",1,"target",{ 0,-0.005 },1 },{ },{ "ForwardVec",1,"target",{ 0,0 },1 },{ "ForwardVec",1,"target",{ 0,0 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.06 },1 },{ "ForwardVec",1,"target",{ 0,0.055 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.05 },1 },{ "ForwardVec",1,"target",{ 0,0.045 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.04 },1 },{ "ForwardVec",1,"target",{ 0,0.035 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.03 },1 },{ "ForwardVec",1,"target",{ 0,0.025 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.02 },1 },{ "ForwardVec",1,"target",{ 0,0.015 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.01 },1 },{ "ForwardVec",1,"target",{ 0,0.005 },1 },{ },{ "ForwardVec",1,"target",{ -0.06,0 },1 },{ "ForwardVec",1,"target",{ -0.055,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.05,0 },1 },{ "ForwardVec",1,"target",{ -0.045,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.04,0 },1 },{ "ForwardVec",1,"target",{ -0.035,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.03,0 },1 },{ "ForwardVec",1,"target",{ -0.025,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.02,0 },1 },{ "ForwardVec",1,"target",{ -0.015,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.01,0 },1 },{ "ForwardVec",1,"target",{ -0.005,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.06,0 },1 },{ "ForwardVec",1,"target",{ 0.055,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.05,0 },1 },{ "ForwardVec",1,"target",{ 0.045,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.04,0 },1 },{ "ForwardVec",1,"target",{ 0.035,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.03,0 },1 },{ "ForwardVec",1,"target",{ 0.025,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.02,0 },1 },{ "ForwardVec",1,"target",{ 0.015,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.01,0 },1 },{ "ForwardVec",1,"target",{ 0.005,0 },1 },{ }}; - }; - class RadarTargets - { - type = "radar"; - pos0[] = {0.5,0.5}; - pos10[] = {0.753,0.753}; - width = 2.5; - points[] = {{ "ForwardVec",1,"RadarContact",{ -0.01,-0.01 },1 },{ "ForwardVec",1,"RadarContact",{ 0.01,-0.01 },1 },{ "ForwardVec",1,"RadarContact",{ 0.01,0.01 },1 },{ "ForwardVec",1,"RadarContact",{ -0.01,0.01 },1 },{ "ForwardVec",1,"RadarContact",{ -0.01,-0.01 },1 }}; - }; - }; - helmetMountedDisplay = 1; - helmetPosition[] = {-0.035,0.035,0.1}; - helmetRight[] = {0.07,0,0}; - helmetDown[] = {0,-0.07,0}; - }; - }; - - class Turrets: Turrets { - class MainTurret: MainTurret { - weapons[] = {"ACE_gatling_20mm_Comanche","missiles_DAGR","missiles_ASRAAM", "ACE_AIR_SAFETY"}; - magazines[] = {"ACE_500Rnd_20mm_shells_Comanche","4Rnd_AAA_missiles","24Rnd_PG_missiles"}; - - outGunnerMayFire = 1; - commanding = -1; - primaryGunner = 1; - gunnerOpticsModel = ""; - gunnerOpticsEffect[] = {"TankCommanderOptics1"}; - gunnerForceOptics = 0; - turretInfoType = "Rsc_ACE_Helo_UI_Turret"; - showAllTargets = 2; - discretedistance[] = {100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000}; - discretedistanceinitindex = 3; - copilotHasFlares = 1; - directionStabilized = 1; - isCopilot = 1; - showHMD = 1; - CanEject = 1; - startEngine = 0; - minElev = -51; - maxElev = 9; - initElev = 6; - minTurn = -120; - maxTurn = 120; - initTurn = 0; - - class OpticsIn - { - delete Narrow; - delete Medium; - delete Wide; - - class ACE_WideUnstabilized { - opticsDisplayName = "W NS"; - initAngleX = 0; - minAngleX = -35; - maxAngleX = 10; - initAngleY = 0; - minAngleY = -100; - maxAngleY = 100; - initFov = 0.466; - minFov = 0.466; - maxFov = 0.466; - visionMode[] = {"Normal","Ti"}; - thermalMode[] = {0,1}; - gunnerOpticsColor[] = {0,0,0,1}; - directionStabilized = 0; - horizontallyStabilized = 1; - gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_wide_F"; - }; - class ACE_Wide: ACE_WideUnstabilized { - opticsDisplayName = "W"; - initAngleX = 0; - minAngleX = -35; - maxAngleX = 10; - initAngleY = 0; - minAngleY = -100; - maxAngleY = 100; - initFov = 0.466; - minFov = 0.466; - maxFov = 0.466; - visionMode[] = {"Normal","Ti"}; - thermalMode[] = {0,1}; - gunnerOpticsColor[] = {0,0,0,1}; - directionStabilized = 1; - horizontallyStabilized = 1; - gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_wide_F"; - }; - class ACE_Medium: ACE_Wide { - opticsDisplayName = "M"; - initFov = 0.093; - minFov = 0.093; - maxFov = 0.093; - gunnerOpticsColor[] = {0,0,0,1}; - directionStabilized = 1; - horizontallyStabilized = 1; - gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_medium_F"; - }; - class ACE_Narrow: ACE_Wide { - opticsDisplayName = "N"; - initFov = 0.029; - minFov = 0.029; - maxFov = 0.029; - gunnerOpticsColor[] = {0,0,0,1}; - directionStabilized = 1; - horizontallyStabilized = 1; - gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_narrow_F"; - - }; - class ACE_Narrower: ACE_Wide { - opticsDisplayName = "Z"; - initFov = 0.01; - minFov = 0.01; - maxFov = 0.01; - gunnerOpticsColor[] = {0,0,0,1}; - directionStabilized = 1; - horizontallyStabilized = 1; - gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_narrow_F"; - - }; - }; - class OpticsOut - { - class Monocular - { - initAngleX = 0; - minAngleX = -30; - maxAngleX = 30; - initAngleY = 0; - minAngleY = -100; - maxAngleY = 100; - initFov = 1.1; - minFov = 0.133; - maxFov = 1.1; - visionMode[] = {"Normal","NVG"}; - gunnerOpticsModel = ""; - gunnerOpticsEffect[] = {}; - hideUnitInfo = 1; - }; - }; - }; - }; - - class AnimationSources: AnimationSources { - class Gatling { - weapon = "ACE_gatling_20mm_Comanche"; - }; - class Muzzle_flash { - weapon = "ACE_gatling_20mm_Comanche"; - }; - }; -}; +class Heli_Attack_01_base_F: Helicopter_Base_F { + lockDetectionSystem = 12; + incomingMissileDetectionSystem = 16; + driverCanEject = 1; + + class MFD + { + class AirplaneHUD + { + class Bones{}; + class Draw{}; + topLeft = "HUD_top_left"; + topRight = "HUD_top_right"; + bottomLeft = "HUD_bottom_left"; + borderLeft = 0; + borderRight = 0; + borderTop = 0; + borderBottom = 0; + color[] = {0.15,1,0.15,1}; + enableParallax = 0; + helmetMountedDisplay = 1; + helmetPosition[] = {0,0,0}; + helmetRight[] = {0,0,0}; + helmetDown[] = {0,0,0}; + }; + class ACE_HUD_1 + { + topLeft = "HUD_top_left"; + topRight = "HUD_top_right"; + bottomLeft = "HUD_bottom_left"; + borderLeft = 0; + borderRight = 0; + borderTop = 0; + borderBottom = 0; + color[] = {0.15,1,0.15,1}; + enableParallax = 0; + class Bones + { + class GunnerAim + { + type = "vector"; + source = "weapon"; + pos0[] = {0.5,"0.9 - 0.04 + 0.012"}; + pos10[] = {"0.5 + 0.0111","0.9 - 0.04 + 0.012 + 0.0133"}; + }; + class Target + { + source = "target"; + type = "vector"; + pos0[] = {0.5,0.5}; + pos10[] = {0.85,0.85}; + }; + class Velocity + { + type = "vector"; + source = "velocity"; + pos0[] = {0.5,0.5}; + pos10[] = {0.65,0.65}; + }; + class Velocity_slip + { + type = "vector"; + source = "velocity"; + pos0[] = {0.5,0.845}; + pos10[] = {0.53,0.845}; + }; + class VspeedBone + { + type = "linear"; + source = "vspeed"; + sourceScale = 1; + min = -10; + max = 10; + minPos[] = {0.93,0.2}; + maxPos[] = {0.93,0.8}; + }; + class RadarAltitudeBone + { + type = "linear"; + source = "altitudeAGL"; + sourceScale = 1; + min = 0; + max = 60; + minPos[] = {0.965,0.2}; + maxPos[] = {0.965,0.8}; + }; + class HorizonBankRot + { + type = "rotational"; + source = "horizonBank"; + center[] = {0.5,0.5}; + min = -3.1416; + max = 3.1416; + minAngle = -180; + maxAngle = 180; + aspectRatio = 1; + }; + class ForwardVec + { + type = "vector"; + source = "forward"; + pos0[] = {0,0}; + pos10[] = {0.25,0.25}; + }; + class WeaponAim + { + type = "vector"; + source = "weapon"; + pos0[] = {0.5,0.5}; + pos10[] = {0.75,0.75}; + }; + class Level0 + { + type = "horizon"; + pos0[] = {0.5,0.5}; + pos10[] = {0.78,0.78}; + angle = 0; + }; + class LevelP5: Level0 + { + angle = 5; + }; + class LevelM5: Level0 + { + angle = -5; + }; + class LevelP10: Level0 + { + angle = 10; + }; + class LevelM10: Level0 + { + angle = -10; + }; + class LevelP15: Level0 + { + angle = 15; + }; + class LevelM15: Level0 + { + angle = -15; + }; + class LevelP20: Level0 + { + angle = 20; + }; + class LevelM20: Level0 + { + angle = -20; + }; + class LevelP25: Level0 + { + angle = 25; + }; + class LevelM25: Level0 + { + angle = -25; + }; + class LevelP30: Level0 + { + angle = 30; + }; + class LevelM30: Level0 + { + angle = -30; + }; + class LevelP35: Level0 + { + angle = 35; + }; + class LevelM35: Level0 + { + angle = -35; + }; + class LevelP40: Level0 + { + angle = 40; + }; + class LevelM40: Level0 + { + angle = -40; + }; + class LevelP45: Level0 + { + angle = 45; + }; + class LevelM45: Level0 + { + angle = -45; + }; + class LevelP50: Level0 + { + angle = 50; + }; + class LevelM50: Level0 + { + angle = -50; + }; + }; + class Draw + { + color[] = {0.18,1,0.18}; + alpha = 1; + condition = "on"; + class Horizont + { + clipTL[] = {0.15,0.15}; + clipBR[] = {0.85,0.85}; + class Dimmed + { + class Level0 + { + type = "line"; + points[] = {{ "Level0",{ -0.42,0 },1 },{ "Level0",{ -0.38,0 },1 },{ },{ "Level0",{ -0.37,0 },1 },{ "Level0",{ -0.33,0 },1 },{ },{ "Level0",{ -0.32,0 },1 },{ "Level0",{ -0.28,0 },1 },{ },{ "Level0",{ -0.27,0 },1 },{ "Level0",{ -0.23,0 },1 },{ },{ "Level0",{ -0.22,0 },1 },{ "Level0",{ -0.18,0 },1 },{ },{ "Level0",{ -0.17,0 },1 },{ "Level0",{ -0.13,0 },1 },{ },{ "Level0",{ -0.12,0 },1 },{ "Level0",{ -0.08,0 },1 },{ },{ "Level0",{ 0.42,0 },1 },{ "Level0",{ 0.38,0 },1 },{ },{ "Level0",{ 0.37,0 },1 },{ "Level0",{ 0.33,0 },1 },{ },{ "Level0",{ 0.32,0 },1 },{ "Level0",{ 0.28,0 },1 },{ },{ "Level0",{ 0.27,0 },1 },{ "Level0",{ 0.23,0 },1 },{ },{ "Level0",{ 0.22,0 },1 },{ "Level0",{ 0.18,0 },1 },{ },{ "Level0",{ 0.17,0 },1 },{ "Level0",{ 0.13,0 },1 },{ },{ "Level0",{ 0.12,0 },1 },{ "Level0",{ 0.08,0 },1 }}; + }; + }; + }; + class HorizonBankRot + { + type = "line"; + width = 3; + points[] = {{ "HorizonBankRot",{ 0,0.25 },1 },{ "HorizonBankRot",{ -0.01,0.23 },1 },{ "HorizonBankRot",{ 0.01,0.23 },1 },{ "HorizonBankRot",{ 0,0.25 },1 }}; + }; + class Static_HAD_BOX + { + clipTL[] = {0,1}; + clipBR[] = {1,0}; + type = "line"; + width = 5; + points[] = {{ { "0.5-0.1","0.9-0.04" },1 },{ { "0.5-0.1","0.9+0.04" },1 },{ { "0.5+0.1","0.9+0.04" },1 },{ { "0.5+0.1","0.9-0.04" },1 },{ { "0.5-0.1","0.9-0.04" },1 },{ },{ { "0.5-0.1","0.9-0.04+0.012" },1 },{ { "0.5-0.092","0.9-0.04+0.012" },1 },{ },{ { "0.5+0.1","0.9-0.04+0.012" },1 },{ { "0.5+0.092","0.9-0.04+0.012" },1 },{ },{ { 0.5,"0.9-0.04" },1 },{ { 0.5,"0.9-0.032" },1 },{ },{ { 0.5,"0.9+0.04" },1 },{ { 0.5,"0.9+0.032" },1 },{ }}; + }; + class Gunner_HAD + { + type = "line"; + width = 6; + points[] = {{ "GunnerAim",{ -0.015,-0.008 },1 },{ "GunnerAim",{ -0.015,0.008 },1 },{ "GunnerAim",{ 0.015,0.008 },1 },{ "GunnerAim",{ 0.015,-0.008 },1 },{ "GunnerAim",{ -0.015,-0.008 },1 }}; + }; + class Slip_ball_group + { + class Slip_bars + { + type = "line"; + width = 4; + points[] = {{ { "0.5-0.018","0.9-0.04" },1 },{ { "0.5-0.018","0.9-0.075" },1 },{ },{ { "0.5+0.018","0.9-0.04" },1 },{ { "0.5+0.018","0.9-0.075" },1 }}; + }; + class Slip_ball + { + type = "line"; + width = 6; + points[] = {{ "Velocity_slip",1,{ "0 * 0.75","-0.02 * 0.75" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.75","-0.01732 * 0.75" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.75","-0.0099999998 * 0.75" },1 },{ "Velocity_slip",1,{ "0.02 * 0.75","0 * 0.75" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.75","0.0099999998 * 0.75" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.75","0.01732 * 0.75" },1 },{ "Velocity_slip",1,{ "0 * 0.75","0.02 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.75","0.01732 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.75","0.0099999998 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.75","0 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.75","-0.0099999998 * 0.75" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.75","-0.01732 * 0.75" },1 },{ "Velocity_slip",1,{ "0 * 0.75","-0.02 * 0.75" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.6","-0.02 * 0.6" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.6","-0.01732 * 0.6" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.6","-0.0099999998 * 0.6" },1 },{ "Velocity_slip",1,{ "0.02 * 0.6","0 * 0.6" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.6","0.0099999998 * 0.6" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.6","0.01732 * 0.6" },1 },{ "Velocity_slip",1,{ "0 * 0.6","0.02 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.6","0.01732 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.6","0.0099999998 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.6","0 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.6","-0.0099999998 * 0.6" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.6","-0.01732 * 0.6" },1 },{ "Velocity_slip",1,{ "0 * 0.6","-0.02 * 0.6" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.5","-0.02 * 0.5" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.5","-0.01732 * 0.5" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.5","-0.0099999998 * 0.5" },1 },{ "Velocity_slip",1,{ "0.02 * 0.5","0 * 0.5" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.5","0.0099999998 * 0.5" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.5","0.01732 * 0.5" },1 },{ "Velocity_slip",1,{ "0 * 0.5","0.02 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.5","0.01732 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.5","0.0099999998 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.5","0 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.5","-0.0099999998 * 0.5" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.5","-0.01732 * 0.5" },1 },{ "Velocity_slip",1,{ "0 * 0.5","-0.02 * 0.5" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.4","-0.02 * 0.4" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.4","-0.01732 * 0.4" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.4","-0.0099999998 * 0.4" },1 },{ "Velocity_slip",1,{ "0.02 * 0.4","0 * 0.4" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.4","0.0099999998 * 0.4" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.4","0.01732 * 0.4" },1 },{ "Velocity_slip",1,{ "0 * 0.4","0.02 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.4","0.01732 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.4","0.0099999998 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.4","0 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.4","-0.0099999998 * 0.4" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.4","-0.01732 * 0.4" },1 },{ "Velocity_slip",1,{ "0 * 0.4","-0.02 * 0.4" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.30","-0.02 * 0.30" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.30","-0.01732 * 0.30" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.30","-0.0099999998 * 0.30" },1 },{ "Velocity_slip",1,{ "0.02 * 0.30","0 * 0.30" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.30","0.0099999998 * 0.30" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.30","0.01732 * 0.30" },1 },{ "Velocity_slip",1,{ "0 * 0.30","0.02 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.30","0.01732 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.30","0.0099999998 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.30","0 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.30","-0.0099999998 * 0.30" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.30","-0.01732 * 0.30" },1 },{ "Velocity_slip",1,{ "0 * 0.30","-0.02 * 0.30" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.20","-0.02 * 0.20" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.20","-0.01732 * 0.20" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.20","-0.0099999998 * 0.20" },1 },{ "Velocity_slip",1,{ "0.02 * 0.20","0 * 0.20" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.20","0.0099999998 * 0.20" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.20","0.01732 * 0.20" },1 },{ "Velocity_slip",1,{ "0 * 0.20","0.02 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.20","0.01732 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.20","0.0099999998 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.20","0 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.20","-0.0099999998 * 0.20" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.20","-0.01732 * 0.20" },1 },{ "Velocity_slip",1,{ "0 * 0.20","-0.02 * 0.20" },1 },{ },{ "Velocity_slip",1,{ "0 * 0.1","-0.02 * 0.1" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.1","-0.01732 * 0.1" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.1","-0.0099999998 * 0.1" },1 },{ "Velocity_slip",1,{ "0.02 * 0.1","0 * 0.1" },1 },{ "Velocity_slip",1,{ "0.01732 * 0.1","0.0099999998 * 0.1" },1 },{ "Velocity_slip",1,{ "0.0099999998 * 0.1","0.01732 * 0.1" },1 },{ "Velocity_slip",1,{ "0 * 0.1","0.02 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.1","0.01732 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.1","0.0099999998 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.02 * 0.1","0 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.01732 * 0.1","-0.0099999998 * 0.1" },1 },{ "Velocity_slip",1,{ "-0.0099999998 * 0.1","-0.01732 * 0.1" },1 },{ "Velocity_slip",1,{ "0 * 0.1","-0.02 * 0.1" },1 }}; + }; + }; + class Centerline + { + type = "line"; + width = 5; + points[] = {{ { 0.5,0.48 },1 },{ { 0.5,0.45 },1 },{ },{ { 0.5,0.52 },1 },{ { 0.5,0.55 },1 },{ },{ { 0.48,0.5 },1 },{ { 0.45,0.5 },1 },{ },{ { 0.52,0.5 },1 },{ { 0.55,0.5 },1 },{ }}; + }; + class WeaponName + { + type = "text"; + source = "weapon"; + sourceScale = 1; + align = "right"; + scale = 1; + pos[] = {{ 0.61,0.86 },1}; + right[] = {{ 0.65,0.86 },1}; + down[] = {{ 0.61,0.9 },1}; + }; + class Ammo_GUN + { + type = "group"; + condition = "mgun"; + class Ammo_count_GUN + { + type = "text"; + source = "ammo"; + sourceScale = 1; + align = "right"; + scale = 1; + pos[] = {{ 0.61,0.89 },1}; + right[] = {{ 0.65,0.89 },1}; + down[] = {{ 0.61,0.93 },1}; + }; + }; + class Ammo_RKT + { + type = "group"; + condition = "rocket"; + class Ammo_count_RKT + { + type = "text"; + source = "ammo"; + sourceScale = 1; + align = "right"; + scale = 1; + pos[] = {{ 0.61,0.89 },1}; + right[] = {{ 0.65,0.89 },1}; + down[] = {{ 0.61,0.93 },1}; + }; + }; + class Ammo_AGM + { + type = "group"; + condition = "AAmissile"; + class Ammo_count_AGM + { + type = "text"; + source = "ammo"; + sourceScale = 1; + align = "right"; + scale = 1; + pos[] = {{ 0.61,0.89 },1}; + right[] = {{ 0.65,0.89 },1}; + down[] = {{ 0.61,0.93 },1}; + }; + }; + class Ammo_AAM + { + type = "group"; + condition = "ATmissile"; + class Ammo_count_AAM + { + type = "text"; + source = "ammo"; + sourceScale = 1; + align = "right"; + scale = 1; + pos[] = {{ 0.61,0.89 },1}; + right[] = {{ 0.65,0.89 },1}; + down[] = {{ 0.61,0.93 },1}; + }; + }; + class Ammo_Bomb + { + type = "group"; + condition = "Bomb"; + class Ammo_count_Bomb + { + type = "text"; + source = "ammo"; + sourceScale = 1; + align = "right"; + scale = 1; + pos[] = {{ 0.61,0.89 },1}; + right[] = {{ 0.65,0.89 },1}; + down[] = {{ 0.61,0.93 },1}; + }; + }; + class LightsGroup + { + type = "group"; + condition = "lights"; + class LightsText + { + type = "text"; + source = "static"; + text = "LIGHTS"; + align = "right"; + scale = 1; + pos[] = {{ 0.03,"0.53 + 0.055" },1}; + right[] = {{ 0.07,"0.53 + 0.055" },1}; + down[] = {{ 0.03,"0.53 + 0.095" },1}; + }; + }; + class CollisionLightsGroup + { + type = "group"; + condition = "collisionlights"; + class CollisionLightsText + { + type = "text"; + source = "static"; + text = "A-COL"; + align = "right"; + scale = 1; + pos[] = {{ 0.03,"0.53 + 0.105" },1}; + right[] = {{ 0.07,"0.53 + 0.105" },1}; + down[] = {{ 0.03,"0.53 + 0.145" },1}; + }; + }; + class GearGroup + { + type = "group"; + condition = "ils"; + class GearText + { + type = "text"; + source = "static"; + text = "GEAR"; + align = "right"; + scale = 1; + pos[] = {{ 0.03,"0.53 + 0.155" },1}; + right[] = {{ 0.07,"0.53 + 0.155" },1}; + down[] = {{ 0.03,"0.53 + 0.195" },1}; + }; + }; + class ATMissileTOFGroup + { + condition = "ATmissile"; + type = "group"; + class TOFtext + { + type = "text"; + align = "right"; + source = "static"; + text = "TOF="; + scale = 1; + pos[] = {{ 0.61,0.92 },1}; + right[] = {{ 0.65,0.92 },1}; + down[] = {{ 0.61,0.96 },1}; + }; + class TOFnumber + { + type = "text"; + source = "targetDist"; + sourcescale = 0.0025; + align = "right"; + scale = 1; + pos[] = {{ 0.69,0.92 },1}; + right[] = {{ 0.73,0.92 },1}; + down[] = {{ 0.69,0.96 },1}; + }; + }; + class LaserTOFGroup + { + condition = "Bomb"; + type = "group"; + class TOFtext + { + type = "text"; + align = "right"; + source = "static"; + text = "TOF="; + scale = 1; + pos[] = {{ 0.61,0.92 },1}; + right[] = {{ 0.65,0.92 },1}; + down[] = {{ 0.61,0.96 },1}; + }; + class TOFnumber + { + type = "text"; + source = "targetDist"; + sourcescale = 0.0025; + align = "right"; + scale = 1; + pos[] = {{ 0.69,0.92 },1}; + right[] = {{ 0.73,0.92 },1}; + down[] = {{ 0.69,0.96 },1}; + }; + }; + class RocketTOFGroup + { + condition = "Rocket"; + type = "group"; + class TOFtext + { + type = "text"; + align = "right"; + source = "static"; + text = "TOF="; + scale = 1; + pos[] = {{ 0.61,0.92 },1}; + right[] = {{ 0.65,0.92 },1}; + down[] = {{ 0.61,0.96 },1}; + }; + class TOFnumber + { + type = "text"; + source = "targetDist"; + sourcescale = 0.0025; + align = "right"; + scale = 1; + pos[] = {{ 0.69,0.92 },1}; + right[] = {{ 0.73,0.92 },1}; + down[] = {{ 0.69,0.96 },1}; + }; + }; + class RangeNumber + { + type = "text"; + source = "targetDist"; + sourceScale = 1; + align = "left"; + scale = 1; + pos[] = {{ 0.39,0.89 },1}; + right[] = {{ 0.43,0.89 },1}; + down[] = {{ 0.39,0.93 },1}; + }; + class RangeText + { + type = "text"; + source = "static"; + text = "RNG"; + align = "left"; + scale = 1; + pos[] = {{ 0.39,0.86 },1}; + right[] = {{ 0.43,0.86 },1}; + down[] = {{ 0.39,0.9 },1}; + }; + class SpeedNumber + { + type = "text"; + align = "right"; + scale = 1; + source = "speed"; + sourceScale = 3.6; + pos[] = {{ 0.03,0.475 },1}; + right[] = {{ 0.08,0.475 },1}; + down[] = {{ 0.03,0.525 },1}; + }; + class TorqueNumber + { + condition = "simulRTD"; + class Torque_number + { + type = "text"; + align = "left"; + scale = 1; + source = "rtdRotorTorque"; + sourceScale = 290; + pos[] = {{ 0.065,0.175 },1}; + right[] = {{ 0.115,0.175 },1}; + down[] = {{ 0.065,0.225 },1}; + }; + class Torquetext + { + type = "text"; + source = "static"; + text = "%"; + align = "right"; + scale = 1; + pos[] = {{ 0.07,0.175 },1}; + right[] = {{ 0.12,0.175 },1}; + down[] = {{ 0.07,0.225 },1}; + }; + }; + class AltNumber: SpeedNumber + { + align = "right"; + source = "altitudeAGL"; + sourceScale = 1; + pos[] = {{ 0.83,0.475 },1}; + right[] = {{ 0.88,0.475 },1}; + down[] = {{ 0.83,0.525 },1}; + }; + class ASLNumber + { + type = "text"; + source = "altitudeASL"; + sourceScale = 1; + align = "right"; + scale = 1; + pos[] = {{ 0.835,0.18 },1}; + right[] = {{ 0.875,0.18 },1}; + down[] = {{ 0.835,0.22 },1}; + }; + class VspeedScalePosta + { + type = "line"; + width = 5; + points[] = {{ { 0.98,0.2 },1 },{ { 1,0.2 },1 },{ },{ { 0.93,0.2 },1 },{ { 0.95,0.2 },1 },{ },{ { 0.98,0.35 },1 },{ { 1,0.35 },1 },{ },{ { 0.93,0.35 },1 },{ { 0.95,0.35 },1 },{ },{ { 0.94,0.38 },1 },{ { 0.95,0.38 },1 },{ },{ { 0.94,0.41 },1 },{ { 0.95,0.41 },1 },{ },{ { 0.94,0.44 },1 },{ { 0.95,0.44 },1 },{ },{ { 0.94,0.47 },1 },{ { 0.95,0.47 },1 },{ },{ { 0.98,0.5 },1 },{ { 1,0.5 },1 },{ },{ { 0.93,0.5 },1 },{ { 0.95,0.5 },1 },{ },{ { 0.94,0.53 },1 },{ { 0.95,0.53 },1 },{ },{ { 0.94,0.56 },1 },{ { 0.95,0.56 },1 },{ },{ { 0.94,0.59 },1 },{ { 0.95,0.59 },1 },{ },{ { 0.94,0.62 },1 },{ { 0.95,0.62 },1 },{ },{ { 0.98,0.65 },1 },{ { 1,0.65 },1 },{ },{ { 0.93,0.65 },1 },{ { 0.95,0.65 },1 },{ },{ { 0.99,0.68 },1 },{ { 0.98,0.68 },1 },{ },{ { 0.99,0.71 },1 },{ { 0.98,0.71 },1 },{ },{ { 0.99,0.74 },1 },{ { 0.98,0.74 },1 },{ },{ { 0.99,0.77 },1 },{ { 0.98,0.77 },1 },{ },{ { 0.98,0.8 },1 },{ { 1,0.8 },1 },{ },{ { 0.93,0.8 },1 },{ { 0.95,0.8 },1 },{ }}; + }; + class RadarAltitudeBand + { + clipTL[] = {0,0.2}; + clipBR[] = {1,0.8}; + hideValue = 201; + class radarbanda + { + type = "line"; + width = 17; + points[] = {{ "RadarAltitudeBone",{ 0,0 },1 },{ "RadarAltitudeBone",{ 0,0.6 },1 }}; + }; + }; + class VspeedBand + { + type = "line"; + width = 3; + points[] = {{ "VspeedBone",{ -0.01,0 },1 },{ "VspeedBone",{ -0.025,-0.015 },1 },{ "VspeedBone",{ -0.025,0.015 },1 },{ "VspeedBone",{ -0.01,0 },1 },{ }}; + }; + class HeadingNumber: SpeedNumber + { + source = "heading"; + sourceScale = 1; + align = "center"; + pos[] = {{ 0.5,0.045 },1}; + right[] = {{ 0.56,0.045 },1}; + down[] = {{ 0.5,"0.045 + 0.06" },1}; + }; + class Center_box + { + type = "line"; + width = 1.5; + points[] = {{ { 0.45,"0.02 + 0.085 - 0.06" },1 },{ { "0.45 + 0.10","0.02 + 0.085 - 0.06" },1 },{ { "0.45 + 0.10","0.02 + 0.085" },1 },{ { 0.45,"0.02 + 0.085" },1 },{ { 0.45,"0.02 + 0.085 - 0.06" },1 }}; + }; + class HeadingArrow + { + type = "line"; + width = 7; + points[] = {{ { "0.5","0.128 + 0.03" },1 },{ { 0.5,0.128 },1 }}; + }; + class HeadingScale_LEFT + { + clipTL[] = {0,0}; + clipBR[] = {0.45,1}; + class Heading_group + { + type = "scale"; + horizontal = 1; + source = "heading"; + sourceScale = 1; + width = 5; + top = 0.12; + center = 0.5; + bottom = 0.88; + lineXleft = "0.03 + 0.085"; + lineYright = "0.02 + 0.085"; + lineXleftMajor = "0.04 + 0.085"; + lineYrightMajor = "0.02 + 0.085"; + majorLineEach = 3; + numberEach = 3; + step = 10; + stepSize = "0.05"; + align = "center"; + scale = 1; + pos[] = {0.12,"0.0 + 0.065"}; + right[] = {0.16,"0.0 + 0.065"}; + down[] = {0.12,"0.04 + 0.065"}; + }; + }; + class HeadingScale_RIGHT + { + clipTL[] = {0.55,0}; + clipBR[] = {1,1}; + class Heading_group + { + type = "scale"; + horizontal = 1; + source = "heading"; + sourceScale = 1; + width = 5; + top = 0.12; + center = 0.5; + bottom = 0.88; + lineXleft = "0.03 + 0.085"; + lineYright = "0.02 + 0.085"; + lineXleftMajor = "0.04 + 0.085"; + lineYrightMajor = "0.02 + 0.085"; + majorLineEach = 3; + numberEach = 3; + step = 10; + stepSize = "0.05"; + align = "center"; + scale = 1; + pos[] = {0.12,"0.0 + 0.065"}; + right[] = {0.16,"0.0 + 0.065"}; + down[] = {0.12,"0.04 + 0.065"}; + }; + }; + class HeadingScale_BOTTOM + { + clipTL[] = {0.45,"0.02 + 0.085"}; + clipBR[] = {"0.45 + 0.10",1}; + class Heading_group + { + type = "scale"; + horizontal = 1; + source = "heading"; + sourceScale = 1; + width = 5; + top = 0.12; + center = 0.5; + bottom = 0.88; + lineXleft = "0.03 + 0.085"; + lineYright = "0.02 + 0.085"; + lineXleftMajor = "0.04 + 0.085"; + lineYrightMajor = "0.02 + 0.085"; + majorLineEach = 3; + numberEach = 3; + step = 10; + stepSize = "0.05"; + align = "center"; + scale = 1; + pos[] = {0.12,"0.0 + 0.065"}; + right[] = {0.16,"0.0 + 0.065"}; + down[] = {0.12,"0.04 + 0.065"}; + }; + }; + class Fuel_Text + { + type = "text"; + source = "static"; + text = "Fuel"; + align = "right"; + scale = 1; + pos[] = {{ 0.03,0.9 },1}; + right[] = {{ 0.07,0.9 },1}; + down[] = {{ 0.03,0.94 },1}; + }; + class Fuel_Number + { + type = "text"; + source = "fuel"; + sourceScale = 100; + align = "right"; + scale = 1; + pos[] = {{ 0.1,0.9 },1}; + right[] = {{ 0.14,0.9 },1}; + down[] = {{ 0.1,0.94 },1}; + }; + }; + helmetMountedDisplay = 1; + helmetPosition[] = {-0.04,0.04,0.1}; + helmetRight[] = {0.08,0,0}; + helmetDown[] = {0,-0.08,0}; + }; + class ACE_HUD_2 + { + topLeft = "HUD_top_left"; + topRight = "HUD_top_right"; + bottomLeft = "HUD_bottom_left"; + borderLeft = 0; + borderRight = 0; + borderTop = 0; + borderBottom = 0; + color[] = {0.15,1,0.15,1}; + enableParallax = 0; + class Bones + { + class Velocity + { + type = "vector"; + source = "velocity"; + pos0[] = {0.5,0.5}; + pos10[] = {0.75,0.75}; + }; + class ForwardVec1 + { + type = "vector"; + source = "forward"; + pos0[] = {0,0}; + pos10[] = {0.25,0.25}; + }; + class ForwardVec + { + type = "vector"; + source = "forward"; + pos0[] = {0,0}; + pos10[] = {0.253,0.253}; + }; + class WeaponAim + { + type = "vector"; + source = "weapon"; + pos0[] = {0.5,0.5}; + pos10[] = {0.753,0.753}; + }; + class WeaponAim1 + { + type = "vector"; + source = "weapon"; + pos0[] = {0,0}; + pos10[] = {0.253,0.23}; + }; + class Target + { + type = "vector"; + source = "target"; + pos0[] = {0.5,0.5}; + pos10[] = {0.753,0.753}; + }; + class RadarContact + { + type = "fixed"; + pos[] = {0,0}; + }; + }; + class Draw + { + color[] = {0.18,1,0.18}; + alpha = 1; + condition = "on"; + class PlaneMovementCrosshair + { + type = "line"; + width = 7; + points[] = {{ "ForwardVec1",1,"Velocity",1,{ 0,-0.02 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.01,-0.01732 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.01732,-0.01 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.02,0 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.01732,0.01 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.01,0.01732 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0,0.02 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.01,0.01732 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.01732,0.01 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.02,0 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.01732,-0.01 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.01,-0.01732 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0,-0.02 },1 },{ },{ "ForwardVec1",1,"Velocity",1,{ 0.04,0 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0.02,0 },1 },{ },{ "ForwardVec1",1,"Velocity",1,{ -0.04,0 },1 },{ "ForwardVec1",1,"Velocity",1,{ -0.02,0 },1 },{ },{ "ForwardVec1",1,"Velocity",1,{ 0,-0.04 },1 },{ "ForwardVec1",1,"Velocity",1,{ 0,-0.02 },1 }}; + }; + class Gunner_AIM + { + type = "group"; + class Circle + { + type = "line"; + width = 6; + points[] = {{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.015 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.03 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.0325 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.0475 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.015 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.03 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.0325 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.0475 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ -0.015,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.03,0 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ -0.0325,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.0475,0 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0.015,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.03,0 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0.0325,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.0475,0 },1 }}; + }; + }; + class GunCross + { + condition = "mgun"; + class Circle + { + type = "line"; + width = 9; + points[] = {{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.05 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.015 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.015 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.05 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ -0.05,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.015,0 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0.015,0 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.05,0 },1 },{ }}; + }; + }; + class RocketCross + { + condition = "rocket"; + width = 6; + class Circle + { + type = "line"; + width = 6; + points[] = {{ "ForwardVec",1,"WeaponAim",1,{ -0.05,-0.08 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.05,-0.08 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ 0,-0.08 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0,0.08 },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ -0.05,0.08 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.05,0.08 },1 },{ }}; + }; + }; + class AT_Aim + { + condition = "ATmissile"; + width = 2; + class Circle + { + type = "line"; + width = 2; + points[] = {{ "ForwardVec",1,"WeaponAim",1,{ -0.1,-0.1 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.1,-0.1 },1 },{ "ForwardVec",1,"WeaponAim",1,{ 0.1,0.1 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.1,0.1 },1 },{ "ForwardVec",1,"WeaponAim",1,{ -0.1,-0.1 },1 }}; + }; + }; + class AA_aim + { + condition = "AAmissile"; + class Circle + { + type = "line"; + width = 2.5; + points[] = {{ "ForwardVec",1,"WeaponAim",1,{ "0 / 4","-0.248559 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0434 / 4","-0.244781 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0855 / 4","-0.233571 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.125 / 4","-0.215252 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1607 / 4","-0.190396 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1915 / 4","-0.159774 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2165 / 4","-0.12428 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.234925 / 4","-0.0850072 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2462 / 4","-0.0431499 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.25 / 4","0 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2462 / 4","0.0431499 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.234925 / 4","0.0850072 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2165 / 4","0.12428 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1915 / 4","0.159774 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1607 / 4","0.190396 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.125 / 4","0.215252 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0855 / 4","0.233571 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0434 / 4","0.244781 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 4","0.248559 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0434 / 4","0.244781 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0855 / 4","0.233571 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.125 / 4","0.215252 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1607 / 4","0.190396 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1915 / 4","0.159774 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2165 / 4","0.12428 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.234925 / 4","0.0850072 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2462 / 4","0.0431499 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.25 / 4","0 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2462 / 4","-0.0431499 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.234925 / 4","-0.0850072 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2165 / 4","-0.12428 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1915 / 4","-0.159774 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1607 / 4","-0.190396 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.125 / 4","-0.215252 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0855 / 4","-0.233571 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0434 / 4","-0.244781 / 4" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 4","-0.248559 / 4" },1 },{ },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 2","-0.248559 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0434 / 2","-0.244781 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0855 / 2","-0.233571 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.125 / 2","-0.215252 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1607 / 2","-0.190396 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1915 / 2","-0.159774 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2165 / 2","-0.12428 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.234925 / 2","-0.0850072 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2462 / 2","-0.0431499 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.25 / 2","0 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2462 / 2","0.0431499 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.234925 / 2","0.0850072 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.2165 / 2","0.12428 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1915 / 2","0.159774 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.1607 / 2","0.190396 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.125 / 2","0.215252 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0855 / 2","0.233571 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0.0434 / 2","0.244781 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 2","0.248559 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0434 / 2","0.244781 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0855 / 2","0.233571 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.125 / 2","0.215252 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1607 / 2","0.190396 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1915 / 2","0.159774 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2165 / 2","0.12428 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.234925 / 2","0.0850072 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2462 / 2","0.0431499 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.25 / 2","0 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2462 / 2","-0.0431499 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.234925 / 2","-0.0850072 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.2165 / 2","-0.12428 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1915 / 2","-0.159774 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.1607 / 2","-0.190396 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.125 / 2","-0.215252 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0855 / 2","-0.233571 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "-0.0434 / 2","-0.244781 / 2" },1 },{ "ForwardVec",1,"WeaponAim",1,{ "0 / 2","-0.248559 / 2" },1 }}; + }; + }; + class TargetACQ + { + type = "line"; + width = 2; + points[] = {{ "ForwardVec",1,"target",{ 0,-0.06 },1 },{ "ForwardVec",1,"target",{ 0,-0.055 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.05 },1 },{ "ForwardVec",1,"target",{ 0,-0.045 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.04 },1 },{ "ForwardVec",1,"target",{ 0,-0.035 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.03 },1 },{ "ForwardVec",1,"target",{ 0,-0.025 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.02 },1 },{ "ForwardVec",1,"target",{ 0,-0.015 },1 },{ },{ "ForwardVec",1,"target",{ 0,-0.01 },1 },{ "ForwardVec",1,"target",{ 0,-0.005 },1 },{ },{ "ForwardVec",1,"target",{ 0,0 },1 },{ "ForwardVec",1,"target",{ 0,0 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.06 },1 },{ "ForwardVec",1,"target",{ 0,0.055 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.05 },1 },{ "ForwardVec",1,"target",{ 0,0.045 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.04 },1 },{ "ForwardVec",1,"target",{ 0,0.035 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.03 },1 },{ "ForwardVec",1,"target",{ 0,0.025 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.02 },1 },{ "ForwardVec",1,"target",{ 0,0.015 },1 },{ },{ "ForwardVec",1,"target",{ 0,0.01 },1 },{ "ForwardVec",1,"target",{ 0,0.005 },1 },{ },{ "ForwardVec",1,"target",{ -0.06,0 },1 },{ "ForwardVec",1,"target",{ -0.055,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.05,0 },1 },{ "ForwardVec",1,"target",{ -0.045,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.04,0 },1 },{ "ForwardVec",1,"target",{ -0.035,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.03,0 },1 },{ "ForwardVec",1,"target",{ -0.025,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.02,0 },1 },{ "ForwardVec",1,"target",{ -0.015,0 },1 },{ },{ "ForwardVec",1,"target",{ -0.01,0 },1 },{ "ForwardVec",1,"target",{ -0.005,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.06,0 },1 },{ "ForwardVec",1,"target",{ 0.055,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.05,0 },1 },{ "ForwardVec",1,"target",{ 0.045,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.04,0 },1 },{ "ForwardVec",1,"target",{ 0.035,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.03,0 },1 },{ "ForwardVec",1,"target",{ 0.025,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.02,0 },1 },{ "ForwardVec",1,"target",{ 0.015,0 },1 },{ },{ "ForwardVec",1,"target",{ 0.01,0 },1 },{ "ForwardVec",1,"target",{ 0.005,0 },1 },{ }}; + }; + class RadarTargets + { + type = "radar"; + pos0[] = {0.5,0.5}; + pos10[] = {0.753,0.753}; + width = 2.5; + points[] = {{ "ForwardVec",1,"RadarContact",{ -0.01,-0.01 },1 },{ "ForwardVec",1,"RadarContact",{ 0.01,-0.01 },1 },{ "ForwardVec",1,"RadarContact",{ 0.01,0.01 },1 },{ "ForwardVec",1,"RadarContact",{ -0.01,0.01 },1 },{ "ForwardVec",1,"RadarContact",{ -0.01,-0.01 },1 }}; + }; + }; + helmetMountedDisplay = 1; + helmetPosition[] = {-0.035,0.035,0.1}; + helmetRight[] = {0.07,0,0}; + helmetDown[] = {0,-0.07,0}; + }; + }; + + class Turrets: Turrets { + class MainTurret: MainTurret { + weapons[] = {"ACE_gatling_20mm_Comanche","missiles_DAGR","missiles_ASRAAM", "ACE_AIR_SAFETY"}; + magazines[] = {"ACE_500Rnd_20mm_shells_Comanche","4Rnd_AAA_missiles","24Rnd_PG_missiles"}; + + outGunnerMayFire = 1; + commanding = -1; + primaryGunner = 1; + gunnerOpticsModel = ""; + gunnerOpticsEffect[] = {"TankCommanderOptics1"}; + gunnerForceOptics = 0; + turretInfoType = "Rsc_ACE_Helo_UI_Turret"; + showAllTargets = 2; + discretedistance[] = {100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000}; + discretedistanceinitindex = 3; + copilotHasFlares = 1; + directionStabilized = 1; + isCopilot = 1; + showHMD = 1; + CanEject = 1; + startEngine = 0; + minElev = -51; + maxElev = 9; + initElev = 6; + minTurn = -120; + maxTurn = 120; + initTurn = 0; + + class OpticsIn + { + delete Narrow; + delete Medium; + delete Wide; + + class ACE_WideUnstabilized { + opticsDisplayName = "W NS"; + initAngleX = 0; + minAngleX = -35; + maxAngleX = 10; + initAngleY = 0; + minAngleY = -100; + maxAngleY = 100; + initFov = 0.466; + minFov = 0.466; + maxFov = 0.466; + visionMode[] = {"Normal","Ti"}; + thermalMode[] = {0,1}; + gunnerOpticsColor[] = {0,0,0,1}; + directionStabilized = 0; + horizontallyStabilized = 1; + gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_wide_F"; + }; + class ACE_Wide: ACE_WideUnstabilized { + opticsDisplayName = "W"; + initAngleX = 0; + minAngleX = -35; + maxAngleX = 10; + initAngleY = 0; + minAngleY = -100; + maxAngleY = 100; + initFov = 0.466; + minFov = 0.466; + maxFov = 0.466; + visionMode[] = {"Normal","Ti"}; + thermalMode[] = {0,1}; + gunnerOpticsColor[] = {0,0,0,1}; + directionStabilized = 1; + horizontallyStabilized = 1; + gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_wide_F"; + }; + class ACE_Medium: ACE_Wide { + opticsDisplayName = "M"; + initFov = 0.093; + minFov = 0.093; + maxFov = 0.093; + gunnerOpticsColor[] = {0,0,0,1}; + directionStabilized = 1; + horizontallyStabilized = 1; + gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_medium_F"; + }; + class ACE_Narrow: ACE_Wide { + opticsDisplayName = "N"; + initFov = 0.029; + minFov = 0.029; + maxFov = 0.029; + gunnerOpticsColor[] = {0,0,0,1}; + directionStabilized = 1; + horizontallyStabilized = 1; + gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_narrow_F"; + + }; + class ACE_Narrower: ACE_Wide { + opticsDisplayName = "Z"; + initFov = 0.01; + minFov = 0.01; + maxFov = 0.01; + gunnerOpticsColor[] = {0,0,0,1}; + directionStabilized = 1; + horizontallyStabilized = 1; + gunnerOpticsModel = "\A3\Weapons_F_Beta\Reticle\Heli_Attack_01_Optics_Gunner_narrow_F"; + + }; + }; + class OpticsOut + { + class Monocular + { + initAngleX = 0; + minAngleX = -30; + maxAngleX = 30; + initAngleY = 0; + minAngleY = -100; + maxAngleY = 100; + initFov = 1.1; + minFov = 0.133; + maxFov = 1.1; + visionMode[] = {"Normal","NVG"}; + gunnerOpticsModel = ""; + gunnerOpticsEffect[] = {}; + hideUnitInfo = 1; + }; + }; + }; + }; + + class AnimationSources: AnimationSources { + class Gatling { + weapon = "ACE_gatling_20mm_Comanche"; + }; + class Muzzle_flash { + weapon = "ACE_gatling_20mm_Comanche"; + }; + }; +}; diff --git a/addons/aircraft/RscInGameUI.hpp b/addons/aircraft/RscInGameUI.hpp index 620d895d9e..83d46b5a03 100644 --- a/addons/aircraft/RscInGameUI.hpp +++ b/addons/aircraft/RscInGameUI.hpp @@ -1,581 +1,581 @@ -class RscControlsGroup; -class RscText; -class RangeText: RscText{}; -class RscPicture; -class RscOpticsText; -class RscIGProgress; -class RscOpticsValue; -class VScrollbar; -class HScrollbar; -class RscLadderPicture; -class RscControlsGroupNoScrollbars; - - -class RscInGameUI -{ - class RscUnitInfo; - class Rsc_ACE_Helo_UI_Turret: RscUnitInfo - { - idd = 300; - controls[] = {"CA_IGUI_elements_group","CA_VehicleToggles"}; - class VScrollbar; - class HScrollbar; - class CA_IGUI_elements_group: RscControlsGroup - { - idc = 170; - class VScrollbar: VScrollbar - { - width = 0; - }; - class HScrollbar: HScrollbar - { - height = 0; - }; - x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; - y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; - w = "53.5 * (0.01875 * SafezoneH)"; - h = "40 * (0.025 * SafezoneH)"; - class controls - { - class CA_Distance: RscText - { - idc = 151; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - x = "24.78 * (0.01875 * SafezoneH)"; - y = "30.88 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class CA_Speed: RangeText - { - idc = 188; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "120"; - x = "14.78 * (0.01875 * SafezoneH)"; - y = "30.88 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class CA_Alt: RangeText - { - idc = 189; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "3825"; - x = "34.78 * (0.01875 * SafezoneH)"; - y = "30.88 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class CA_VisionMode: RscText - { - idc = 152; - style = 0; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "VIS"; - x = "12.58 * (0.01875 * SafezoneH)"; - y = "8 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class CA_FlirMode: RscText - { - idc = 153; - style = 0; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "BHOT"; - x = "15.78 * (0.01875 * SafezoneH)"; - y = "8 * (0.025 * SafezoneH)"; - w = "4.5 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class ValueGrid: RangeText - { - idc = 172; - font = "EtelkaMonospacePro"; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - x = "12.20 * (0.01875 * SafezoneH)"; - y = "3.5 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class TextTADS: RangeText - { - idc = 1010; - text = "TADS"; - font = "EtelkaMonospacePro"; - style = 2; - shadow = 0; - x = "12.30 * (0.01875 * SafezoneH)"; - y = "5 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class ValueTime: RangeText - { - idc = 190; - text = "20:28:35"; - font = "EtelkaMonospacePro"; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - x = "12.1 * (0.01875 * SafezoneH)"; - y = "6.5 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class CA_Laser: RscText - { - idc = 158; - style = "0x30 + 0x800"; - sizeEx = "0.038*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = PATHTOF(data\Helo_LaserON.paa); - x = "20.45 * (0.01875 * SafezoneH)"; - y = "14.1 * (0.025 * SafezoneH)"; - w = "12.5 * (0.01875 * SafezoneH)"; - h = "12 * (0.025 * SafezoneH)"; - }; - class CA_Heading: RscText - { - idc = 156; - style = 0; - sizeEx = "0.038*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "023"; - x = "24.83 * (0.01875 * SafezoneH)"; - y = "6 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - }; - }; - }; - class Rsc_ACE_Helo_UI_01: RscUnitInfo - { - controls[] = {"WeaponInfoControlsGroupRight","CA_TextFlaresMode","CA_TextFlares","CA_VehicleToggles","CA_Radar"}; - }; - class Rsc_ACE_Helo_UI_02: RscUnitInfo - { - controls[] = {"CA_TextFlaresMode","CA_TextFlares","CA_VehicleToggles","CA_Radar"}; - }; - class Rsc_ACE_Drones_UI_Turret: RscUnitInfo - { - idd = 300; - controls[] = {"CA_Zeroing","CA_IGUI_elements_group","CA_VehicleToggles"}; - class CA_IGUI_elements_group: RscControlsGroup - { - idc = 170; - class VScrollbar: VScrollbar - { - width = 0; - }; - class HScrollbar: HScrollbar - { - height = 0; - }; - x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; - y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; - w = "53.5 * (0.01875 * SafezoneH)"; - h = "40 * (0.025 * SafezoneH)"; - class controls - { - class CA_Distance: RscText - { - idc = 151; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - x = "24.78 * (0.01875 * SafezoneH)"; - y = "30.88 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class CA_Speed: RangeText - { - idc = 188; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "120"; - x = "14.78 * (0.01875 * SafezoneH)"; - y = "30.88 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class CA_Alt: RangeText - { - idc = 189; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "3825"; - x = "34.78 * (0.01875 * SafezoneH)"; - y = "30.88 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class ValueTime: RangeText - { - idc = 190; - text = "20:28:35"; - font = "EtelkaMonospacePro"; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - x = "1.75 * (0.01875 * SafezoneH)"; - y = "10.5 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class CA_VisionMode: RscText - { - idc = 152; - style = 0; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "VIS"; - align = "right"; - x = "2.6 * (0.01875 * SafezoneH)"; - y = "12.0 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.0 * (0.025 * SafezoneH)"; - }; - class CA_FlirMode: RscText - { - idc = 153; - style = 0; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "BHOT"; - align = "right"; - x = "6.18 * (0.01875 * SafezoneH)"; - y = "12.0 * (0.025 * SafezoneH)"; - w = "4.5 * (0.01875 * SafezoneH)"; - h = "1.0 * (0.025 * SafezoneH)"; - }; - class TgT_Grid_text: RangeText - { - idc = 1005; - text = "TGT:"; - font = "EtelkaMonospacePro"; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - x = "1.20 * (0.01875 * SafezoneH)"; - y = "13.5 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class TGT_ValueGrid: RangeText - { - idc = 172; - font = "EtelkaMonospacePro"; - colorText[] = {0.706,0.0745,0.0196,0.8}; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - x = "5.20 * (0.01875 * SafezoneH)"; - y = "13.5 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class OWN_Grid_text: RangeText - { - idc = 1005; - text = "OWN:"; - font = "EtelkaMonospacePro"; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - x = "1.20 * (0.01875 * SafezoneH)"; - y = "15 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class OWN_ValueGrid: RangeText - { - idc = 171; - font = "EtelkaMonospacePro"; - colorText[] = {0.15,1,0.15,0.8}; - style = 2; - sizeEx = "0.0295*SafezoneH"; - shadow = 0; - x = "5.20 * (0.01875 * SafezoneH)"; - y = "15 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class CA_Laser: RscText - { - idc = 158; - style = "0x30 + 0x800"; - sizeEx = "0.038*SafezoneH"; - shadow = 0; - align = "right"; - font = "EtelkaMonospacePro"; - text = PATHTOF(data\Helo_LaserON.paa); - x = "20.45 * (0.01875 * SafezoneH)"; - y = "14.1 * (0.025 * SafezoneH)"; - w = "12.5 * (0.01875 * SafezoneH)"; - h = "12 * (0.025 * SafezoneH)"; - }; - class CA_Heading: RscText - { - idc = 156; - style = 0; - sizeEx = "0.038*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "023"; - align = "right"; - x = "25 * (0.01875 * SafezoneH)"; - y = "5 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - }; - }; - }; - class Rsc_ACE_Drones_UI_Pilots: RscUnitInfo - { - idd = 300; - controls[] = {"WeaponInfoControlsGroupRight","CA_BackgroundVehicle","CA_BackgroundVehicleTitle","CA_BackgroundVehicleTitleDark","CA_BackgroundFuel","CA_Vehicle","CA_VehicleRole","CA_HitZones","CA_SpeedBackground","CA_SpeedUnits","CA_Speed","CA_ValueFuel","CA_AltBackground","CA_AltUnits","CA_Alt","CA_VehicleToggles","CA_Radar","DriverOpticsGroup"}; - class DriverOpticsGroup: RscControlsGroup - { - idc = 392; - class VScrollbar: VScrollbar - { - width = 0; - }; - class HScrollbar: HScrollbar - { - height = 0; - }; - x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; - y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; - w = "53.5 * (0.01875 * SafezoneH)"; - h = "40 * (0.025 * SafezoneH)"; - class controls - { - class TextGrid: RscText - { - style = 0; - sizeEx = "0.02*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - idc = 1005; - text = "GRID:"; - x = "5.8 * (0.01875 * SafezoneH)"; - y = "31.8 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class ValueGrid: TextGrid - { - idc = 189; - text = "382546"; - x = "10.3 * (0.01875 * SafezoneH)"; - y = "31.8 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class TextTime: TextGrid - { - idc = 1010; - text = "TIME [UTC]:"; - x = "5.8 * (0.01875 * SafezoneH)"; - y = "32.6 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class ValueTime: TextGrid - { - idc = 101; - text = "20:28:35"; - x = "10 * (0.01875 * SafezoneH)"; - y = "32.6 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class TextMag: TextGrid - { - idc = 1011; - text = "CAM MAG:"; - x = "5.8 * (0.01875 * SafezoneH)"; - y = "7 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class OpticsZoom: TextGrid - { - idc = 192; - text = "28x"; - x = "10.3 * (0.01875 * SafezoneH)"; - y = "7 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class BorderLineSpdTop: RscPicture - { - idc = 1203; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\border_line_ca.paa"; - x = "3.343 * (0.01875 * SafezoneH)"; - y = "12.4 * (0.025 * SafezoneH)"; - w = "3 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class BorderLineSpdBottom: RscPicture - { - idc = 1207; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\border_line_ca.paa"; - x = "3.343 * (0.01875 * SafezoneH)"; - y = "26.5 * (0.025 * SafezoneH)"; - w = "3 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class BorderLineAltTop: RscPicture - { - idc = 1205; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\border_line_ca.paa"; - x = "47.16 * (0.01875 * SafezoneH)"; - y = "12.4 * (0.025 * SafezoneH)"; - w = "3 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class BorderLineAltBottom: RscPicture - { - idc = 1206; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\border_line_ca.paa"; - x = "47.16 * (0.01875 * SafezoneH)"; - y = "26.5 * (0.025 * SafezoneH)"; - w = "3 * (0.01875 * SafezoneH)"; - h = "1 * (0.025 * SafezoneH)"; - }; - class TextSpd: TextGrid - { - idc = 1004; - text = "SPD"; - x = "4.8 * (0.01875 * SafezoneH)"; - y = "11.8 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class SpeedValueBorder: RscPicture - { - idc = 1200; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\altimeter_value_ca.paa"; - x = "6.3 * (0.01875 * SafezoneH)"; - y = "19 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "2 * (0.025 * SafezoneH)"; - }; - class CA_Speed: TextGrid - { - idc = 190; - sizeEx = "0.03*SafezoneH"; - text = "120"; - x = "7.5 * (0.01875 * SafezoneH)"; - y = "19.5 * (0.025 * SafezoneH)"; - w = "6 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class AnalogueSpeed: RscLadderPicture - { - idc = 384; - topValue = 1312; - bottomValue = -345; - visibleRange = -1; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\UAVspeedLadder_ca.paa"; - x = "1.5 * (0.01875 * SafezoneH)"; - y = "13 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "14 * (0.025 * SafezoneH)"; - }; - class TextAlt: TextGrid - { - idc = 1006; - text = "ALT"; - x = "46.9 * (0.01875 * SafezoneH)"; - y = "11.8 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class AltValueBorder: RscPicture - { - idc = 1201; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\airspeed_value_ca.paa"; - x = "42.25 * (0.01875 * SafezoneH)"; - y = "19 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "2 * (0.025 * SafezoneH)"; - }; - class CA_Alt: TextGrid - { - idc = 191; - sizeEx = "0.03*SafezoneH"; - style = 1; - text = "3825"; - x = "43 * (0.01875 * SafezoneH)"; - y = "19.5 * (0.025 * SafezoneH)"; - w = "3.2 * (0.01875 * SafezoneH)"; - h = "1.2 * (0.025 * SafezoneH)"; - }; - class AnalogueAlt: RscLadderPicture - { - idc = 385; - topValue = 14430; - bottomValue = -2110; - visibleRange = -1; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\UAValtLadder_ca.paa"; - x = "47 * (0.01875 * SafezoneH)"; - y = "13 * (0.025 * SafezoneH)"; - w = "2.5 * (0.01875 * SafezoneH)"; - h = "14 * (0.025 * SafezoneH)"; - }; - class AnalogueHorizon: RscLadderPicture - { - idc = 383; - topValue = 90; - bottomValue = -90; - visibleRange = -1; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\horizon_ladder_ca.paa"; - x = "16.75 * (0.01875 * SafezoneH)"; - y = "5 * (0.025 * SafezoneH)"; - w = "20 * (0.01875 * SafezoneH)"; - h = "30 * (0.025 * SafezoneH)"; - }; - class HorizonCenter: RscPicture - { - idc = 1202; - text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\horizon_aircraft_ca.paa"; - x = "24.75 * (0.01875 * SafezoneH)"; - y = "19 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "2 * (0.025 * SafezoneH)"; - }; - }; - }; - }; +class RscControlsGroup; +class RscText; +class RangeText: RscText{}; +class RscPicture; +class RscOpticsText; +class RscIGProgress; +class RscOpticsValue; +class VScrollbar; +class HScrollbar; +class RscLadderPicture; +class RscControlsGroupNoScrollbars; + + +class RscInGameUI +{ + class RscUnitInfo; + class Rsc_ACE_Helo_UI_Turret: RscUnitInfo + { + idd = 300; + controls[] = {"CA_IGUI_elements_group","CA_VehicleToggles"}; + class VScrollbar; + class HScrollbar; + class CA_IGUI_elements_group: RscControlsGroup + { + idc = 170; + class VScrollbar: VScrollbar + { + width = 0; + }; + class HScrollbar: HScrollbar + { + height = 0; + }; + x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; + y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; + w = "53.5 * (0.01875 * SafezoneH)"; + h = "40 * (0.025 * SafezoneH)"; + class controls + { + class CA_Distance: RscText + { + idc = 151; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + x = "24.78 * (0.01875 * SafezoneH)"; + y = "30.88 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class CA_Speed: RangeText + { + idc = 188; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "120"; + x = "14.78 * (0.01875 * SafezoneH)"; + y = "30.88 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class CA_Alt: RangeText + { + idc = 189; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "3825"; + x = "34.78 * (0.01875 * SafezoneH)"; + y = "30.88 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class CA_VisionMode: RscText + { + idc = 152; + style = 0; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "VIS"; + x = "12.58 * (0.01875 * SafezoneH)"; + y = "8 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class CA_FlirMode: RscText + { + idc = 153; + style = 0; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "BHOT"; + x = "15.78 * (0.01875 * SafezoneH)"; + y = "8 * (0.025 * SafezoneH)"; + w = "4.5 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class ValueGrid: RangeText + { + idc = 172; + font = "EtelkaMonospacePro"; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + x = "12.20 * (0.01875 * SafezoneH)"; + y = "3.5 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class TextTADS: RangeText + { + idc = 1010; + text = "TADS"; + font = "EtelkaMonospacePro"; + style = 2; + shadow = 0; + x = "12.30 * (0.01875 * SafezoneH)"; + y = "5 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class ValueTime: RangeText + { + idc = 190; + text = "20:28:35"; + font = "EtelkaMonospacePro"; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + x = "12.1 * (0.01875 * SafezoneH)"; + y = "6.5 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class CA_Laser: RscText + { + idc = 158; + style = "0x30 + 0x800"; + sizeEx = "0.038*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = PATHTOF(data\Helo_LaserON.paa); + x = "20.45 * (0.01875 * SafezoneH)"; + y = "14.1 * (0.025 * SafezoneH)"; + w = "12.5 * (0.01875 * SafezoneH)"; + h = "12 * (0.025 * SafezoneH)"; + }; + class CA_Heading: RscText + { + idc = 156; + style = 0; + sizeEx = "0.038*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "023"; + x = "24.83 * (0.01875 * SafezoneH)"; + y = "6 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + }; + }; + }; + class Rsc_ACE_Helo_UI_01: RscUnitInfo + { + controls[] = {"WeaponInfoControlsGroupRight","CA_TextFlaresMode","CA_TextFlares","CA_VehicleToggles","CA_Radar"}; + }; + class Rsc_ACE_Helo_UI_02: RscUnitInfo + { + controls[] = {"CA_TextFlaresMode","CA_TextFlares","CA_VehicleToggles","CA_Radar"}; + }; + class Rsc_ACE_Drones_UI_Turret: RscUnitInfo + { + idd = 300; + controls[] = {"CA_Zeroing","CA_IGUI_elements_group","CA_VehicleToggles"}; + class CA_IGUI_elements_group: RscControlsGroup + { + idc = 170; + class VScrollbar: VScrollbar + { + width = 0; + }; + class HScrollbar: HScrollbar + { + height = 0; + }; + x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; + y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; + w = "53.5 * (0.01875 * SafezoneH)"; + h = "40 * (0.025 * SafezoneH)"; + class controls + { + class CA_Distance: RscText + { + idc = 151; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + x = "24.78 * (0.01875 * SafezoneH)"; + y = "30.88 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class CA_Speed: RangeText + { + idc = 188; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "120"; + x = "14.78 * (0.01875 * SafezoneH)"; + y = "30.88 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class CA_Alt: RangeText + { + idc = 189; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "3825"; + x = "34.78 * (0.01875 * SafezoneH)"; + y = "30.88 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class ValueTime: RangeText + { + idc = 190; + text = "20:28:35"; + font = "EtelkaMonospacePro"; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + x = "1.75 * (0.01875 * SafezoneH)"; + y = "10.5 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class CA_VisionMode: RscText + { + idc = 152; + style = 0; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "VIS"; + align = "right"; + x = "2.6 * (0.01875 * SafezoneH)"; + y = "12.0 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.0 * (0.025 * SafezoneH)"; + }; + class CA_FlirMode: RscText + { + idc = 153; + style = 0; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "BHOT"; + align = "right"; + x = "6.18 * (0.01875 * SafezoneH)"; + y = "12.0 * (0.025 * SafezoneH)"; + w = "4.5 * (0.01875 * SafezoneH)"; + h = "1.0 * (0.025 * SafezoneH)"; + }; + class TgT_Grid_text: RangeText + { + idc = 1005; + text = "TGT:"; + font = "EtelkaMonospacePro"; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + x = "1.20 * (0.01875 * SafezoneH)"; + y = "13.5 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class TGT_ValueGrid: RangeText + { + idc = 172; + font = "EtelkaMonospacePro"; + colorText[] = {0.706,0.0745,0.0196,0.8}; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + x = "5.20 * (0.01875 * SafezoneH)"; + y = "13.5 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class OWN_Grid_text: RangeText + { + idc = 1005; + text = "OWN:"; + font = "EtelkaMonospacePro"; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + x = "1.20 * (0.01875 * SafezoneH)"; + y = "15 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class OWN_ValueGrid: RangeText + { + idc = 171; + font = "EtelkaMonospacePro"; + colorText[] = {0.15,1,0.15,0.8}; + style = 2; + sizeEx = "0.0295*SafezoneH"; + shadow = 0; + x = "5.20 * (0.01875 * SafezoneH)"; + y = "15 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class CA_Laser: RscText + { + idc = 158; + style = "0x30 + 0x800"; + sizeEx = "0.038*SafezoneH"; + shadow = 0; + align = "right"; + font = "EtelkaMonospacePro"; + text = PATHTOF(data\Helo_LaserON.paa); + x = "20.45 * (0.01875 * SafezoneH)"; + y = "14.1 * (0.025 * SafezoneH)"; + w = "12.5 * (0.01875 * SafezoneH)"; + h = "12 * (0.025 * SafezoneH)"; + }; + class CA_Heading: RscText + { + idc = 156; + style = 0; + sizeEx = "0.038*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "023"; + align = "right"; + x = "25 * (0.01875 * SafezoneH)"; + y = "5 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + }; + }; + }; + class Rsc_ACE_Drones_UI_Pilots: RscUnitInfo + { + idd = 300; + controls[] = {"WeaponInfoControlsGroupRight","CA_BackgroundVehicle","CA_BackgroundVehicleTitle","CA_BackgroundVehicleTitleDark","CA_BackgroundFuel","CA_Vehicle","CA_VehicleRole","CA_HitZones","CA_SpeedBackground","CA_SpeedUnits","CA_Speed","CA_ValueFuel","CA_AltBackground","CA_AltUnits","CA_Alt","CA_VehicleToggles","CA_Radar","DriverOpticsGroup"}; + class DriverOpticsGroup: RscControlsGroup + { + idc = 392; + class VScrollbar: VScrollbar + { + width = 0; + }; + class HScrollbar: HScrollbar + { + height = 0; + }; + x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; + y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; + w = "53.5 * (0.01875 * SafezoneH)"; + h = "40 * (0.025 * SafezoneH)"; + class controls + { + class TextGrid: RscText + { + style = 0; + sizeEx = "0.02*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + idc = 1005; + text = "GRID:"; + x = "5.8 * (0.01875 * SafezoneH)"; + y = "31.8 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class ValueGrid: TextGrid + { + idc = 189; + text = "382546"; + x = "10.3 * (0.01875 * SafezoneH)"; + y = "31.8 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class TextTime: TextGrid + { + idc = 1010; + text = "TIME [UTC]:"; + x = "5.8 * (0.01875 * SafezoneH)"; + y = "32.6 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class ValueTime: TextGrid + { + idc = 101; + text = "20:28:35"; + x = "10 * (0.01875 * SafezoneH)"; + y = "32.6 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class TextMag: TextGrid + { + idc = 1011; + text = "CAM MAG:"; + x = "5.8 * (0.01875 * SafezoneH)"; + y = "7 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class OpticsZoom: TextGrid + { + idc = 192; + text = "28x"; + x = "10.3 * (0.01875 * SafezoneH)"; + y = "7 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class BorderLineSpdTop: RscPicture + { + idc = 1203; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\border_line_ca.paa"; + x = "3.343 * (0.01875 * SafezoneH)"; + y = "12.4 * (0.025 * SafezoneH)"; + w = "3 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class BorderLineSpdBottom: RscPicture + { + idc = 1207; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\border_line_ca.paa"; + x = "3.343 * (0.01875 * SafezoneH)"; + y = "26.5 * (0.025 * SafezoneH)"; + w = "3 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class BorderLineAltTop: RscPicture + { + idc = 1205; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\border_line_ca.paa"; + x = "47.16 * (0.01875 * SafezoneH)"; + y = "12.4 * (0.025 * SafezoneH)"; + w = "3 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class BorderLineAltBottom: RscPicture + { + idc = 1206; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\border_line_ca.paa"; + x = "47.16 * (0.01875 * SafezoneH)"; + y = "26.5 * (0.025 * SafezoneH)"; + w = "3 * (0.01875 * SafezoneH)"; + h = "1 * (0.025 * SafezoneH)"; + }; + class TextSpd: TextGrid + { + idc = 1004; + text = "SPD"; + x = "4.8 * (0.01875 * SafezoneH)"; + y = "11.8 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class SpeedValueBorder: RscPicture + { + idc = 1200; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\altimeter_value_ca.paa"; + x = "6.3 * (0.01875 * SafezoneH)"; + y = "19 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "2 * (0.025 * SafezoneH)"; + }; + class CA_Speed: TextGrid + { + idc = 190; + sizeEx = "0.03*SafezoneH"; + text = "120"; + x = "7.5 * (0.01875 * SafezoneH)"; + y = "19.5 * (0.025 * SafezoneH)"; + w = "6 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class AnalogueSpeed: RscLadderPicture + { + idc = 384; + topValue = 1312; + bottomValue = -345; + visibleRange = -1; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\UAVspeedLadder_ca.paa"; + x = "1.5 * (0.01875 * SafezoneH)"; + y = "13 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "14 * (0.025 * SafezoneH)"; + }; + class TextAlt: TextGrid + { + idc = 1006; + text = "ALT"; + x = "46.9 * (0.01875 * SafezoneH)"; + y = "11.8 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class AltValueBorder: RscPicture + { + idc = 1201; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\airspeed_value_ca.paa"; + x = "42.25 * (0.01875 * SafezoneH)"; + y = "19 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "2 * (0.025 * SafezoneH)"; + }; + class CA_Alt: TextGrid + { + idc = 191; + sizeEx = "0.03*SafezoneH"; + style = 1; + text = "3825"; + x = "43 * (0.01875 * SafezoneH)"; + y = "19.5 * (0.025 * SafezoneH)"; + w = "3.2 * (0.01875 * SafezoneH)"; + h = "1.2 * (0.025 * SafezoneH)"; + }; + class AnalogueAlt: RscLadderPicture + { + idc = 385; + topValue = 14430; + bottomValue = -2110; + visibleRange = -1; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\UAValtLadder_ca.paa"; + x = "47 * (0.01875 * SafezoneH)"; + y = "13 * (0.025 * SafezoneH)"; + w = "2.5 * (0.01875 * SafezoneH)"; + h = "14 * (0.025 * SafezoneH)"; + }; + class AnalogueHorizon: RscLadderPicture + { + idc = 383; + topValue = 90; + bottomValue = -90; + visibleRange = -1; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\horizon_ladder_ca.paa"; + x = "16.75 * (0.01875 * SafezoneH)"; + y = "5 * (0.025 * SafezoneH)"; + w = "20 * (0.01875 * SafezoneH)"; + h = "30 * (0.025 * SafezoneH)"; + }; + class HorizonCenter: RscPicture + { + idc = 1202; + text = "\A3\Ui_f\data\IGUI\Cfg\HelicopterHUD\horizon_aircraft_ca.paa"; + x = "24.75 * (0.01875 * SafezoneH)"; + y = "19 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "2 * (0.025 * SafezoneH)"; + }; + }; + }; + }; }; \ No newline at end of file diff --git a/addons/atragmx/functions/fnc_on_close_dialog.sqf b/addons/atragmx/functions/fnc_on_close_dialog.sqf index 1f254c646a..fca60574a9 100644 --- a/addons/atragmx/functions/fnc_on_close_dialog.sqf +++ b/addons/atragmx/functions/fnc_on_close_dialog.sqf @@ -1,5 +1,5 @@ -#include "script_component.hpp" - -uiNamespace setVariable ['ATragMX_Display', nil]; -GVAR(active) = false; +#include "script_component.hpp" + +uiNamespace setVariable ['ATragMX_Display', nil]; +GVAR(active) = false; [GVAR(DialogPFH)] call CBA_fnc_removePerFrameHandler; \ No newline at end of file diff --git a/addons/ballistics/CfgAmmo.hpp b/addons/ballistics/CfgAmmo.hpp index eeb64fec47..0819f8aa4b 100644 --- a/addons/ballistics/CfgAmmo.hpp +++ b/addons/ballistics/CfgAmmo.hpp @@ -1,806 +1,806 @@ - -class CfgAmmo { - class BulletCore; - - class BulletBase: BulletCore { - timeToLive=6; - }; - - class B_556x45_Ball : BulletBase { - airFriction=-0.00126466; - hit=8; - typicalSpeed=750; - tracerScale = 1; - tracerStartTime=0.073; // M856 tracer burns out to 800m - tracerEndTime=1.57123; // Time in seconds calculated with ballistics calculator - ACE_caliber=5.69; - ACE_bulletLength=23.012; - ACE_bulletMass=4.0176; - ACE_ammoTempMuzzleVelocityShifts[]={-27.20, -26.44, -23.76, -21.00, -17.54, -13.10, -7.95, -1.62, 6.24, 15.48, 27.75}; - ACE_ballisticCoefficients[]={0.151}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={723, 764, 796, 825, 843, 866, 878, 892, 906, 915, 922, 900}; - ACE_barrelLengths[]={210.82, 238.76, 269.24, 299.72, 330.2, 360.68, 391.16, 419.1, 449.58, 480.06, 508.0, 609.6}; - }; - class ACE_556x45_Ball_Mk262 : B_556x45_Ball { - airFriction=-0.00109563; - caliber=0.8; - deflecting=18; - hit=11; - typicalSpeed=836; - ACE_caliber=5.69; - ACE_bulletLength=23.012; - ACE_bulletMass=4.9896; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.361}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={624, 816, 832, 838}; - ACE_barrelLengths[]={190.5, 368.3, 457.2, 508.0}; - }; - class ACE_556x45_Ball_Mk318 : B_556x45_Ball { - airFriction=-0.00123318; - caliber=0.8; - deflecting=18; - hit=9; - typicalSpeed=886; - ACE_caliber=5.69; - ACE_bulletLength=23.012; - ACE_bulletMass=4.0176; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.307}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={780, 886, 950}; - ACE_barrelLengths[]={254.0, 393.7, 508.0}; - }; - class ACE_556x45_Ball_M995_AP : B_556x45_Ball { - airFriction=-0.00123272; - caliber=1.6; - deflecting=18; - hit=6; - typicalSpeed=869; - ACE_caliber=5.69; - ACE_bulletLength=23.012; - ACE_bulletMass=4.5359237; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.310}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={820, 865, 880}; - ACE_barrelLengths[]={254.0, 368.3, 508.0}; - }; - class B_556x45_Ball_Tracer_Red; - class ACE_B_556x45_Ball_Tracer_Dim: B_556x45_Ball_Tracer_Red { - nvgOnly = 1; - }; - class ACE_545x39_Ball_7N6M : B_556x45_Ball { - airFriction=-0.00114744; - caliber=0.6; - deflecting=18; - hit=7; - typicalSpeed=880; - ACE_caliber=5.588; - ACE_bulletLength=21.59; - ACE_bulletMass=3.42792; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.168}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={780, 880, 920}; - ACE_barrelLengths[]={254.0, 414.02, 508.0}; - }; - class B_556x45_Ball_Tracer_Green; - class ACE_545x39_Ball_7T3M : B_556x45_Ball_Tracer_Green { - airFriction=-0.00114744; - caliber=0.6; - deflecting=18; - hit=7; - typicalSpeed=883; - tracerStartTime=0.073; // 7T3M tracer burns out to 850m - tracerEndTime=1.70236; // Time in seconds calculated with ballistics calculator - ACE_caliber=5.588; - ACE_bulletLength=21.59; - ACE_bulletMass=3.22704; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.168}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={785, 883, 925}; - ACE_barrelLengths[]={254.0, 414.02, 508.0}; - }; - class B_56x15_dual: BulletBase { - tracerScale = 0.5; - }; - class B_65x39_Caseless : BulletBase { - airFriction=-0.00075308; - typicalSpeed=800; - tracerScale = 1.1; //1.0; - ACE_caliber=6.706; - ACE_bulletLength=32.893; - ACE_bulletMass=7.9704; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.263}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={730, 760, 788, 800, 810, 830}; - ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4, 762.0}; - }; - class B_65x39_Case_yellow; - class ACE_65x39_Caseless_Tracer_Dim : B_65x39_Case_yellow { - nvgOnly = 1; - }; - class B_65x39_Caseless_green; - class ACE_65x39_Caseless_green_Tracer_Dim : B_65x39_Caseless_green { - nvgOnly = 1; - }; - class ACE_65x47_Ball_Scenar: B_65x39_Caseless { - airFriction=-0.00067037; - typicalSpeed=820 ; - caliber=0.9; - ACE_caliber=6.706; - ACE_bulletLength=34.646; - ACE_bulletMass=9.0072; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.290}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={730, 760, 790, 820, 830}; - ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; - }; - class ACE_65_Creedmor_Ball: B_65x39_Caseless { - airFriction=-0.00060887; - typicalSpeed=860 ; - caliber=1.1; - ACE_caliber=6.706; - ACE_bulletLength=36.22; - ACE_bulletMass=9.072; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.317}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={750, 820, 840, 852, 860}; - ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; - }; - class SubmunitionBullet; - class B_65x39_Minigun_Caseless: SubmunitionBullet { - tracerScale = 1.1; //1.0; - }; - class B_762x51_Ball : BulletBase { - airFriction=-0.00100957; - typicalSpeed=833; - hit=9; - tracerScale = 1.2; //0.6; - tracerStartTime=0.073; // Based on the British L5A1 which burns out to 1000m - tracerEndTime=2.15957; // Time in seconds calculated with ballistics calculator - ACE_caliber=7.823; - ACE_bulletLength=28.956; - ACE_bulletMass=9.4608; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.2}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={700, 800, 820, 833, 845}; - ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; - }; - class B_762x51_Tracer_Yellow; - class ACE_B_762x51_Tracer_Dim: B_762x51_Tracer_Yellow { - nvgOnly = 1; - }; - class ACE_762x51_Ball_M118LR : B_762x51_Ball { - airFriction=-0.00082828; - caliber=1.8; - hit=16; - typicalSpeed=790; - ACE_caliber=7.823; - ACE_bulletLength=31.496; - ACE_bulletMass=11.34; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.243}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={750, 780, 790, 794}; - ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; - }; - class ACE_762x51_Ball_Mk316_Mod_0 : B_762x51_Ball { - airFriction=-0.00082029; - caliber=1.8; - hit=16; - typicalSpeed=790; - ACE_caliber=7.823; - ACE_bulletLength=31.496; - ACE_bulletMass=11.34; - ACE_ammoTempMuzzleVelocityShifts[]={-5.3, -5.1, -4.6, -4.2, -3.4, -2.6, -1.4, -0.3, 1.4, 3.0, 5.2}; - ACE_ballisticCoefficients[]={0.243}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={775, 790, 805, 810}; - ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; - }; - class ACE_762x51_Ball_Mk319_Mod_0 : B_762x51_Ball { - airFriction=-0.00102338; - caliber=1.5; - hit=14; - typicalSpeed=900; - ACE_caliber=7.823; - ACE_bulletLength=31.496; - ACE_bulletMass=8.424; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={0.377}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={838, 892, 910}; - ACE_barrelLengths[]={330.2, 406.4, 508.0}; - }; - class ACE_762x51_Ball_M993_AP : B_762x51_Ball { - airFriction=-0.00107148; - caliber=2.2; - hit=11; - typicalSpeed=910; - ACE_caliber=7.823; - ACE_bulletLength=31.496; - ACE_bulletMass=8.22946157; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.359}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={875, 910, 930}; - ACE_barrelLengths[]={330.2, 406.4, 508.0}; - }; - class ACE_762x51_Ball_Subsonic : B_762x51_Ball { - airFriction=-0.00049899; - caliber=1; - hit=6; - typicalSpeed=320; - ACE_caliber=7.823; - ACE_bulletLength=34.036; - ACE_bulletMass=12.96; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={0.235}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={305, 325, 335, 340}; - ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; - }; - class ACE_30_06_M1_Ball : B_762x51_Ball { - airFriction=-0.00080900; - typicalSpeed=800; - caliber=2.0; - hit=10; - ACE_caliber=7.823; - ACE_bulletLength=30.734; - ACE_bulletMass=11.2752; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.494}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={700, 785, 800, 830, 840}; - ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; - }; - class ACE_7_Remington_Magnum_Ball : B_762x51_Ball { - airFriction=-0.00056738; - typicalSpeed=820; - caliber=2.1; - hit=8; - ACE_caliber=7.214; - ACE_bulletLength=38.837; - ACE_bulletMass=11.664; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.345}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={720, 780, 812, 822, 830}; - ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; - }; - class ACE_243_Winchester_Ball : B_762x51_Ball { - airFriction=-0.00067875; - typicalSpeed=915; - caliber=2.3; - hit=6; - ACE_caliber=6.172; - ACE_bulletLength=32.563; - ACE_bulletMass=11.664; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.278}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={830, 875, 900, 915, 920}; - ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; - }; - class ACE_762x67_Ball_Mk248_Mod_0 : B_762x51_Ball { - airFriction=-0.00070530; - caliber=1.8; - hit=17; - typicalSpeed=900; - ACE_caliber=7.823; - ACE_bulletLength=34.366; - ACE_bulletMass=12.312; - ACE_ammoTempMuzzleVelocityShifts[]={-5.3, -5.1, -4.6, -4.2, -3.4, -2.6, -1.4, -0.3, 1.4, 3.0, 5.2}; - ACE_ballisticCoefficients[]={0.268}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={865, 900, 924}; - ACE_barrelLengths[]={508.0, 609.6, 660.4}; - }; - class ACE_762x67_Ball_Mk248_Mod_1 : B_762x51_Ball { - airFriction=-0.00061188; - caliber=1.9; - hit=18; - typicalSpeed=867; - ACE_caliber=7.823; - ACE_bulletLength=37.821; - ACE_bulletMass=14.256; - ACE_ammoTempMuzzleVelocityShifts[]={-5.3, -5.1, -4.6, -4.2, -3.4, -2.6, -1.4, -0.3, 1.4, 3.0, 5.2}; - ACE_ballisticCoefficients[]={0.310}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={847, 867, 877}; - ACE_barrelLengths[]={508.0, 609.6, 660.4}; - }; - class ACE_762x67_Ball_Berger_Hybrid_OTM : B_762x51_Ball { - airFriction=-0.00053733; - caliber=2.0; - hit=19; - typicalSpeed=853; - ACE_caliber=7.823; - ACE_bulletLength=40.691; - ACE_bulletMass=14.904; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.368}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={800, 853, 884}; - ACE_barrelLengths[]={508.0, 609.6, 660.4}; - }; - class B_762x54_Ball: B_762x51_Ball { - airFriction=-0.00100023; - typicalSpeed=820; - ACE_caliber=7.925; - ACE_bulletLength=28.956; - ACE_bulletMass=9.8496; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.4}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={700, 800, 820, 833}; - ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; - }; - class ACE_762x54_Ball_7N14 : B_762x51_Ball { - airFriction=-0.00100023; - caliber=1.5; - hit=15; - typicalSpeed=820; - ACE_caliber=7.925; - ACE_bulletLength=28.956; - ACE_bulletMass=9.8496; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.4}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={700, 800, 820, 833}; - ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; - }; - class B_762x54_Tracer_Green; - class ACE_762x54_Ball_7T2 : B_762x54_Tracer_Green { - airFriction=-0.00103989; - caliber=1.5; - hit=15; - typicalSpeed=800; - tracerStartTime=0.073; // Based on the 7T2 which burns three seconds - tracerEndTime=3; - ACE_caliber=7.925; - ACE_bulletLength=28.956; - ACE_bulletMass=9.6552; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.395}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={680, 750, 798, 800}; - ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; - }; - class ACE_762x35_Ball : B_762x51_Ball { - airFriction=-0.00128942; - caliber=1.5; - hit=11; - typicalSpeed=790; - ACE_caliber=7.823; - ACE_bulletLength=29.286; - ACE_bulletMass=8.1; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.349, 0.338, 0.330, 0.310}; - ACE_velocityBoundaries[]={792, 610, 488}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={620, 655, 675}; - ACE_barrelLengths[]={228.6, 406.4, 508.0}; - }; - class ACE_762x39_Ball : B_762x51_Ball { - airFriction=-0.00151621; - hit=12; - caliber=1.5; - typicalSpeed=716; - ACE_caliber=7.823; - ACE_bulletLength=28.956; - ACE_bulletMass=7.9704; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.275}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={650, 716, 750}; - ACE_barrelLengths[]={254.0, 414.02, 508.0}; - }; - class ACE_762x39_Ball_57N231P : B_762x54_Tracer_Green { - airFriction=-0.00151621; - hit=12; - caliber=1.5; - typicalSpeed=716; - tracerStartTime = 0.073; //57N231P tracer burns out to 800m - tracerEndTime = 2.082; //Time in seconds calculated with ballistics calculator - ACE_caliber=7.823; - ACE_bulletLength=28.956; - ACE_bulletMass=7.5816; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.275}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={650, 716, 750}; - ACE_barrelLengths[]={254.0, 414.02, 508.0}; - }; - class B_9x21_Ball : BulletBase { - airFriction=-0.00226847; - typicalSpeed=390; - tracerScale = 0.5; - hit=6; - ACE_caliber=9.042; - ACE_bulletLength=15.494; - ACE_bulletMass=7.452; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={0.17}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={440, 460, 480}; - ACE_barrelLengths[]={101.6, 127.0, 228.6}; - }; - class B_9x21_Ball_Tracer_Green: B_9x21_Ball { - tracerScale = 0.5; - }; - class ACE_9x18_Ball_57N181S : B_9x21_Ball { - hit=5; - airFriction=-0.00190333; - typicalSpeed=298; - ACE_caliber=9.271; - ACE_bulletLength=15.494; - ACE_bulletMass=6.00048; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={0.125}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={298, 330, 350}; - ACE_barrelLengths[]={96.52, 127.0, 228.6}; - }; - class ACE_9x19_Ball : B_9x21_Ball { - airFriction=-0.0018577; - typicalSpeed=370; - hit=6; - ACE_caliber=9.017; - ACE_bulletLength=15.494; - ACE_bulletMass=8.0352; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={0.165}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={340, 370, 400}; - ACE_barrelLengths[]={101.6, 127.0, 228.6}; - }; - class ACE_10x25_Ball : B_9x21_Ball { - airFriction=-0.00181928; - typicalSpeed=425; - hit=7; - ACE_caliber=12.7; - ACE_bulletLength=19.406; - ACE_bulletMass=10.692; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={0.189}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={360, 400, 430}; - ACE_barrelLengths[]={101.6, 117.094, 228.6}; - }; - class ACE_765x17_Ball: B_9x21_Ball { - airFriction=-0.00163356; - typicalSpeed=282; - hit=7; - ACE_caliber=7.938; - ACE_bulletLength=15.494; - ACE_bulletMass=4.212; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={0.118}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={282, 300, 320}; - ACE_barrelLengths[]={101.6, 127.0, 228.6}; - }; - class ACE_303_Ball : ACE_762x51_Ball_M118LR { - airFriction=-0.0008349; - typicalSpeed=761; - caliber=2.0; - ACE_caliber=7.899; - ACE_bulletLength=31.166; - ACE_bulletMass=11.2752; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.499, 0.493, 0.48}; - ACE_velocityBoundaries[]={671, 549}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={748, 761, 765}; - ACE_barrelLengths[]={508.0, 609.6, 660.4}; - }; - class B_93x64_Ball : BulletBase { - airFriction=-0.00108571; - typicalSpeed=880; - ACE_caliber=9.296; - ACE_bulletLength=34.29; - ACE_bulletMass=14.904; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.368}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={850, 870, 880}; - ACE_barrelLengths[]={508.0, 620.014, 660.4}; - }; - class B_408_Ball : BulletBase { - timeToLive=10; - airFriction=-0.00038944; - typicalSpeed=910; - tracerScale = 1.3; //1.2; - ACE_caliber=10.363; - ACE_bulletLength=54.0; - ACE_bulletMass=26.568; - ACE_transonicStabilityCoef=1; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.97}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={910}; - ACE_barrelLengths[]={736.6}; - }; - class ACE_106x83mm_Ball : B_408_Ball { - timeToLive=10; - airFriction=-0.00052047; - ACE_caliber=10.566; - ACE_bulletLength=53.061; - ACE_bulletMass=25.7904; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.72}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={960}; - ACE_barrelLengths[]={736.6}; - }; - class B_338_Ball : BulletBase { - timeToLive=10; - airFriction=-0.00059133; - typicalSpeed=915; - ACE_caliber=8.585; - ACE_bulletLength=39.573; - ACE_bulletMass=16.2; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.322}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={880, 915, 925}; - ACE_barrelLengths[]={508.0, 660.4, 711.2}; - }; - class B_338_NM_Ball : BulletBase { - airFriction=-0.00052201; - typicalSpeed=820; - ACE_caliber=8.585; - ACE_bulletLength=43.18; - ACE_bulletMass=19.44; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.381}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={790, 807, 820}; - ACE_barrelLengths[]={508.0, 609.6, 660.4}; - }; - class ACE_338_Ball : B_338_Ball { - timeToLive=10; - airFriction=-0.00052190; - typicalSpeed=826; - ACE_caliber=8.585; - ACE_bulletLength=43.18; - ACE_bulletMass=19.44; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.381}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=7; - ACE_muzzleVelocities[]={800, 820, 826, 830}; - ACE_barrelLengths[]={508.0, 609.6, 673.1, 711.2}; - }; - class ACE_338_Ball_API526 : B_338_Ball { - timeToLive=10; - airFriction=-0.00069611; - caliber=2.8; - typicalSpeed=895; - ACE_caliber=8.585; - ACE_bulletLength=38.989; - ACE_bulletMass=16.3941242; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.560}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ICAO"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={880, 915, 925}; - ACE_barrelLengths[]={508.0, 660.4, 711.2}; - }; - class B_127x33_Ball: BulletBase { - tracerScale = 1.3; //1.2; - }; - class B_127x54_Ball : BulletBase { - airFriction=-0.00019268; - typicalSpeed=300; - tracerScale = 1.3;// - ACE_caliber=12.954; - ACE_bulletLength=64.516; - ACE_bulletMass=48.6; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={1.050}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={300}; - ACE_barrelLengths[]={436.88}; - }; - class B_127x99_Ball : BulletBase { - timeToLive=10; - airFriction=-0.00057503; - typicalSpeed=900; - tracerScale = 1.3; //1.2; - ACE_caliber=12.954; - ACE_bulletLength=58.674; - ACE_bulletMass=41.9256; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.670}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={900}; - ACE_barrelLengths[]={736.6}; - }; - class ACE_127x99_API : BulletBase { - timeToLive=10; - airFriction=-0.00057503; - typicalSpeed=900; - tracerScale = 1.3;// - hit=25; - caliber=4.0; - ACE_caliber=12.954; - ACE_bulletLength=58.674; - ACE_bulletMass=41.9904; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.670}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={900}; - ACE_barrelLengths[]={736.6}; - }; - class ACE_127x99_Ball_AMAX : B_127x99_Ball { - timeToLive=10; - airFriction=-0.00036645; - typicalSpeed=860; - caliber=3.0; - ACE_caliber=12.954; - ACE_bulletLength=64.516; - ACE_bulletMass=48.6; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={1.050}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={860}; - ACE_barrelLengths[]={736.6}; - }; - class B_127x108_Ball : BulletBase { - timeToLive=10; - airFriction=-0.00063800; - typicalSpeed=820; - tracerScale = 1.3; //1.5; - ACE_caliber=12.979; - ACE_bulletLength=64.008; - ACE_bulletMass=48.276; - ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; - ACE_ballisticCoefficients[]={0.63}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={820}; - ACE_barrelLengths[]={728.98}; - }; - class B_45ACP_Ball : BulletBase { - airFriction=-0.00081221; - typicalSpeed=250; - tracerScale = 0.6; - ACE_caliber=11.481; - ACE_bulletLength=17.272; - ACE_bulletMass=14.904; - ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; - ACE_ballisticCoefficients[]={0.195}; - ACE_velocityBoundaries[]={}; - ACE_standardAtmosphere="ASM"; - ACE_dragModel=1; - ACE_muzzleVelocities[]={230, 250, 285}; - ACE_barrelLengths[]={101.6, 127.0, 228.6}; - }; - class B_19mm_HE: BulletBase { - tracerScale = 1; - }; - class B_30mm_HE: B_19mm_HE { - tracerScale = 2.5; - }; - class B_20mm: BulletBase { - timeToLive=30; - tracerScale = 1.5; //1; - }; - class B_25mm: BulletBase { - timeToLive=30; - tracerScale = 2.0; //1; - }; - class B_30mm_AP: BulletBase { - timeToLive=30; - tracerScale = 2.5; - }; - class B_35mm_AA: BulletBase { - timeToLive=30; - tracerScale = 2.75; //1.85; - }; - class ShellBase; - class Sh_120mm_HE: ShellBase { - tracerScale = 3; - }; - class Sh_120mm_APFSDS: ShellBase { - tracerScale = 3; - }; - class Gatling_30mm_HE_Plane_CAS_01_F: BulletBase { - tracerScale = 2.5; - }; -}; + +class CfgAmmo { + class BulletCore; + + class BulletBase: BulletCore { + timeToLive=6; + }; + + class B_556x45_Ball : BulletBase { + airFriction=-0.00126466; + hit=8; + typicalSpeed=750; + tracerScale = 1; + tracerStartTime=0.073; // M856 tracer burns out to 800m + tracerEndTime=1.57123; // Time in seconds calculated with ballistics calculator + ACE_caliber=5.69; + ACE_bulletLength=23.012; + ACE_bulletMass=4.0176; + ACE_ammoTempMuzzleVelocityShifts[]={-27.20, -26.44, -23.76, -21.00, -17.54, -13.10, -7.95, -1.62, 6.24, 15.48, 27.75}; + ACE_ballisticCoefficients[]={0.151}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={723, 764, 796, 825, 843, 866, 878, 892, 906, 915, 922, 900}; + ACE_barrelLengths[]={210.82, 238.76, 269.24, 299.72, 330.2, 360.68, 391.16, 419.1, 449.58, 480.06, 508.0, 609.6}; + }; + class ACE_556x45_Ball_Mk262 : B_556x45_Ball { + airFriction=-0.00109563; + caliber=0.8; + deflecting=18; + hit=11; + typicalSpeed=836; + ACE_caliber=5.69; + ACE_bulletLength=23.012; + ACE_bulletMass=4.9896; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.361}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={624, 816, 832, 838}; + ACE_barrelLengths[]={190.5, 368.3, 457.2, 508.0}; + }; + class ACE_556x45_Ball_Mk318 : B_556x45_Ball { + airFriction=-0.00123318; + caliber=0.8; + deflecting=18; + hit=9; + typicalSpeed=886; + ACE_caliber=5.69; + ACE_bulletLength=23.012; + ACE_bulletMass=4.0176; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.307}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={780, 886, 950}; + ACE_barrelLengths[]={254.0, 393.7, 508.0}; + }; + class ACE_556x45_Ball_M995_AP : B_556x45_Ball { + airFriction=-0.00123272; + caliber=1.6; + deflecting=18; + hit=6; + typicalSpeed=869; + ACE_caliber=5.69; + ACE_bulletLength=23.012; + ACE_bulletMass=4.5359237; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.310}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={820, 865, 880}; + ACE_barrelLengths[]={254.0, 368.3, 508.0}; + }; + class B_556x45_Ball_Tracer_Red; + class ACE_B_556x45_Ball_Tracer_Dim: B_556x45_Ball_Tracer_Red { + nvgOnly = 1; + }; + class ACE_545x39_Ball_7N6M : B_556x45_Ball { + airFriction=-0.00114744; + caliber=0.6; + deflecting=18; + hit=7; + typicalSpeed=880; + ACE_caliber=5.588; + ACE_bulletLength=21.59; + ACE_bulletMass=3.42792; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.168}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={780, 880, 920}; + ACE_barrelLengths[]={254.0, 414.02, 508.0}; + }; + class B_556x45_Ball_Tracer_Green; + class ACE_545x39_Ball_7T3M : B_556x45_Ball_Tracer_Green { + airFriction=-0.00114744; + caliber=0.6; + deflecting=18; + hit=7; + typicalSpeed=883; + tracerStartTime=0.073; // 7T3M tracer burns out to 850m + tracerEndTime=1.70236; // Time in seconds calculated with ballistics calculator + ACE_caliber=5.588; + ACE_bulletLength=21.59; + ACE_bulletMass=3.22704; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.168}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={785, 883, 925}; + ACE_barrelLengths[]={254.0, 414.02, 508.0}; + }; + class B_56x15_dual: BulletBase { + tracerScale = 0.5; + }; + class B_65x39_Caseless : BulletBase { + airFriction=-0.00075308; + typicalSpeed=800; + tracerScale = 1.1; //1.0; + ACE_caliber=6.706; + ACE_bulletLength=32.893; + ACE_bulletMass=7.9704; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.263}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={730, 760, 788, 800, 810, 830}; + ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4, 762.0}; + }; + class B_65x39_Case_yellow; + class ACE_65x39_Caseless_Tracer_Dim : B_65x39_Case_yellow { + nvgOnly = 1; + }; + class B_65x39_Caseless_green; + class ACE_65x39_Caseless_green_Tracer_Dim : B_65x39_Caseless_green { + nvgOnly = 1; + }; + class ACE_65x47_Ball_Scenar: B_65x39_Caseless { + airFriction=-0.00067037; + typicalSpeed=820 ; + caliber=0.9; + ACE_caliber=6.706; + ACE_bulletLength=34.646; + ACE_bulletMass=9.0072; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.290}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={730, 760, 790, 820, 830}; + ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; + }; + class ACE_65_Creedmor_Ball: B_65x39_Caseless { + airFriction=-0.00060887; + typicalSpeed=860 ; + caliber=1.1; + ACE_caliber=6.706; + ACE_bulletLength=36.22; + ACE_bulletMass=9.072; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.317}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={750, 820, 840, 852, 860}; + ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; + }; + class SubmunitionBullet; + class B_65x39_Minigun_Caseless: SubmunitionBullet { + tracerScale = 1.1; //1.0; + }; + class B_762x51_Ball : BulletBase { + airFriction=-0.00100957; + typicalSpeed=833; + hit=9; + tracerScale = 1.2; //0.6; + tracerStartTime=0.073; // Based on the British L5A1 which burns out to 1000m + tracerEndTime=2.15957; // Time in seconds calculated with ballistics calculator + ACE_caliber=7.823; + ACE_bulletLength=28.956; + ACE_bulletMass=9.4608; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.2}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={700, 800, 820, 833, 845}; + ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; + }; + class B_762x51_Tracer_Yellow; + class ACE_B_762x51_Tracer_Dim: B_762x51_Tracer_Yellow { + nvgOnly = 1; + }; + class ACE_762x51_Ball_M118LR : B_762x51_Ball { + airFriction=-0.00082828; + caliber=1.8; + hit=16; + typicalSpeed=790; + ACE_caliber=7.823; + ACE_bulletLength=31.496; + ACE_bulletMass=11.34; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.243}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={750, 780, 790, 794}; + ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; + }; + class ACE_762x51_Ball_Mk316_Mod_0 : B_762x51_Ball { + airFriction=-0.00082029; + caliber=1.8; + hit=16; + typicalSpeed=790; + ACE_caliber=7.823; + ACE_bulletLength=31.496; + ACE_bulletMass=11.34; + ACE_ammoTempMuzzleVelocityShifts[]={-5.3, -5.1, -4.6, -4.2, -3.4, -2.6, -1.4, -0.3, 1.4, 3.0, 5.2}; + ACE_ballisticCoefficients[]={0.243}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={775, 790, 805, 810}; + ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; + }; + class ACE_762x51_Ball_Mk319_Mod_0 : B_762x51_Ball { + airFriction=-0.00102338; + caliber=1.5; + hit=14; + typicalSpeed=900; + ACE_caliber=7.823; + ACE_bulletLength=31.496; + ACE_bulletMass=8.424; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={0.377}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={838, 892, 910}; + ACE_barrelLengths[]={330.2, 406.4, 508.0}; + }; + class ACE_762x51_Ball_M993_AP : B_762x51_Ball { + airFriction=-0.00107148; + caliber=2.2; + hit=11; + typicalSpeed=910; + ACE_caliber=7.823; + ACE_bulletLength=31.496; + ACE_bulletMass=8.22946157; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.359}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={875, 910, 930}; + ACE_barrelLengths[]={330.2, 406.4, 508.0}; + }; + class ACE_762x51_Ball_Subsonic : B_762x51_Ball { + airFriction=-0.00049899; + caliber=1; + hit=6; + typicalSpeed=320; + ACE_caliber=7.823; + ACE_bulletLength=34.036; + ACE_bulletMass=12.96; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={0.235}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={305, 325, 335, 340}; + ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; + }; + class ACE_30_06_M1_Ball : B_762x51_Ball { + airFriction=-0.00080900; + typicalSpeed=800; + caliber=2.0; + hit=10; + ACE_caliber=7.823; + ACE_bulletLength=30.734; + ACE_bulletMass=11.2752; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.494}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={700, 785, 800, 830, 840}; + ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; + }; + class ACE_7_Remington_Magnum_Ball : B_762x51_Ball { + airFriction=-0.00056738; + typicalSpeed=820; + caliber=2.1; + hit=8; + ACE_caliber=7.214; + ACE_bulletLength=38.837; + ACE_bulletMass=11.664; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.345}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={720, 780, 812, 822, 830}; + ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; + }; + class ACE_243_Winchester_Ball : B_762x51_Ball { + airFriction=-0.00067875; + typicalSpeed=915; + caliber=2.3; + hit=6; + ACE_caliber=6.172; + ACE_bulletLength=32.563; + ACE_bulletMass=11.664; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.278}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={830, 875, 900, 915, 920}; + ACE_barrelLengths[]={254.0, 406.4, 508.0, 609.6, 660.4}; + }; + class ACE_762x67_Ball_Mk248_Mod_0 : B_762x51_Ball { + airFriction=-0.00070530; + caliber=1.8; + hit=17; + typicalSpeed=900; + ACE_caliber=7.823; + ACE_bulletLength=34.366; + ACE_bulletMass=12.312; + ACE_ammoTempMuzzleVelocityShifts[]={-5.3, -5.1, -4.6, -4.2, -3.4, -2.6, -1.4, -0.3, 1.4, 3.0, 5.2}; + ACE_ballisticCoefficients[]={0.268}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={865, 900, 924}; + ACE_barrelLengths[]={508.0, 609.6, 660.4}; + }; + class ACE_762x67_Ball_Mk248_Mod_1 : B_762x51_Ball { + airFriction=-0.00061188; + caliber=1.9; + hit=18; + typicalSpeed=867; + ACE_caliber=7.823; + ACE_bulletLength=37.821; + ACE_bulletMass=14.256; + ACE_ammoTempMuzzleVelocityShifts[]={-5.3, -5.1, -4.6, -4.2, -3.4, -2.6, -1.4, -0.3, 1.4, 3.0, 5.2}; + ACE_ballisticCoefficients[]={0.310}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={847, 867, 877}; + ACE_barrelLengths[]={508.0, 609.6, 660.4}; + }; + class ACE_762x67_Ball_Berger_Hybrid_OTM : B_762x51_Ball { + airFriction=-0.00053733; + caliber=2.0; + hit=19; + typicalSpeed=853; + ACE_caliber=7.823; + ACE_bulletLength=40.691; + ACE_bulletMass=14.904; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.368}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={800, 853, 884}; + ACE_barrelLengths[]={508.0, 609.6, 660.4}; + }; + class B_762x54_Ball: B_762x51_Ball { + airFriction=-0.00100023; + typicalSpeed=820; + ACE_caliber=7.925; + ACE_bulletLength=28.956; + ACE_bulletMass=9.8496; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.4}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={700, 800, 820, 833}; + ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; + }; + class ACE_762x54_Ball_7N14 : B_762x51_Ball { + airFriction=-0.00100023; + caliber=1.5; + hit=15; + typicalSpeed=820; + ACE_caliber=7.925; + ACE_bulletLength=28.956; + ACE_bulletMass=9.8496; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.4}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={700, 800, 820, 833}; + ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; + }; + class B_762x54_Tracer_Green; + class ACE_762x54_Ball_7T2 : B_762x54_Tracer_Green { + airFriction=-0.00103989; + caliber=1.5; + hit=15; + typicalSpeed=800; + tracerStartTime=0.073; // Based on the 7T2 which burns three seconds + tracerEndTime=3; + ACE_caliber=7.925; + ACE_bulletLength=28.956; + ACE_bulletMass=9.6552; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.395}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={680, 750, 798, 800}; + ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; + }; + class ACE_762x35_Ball : B_762x51_Ball { + airFriction=-0.00128942; + caliber=1.5; + hit=11; + typicalSpeed=790; + ACE_caliber=7.823; + ACE_bulletLength=29.286; + ACE_bulletMass=8.1; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.349, 0.338, 0.330, 0.310}; + ACE_velocityBoundaries[]={792, 610, 488}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={620, 655, 675}; + ACE_barrelLengths[]={228.6, 406.4, 508.0}; + }; + class ACE_762x39_Ball : B_762x51_Ball { + airFriction=-0.00151621; + hit=12; + caliber=1.5; + typicalSpeed=716; + ACE_caliber=7.823; + ACE_bulletLength=28.956; + ACE_bulletMass=7.9704; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.275}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={650, 716, 750}; + ACE_barrelLengths[]={254.0, 414.02, 508.0}; + }; + class ACE_762x39_Ball_57N231P : B_762x54_Tracer_Green { + airFriction=-0.00151621; + hit=12; + caliber=1.5; + typicalSpeed=716; + tracerStartTime = 0.073; //57N231P tracer burns out to 800m + tracerEndTime = 2.082; //Time in seconds calculated with ballistics calculator + ACE_caliber=7.823; + ACE_bulletLength=28.956; + ACE_bulletMass=7.5816; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.275}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={650, 716, 750}; + ACE_barrelLengths[]={254.0, 414.02, 508.0}; + }; + class B_9x21_Ball : BulletBase { + airFriction=-0.00226847; + typicalSpeed=390; + tracerScale = 0.5; + hit=6; + ACE_caliber=9.042; + ACE_bulletLength=15.494; + ACE_bulletMass=7.452; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={0.17}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={440, 460, 480}; + ACE_barrelLengths[]={101.6, 127.0, 228.6}; + }; + class B_9x21_Ball_Tracer_Green: B_9x21_Ball { + tracerScale = 0.5; + }; + class ACE_9x18_Ball_57N181S : B_9x21_Ball { + hit=5; + airFriction=-0.00190333; + typicalSpeed=298; + ACE_caliber=9.271; + ACE_bulletLength=15.494; + ACE_bulletMass=6.00048; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={0.125}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={298, 330, 350}; + ACE_barrelLengths[]={96.52, 127.0, 228.6}; + }; + class ACE_9x19_Ball : B_9x21_Ball { + airFriction=-0.0018577; + typicalSpeed=370; + hit=6; + ACE_caliber=9.017; + ACE_bulletLength=15.494; + ACE_bulletMass=8.0352; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={0.165}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={340, 370, 400}; + ACE_barrelLengths[]={101.6, 127.0, 228.6}; + }; + class ACE_10x25_Ball : B_9x21_Ball { + airFriction=-0.00181928; + typicalSpeed=425; + hit=7; + ACE_caliber=12.7; + ACE_bulletLength=19.406; + ACE_bulletMass=10.692; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={0.189}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={360, 400, 430}; + ACE_barrelLengths[]={101.6, 117.094, 228.6}; + }; + class ACE_765x17_Ball: B_9x21_Ball { + airFriction=-0.00163356; + typicalSpeed=282; + hit=7; + ACE_caliber=7.938; + ACE_bulletLength=15.494; + ACE_bulletMass=4.212; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={0.118}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={282, 300, 320}; + ACE_barrelLengths[]={101.6, 127.0, 228.6}; + }; + class ACE_303_Ball : ACE_762x51_Ball_M118LR { + airFriction=-0.0008349; + typicalSpeed=761; + caliber=2.0; + ACE_caliber=7.899; + ACE_bulletLength=31.166; + ACE_bulletMass=11.2752; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.499, 0.493, 0.48}; + ACE_velocityBoundaries[]={671, 549}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={748, 761, 765}; + ACE_barrelLengths[]={508.0, 609.6, 660.4}; + }; + class B_93x64_Ball : BulletBase { + airFriction=-0.00108571; + typicalSpeed=880; + ACE_caliber=9.296; + ACE_bulletLength=34.29; + ACE_bulletMass=14.904; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.368}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={850, 870, 880}; + ACE_barrelLengths[]={508.0, 620.014, 660.4}; + }; + class B_408_Ball : BulletBase { + timeToLive=10; + airFriction=-0.00038944; + typicalSpeed=910; + tracerScale = 1.3; //1.2; + ACE_caliber=10.363; + ACE_bulletLength=54.0; + ACE_bulletMass=26.568; + ACE_transonicStabilityCoef=1; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.97}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={910}; + ACE_barrelLengths[]={736.6}; + }; + class ACE_106x83mm_Ball : B_408_Ball { + timeToLive=10; + airFriction=-0.00052047; + ACE_caliber=10.566; + ACE_bulletLength=53.061; + ACE_bulletMass=25.7904; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.72}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={960}; + ACE_barrelLengths[]={736.6}; + }; + class B_338_Ball : BulletBase { + timeToLive=10; + airFriction=-0.00059133; + typicalSpeed=915; + ACE_caliber=8.585; + ACE_bulletLength=39.573; + ACE_bulletMass=16.2; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.322}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={880, 915, 925}; + ACE_barrelLengths[]={508.0, 660.4, 711.2}; + }; + class B_338_NM_Ball : BulletBase { + airFriction=-0.00052201; + typicalSpeed=820; + ACE_caliber=8.585; + ACE_bulletLength=43.18; + ACE_bulletMass=19.44; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.381}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={790, 807, 820}; + ACE_barrelLengths[]={508.0, 609.6, 660.4}; + }; + class ACE_338_Ball : B_338_Ball { + timeToLive=10; + airFriction=-0.00052190; + typicalSpeed=826; + ACE_caliber=8.585; + ACE_bulletLength=43.18; + ACE_bulletMass=19.44; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.381}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=7; + ACE_muzzleVelocities[]={800, 820, 826, 830}; + ACE_barrelLengths[]={508.0, 609.6, 673.1, 711.2}; + }; + class ACE_338_Ball_API526 : B_338_Ball { + timeToLive=10; + airFriction=-0.00069611; + caliber=2.8; + typicalSpeed=895; + ACE_caliber=8.585; + ACE_bulletLength=38.989; + ACE_bulletMass=16.3941242; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.560}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ICAO"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={880, 915, 925}; + ACE_barrelLengths[]={508.0, 660.4, 711.2}; + }; + class B_127x33_Ball: BulletBase { + tracerScale = 1.3; //1.2; + }; + class B_127x54_Ball : BulletBase { + airFriction=-0.00019268; + typicalSpeed=300; + tracerScale = 1.3;// + ACE_caliber=12.954; + ACE_bulletLength=64.516; + ACE_bulletMass=48.6; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={1.050}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={300}; + ACE_barrelLengths[]={436.88}; + }; + class B_127x99_Ball : BulletBase { + timeToLive=10; + airFriction=-0.00057503; + typicalSpeed=900; + tracerScale = 1.3; //1.2; + ACE_caliber=12.954; + ACE_bulletLength=58.674; + ACE_bulletMass=41.9256; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.670}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={900}; + ACE_barrelLengths[]={736.6}; + }; + class ACE_127x99_API : BulletBase { + timeToLive=10; + airFriction=-0.00057503; + typicalSpeed=900; + tracerScale = 1.3;// + hit=25; + caliber=4.0; + ACE_caliber=12.954; + ACE_bulletLength=58.674; + ACE_bulletMass=41.9904; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.670}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={900}; + ACE_barrelLengths[]={736.6}; + }; + class ACE_127x99_Ball_AMAX : B_127x99_Ball { + timeToLive=10; + airFriction=-0.00036645; + typicalSpeed=860; + caliber=3.0; + ACE_caliber=12.954; + ACE_bulletLength=64.516; + ACE_bulletMass=48.6; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={1.050}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={860}; + ACE_barrelLengths[]={736.6}; + }; + class B_127x108_Ball : BulletBase { + timeToLive=10; + airFriction=-0.00063800; + typicalSpeed=820; + tracerScale = 1.3; //1.5; + ACE_caliber=12.979; + ACE_bulletLength=64.008; + ACE_bulletMass=48.276; + ACE_ammoTempMuzzleVelocityShifts[]={-26.55, -25.47, -22.85, -20.12, -16.98, -12.80, -7.64, -1.53, 5.96, 15.17, 26.19}; + ACE_ballisticCoefficients[]={0.63}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={820}; + ACE_barrelLengths[]={728.98}; + }; + class B_45ACP_Ball : BulletBase { + airFriction=-0.00081221; + typicalSpeed=250; + tracerScale = 0.6; + ACE_caliber=11.481; + ACE_bulletLength=17.272; + ACE_bulletMass=14.904; + ACE_ammoTempMuzzleVelocityShifts[]={-2.655, -2.547, -2.285, -2.012, -1.698, -1.280, -0.764, -0.153, 0.596, 1.517, 2.619}; + ACE_ballisticCoefficients[]={0.195}; + ACE_velocityBoundaries[]={}; + ACE_standardAtmosphere="ASM"; + ACE_dragModel=1; + ACE_muzzleVelocities[]={230, 250, 285}; + ACE_barrelLengths[]={101.6, 127.0, 228.6}; + }; + class B_19mm_HE: BulletBase { + tracerScale = 1; + }; + class B_30mm_HE: B_19mm_HE { + tracerScale = 2.5; + }; + class B_20mm: BulletBase { + timeToLive=30; + tracerScale = 1.5; //1; + }; + class B_25mm: BulletBase { + timeToLive=30; + tracerScale = 2.0; //1; + }; + class B_30mm_AP: BulletBase { + timeToLive=30; + tracerScale = 2.5; + }; + class B_35mm_AA: BulletBase { + timeToLive=30; + tracerScale = 2.75; //1.85; + }; + class ShellBase; + class Sh_120mm_HE: ShellBase { + tracerScale = 3; + }; + class Sh_120mm_APFSDS: ShellBase { + tracerScale = 3; + }; + class Gatling_30mm_HE_Plane_CAS_01_F: BulletBase { + tracerScale = 2.5; + }; +}; diff --git a/addons/common/functions/fnc__handleNetEvent.sqf b/addons/common/functions/fnc__handleNetEvent.sqf index 54cef66228..89814de12f 100644 --- a/addons/common/functions/fnc__handleNetEvent.sqf +++ b/addons/common/functions/fnc__handleNetEvent.sqf @@ -1,81 +1,81 @@ -/* - * Author: jaynus - * Internal net event handler. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -params ["_eventType", "_event"]; - -if (_eventType == "ACEg") then { - _event params ["_eventName", "_eventArgs"]; - - private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; - if (!isNil "_eventFunctions") then { - - #ifdef DEBUG_EVENTS - ACE_LOGINFO_1("* Net Event %1",_eventName); - ACE_LOGINFO_1(" args=%1",_eventArgs); - #endif - - { - if (!isNil "_x") then { - _eventArgs call CALLSTACK_NAMED(_x, FORMAT_2("Net Event %1 ID: %2",_eventName,_forEachIndex)); - #ifdef DEBUG_EVENTS_CALLSTACK - ACE_LOGINFO_1(" ID: %1",_forEachIndex); - #endif - }; - } forEach _eventFunctions; - }; -}; - -if (_eventType == "ACEc") then { - if (isServer) then { - _event params ["_eventName", "_eventTargets", "_eventArgs"]; - - private _sentEvents = []; - - if (!IS_ARRAY(_eventTargets)) then { - _eventTargets = [_eventTargets]; - }; - - //If not multiplayer, and there are targets, then just run localy - if (!isMultiplayer && {count _eventTargets > 0}) exitWith { - ACEg = [_eventName, _eventArgs]; - ["ACEg", ACEg] call FUNC(_handleNetEvent); - }; - - private _serverFlagged = false; - - { - private _owner = _x; - - if (IS_OBJECT(_x)) then { - _owner = owner _x; - }; - if !(_owner in _sentEvents) then { - _sentEvents pushBack _owner; - ACEg = [_eventName, _eventArgs]; - - if (isDedicated || {_x != ACE_player}) then { - if (isDedicated && {local _x} && {!_serverFlagged}) then { - _serverFlagged = true; - ["ACEg", ACEg] call FUNC(_handleNetEvent); - } else { - _owner publicVariableClient "ACEg"; - }; - } else { - ["ACEg", ACEg] call FUNC(_handleNetEvent); - }; - }; - false - } count _eventTargets; - }; -}; +/* + * Author: jaynus + * Internal net event handler. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +params ["_eventType", "_event"]; + +if (_eventType == "ACEg") then { + _event params ["_eventName", "_eventArgs"]; + + private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; + if (!isNil "_eventFunctions") then { + + #ifdef DEBUG_EVENTS + ACE_LOGINFO_1("* Net Event %1",_eventName); + ACE_LOGINFO_1(" args=%1",_eventArgs); + #endif + + { + if (!isNil "_x") then { + _eventArgs call CALLSTACK_NAMED(_x, FORMAT_2("Net Event %1 ID: %2",_eventName,_forEachIndex)); + #ifdef DEBUG_EVENTS_CALLSTACK + ACE_LOGINFO_1(" ID: %1",_forEachIndex); + #endif + }; + } forEach _eventFunctions; + }; +}; + +if (_eventType == "ACEc") then { + if (isServer) then { + _event params ["_eventName", "_eventTargets", "_eventArgs"]; + + private _sentEvents = []; + + if (!IS_ARRAY(_eventTargets)) then { + _eventTargets = [_eventTargets]; + }; + + //If not multiplayer, and there are targets, then just run localy + if (!isMultiplayer && {count _eventTargets > 0}) exitWith { + ACEg = [_eventName, _eventArgs]; + ["ACEg", ACEg] call FUNC(_handleNetEvent); + }; + + private _serverFlagged = false; + + { + private _owner = _x; + + if (IS_OBJECT(_x)) then { + _owner = owner _x; + }; + if !(_owner in _sentEvents) then { + _sentEvents pushBack _owner; + ACEg = [_eventName, _eventArgs]; + + if (isDedicated || {_x != ACE_player}) then { + if (isDedicated && {local _x} && {!_serverFlagged}) then { + _serverFlagged = true; + ["ACEg", ACEg] call FUNC(_handleNetEvent); + } else { + _owner publicVariableClient "ACEg"; + }; + } else { + ["ACEg", ACEg] call FUNC(_handleNetEvent); + }; + }; + false + } count _eventTargets; + }; +}; diff --git a/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf b/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf index 8c8cbd1486..dbc4febbbf 100644 --- a/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf +++ b/addons/common/functions/fnc__handleRequestAllSyncedEvents.sqf @@ -1,25 +1,25 @@ -/* - * Author: jaynus - * Handles a server-side request for synchronization ALL events on JIP to a client. - * - * Arguments: - * 0: client - * - * Return Value: - * Event is successed - * - * Public: No - */ -#include "script_component.hpp" - -params ["_client"]; - -{ - private _eventEntry = HASH_GET(GVAR(syncedEvents),_x); - _eventEntry params ["", "_eventLog"]; - - ["SEH_s", _client, [_x, _eventLog]] call FUNC(targetEvent); - false -} count (GVAR(syncedEvents) select 0); - -true +/* + * Author: jaynus + * Handles a server-side request for synchronization ALL events on JIP to a client. + * + * Arguments: + * 0: client + * + * Return Value: + * Event is successed + * + * Public: No + */ +#include "script_component.hpp" + +params ["_client"]; + +{ + private _eventEntry = HASH_GET(GVAR(syncedEvents),_x); + _eventEntry params ["", "_eventLog"]; + + ["SEH_s", _client, [_x, _eventLog]] call FUNC(targetEvent); + false +} count (GVAR(syncedEvents) select 0); + +true diff --git a/addons/common/functions/fnc__handleRequestSyncedEvent.sqf b/addons/common/functions/fnc__handleRequestSyncedEvent.sqf index 9d6c062ac2..36db271cb2 100644 --- a/addons/common/functions/fnc__handleRequestSyncedEvent.sqf +++ b/addons/common/functions/fnc__handleRequestSyncedEvent.sqf @@ -1,48 +1,48 @@ -/* - * Author: jaynus - * Receives either requests for synchronization from clients, or the synchronization data from the server. - * - * Arguments [Client] : - * 0: eventName - * 1: eventLog - * - * Arguments [Server] : - * 0: eventName - * 1: client - * - * Return Value: - * Event is successed - * - * Public: No - */ -#include "script_component.hpp" - -//SEH_s -if (isServer) then { - // Find the event name, and shovel out the events to the client - params ["_eventName", "_client"]; - - if (!HASH_HASKEY(GVAR(syncedEvents),_eventName)) exitWith { - ACE_LOGERROR_1("Request for synced event - key [%1] not found.", _eventName); - false - }; - - private _eventEntry = HASH_GET(GVAR(syncedEvents),_eventName); - _eventEntry params ["", "_eventLog"]; - - ["SEH_s", _client, [_eventName, _eventLog]] call FUNC(targetEvent); -} else { - params ["_eventName", "_eventLog"]; - - // This is the client handling the response from the server - // Start running the events - { - _x params ["", "_eventArgs","_ttl"]; - [_eventName, _eventArgs, _ttl] call FUNC(_handleSyncedEvent); - false - } count _eventLog; - - ACE_LOGINFO_1("[%1] synchronized",_eventName); -}; - -true +/* + * Author: jaynus + * Receives either requests for synchronization from clients, or the synchronization data from the server. + * + * Arguments [Client] : + * 0: eventName + * 1: eventLog + * + * Arguments [Server] : + * 0: eventName + * 1: client + * + * Return Value: + * Event is successed + * + * Public: No + */ +#include "script_component.hpp" + +//SEH_s +if (isServer) then { + // Find the event name, and shovel out the events to the client + params ["_eventName", "_client"]; + + if (!HASH_HASKEY(GVAR(syncedEvents),_eventName)) exitWith { + ACE_LOGERROR_1("Request for synced event - key [%1] not found.", _eventName); + false + }; + + private _eventEntry = HASH_GET(GVAR(syncedEvents),_eventName); + _eventEntry params ["", "_eventLog"]; + + ["SEH_s", _client, [_eventName, _eventLog]] call FUNC(targetEvent); +} else { + params ["_eventName", "_eventLog"]; + + // This is the client handling the response from the server + // Start running the events + { + _x params ["", "_eventArgs","_ttl"]; + [_eventName, _eventArgs, _ttl] call FUNC(_handleSyncedEvent); + false + } count _eventLog; + + ACE_LOGINFO_1("[%1] synchronized",_eventName); +}; + +true diff --git a/addons/common/functions/fnc__handleSyncedEvent.sqf b/addons/common/functions/fnc__handleSyncedEvent.sqf index db8151dbd7..870cd563dd 100644 --- a/addons/common/functions/fnc__handleSyncedEvent.sqf +++ b/addons/common/functions/fnc__handleSyncedEvent.sqf @@ -1,37 +1,37 @@ -/* - * Author: jaynus - * Handles synced events being received. Server will log them, and server/client will execute them. - * - * Arguments [Client] : - * 0: eventName - * 1: arguments - * 2: ttl - * - * Return Value: - * Boolean of success - * - * Public: No - */ -#include "script_component.hpp" - -params ["_name", "_args", "_ttl"]; - -if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { - ACE_LOGERROR_1("Synced event key [%1] not found (_handleSyncedEvent).", _name); - false -}; - -private _internalData = HASH_GET(GVAR(syncedEvents),_name); - -if (isServer) then { - // Server needs to internally log it for synchronization - if (_ttl > -1) then { - _internalData = HASH_GET(GVAR(syncedEvents),_name); - - _internalData params ["", "_eventLog"]; - _eventLog pushBack [ACE_diagTime, _args, _ttl]; - }; -}; - -_internalData params ["_eventCode"]; -_args call _eventCode; +/* + * Author: jaynus + * Handles synced events being received. Server will log them, and server/client will execute them. + * + * Arguments [Client] : + * 0: eventName + * 1: arguments + * 2: ttl + * + * Return Value: + * Boolean of success + * + * Public: No + */ +#include "script_component.hpp" + +params ["_name", "_args", "_ttl"]; + +if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { + ACE_LOGERROR_1("Synced event key [%1] not found (_handleSyncedEvent).", _name); + false +}; + +private _internalData = HASH_GET(GVAR(syncedEvents),_name); + +if (isServer) then { + // Server needs to internally log it for synchronization + if (_ttl > -1) then { + _internalData = HASH_GET(GVAR(syncedEvents),_name); + + _internalData params ["", "_eventLog"]; + _eventLog pushBack [ACE_diagTime, _args, _ttl]; + }; +}; + +_internalData params ["_eventCode"]; +_args call _eventCode; diff --git a/addons/common/functions/fnc_addEventHandler.sqf b/addons/common/functions/fnc_addEventHandler.sqf index e7df00f5ff..a81b330727 100644 --- a/addons/common/functions/fnc_addEventHandler.sqf +++ b/addons/common/functions/fnc_addEventHandler.sqf @@ -1,25 +1,25 @@ -/* - * Author: Nou - * Add an event handler. - * - * Arguments: - * 0: Event name - * 1: Event code - * - * Return Value: - * Event handler ID number (for use with fnc_removeEventHandler) - * - * Public: Yes - */ -#include "script_component.hpp" - -params ["_eventName", "_eventCode"]; - -private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; - -if (isNil "_eventFunctions") then { - _eventFunctions = []; - GVAR(eventsLocation) setVariable [_eventName, _eventFunctions]; -}; - -_eventFunctions pushBack _eventCode // Return event function count +/* + * Author: Nou + * Add an event handler. + * + * Arguments: + * 0: Event name + * 1: Event code + * + * Return Value: + * Event handler ID number (for use with fnc_removeEventHandler) + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_eventName", "_eventCode"]; + +private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; + +if (isNil "_eventFunctions") then { + _eventFunctions = []; + GVAR(eventsLocation) setVariable [_eventName, _eventFunctions]; +}; + +_eventFunctions pushBack _eventCode // Return event function count diff --git a/addons/common/functions/fnc_addSyncedEventHandler.sqf b/addons/common/functions/fnc_addSyncedEventHandler.sqf index 126bb6a957..9d8c23de3c 100644 --- a/addons/common/functions/fnc_addSyncedEventHandler.sqf +++ b/addons/common/functions/fnc_addSyncedEventHandler.sqf @@ -1,30 +1,30 @@ -/* - * Author: jaynus - * Register an event handler for an ACE synced event - * - * Arguments: - * 0: Name - * 1: Handler - * 2: TTL (optional: 0) - * - * Return Value: - * Boolean of success - * - * Example: - * ["myEvent", {_this call x}, 0] call ace_common_fnc_addSyncedEventHandler - * - * Public: Yes - */ -#include "script_component.hpp" - -params ["_name", "_handler", ["_ttl", 0]]; - -if (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { - ACE_LOGERROR_1("Duplicate synced event [%1] creation.",_name); - false -}; - -private _eventId = [_name, FUNC(_handleSyncedEvent)] call FUNC(addEventHandler); -private _data = [_handler, [], _ttl, _eventId]; - -HASH_SET(GVAR(syncedEvents),_name,_data); +/* + * Author: jaynus + * Register an event handler for an ACE synced event + * + * Arguments: + * 0: Name + * 1: Handler + * 2: TTL (optional: 0) + * + * Return Value: + * Boolean of success + * + * Example: + * ["myEvent", {_this call x}, 0] call ace_common_fnc_addSyncedEventHandler + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_name", "_handler", ["_ttl", 0]]; + +if (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { + ACE_LOGERROR_1("Duplicate synced event [%1] creation.",_name); + false +}; + +private _eventId = [_name, FUNC(_handleSyncedEvent)] call FUNC(addEventHandler); +private _data = [_handler, [], _ttl, _eventId]; + +HASH_SET(GVAR(syncedEvents),_name,_data); diff --git a/addons/common/functions/fnc_dumpArray.sqf b/addons/common/functions/fnc_dumpArray.sqf index 026b08501e..b274f1119e 100644 --- a/addons/common/functions/fnc_dumpArray.sqf +++ b/addons/common/functions/fnc_dumpArray.sqf @@ -1,44 +1,44 @@ -/* - * Author: ? - * Dumps an array to the RPT, showing the depth of each element. - * - * Arguments: - * 0: Array to be dumped - * 1: Depth - * - * Return Value: - * None - * - * Example: - * [[0, [1,2], [[3]]]] call ace_common_fnc_dumpArray - * - * Public: No - */ -#include "script_component.hpp" - -params ["_var", ["_depth", 0, [0]]]; - -private _pad = ""; - -for "_i" from 0 to _depth do { - _pad = _pad + toString [9]; -}; - -_depth = _depth + 1; - -if (IS_ARRAY(_var)) then { - if (_var isEqualTo []) then { - diag_log text format ["%1[],", _pad]; - } else { - diag_log text format ["%1[", _pad]; - - { - [_x, _depth] call FUNC(dumpArray); - false - } count _var; - - diag_log text format ["%1],", _pad]; - }; -} else { - diag_log text format ["%1%2", _pad, _var]; -}; +/* + * Author: ? + * Dumps an array to the RPT, showing the depth of each element. + * + * Arguments: + * 0: Array to be dumped + * 1: Depth + * + * Return Value: + * None + * + * Example: + * [[0, [1,2], [[3]]]] call ace_common_fnc_dumpArray + * + * Public: No + */ +#include "script_component.hpp" + +params ["_var", ["_depth", 0, [0]]]; + +private _pad = ""; + +for "_i" from 0 to _depth do { + _pad = _pad + toString [9]; +}; + +_depth = _depth + 1; + +if (IS_ARRAY(_var)) then { + if (_var isEqualTo []) then { + diag_log text format ["%1[],", _pad]; + } else { + diag_log text format ["%1[", _pad]; + + { + [_x, _depth] call FUNC(dumpArray); + false + } count _var; + + diag_log text format ["%1],", _pad]; + }; +} else { + diag_log text format ["%1%2", _pad, _var]; +}; diff --git a/addons/common/functions/fnc_dumpPerformanceCounters.sqf b/addons/common/functions/fnc_dumpPerformanceCounters.sqf index afb71b423a..ec6f225ce4 100644 --- a/addons/common/functions/fnc_dumpPerformanceCounters.sqf +++ b/addons/common/functions/fnc_dumpPerformanceCounters.sqf @@ -1,88 +1,88 @@ -/* - * Author: ? - * Dumps performance counter statistics into Logs. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -diag_log text format ["REGISTERED ACE PFH HANDLERS"]; -diag_log text format ["-------------------------------------------"]; - -if (!isNil "ACE_PFH_COUNTER") then { - { - _x params ["_pfh", "_parameters"]; - - private _isActive = ["ACTIVE", "REMOVED"] select isNil {CBA_common_PFHhandles select (_pfh select 0)}; - - diag_log text format ["Registered PFH: id=%1 [%2, delay %3], %4:%5", _pfh select 0, _isActive, _parameters select 1, _pfh select 1, _pfh select 2]; - false - } count ACE_PFH_COUNTER; -}; - -diag_log text format ["ACE COUNTER RESULTS"]; -diag_log text format ["-------------------------------------------"]; - -{ - private _counterEntry = _x; - private _iter = 0; - private _total = 0; - private _count = 0; - private _averageResult = 0; - - if (count _counterEntry > 3) then { - // calc - { - if (_iter > 2) then { - _count = _count + 1; - private _delta = (_x select 1) - (_x select 0); - - _total = _total + _delta; - }; - - _iter = _iter + 1; - false - } count _counterEntry; - - // results - _averageResult = (_total / _count) * 1000; - - // dump results - diag_log text format ["%1: Average: %2s / %3 = %4ms", _counterEntry select 0, _total, _count, _averageResult]; - } else { - diag_log text format ["%1: No results", _counterEntry select 0]; - }; - false -} count ACE_COUNTERS; - -/* -// Dump PFH Trackers -diag_log text format["ACE_PERFORMANCE_EXCESSIVE_STEP_TRACKER"]; -diag_log text format["-------------------------------------------"]; -{ - private _delay = _x select 2; - //if(_delay > 0) then { _delay = _delay / 1000; }; - - diag_log text format["%1: %2s, delay=%3, handle=%4",(_x select 0), _delay, (_x select 3), (_x select 4)]; -} forEach ACE_PERFORMANCE_EXCESSIVE_STEP_TRACKER; - -// Dump PFH Trackers -diag_log text format["ACE_PERFORMANCE_EXCESSIVE_FRAME_TRACKER"]; -diag_log text format["-------------------------------------------"]; -{ - private _delta = _x select 1; - //if(_delta > 0) then { _delta = _delta / 1000; }; - diag_log text format[" DELTA: %1s", _delta]; -} forEach ACE_PERFORMANCE_EXCESSIVE_FRAME_TRACKER; - -//{ -// -//} forEach ACRE_EXCESSIVE_FRAME_TRACKER; - -*/ +/* + * Author: ? + * Dumps performance counter statistics into Logs. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +diag_log text format ["REGISTERED ACE PFH HANDLERS"]; +diag_log text format ["-------------------------------------------"]; + +if (!isNil "ACE_PFH_COUNTER") then { + { + _x params ["_pfh", "_parameters"]; + + private _isActive = ["ACTIVE", "REMOVED"] select isNil {CBA_common_PFHhandles select (_pfh select 0)}; + + diag_log text format ["Registered PFH: id=%1 [%2, delay %3], %4:%5", _pfh select 0, _isActive, _parameters select 1, _pfh select 1, _pfh select 2]; + false + } count ACE_PFH_COUNTER; +}; + +diag_log text format ["ACE COUNTER RESULTS"]; +diag_log text format ["-------------------------------------------"]; + +{ + private _counterEntry = _x; + private _iter = 0; + private _total = 0; + private _count = 0; + private _averageResult = 0; + + if (count _counterEntry > 3) then { + // calc + { + if (_iter > 2) then { + _count = _count + 1; + private _delta = (_x select 1) - (_x select 0); + + _total = _total + _delta; + }; + + _iter = _iter + 1; + false + } count _counterEntry; + + // results + _averageResult = (_total / _count) * 1000; + + // dump results + diag_log text format ["%1: Average: %2s / %3 = %4ms", _counterEntry select 0, _total, _count, _averageResult]; + } else { + diag_log text format ["%1: No results", _counterEntry select 0]; + }; + false +} count ACE_COUNTERS; + +/* +// Dump PFH Trackers +diag_log text format["ACE_PERFORMANCE_EXCESSIVE_STEP_TRACKER"]; +diag_log text format["-------------------------------------------"]; +{ + private _delay = _x select 2; + //if(_delay > 0) then { _delay = _delay / 1000; }; + + diag_log text format["%1: %2s, delay=%3, handle=%4",(_x select 0), _delay, (_x select 3), (_x select 4)]; +} forEach ACE_PERFORMANCE_EXCESSIVE_STEP_TRACKER; + +// Dump PFH Trackers +diag_log text format["ACE_PERFORMANCE_EXCESSIVE_FRAME_TRACKER"]; +diag_log text format["-------------------------------------------"]; +{ + private _delta = _x select 1; + //if(_delta > 0) then { _delta = _delta / 1000; }; + diag_log text format[" DELTA: %1s", _delta]; +} forEach ACE_PERFORMANCE_EXCESSIVE_FRAME_TRACKER; + +//{ +// +//} forEach ACRE_EXCESSIVE_FRAME_TRACKER; + +*/ diff --git a/addons/common/functions/fnc_getTurretDirection.sqf b/addons/common/functions/fnc_getTurretDirection.sqf index 92c84cdca9..1de8af459e 100644 --- a/addons/common/functions/fnc_getTurretDirection.sqf +++ b/addons/common/functions/fnc_getTurretDirection.sqf @@ -1,42 +1,42 @@ -/* - * Author: jaynus - * Get the absolute turret direction for FOV/PIP turret. - * - * Arguments: - * 0: Vehicle - * 1: Turret Position - * - * Return Value: - * 0: Position ASL - * 1: Direction - * - * Public: Yes - */ -#include "script_component.hpp" - -params ["_vehicle", "_position"]; - -private _turret = [_vehicle, _position] call CBA_fnc_getTurret; - -private _pov = getText (_turret >> "memoryPointGunnerOptics"); -private _gunBeg = getText (_turret >> "gunBeg"); -private _gunEnd = getText (_turret >> "gunEnd"); - -TRACE_3("", _pov, _gunBeg, _gunEnd); - -// Pull the PIP pov or barrel direction, depending on how the model is set up -private _povPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _pov)); //@todo AGLToASL ? -private _povDir = [0,0,0]; - -if (_pov == "pip0_pos") then { - private _pipDir = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition "pip0_dir")); - - _povDir = _pipDir vectorDiff _povPos; -} else { - private _gunBeginPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg)); - private _gunEndPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd)); - - _povDir = _gunBeginPos vectorDiff _gunEndPos; -}; - -[_povPos, _povDir] +/* + * Author: jaynus + * Get the absolute turret direction for FOV/PIP turret. + * + * Arguments: + * 0: Vehicle + * 1: Turret Position + * + * Return Value: + * 0: Position ASL + * 1: Direction + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_vehicle", "_position"]; + +private _turret = [_vehicle, _position] call CBA_fnc_getTurret; + +private _pov = getText (_turret >> "memoryPointGunnerOptics"); +private _gunBeg = getText (_turret >> "gunBeg"); +private _gunEnd = getText (_turret >> "gunEnd"); + +TRACE_3("", _pov, _gunBeg, _gunEnd); + +// Pull the PIP pov or barrel direction, depending on how the model is set up +private _povPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _pov)); //@todo AGLToASL ? +private _povDir = [0,0,0]; + +if (_pov == "pip0_pos") then { + private _pipDir = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition "pip0_dir")); + + _povDir = _pipDir vectorDiff _povPos; +} else { + private _gunBeginPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunBeg)); + private _gunEndPos = ATLtoASL (_vehicle modelToWorldVisual (_vehicle selectionPosition _gunEnd)); + + _povDir = _gunBeginPos vectorDiff _gunEndPos; +}; + +[_povPos, _povDir] diff --git a/addons/common/functions/fnc_globalEvent.sqf b/addons/common/functions/fnc_globalEvent.sqf index 126419b553..69bfc210b1 100644 --- a/addons/common/functions/fnc_globalEvent.sqf +++ b/addons/common/functions/fnc_globalEvent.sqf @@ -1,21 +1,21 @@ -/* - * Author: Nou - * Execute a global event on all clients, including self. - * - * Arguments: - * 0: Event name - * 1: Event args - * - * Return Value: - * None - * - * Public: Yes - */ -#include "script_component.hpp" - -params ["_eventName", "_eventArgs"]; - -ACEg = [_eventName, _eventArgs]; -publicVariable "ACEg"; - -["ACEg", ACEg] call FUNC(_handleNetEvent); +/* + * Author: Nou + * Execute a global event on all clients, including self. + * + * Arguments: + * 0: Event name + * 1: Event args + * + * Return Value: + * None + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_eventName", "_eventArgs"]; + +ACEg = [_eventName, _eventArgs]; +publicVariable "ACEg"; + +["ACEg", ACEg] call FUNC(_handleNetEvent); diff --git a/addons/common/functions/fnc_localEvent.sqf b/addons/common/functions/fnc_localEvent.sqf index bf17cc0d0e..fa7c721a98 100644 --- a/addons/common/functions/fnc_localEvent.sqf +++ b/addons/common/functions/fnc_localEvent.sqf @@ -1,36 +1,36 @@ -/* - * Author: Nou - * Execute a local event on this client only. - * - * Arguments: - * 0: Event name (string) - * 1: Event args (any) - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -params ["_eventName", "_eventArgs"]; - -private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; - -if (!isNil "_eventFunctions") then { - - #ifdef DEBUG_EVENTS - ACE_LOGINFO_1("* Local Event: %1",_eventName); - ACE_LOGINFO_1(" args=%1",_eventArgs); - #endif - - { - if (!isNil "_x") then { - _eventArgs call CALLSTACK_NAMED(_x,FORMAT_2("Local Event %1 ID: %2",_eventName,_forEachIndex)); - - #ifdef DEBUG_EVENTS_CALLSTACK - ACE_LOGINFO_1(" ID: %1",_forEachIndex); - #endif - }; - } forEach _eventFunctions; -}; +/* + * Author: Nou + * Execute a local event on this client only. + * + * Arguments: + * 0: Event name (string) + * 1: Event args (any) + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +params ["_eventName", "_eventArgs"]; + +private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; + +if (!isNil "_eventFunctions") then { + + #ifdef DEBUG_EVENTS + ACE_LOGINFO_1("* Local Event: %1",_eventName); + ACE_LOGINFO_1(" args=%1",_eventArgs); + #endif + + { + if (!isNil "_x") then { + _eventArgs call CALLSTACK_NAMED(_x,FORMAT_2("Local Event %1 ID: %2",_eventName,_forEachIndex)); + + #ifdef DEBUG_EVENTS_CALLSTACK + ACE_LOGINFO_1(" ID: %1",_forEachIndex); + #endif + }; + } forEach _eventFunctions; +}; diff --git a/addons/common/functions/fnc_removeAllEventHandlers.sqf b/addons/common/functions/fnc_removeAllEventHandlers.sqf index ed1cce278c..5266c4554f 100644 --- a/addons/common/functions/fnc_removeAllEventHandlers.sqf +++ b/addons/common/functions/fnc_removeAllEventHandlers.sqf @@ -1,17 +1,17 @@ -/* - * Author: Nou - * Remove all events of a certain event type. - * - * Argument: - * 0: Event name - * - * Return Value: - * None - * - * Public: Yes - */ -#include "script_component.hpp" - -params ["_eventName"]; - -GVAR(eventsLocation) setVariable [_eventName, nil]; +/* + * Author: Nou + * Remove all events of a certain event type. + * + * Argument: + * 0: Event name + * + * Return Value: + * None + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_eventName"]; + +GVAR(eventsLocation) setVariable [_eventName, nil]; diff --git a/addons/common/functions/fnc_removeEventHandler.sqf b/addons/common/functions/fnc_removeEventHandler.sqf index a0b5ed5333..bedb99ed02 100644 --- a/addons/common/functions/fnc_removeEventHandler.sqf +++ b/addons/common/functions/fnc_removeEventHandler.sqf @@ -1,23 +1,23 @@ -/* - * Author: Nou - * Remove an event handler. - * - * Argument: - * 0: Event name - * 1: Event code - * - * Return Value: - * None - * - * Public: Yes - */ -#include "script_component.hpp" - -params ["_eventName", "_eventCodeIndex"]; - -private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; - -if (isNil "_eventFunctions") exitWith {TRACE_1("eventName not found",_eventName);}; -if ((_eventCodeIndex < 0) || {(count _eventFunctions) <= _eventCodeIndex}) exitWith {TRACE_2("index out of bounds",_eventName,_eventCodeIndex);}; - -_eventFunctions set [_eventCodeIndex, nil]; +/* + * Author: Nou + * Remove an event handler. + * + * Argument: + * 0: Event name + * 1: Event code + * + * Return Value: + * None + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_eventName", "_eventCodeIndex"]; + +private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; + +if (isNil "_eventFunctions") exitWith {TRACE_1("eventName not found",_eventName);}; +if ((_eventCodeIndex < 0) || {(count _eventFunctions) <= _eventCodeIndex}) exitWith {TRACE_2("index out of bounds",_eventName,_eventCodeIndex);}; + +_eventFunctions set [_eventCodeIndex, nil]; diff --git a/addons/common/functions/fnc_removeSyncedEventHandler.sqf b/addons/common/functions/fnc_removeSyncedEventHandler.sqf index 23803acdd1..4190de5e1b 100644 --- a/addons/common/functions/fnc_removeSyncedEventHandler.sqf +++ b/addons/common/functions/fnc_removeSyncedEventHandler.sqf @@ -1,26 +1,26 @@ -/* - * Author: jaynus - * Remove a synced event handler - * - * Arguments: - * 0: Name - * - * Return Value: - * Boolean of success - * - * Public: No - */ -#include "script_component.hpp" - -params ["_name"]; - -if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { - ACE_LOGERROR_1("Synced event key [%1] not found (removeSyncedEventHandler).", _name); - false -}; - -private _data = HASH_GET(GVAR(syncedEvents),_name); -_data params ["", "", "", "_eventId"]; - -[_eventId] call FUNC(removeEventHandler); -HASH_REM(GVAR(syncedEvents),_name); +/* + * Author: jaynus + * Remove a synced event handler + * + * Arguments: + * 0: Name + * + * Return Value: + * Boolean of success + * + * Public: No + */ +#include "script_component.hpp" + +params ["_name"]; + +if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { + ACE_LOGERROR_1("Synced event key [%1] not found (removeSyncedEventHandler).", _name); + false +}; + +private _data = HASH_GET(GVAR(syncedEvents),_name); +_data params ["", "", "", "_eventId"]; + +[_eventId] call FUNC(removeEventHandler); +HASH_REM(GVAR(syncedEvents),_name); diff --git a/addons/common/functions/fnc_requestSyncedEvent.sqf b/addons/common/functions/fnc_requestSyncedEvent.sqf index 7cbc8f6c8d..e7879a909a 100644 --- a/addons/common/functions/fnc_requestSyncedEvent.sqf +++ b/addons/common/functions/fnc_requestSyncedEvent.sqf @@ -1,20 +1,20 @@ -/* - * Author: jaynus - * Send a request to synchronize an event name from the client->server. Execute on client only. - * - * Arguments: - * 0: eventName - * - * Return Value: - * Boolean of success - * - * Public: No - */ -#include "script_component.hpp" - -params ["_eventName"]; - -// Only JIP machines on initialization send this off, requesting sync on events with the serverCommand -if (isServer) exitWith {false}; - -["SEH_s", [_eventName, ACE_player] ] call FUNC(serverEvent); +/* + * Author: jaynus + * Send a request to synchronize an event name from the client->server. Execute on client only. + * + * Arguments: + * 0: eventName + * + * Return Value: + * Boolean of success + * + * Public: No + */ +#include "script_component.hpp" + +params ["_eventName"]; + +// Only JIP machines on initialization send this off, requesting sync on events with the serverCommand +if (isServer) exitWith {false}; + +["SEH_s", [_eventName, ACE_player] ] call FUNC(serverEvent); diff --git a/addons/common/functions/fnc_serverEvent.sqf b/addons/common/functions/fnc_serverEvent.sqf index 65ab0da2a7..b9dccd2c70 100644 --- a/addons/common/functions/fnc_serverEvent.sqf +++ b/addons/common/functions/fnc_serverEvent.sqf @@ -1,29 +1,29 @@ -/* - * Author: Nou - * Execute a event only on the server. - * - * Argument: - * 0: Event name - * 1: Event args - * - * Return Value: - * None - * - * Public: Yes - */ -#include "script_component.hpp" - -params ["_eventName", "_eventArgs"]; - -#ifdef DEBUG_EVENTS - ACE_LOGINFO_1("* Server Event: %1",_eventName); - ACE_LOGINFO_1(" args=%1",_eventArgs); -#endif - -ACEg = [_eventName, _eventArgs]; - -if (!isServer) then { - publicVariableServer "ACEg"; -} else { - ["ACEg", ACEg] call FUNC(_handleNetEvent); -}; +/* + * Author: Nou + * Execute a event only on the server. + * + * Argument: + * 0: Event name + * 1: Event args + * + * Return Value: + * None + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_eventName", "_eventArgs"]; + +#ifdef DEBUG_EVENTS + ACE_LOGINFO_1("* Server Event: %1",_eventName); + ACE_LOGINFO_1(" args=%1",_eventArgs); +#endif + +ACEg = [_eventName, _eventArgs]; + +if (!isServer) then { + publicVariableServer "ACEg"; +} else { + ["ACEg", ACEg] call FUNC(_handleNetEvent); +}; diff --git a/addons/common/functions/fnc_syncedEvent.sqf b/addons/common/functions/fnc_syncedEvent.sqf index c752d1eba2..3ee2668019 100644 --- a/addons/common/functions/fnc_syncedEvent.sqf +++ b/addons/common/functions/fnc_syncedEvent.sqf @@ -1,26 +1,26 @@ -/* - * Author: jaynus - * Call and propegate a synced event - * - * Arguments: - * 0: Name - * 1: Arguments - * 2: TTL [Optional] for this specific event call - * - * Return Value: - * Boolean of success - * - * Public: No - */ -#include "script_component.hpp" - -params ["_name", "_args", ["_ttl", 0]]; - -if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { - ACE_LOGERROR_1("Synced event key [%1] not found (syncedEvent).", _name); - false -}; - -private _eventData = [_name, _args, _ttl]; - -["SEH", _eventData] call FUNC(globalEvent); +/* + * Author: jaynus + * Call and propegate a synced event + * + * Arguments: + * 0: Name + * 1: Arguments + * 2: TTL [Optional] for this specific event call + * + * Return Value: + * Boolean of success + * + * Public: No + */ +#include "script_component.hpp" + +params ["_name", "_args", ["_ttl", 0]]; + +if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith { + ACE_LOGERROR_1("Synced event key [%1] not found (syncedEvent).", _name); + false +}; + +private _eventData = [_name, _args, _ttl]; + +["SEH", _eventData] call FUNC(globalEvent); diff --git a/addons/common/functions/fnc_syncedEventPFH.sqf b/addons/common/functions/fnc_syncedEventPFH.sqf index 62df8f10a7..ca0cc4829b 100644 --- a/addons/common/functions/fnc_syncedEventPFH.sqf +++ b/addons/common/functions/fnc_syncedEventPFH.sqf @@ -1,62 +1,62 @@ -/* - * Author: ? - * - * ? - * - * Arguments: - * ? - * - * Return Value: - * ? - * - * Public: ? - */ -#include "script_component.hpp" - -if (!isServer) exitWith {false}; - -// Walk through the local synced events and clean up anything thats already EOL -// @TODO: This should be iteration limited to prevent FPS lag - -{ - private _name = _x; - - private _data = HASH_GET(GVAR(syncedEvents),_name); - _data params ["_eventTime", "_eventLog", "_globalEventTTL"]; - - private _newEventLog = []; - - // @TODO: This should be iteration limited to prevent FPS lag - { - private _eventEntry = _x; - private _ttlReturn = true; - - if (_globalEventTTL isEqualType {}) then { - _ttlReturn = [_eventTime, _eventEntry] call _globalEventTTL; - } else { - _ttlReturn = call {_globalEventTTL < 1 || {ACE_diagTime < (_eventEntry select 0) + _globalEventTTL}}; - }; - - if (_ttlReturn) then { - // Do event based TTL check - _eventEntry params ["_time", "", "_eventTTL"]; - - if (_eventTTL isEqualType {}) then { - _ttlReturn = [_eventTime, _eventEntry] call _eventTTL; - } else { - _ttlReturn = call {_eventTTL < 1 || {ACE_diagTime < _time + _eventTTL}}; - }; - }; - - // Finally drop it if the TTL check fails - if (_ttlReturn) then { - _newEventLog pushBack _x; - }; - false - } count _eventLog; - - _data set [1, _newEventLog]; - false -} count (GVAR(syncedEvents) select 0); - -// @TODO: Next, detect if we had a new request from a JIP player, and we need to continue syncing events +/* + * Author: ? + * + * ? + * + * Arguments: + * ? + * + * Return Value: + * ? + * + * Public: ? + */ +#include "script_component.hpp" + +if (!isServer) exitWith {false}; + +// Walk through the local synced events and clean up anything thats already EOL +// @TODO: This should be iteration limited to prevent FPS lag + +{ + private _name = _x; + + private _data = HASH_GET(GVAR(syncedEvents),_name); + _data params ["_eventTime", "_eventLog", "_globalEventTTL"]; + + private _newEventLog = []; + + // @TODO: This should be iteration limited to prevent FPS lag + { + private _eventEntry = _x; + private _ttlReturn = true; + + if (_globalEventTTL isEqualType {}) then { + _ttlReturn = [_eventTime, _eventEntry] call _globalEventTTL; + } else { + _ttlReturn = call {_globalEventTTL < 1 || {ACE_diagTime < (_eventEntry select 0) + _globalEventTTL}}; + }; + + if (_ttlReturn) then { + // Do event based TTL check + _eventEntry params ["_time", "", "_eventTTL"]; + + if (_eventTTL isEqualType {}) then { + _ttlReturn = [_eventTime, _eventEntry] call _eventTTL; + } else { + _ttlReturn = call {_eventTTL < 1 || {ACE_diagTime < _time + _eventTTL}}; + }; + }; + + // Finally drop it if the TTL check fails + if (_ttlReturn) then { + _newEventLog pushBack _x; + }; + false + } count _eventLog; + + _data set [1, _newEventLog]; + false +} count (GVAR(syncedEvents) select 0); + +// @TODO: Next, detect if we had a new request from a JIP player, and we need to continue syncing events diff --git a/addons/common/functions/fnc_targetEvent.sqf b/addons/common/functions/fnc_targetEvent.sqf index b9802f0835..85038f8e35 100644 --- a/addons/common/functions/fnc_targetEvent.sqf +++ b/addons/common/functions/fnc_targetEvent.sqf @@ -1,33 +1,33 @@ -/* - * Author: Nou - * Execute a event only on specific clients. - * - * Arguments: - * 0: Event name (STRING) - * 1: Event targets - * 2: Event args - * - * Note: If local executor is in list of targets, event will execute with - * network delay, and not immediatly. - * - * Return Value: - * None - * - * Public: Yes - */ -#include "script_component.hpp" - -params ["_eventName", "_eventTargets", "_eventArgs"]; - -#ifdef DEBUG_EVENTS - ACE_LOGINFO_2("* Target Event: %1 - %2",_eventName,_eventTargets); - ACE_LOGINFO_1(" args=%1",_eventArgs); -#endif - -ACEc = [_eventName, _eventTargets, _eventArgs]; - -if (!isServer) then { - publicVariableServer "ACEc"; -} else { - ["ACEc", ACEc] call FUNC(_handleNetEvent); -}; +/* + * Author: Nou + * Execute a event only on specific clients. + * + * Arguments: + * 0: Event name (STRING) + * 1: Event targets + * 2: Event args + * + * Note: If local executor is in list of targets, event will execute with + * network delay, and not immediatly. + * + * Return Value: + * None + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_eventName", "_eventTargets", "_eventArgs"]; + +#ifdef DEBUG_EVENTS + ACE_LOGINFO_2("* Target Event: %1 - %2",_eventName,_eventTargets); + ACE_LOGINFO_1(" args=%1",_eventArgs); +#endif + +ACEc = [_eventName, _eventTargets, _eventArgs]; + +if (!isServer) then { + publicVariableServer "ACEc"; +} else { + ["ACEc", ACEc] call FUNC(_handleNetEvent); +}; diff --git a/addons/common/functions/fnc_timePFH.sqf b/addons/common/functions/fnc_timePFH.sqf index e5366d331e..d70c6baea2 100644 --- a/addons/common/functions/fnc_timePFH.sqf +++ b/addons/common/functions/fnc_timePFH.sqf @@ -1,40 +1,40 @@ -/* - * Author: jaynus - * PFEH to set all Ace Time Variables - * - * Arguments: - * None - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -BEGIN_COUNTER(timePFH); - -private _lastTickTime = ACE_diagTime; -private _lastGameTime = ACE_gameTime; - -ACE_gameTime = time; -ACE_diagTime = diag_tickTime; - -private _delta = ACE_diagTime - _lastTickTime; - -if (ACE_gameTime <= _lastGameTime) then { - TRACE_1("paused",_delta); - ACE_paused = true; - // Game is paused or not running - ACE_pausedTime = ACE_pausedTime + _delta; - ACE_virtualPausedTime = ACE_pausedTime + (_delta * accTime); -} else { - TRACE_1("live",_delta); - ACE_paused = false; - // Time is updating - ACE_realTime = ACE_realTime + _delta; - ACE_virtualTime = ACE_virtualTime + (_delta * accTime); - ACE_time = ACE_virtualTime; -}; - -END_COUNTER(timePFH); +/* + * Author: jaynus + * PFEH to set all Ace Time Variables + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +BEGIN_COUNTER(timePFH); + +private _lastTickTime = ACE_diagTime; +private _lastGameTime = ACE_gameTime; + +ACE_gameTime = time; +ACE_diagTime = diag_tickTime; + +private _delta = ACE_diagTime - _lastTickTime; + +if (ACE_gameTime <= _lastGameTime) then { + TRACE_1("paused",_delta); + ACE_paused = true; + // Game is paused or not running + ACE_pausedTime = ACE_pausedTime + _delta; + ACE_virtualPausedTime = ACE_pausedTime + (_delta * accTime); +} else { + TRACE_1("live",_delta); + ACE_paused = false; + // Time is updating + ACE_realTime = ACE_realTime + _delta; + ACE_virtualTime = ACE_virtualTime + (_delta * accTime); + ACE_time = ACE_virtualTime; +}; + +END_COUNTER(timePFH); diff --git a/addons/common/functions/fnc_translateToModelSpace.sqf b/addons/common/functions/fnc_translateToModelSpace.sqf index b9fa35243a..309387086f 100644 --- a/addons/common/functions/fnc_translateToModelSpace.sqf +++ b/addons/common/functions/fnc_translateToModelSpace.sqf @@ -1,23 +1,23 @@ -/* - * Author: ? - * ? - * - * Arguments: - * ? - * - * Return Value: - * ? - * - * Public: ? - */ -#include "script_component.hpp" - -params ["_object", "_matrix", "_offset"]; - -private _origin = getPosASL _object; - -_matrix params ["_xVec", "_yVec", "_zVec"]; - -_offset params ["_x", "_y", "_z"]; - -(_xVec vectorMultiply _x) vectorAdd (_yVec vectorMultiply _y) vectorAdd (_zVec vectorMultiply _z) vectorAdd _origin // return +/* + * Author: ? + * ? + * + * Arguments: + * ? + * + * Return Value: + * ? + * + * Public: ? + */ +#include "script_component.hpp" + +params ["_object", "_matrix", "_offset"]; + +private _origin = getPosASL _object; + +_matrix params ["_xVec", "_yVec", "_zVec"]; + +_offset params ["_x", "_y", "_z"]; + +(_xVec vectorMultiply _x) vectorAdd (_yVec vectorMultiply _y) vectorAdd (_zVec vectorMultiply _z) vectorAdd _origin // return diff --git a/addons/common/functions/fnc_translateToWeaponSpace.sqf b/addons/common/functions/fnc_translateToWeaponSpace.sqf index cd360bd874..fab3fe6a3c 100644 --- a/addons/common/functions/fnc_translateToWeaponSpace.sqf +++ b/addons/common/functions/fnc_translateToWeaponSpace.sqf @@ -1,29 +1,29 @@ -/* - * Author: ? - * ? - * - * Arguments: - * ? - * - * Return Value: - * ? - * - * Public: ? - */ -#include "script_component.hpp" - -params ["_object", "_matrix", "_offset"]; - -private _origin = getPosASL _object; - -_matrix params ["_xVec", "_yVec", "_zVec"]; - -_offset = _offset vectorDiff _origin; - -_offset params ["_x", "_y", "_z"]; - -[ - ((_xVec select 0) * _x) + ((_xVec select 1) * _y) + ((_xVec select 2) * _z), - ((_yVec select 0) * _x) + ((_yVec select 1) * _y) + ((_yVec select 2) * _z), - ((_zVec select 0) * _x) + ((_zVec select 1) * _y) + ((_zVec select 2) * _z) -] // return +/* + * Author: ? + * ? + * + * Arguments: + * ? + * + * Return Value: + * ? + * + * Public: ? + */ +#include "script_component.hpp" + +params ["_object", "_matrix", "_offset"]; + +private _origin = getPosASL _object; + +_matrix params ["_xVec", "_yVec", "_zVec"]; + +_offset = _offset vectorDiff _origin; + +_offset params ["_x", "_y", "_z"]; + +[ + ((_xVec select 0) * _x) + ((_xVec select 1) * _y) + ((_xVec select 2) * _z), + ((_yVec select 0) * _x) + ((_yVec select 1) * _y) + ((_yVec select 2) * _z), + ((_zVec select 0) * _x) + ((_zVec select 1) * _y) + ((_zVec select 2) * _z) +] // return diff --git a/addons/common/functions/fnc_waveHeightAt.sqf b/addons/common/functions/fnc_waveHeightAt.sqf index bc278a9b70..c140b1ce94 100644 --- a/addons/common/functions/fnc_waveHeightAt.sqf +++ b/addons/common/functions/fnc_waveHeightAt.sqf @@ -1,24 +1,24 @@ -/* - * 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 - * - * - * Public: No - */ -#include "script_component.hpp" - -params ["_position"]; - -if (isNil QGVAR(waveHeightLogic)) then { - GVAR(waveHeightLogic) = "Logic" createVehicleLocal [0,0,0]; -}; - -GVAR(waveHeightLogic) setPosASL _position; - -(getPosASLW GVAR(waveHeightLogic) select 2) - (getPosASL GVAR(waveHeightLogic) select 2) +/* + * 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 + * + * + * Public: No + */ +#include "script_component.hpp" + +params ["_position"]; + +if (isNil QGVAR(waveHeightLogic)) then { + GVAR(waveHeightLogic) = "Logic" createVehicleLocal [0,0,0]; +}; + +GVAR(waveHeightLogic) setPosASL _position; + +(getPosASLW GVAR(waveHeightLogic) select 2) - (getPosASL GVAR(waveHeightLogic) select 2) diff --git a/addons/common/functions/fnc_worldToScreenBounds.sqf b/addons/common/functions/fnc_worldToScreenBounds.sqf index c9e5551d19..65b0164ca0 100644 --- a/addons/common/functions/fnc_worldToScreenBounds.sqf +++ b/addons/common/functions/fnc_worldToScreenBounds.sqf @@ -1,74 +1,74 @@ -/* - * Author: zGuba 2011 - * Function helper for framing objects on screen. - * - * Arguments: - * 0: object - * 1: margins 3D - * 0: X - * 1: Y - * 2: Z - * 2: offset 3D - * 0: X - * 1: Y - * 2: Z - * - * Return Value: - * 0: Minimal X - * 1: Minimal Y - * 2: Maximal X - * 3: Maximal Y - * - * Public: No - */ -#include "script_component.hpp" - -params ["_object", "_margins", "_offsets"]; - -private _minX = 10; -private _minY = 10; -private _maxX = -10; -private _maxY = -10; - -private _bounds = boundingBox _object; -_margins params ["_marginsX", "_marginsY", "_marginsZ"]; -_offsets params ["_offsetsX", "_offsetsY", "_offsetsZ"]; - -_bounds params ["_boundsMin", "_boundsMax"]; -_boundsMin params ["_boundsMinX", "_boundsMinY", "_boundsMinZ"]; -_boundsMax params ["_boundsMaxX", "_boundsMaxY", "_boundsMaxZ"]; - -_boundsMinX = _boundsMinX - _marginsX + _offsetsX; -_boundsMinY = _boundsMinY - _marginsY + _offsetsY; -_boundsMinZ = _boundsMinZ - _marginsZ + _offsetsZ; - -_boundsMaxX = _boundsMaxX + _marginsX + _offsetsX; -_boundsMaxY = _boundsMaxY + _marginsY + _offsetsY; -_boundsMaxZ = _boundsMaxZ + _marginsZ + _offsetsZ; - -private _boundsCorners = [ - [_boundsMinX, _boundsMinY, _boundsMinZ], - [_boundsMinX, _boundsMinY, _boundsMaxZ], - [_boundsMinX, _boundsMaxY, _boundsMinZ], - [_boundsMinX, _boundsMaxY, _boundsMaxZ], - [_boundsMaxX, _boundsMinY, _boundsMinZ], - [_boundsMaxX, _boundsMinY, _boundsMaxZ], - [_boundsMaxX, _boundsMaxY, _boundsMinZ], - [_boundsMaxX, _boundsMaxY, _boundsMaxZ] -]; - -{ - private _ppos = worldToScreen (_object modelToWorld _x); - - if (count _ppos >= 2) then { - _ppos params ["_pposX", "_pposY"]; - - if (_pposX < _minX) then {_minX = _pposX}; - if (_pposX > _maxX) then {_maxX = _pposX}; - if (_pposY < _minY) then {_minY = _pposY}; - if (_pposY > _maxY) then {_maxY = _pposY}; - }; //else - what to do if it is offscreen? - false -} count _boundsCorners; - -[_minX, _minY, _maxX, _maxY] +/* + * Author: zGuba 2011 + * Function helper for framing objects on screen. + * + * Arguments: + * 0: object + * 1: margins 3D + * 0: X + * 1: Y + * 2: Z + * 2: offset 3D + * 0: X + * 1: Y + * 2: Z + * + * Return Value: + * 0: Minimal X + * 1: Minimal Y + * 2: Maximal X + * 3: Maximal Y + * + * Public: No + */ +#include "script_component.hpp" + +params ["_object", "_margins", "_offsets"]; + +private _minX = 10; +private _minY = 10; +private _maxX = -10; +private _maxY = -10; + +private _bounds = boundingBox _object; +_margins params ["_marginsX", "_marginsY", "_marginsZ"]; +_offsets params ["_offsetsX", "_offsetsY", "_offsetsZ"]; + +_bounds params ["_boundsMin", "_boundsMax"]; +_boundsMin params ["_boundsMinX", "_boundsMinY", "_boundsMinZ"]; +_boundsMax params ["_boundsMaxX", "_boundsMaxY", "_boundsMaxZ"]; + +_boundsMinX = _boundsMinX - _marginsX + _offsetsX; +_boundsMinY = _boundsMinY - _marginsY + _offsetsY; +_boundsMinZ = _boundsMinZ - _marginsZ + _offsetsZ; + +_boundsMaxX = _boundsMaxX + _marginsX + _offsetsX; +_boundsMaxY = _boundsMaxY + _marginsY + _offsetsY; +_boundsMaxZ = _boundsMaxZ + _marginsZ + _offsetsZ; + +private _boundsCorners = [ + [_boundsMinX, _boundsMinY, _boundsMinZ], + [_boundsMinX, _boundsMinY, _boundsMaxZ], + [_boundsMinX, _boundsMaxY, _boundsMinZ], + [_boundsMinX, _boundsMaxY, _boundsMaxZ], + [_boundsMaxX, _boundsMinY, _boundsMinZ], + [_boundsMaxX, _boundsMinY, _boundsMaxZ], + [_boundsMaxX, _boundsMaxY, _boundsMinZ], + [_boundsMaxX, _boundsMaxY, _boundsMaxZ] +]; + +{ + private _ppos = worldToScreen (_object modelToWorld _x); + + if (count _ppos >= 2) then { + _ppos params ["_pposX", "_pposY"]; + + if (_pposX < _minX) then {_minX = _pposX}; + if (_pposX > _maxX) then {_maxX = _pposX}; + if (_pposY < _minY) then {_minY = _pposY}; + if (_pposY > _maxY) then {_maxY = _pposY}; + }; //else - what to do if it is offscreen? + false +} count _boundsCorners; + +[_minX, _minY, _maxX, _maxY] diff --git a/addons/common/functions/script_component.hpp b/addons/common/functions/script_component.hpp index c213544655..bb0d2d5dff 100644 --- a/addons/common/functions/script_component.hpp +++ b/addons/common/functions/script_component.hpp @@ -1,13 +1,13 @@ -#include "\z\ace\addons\common\script_component.hpp" - -#define VALIDHASH(hash) (IS_ARRAY(hash) && {(count hash) >= 2} && {IS_ARRAY(hash select 0)} && {IS_ARRAY(hash select 1)}) -#define ERROR(msg) throw msg + format[" @ %1:%2", _callFrom, _lineNo] -#define HANDLECATCH diag_log text _exception; assert(exception=="") - -#define ERRORDATA(c) private ["_callFrom", "_lineNo"];\ - _callFrom = "";\ - _lineNo = -1;\ - if((count _this) > c) then {\ - _callFrom = _this select c;\ - _lineNo = _this select c+1;\ - }; +#include "\z\ace\addons\common\script_component.hpp" + +#define VALIDHASH(hash) (IS_ARRAY(hash) && {(count hash) >= 2} && {IS_ARRAY(hash select 0)} && {IS_ARRAY(hash select 1)}) +#define ERROR(msg) throw msg + format[" @ %1:%2", _callFrom, _lineNo] +#define HANDLECATCH diag_log text _exception; assert(exception=="") + +#define ERRORDATA(c) private ["_callFrom", "_lineNo"];\ + _callFrom = "";\ + _lineNo = -1;\ + if((count _this) > c) then {\ + _callFrom = _this select c;\ + _lineNo = _this select c+1;\ + }; diff --git a/addons/fcs/functions/fnc_onForceUpdate.sqf b/addons/fcs/functions/fnc_onForceUpdate.sqf index 1bf1f0d701..2c6d136300 100644 --- a/addons/fcs/functions/fnc_onForceUpdate.sqf +++ b/addons/fcs/functions/fnc_onForceUpdate.sqf @@ -1,13 +1,13 @@ -#include "script_component.hpp" - -params ["_unit"]; - -private _vehicle = vehicle _unit; - -if !([_unit, _vehicle, []] call EFUNC(common,canInteractWith)) exitWith {false}; -if !((!GVAR(enabled) && FUNC(canUseFCS)) || FUNC(canUseRangefinder)) exitWith {false}; - -private _turret = [_unit] call EFUNC(common,getTurretIndex); - -[_vehicle, _turret] call FUNC(keyDown); -[_vehicle, _turret] call FUNC(keyUp); +#include "script_component.hpp" + +params ["_unit"]; + +private _vehicle = vehicle _unit; + +if !([_unit, _vehicle, []] call EFUNC(common,canInteractWith)) exitWith {false}; +if !((!GVAR(enabled) && FUNC(canUseFCS)) || FUNC(canUseRangefinder)) exitWith {false}; + +private _turret = [_unit] call EFUNC(common,getTurretIndex); + +[_vehicle, _turret] call FUNC(keyDown); +[_vehicle, _turret] call FUNC(keyUp); diff --git a/addons/finger/ACE_Settings.hpp b/addons/finger/ACE_Settings.hpp index a4beb40eb8..73e1db1904 100644 --- a/addons/finger/ACE_Settings.hpp +++ b/addons/finger/ACE_Settings.hpp @@ -1,27 +1,27 @@ -class ACE_Settings { - class GVAR(enabled) { - value = 0; - typeName = "BOOL"; - displayName = CSTRING(enabled_displayName); - }; - class GVAR(maxRange) { - value = 4; - typeName = "SCALAR"; - displayName = CSTRING(maxRange_displayName); - description = CSTRING(maxRange_description); - }; - class GVAR(indicatorForSelf) { - value = 1; - typeName = "BOOL"; - isClientSettable = 1; - displayName = CSTRING(indicatorForSelf_name); - description = CSTRING(indicatorForSelf_description); - }; - class GVAR(indicatorColor) { - value[] = {0.83, 0.68, 0.21, 0.75}; - typeName = "COLOR"; - isClientSettable = 1; - displayName = CSTRING(indicatorColor_name); - description = CSTRING(indicatorColor_description); - }; -}; +class ACE_Settings { + class GVAR(enabled) { + value = 0; + typeName = "BOOL"; + displayName = CSTRING(enabled_displayName); + }; + class GVAR(maxRange) { + value = 4; + typeName = "SCALAR"; + displayName = CSTRING(maxRange_displayName); + description = CSTRING(maxRange_description); + }; + class GVAR(indicatorForSelf) { + value = 1; + typeName = "BOOL"; + isClientSettable = 1; + displayName = CSTRING(indicatorForSelf_name); + description = CSTRING(indicatorForSelf_description); + }; + class GVAR(indicatorColor) { + value[] = {0.83, 0.68, 0.21, 0.75}; + typeName = "COLOR"; + isClientSettable = 1; + displayName = CSTRING(indicatorColor_name); + description = CSTRING(indicatorColor_description); + }; +}; diff --git a/addons/finger/config.cpp b/addons/finger/config.cpp index 2cc3be5ddd..8383677c76 100644 --- a/addons/finger/config.cpp +++ b/addons/finger/config.cpp @@ -1,18 +1,18 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - units[] = {QGVAR(moduleSettings)}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"Drill"}; - authorUrl = "https://github.com/TheDrill/"; - VERSION_CONFIG; - }; -}; - - -#include "ACE_Settings.hpp" -#include "CfgEventHandlers.hpp" -#include "CfgVehicles.hpp" +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {QGVAR(moduleSettings)}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Drill"}; + authorUrl = "https://github.com/TheDrill/"; + VERSION_CONFIG; + }; +}; + + +#include "ACE_Settings.hpp" +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/finger/script_component.hpp b/addons/finger/script_component.hpp index edaf93a942..c9164763e7 100644 --- a/addons/finger/script_component.hpp +++ b/addons/finger/script_component.hpp @@ -1,26 +1,26 @@ -#define COMPONENT finger -#include "\z\ace\addons\main\script_mod.hpp" - -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS -// #define ENABLE_PERFORMANCE_COUNTERS - -#ifdef DEBUG_ENABLED_FINGER - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_FINGER - #define DEBUG_SETTINGS DEBUG_SETTINGS_FINGER -#endif - -#include "\z\ace\addons\main\script_macros.hpp" - -#define BASE_SIZE 44 - -#define FP_TIMEOUT 2 -#define FP_ACTION_TIMEOUT 1 - -#define FP_DISTANCE 10000 -#define FP_RANDOMIZATION_X 350 -#define FP_RANDOMIZATION_Y 100 +#define COMPONENT finger +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_FINGER + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_FINGER + #define DEBUG_SETTINGS DEBUG_SETTINGS_FINGER +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + +#define BASE_SIZE 44 + +#define FP_TIMEOUT 2 +#define FP_ACTION_TIMEOUT 1 + +#define FP_DISTANCE 10000 +#define FP_RANDOMIZATION_X 350 +#define FP_RANDOMIZATION_Y 100 diff --git a/addons/frag/CfgAmmo.hpp b/addons/frag/CfgAmmo.hpp index cd6cc64cfd..defa634102 100644 --- a/addons/frag/CfgAmmo.hpp +++ b/addons/frag/CfgAmmo.hpp @@ -1,478 +1,478 @@ -#define BASE_DRAG -0.01 -#define HD_MULT 5 -#define BASE_DRAG_HD (BASE_DRAG*HD_MULT) - -class CfgAmmo { - //class ace_arty_105mm_m1_m782_time; - //class ace_arty_105mm_m1_m782_prox: ace_arty_105mm_m1_m782_time {}; - //class ace_arty_105mm_m1_m782_delay: ace_arty_105mm_m1_m782_prox { - // GVAR(skip) = 1; - //}; - - class Bo_GBU12_LGB; - class ACE_GBU12 : Bo_GBU12_LGB { - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"}; - GVAR(metal) = 140000; - GVAR(charge) = 87000; - GVAR(gurney_c) = 2320; - GVAR(gurney_k) = 1/2; - sideAirFriction = 0.04; - airFriction = 0.04; - laserLock = 0; - }; - - class GrenadeBase; - class Grenade; - class GrenadeHand: Grenade { - GVAR(enabled) = 1; - - GVAR(skip) = 0; - GVAR(force) = 1; - // This is a good high-drag frag type for grenades. - GVAR(classes)[] = {"ACE_frag_tiny_HD"}; - /* - These values are based on the M67 Grenade, should be tweaked for - individual grenades. - */ - GVAR(metal) = 210; // metal in grams - GVAR(charge) = 185; // explosive in grams - GVAR(gurney_c) = 2843; // Gurney velocity constant for explosive type. See: http://en.wikipedia.org/wiki/Gurney_equations - GVAR(gurney_k) = 3/5; // Gurney shape factor, in this case a sphere. See: http://en.wikipedia.org/wiki/Gurney_equations - }; - class GrenadeHand_stone: GrenadeHand { - GVAR(skip) = 1; - }; - class SmokeShell: GrenadeHand { - GVAR(skip) = 1; - }; - - class RocketBase; - class R_Hydra_HE: RocketBase { - // Source: http://fas.org/man/dod-101/sys/missile/hydra-70.htm - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; - GVAR(metal) = 3850; - GVAR(charge) = 1040; - GVAR(gurney_c) = 2700; - GVAR(gurney_k) = 1/2; - }; - //class R_57mm_HE: RocketBase { - // GVAR(skip) = 1; - //}; - - class R_80mm_HE: RocketBase { - GVAR(skip) = 1; - }; - - //class R_S8T_AT: RocketBase { - // GVAR(skip) = 1; - //}; - - class BombCore; - class Bo_Mk82: BombCore { - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"}; - GVAR(metal) = 140000; - GVAR(charge) = 87000; - GVAR(gurney_c) = 2320; - GVAR(gurney_k) = 1/2; - }; - - class G_40mm_HE: GrenadeBase { - // Source: http://www.inetres.com/gp/military/infantry/grenade/40mm_ammo.html#M441 - GVAR(enabled) = 1; - GVAR(force) = 1; - - GVAR(classes)[] = {"ACE_frag_tiny_HD"}; - GVAR(metal) = 200; - GVAR(charge) = 32; - GVAR(gurney_c) = 2700; - GVAR(gurney_k) = 1/2; - }; - class G_40mm_HEDP: G_40mm_HE { - // Source: http://www.inetres.com/gp/military/infantry/grenade/40mm_ammo.html#M433 - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_tiny_HD"}; - GVAR(metal) = 200; - GVAR(charge) = 45; - GVAR(gurney_c) = 2830; - GVAR(gurney_k) = 1/2; - }; - - class ACE_G_40mm_HEDP: G_40mm_HEDP { - }; - class ACE_G_40mm_HE: G_40mm_HE { - }; - class ACE_G_40mm_Practice: ACE_G_40mm_HE { - GVAR(skip) = 1; - GVAR(force) = 0; - }; - class ACE_G40mm_HE_VOG25P: G_40mm_HE { - GVAR(skip) = 0; - GVAR(force) = 1; - }; - - // curator ammo entries - class ShellBase; - class Sh_125mm_HEAT; - class Sh_155mm_AMOS: ShellBase { - // Source: http://www.globalsecurity.org/military/systems/munitions/m795.htm - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"}; - GVAR(metal) = 36000; - GVAR(charge) = 9979; - GVAR(gurney_c) = 2440; - GVAR(gurney_k) = 1/2; - }; - class Sh_82mm_AMOS : Sh_155mm_AMOS { - // Source: http://www.arsenal-bg.com/defense_police/mortar_bombs_82mm.htm - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; - GVAR(metal) = 3200; - GVAR(charge) = 420; - GVAR(gurney_c) = 2440; - GVAR(gurney_k) = 1/2; - }; - class ModuleOrdnanceMortar_F_Ammo: Sh_82mm_AMOS { - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; - GVAR(metal) = 800; - GVAR(charge) = 4200; - GVAR(gurney_c) = 2320; - GVAR(gurney_k) = 1/2; - }; - class Sh_105mm_HEAT_MP : Sh_125mm_HEAT { - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; - GVAR(metal) = 11400; - GVAR(charge) = 7100; - GVAR(gurney_c) = 2800; - GVAR(gurney_k) = 1/2; - }; - class Sh_120mm_HE : ShellBase { - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; - GVAR(metal) = 23000; - GVAR(charge) = 3148; - GVAR(gurney_c) = 2830; - GVAR(gurney_k) = 1/2; - }; - class Sh_125mm_HE: Sh_120mm_HE { - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; - GVAR(metal) = 16000; - GVAR(charge) = 3200; - GVAR(gurney_c) = 2440; - GVAR(gurney_k) = 1/2; - }; - class ModuleOrdnanceHowitzer_F_ammo: Sh_155mm_AMOS { - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"}; - GVAR(metal) = 1950; - GVAR(charge) = 15800; - GVAR(gurney_c) = 2320; - GVAR(gurney_k) = 1/2; - }; - - //class R_230mm_HE; - //class ModuleOrdnanceRocket_F_ammo: R_230mm_HE { - //}; - - //class R_230mm_fly; - //class ModuleOrdnanceRocket_F_subammo: R_230mm_fly { - //}; - // end of curator ammo entries - - //class R_SMAW_HEDP; - //class R_MEEWS_HEDP : R_SMAW_HEDP { - // GVAR(force) = 1; - // GVAR(multiplier) = 1.2; - //}; - - class MissileBase; - class Missile_AGM_02_F : MissileBase { - // Source: http://fas.org/man/dod-101/sys/smart/agm-65.htm - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; - GVAR(metal) = 56250; - GVAR(charge) = 39000; - GVAR(gurney_c) = 2700; - GVAR(gurney_k) = 1/2; - }; - class M_Hellfire_AT: MissileBase { - // Source: http://www.designation-systems.net/dusrm/m-114.html - GVAR(enabled) = 1; - - GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; - GVAR(metal) = 8000; - GVAR(charge) = 2400; - GVAR(gurney_c) = 2700; - GVAR(gurney_k) = 1/2; - }; - - /* - class B_762x51_Ball; - class ACE_frag_base: B_762x51_Ball { ////TODO: B_762x45_Ball no longer exists, is this a valid replacement? - model = "\A3\Weapons_f\ammo\shell"; - timeToLive = 12; - typicalSpeed = 800; - // Fix sounds - effectFly = "AmmoClassic"; - soundDefault1[] = {"A3\sounds_f\weapons\hits\concrete_1.wav",0.158114,1,30}; - soundDefault2[] = {"A3\sounds_f\weapons\hits\concrete_2.wav",0.158114,1,30}; - soundDefault3[] = {"A3\sounds_f\weapons\hits\concrete_3.wav",0.158114,1,30}; - soundDefault4[] = {"A3\sounds_f\weapons\hits\concrete_4.wav",0.158114,1,30}; - soundDefault5[] = {"A3\sounds_f\weapons\hits\concrete_5.wav",0.158114,1,30}; - soundDefault6[] = {"A3\sounds_f\weapons\hits\concrete_6.wav",0.158114,1,30}; - soundDefault7[] = {"A3\sounds_f\weapons\hits\concrete_7.wav",0.158114,1,30}; - soundDefault8[] = {"A3\sounds_f\weapons\hits\concrete_8.wav",0.158114,1,30}; - soundGroundSoft1[] = {"A3\sounds_f\weapons\hits\soft_ground_1.wav",0.02811705,1,30}; - soundGroundSoft2[] = {"A3\sounds_f\weapons\hits\soft_ground_2.wav",0.02811705,1,30}; - soundGroundSoft3[] = {"A3\sounds_f\weapons\hits\soft_ground_3.wav",0.02811705,1,30}; - soundGroundSoft4[] = {"A3\sounds_f\weapons\hits\soft_ground_4.wav",0.02811705,1,30}; - soundGroundSoft5[] = {"A3\sounds_f\weapons\hits\soft_ground_5.wav",0.02811705,1,30}; - soundGroundSoft6[] = {"A3\sounds_f\weapons\hits\soft_ground_6.wav",0.02811705,1,30}; - soundGroundSoft7[] = {"A3\sounds_f\weapons\hits\soft_ground_7.wav",0.02811705,1,30}; - soundGroundSoft8[] = {"A3\sounds_f\weapons\hits\soft_ground_8.wav",0.02811705,1,30}; - soundGroundHard1[] = {"A3\sounds_f\weapons\hits\hard_ground_1.wav",0.62946,1,40}; - soundGroundHard2[] = {"A3\sounds_f\weapons\hits\hard_ground_2.wav",0.62946,1,40}; - soundGroundHard3[] = {"A3\sounds_f\weapons\hits\hard_ground_3.wav",0.62946,1,40}; - soundGroundHard4[] = {"A3\sounds_f\weapons\hits\hard_ground_4.wav",0.62946,1,40}; - soundGroundHard5[] = {"A3\sounds_f\weapons\hits\hard_ground_5.wav",0.62946,1,40}; - soundGroundHard6[] = {"A3\sounds_f\weapons\hits\hard_ground_6.wav",0.62946,1,40}; - soundGroundHard7[] = {"A3\sounds_f\weapons\hits\hard_ground_7.wav",0.62946,1,40}; - soundGroundHard8[] = {"A3\sounds_f\weapons\hits\hard_ground_8.wav",0.62946,1,40}; - soundMetal1[] = {"A3\sounds_f\weapons\hits\metal_1.wav",0.158114,1,45}; - soundMetal2[] = {"A3\sounds_f\weapons\hits\metal_2.wav",0.158114,1,45}; - soundMetal3[] = {"A3\sounds_f\weapons\hits\metal_3.wav",0.158114,1,45}; - soundMetal4[] = {"A3\sounds_f\weapons\hits\metal_4.wav",0.158114,1,45}; - soundMetal5[] = {"A3\sounds_f\weapons\hits\metal_5.wav",0.158114,1,45}; - soundMetal6[] = {"A3\sounds_f\weapons\hits\metal_6.wav",0.158114,1,45}; - soundMetal7[] = {"A3\sounds_f\weapons\hits\metal_7.wav",0.158114,1,45}; - soundMetal8[] = {"A3\sounds_f\weapons\hits\metal_8.wav",0.158114,1,45}; - soundGlass1[] = {"A3\sounds_f\weapons\hits\glass_1.wav",0.177828,1,25}; - soundGlass2[] = {"A3\sounds_f\weapons\hits\glass_2.wav",0.177828,1,25}; - soundGlass3[] = {"A3\sounds_f\weapons\hits\glass_3.wav",0.177828,1,25}; - soundGlass4[] = {"A3\sounds_f\weapons\hits\glass_4.wav",0.177828,1,25}; - soundGlass5[] = {"A3\sounds_f\weapons\hits\glass_5.wav",0.177828,1,25}; - soundGlass6[] = {"A3\sounds_f\weapons\hits\glass_6.wav",0.177828,1,25}; - soundGlass7[] = {"A3\sounds_f\weapons\hits\glass_7.wav",0.177828,1,25}; - soundGlass8[] = {"A3\sounds_f\weapons\hits\glass_8.wav",0.177828,1,25}; - soundGlassArmored1[] = {"A3\sounds_f\weapons\hits\glass_arm_1.wav",0.177828,1,30}; - soundGlassArmored2[] = {"A3\sounds_f\weapons\hits\glass_arm_2.wav",0.177828,1,30}; - soundGlassArmored3[] = {"A3\sounds_f\weapons\hits\glass_arm_3.wav",0.177828,1,30}; - soundGlassArmored4[] = {"A3\sounds_f\weapons\hits\glass_arm_4.wav",0.177828,1,30}; - soundGlassArmored5[] = {"A3\sounds_f\weapons\hits\glass_arm_5.wav",0.177828,1,30}; - soundGlassArmored6[] = {"A3\sounds_f\weapons\hits\glass_arm_6.wav",0.177828,1,30}; - soundGlassArmored7[] = {"A3\sounds_f\weapons\hits\glass_arm_7.wav",0.177828,1,30}; - soundGlassArmored8[] = {"A3\sounds_f\weapons\hits\glass_arm_8.wav",0.177828,1,30}; - soundVehiclePlate1[] = {"A3\sounds_f\weapons\hits\metal_plate_1.wav",0.281170,1,40}; - soundVehiclePlate2[] = {"A3\sounds_f\weapons\hits\metal_plate_2.wav",0.281170,1,40}; - soundVehiclePlate3[] = {"A3\sounds_f\weapons\hits\metal_plate_3.wav",0.281170,1,40}; - soundVehiclePlate4[] = {"A3\sounds_f\weapons\hits\metal_plate_4.wav",0.281170,1,40}; - soundVehiclePlate5[] = {"A3\sounds_f\weapons\hits\metal_plate_5.wav",0.281170,1,40}; - soundVehiclePlate6[] = {"A3\sounds_f\weapons\hits\metal_plate_6.wav",0.281170,1,40}; - soundVehiclePlate7[] = {"A3\sounds_f\weapons\hits\metal_plate_7.wav",0.281170,1,40}; - soundVehiclePlate8[] = {"A3\sounds_f\weapons\hits\metal_plate_8.wav",0.281170,1,40}; - soundWood1[] = {"A3\sounds_f\weapons\hits\wood_1.wav",0.158114,1,30}; - soundWood2[] = {"A3\sounds_f\weapons\hits\wood_2.wav",0.158114,1,30}; - soundWood3[] = {"A3\sounds_f\weapons\hits\wood_3.wav",0.158114,1,30}; - soundWood4[] = {"A3\sounds_f\weapons\hits\wood_4.wav",0.158114,1,30}; - soundWood5[] = {"A3\sounds_f\weapons\hits\wood_5.wav",0.158114,1,30}; - soundWood6[] = {"A3\sounds_f\weapons\hits\wood_6.wav",0.158114,1,30}; - soundWood7[] = {"A3\sounds_f\weapons\hits\wood_7.wav",0.158114,1,30}; - soundWood8[] = {"A3\sounds_f\weapons\hits\wood_8.wav",0.158114,1,30}; - soundHitBody1[] = {"A3\sounds_f\weapons\hits\body_1.wav",0.0177828,1,25}; - soundHitBody2[] = {"A3\sounds_f\weapons\hits\body_2.wav",0.0177828,1,25}; - soundHitBody3[] = {"A3\sounds_f\weapons\hits\body_3.wav",0.0177828,1,25}; - soundHitBody4[] = {"A3\sounds_f\weapons\hits\body_4.wav",0.0177828,1,25}; - soundHitBody5[] = {"A3\sounds_f\weapons\hits\body_5.wav",0.0177828,1,25}; - soundHitBody6[] = {"A3\sounds_f\weapons\hits\body_6.wav",0.0177828,1,25}; - soundHitBody7[] = {"A3\sounds_f\weapons\hits\body_7.wav",0.0177828,1,25}; - soundHitBody8[] = {"A3\sounds_f\weapons\hits\body_8.wav",0.0177828,1,25}; - soundHitBuilding1[] = {"A3\sounds_f\weapons\hits\building_1.wav",0.251189,1,30}; - soundHitBuilding2[] = {"A3\sounds_f\weapons\hits\building_2.wav",0.251189,1,30}; - soundHitBuilding3[] = {"A3\sounds_f\weapons\hits\building_3.wav",0.251189,1,30}; - soundHitBuilding4[] = {"A3\sounds_f\weapons\hits\building_4.wav",0.251189,1,30}; - soundHitBuilding5[] = {"A3\sounds_f\weapons\hits\building_5.wav",0.251189,1,30}; - soundHitBuilding6[] = {"A3\sounds_f\weapons\hits\building_6.wav",0.251189,1,30}; - soundHitBuilding7[] = {"A3\sounds_f\weapons\hits\building_7.wav",0.251189,1,30}; - soundHitBuilding8[] = {"A3\sounds_f\weapons\hits\building_8.wav",0.251189,1,30}; - soundHitFoliage1[] = {"A3\sounds_f\weapons\hits\foliage_1.wav",0.177828,1,25}; - soundHitFoliage2[] = {"A3\sounds_f\weapons\hits\foliage_2.wav",0.177828,1,25}; - soundHitFoliage3[] = {"A3\sounds_f\weapons\hits\foliage_3.wav",0.177828,1,25}; - soundHitFoliage4[] = {"A3\sounds_f\weapons\hits\foliage_4.wav",0.177828,1,25}; - soundHitFoliage5[] = {"A3\sounds_f\weapons\hits\foliage_5.wav",0.177828,1,25}; - soundHitFoliage6[] = {"A3\sounds_f\weapons\hits\foliage_6.wav",0.177828,1,25}; - soundHitFoliage7[] = {"A3\sounds_f\weapons\hits\foliage_7.wav",0.177828,1,25}; - soundHitFoliage8[] = {"A3\sounds_f\weapons\hits\foliage_8.wav",0.177828,1,25}; - soundPlastic1[] = {"A3\sounds_f\weapons\hits\plastic_1.wav",0.177828,1,25}; - soundPlastic2[] = {"A3\sounds_f\weapons\hits\plastic_2.wav",0.177828,1,25}; - soundPlastic3[] = {"A3\sounds_f\weapons\hits\plastic_3.wav",0.177828,1,25}; - soundPlastic4[] = {"A3\sounds_f\weapons\hits\plastic_4.wav",0.177828,1,25}; - soundPlastic5[] = {"A3\sounds_f\weapons\hits\plastic_5.wav",0.177828,1,25}; - soundPlastic6[] = {"A3\sounds_f\weapons\hits\plastic_6.wav",0.177828,1,25}; - soundPlastic7[] = {"A3\sounds_f\weapons\hits\plastic_7.wav",0.177828,1,25}; - soundPlastic8[] = {"A3\sounds_f\weapons\hits\plastic_8.wav",0.177828,1,25}; - soundConcrete1[] = {"A3\sounds_f\weapons\hits\concrete_1.wav",0.177828,1,35}; - soundConcrete2[] = {"A3\sounds_f\weapons\hits\concrete_2.wav",0.177828,1,35}; - soundConcrete3[] = {"A3\sounds_f\weapons\hits\concrete_3.wav",0.177828,1,35}; - soundConcrete4[] = {"A3\sounds_f\weapons\hits\concrete_4.wav",0.177828,1,35}; - soundConcrete5[] = {"A3\sounds_f\weapons\hits\concrete_5.wav",0.177828,1,35}; - soundConcrete6[] = {"A3\sounds_f\weapons\hits\concrete_6.wav",0.177828,1,35}; - soundConcrete7[] = {"A3\sounds_f\weapons\hits\concrete_7.wav",0.177828,1,35}; - soundConcrete8[] = {"A3\sounds_f\weapons\hits\concrete_8.wav",0.177828,1,35}; - soundRubber1[] = {"A3\sounds_f\weapons\hits\tyre_1.wav",0.158114,1,25}; - soundRubber2[] = {"A3\sounds_f\weapons\hits\tyre_2.wav",0.158114,1,25}; - soundRubber3[] = {"A3\sounds_f\weapons\hits\tyre_3.wav",0.158114,1,25}; - soundRubber4[] = {"A3\sounds_f\weapons\hits\tyre_4.wav",0.158114,1,25}; - soundRubber5[] = {"A3\sounds_f\weapons\hits\tyre_5.wav",0.158114,1,25}; - soundRubber6[] = {"A3\sounds_f\weapons\hits\tyre_6.wav",0.158114,1,25}; - soundRubber7[] = {"A3\sounds_f\weapons\hits\tyre_7.wav",0.158114,1,25}; - soundRubber8[] = {"A3\sounds_f\weapons\hits\tyre_8.wav",0.158114,1,25}; - soundWater1[] = {"A3\sounds_f\weapons\hits\water_01.wav",0.158114,1,25}; - soundWater2[] = {"A3\sounds_f\weapons\hits\water_02.wav",0.158114,1,25}; - soundWater3[] = {"A3\sounds_f\weapons\hits\water_03.wav",0.158114,1,25}; - soundWater4[] = {"A3\sounds_f\weapons\hits\water_04.wav",0.158114,1,25}; - soundWater5[] = {"A3\sounds_f\weapons\hits\water_05.wav",0.158114,1,25}; - soundWater6[] = {"A3\sounds_f\weapons\hits\water_06.wav",0.158114,1,25}; - soundWater7[] = {"A3\sounds_f\weapons\hits\water_07.wav",0.158114,1,25}; - soundWater8[] = {"A3\sounds_f\weapons\hits\water_08.wav",0.158114,1,25}; - hitGroundSoft[] = {"soundGroundSoft1",0.2,"soundGroundSoft2",0.2,"soundGroundSoft3",0.1,"soundGroundSoft4",0.1,"soundGroundSoft5",0.1,"soundGroundSoft6",0.1,"soundGroundSoft7",0.1,"soundGroundSoft8",0.1}; - hitGroundHard[] = {"soundGroundHard1",0.2,"soundGroundHard2",0.2,"soundGroundHard3",0.1,"soundGroundHard4",0.1,"soundGroundHard5",0.1,"soundGroundHard6",0.1,"soundGroundHard7",0.1,"soundGroundHard8",0.1}; - hitMan[] = {"soundHitBody1",0.125,"soundHitBody2",0.125,"soundHitBody3",0.125,"soundHitBody4",0.125,"soundHitBody5",0.125,"soundHitBody6",0.125,"soundHitBody7",0.125,"soundHitBody8",0.125}; - hitArmor[] = {"soundVehiclePlate1",0.125,"soundVehiclePlate2",0.125,"soundVehiclePlate3",0.125,"soundVehiclePlate4",0.125,"soundVehiclePlate5",0.125,"soundVehiclePlate6",0.125,"soundVehiclePlate7",0.125,"soundVehiclePlate8",0.125}; - hitBuilding[] = {"soundHitBuilding1",0.2,"soundHitBuilding2",0.2,"soundHitBuilding3",0.1,"soundHitBuilding4",0.1,"soundHitBuilding5",0.1,"soundHitBuilding6",0.1,"soundHitBuilding7",0.1,"soundHitBuilding8",0.1}; - hitFoliage[] = {"soundHitFoliage1",0.125,"soundHitFoliage2",0.125,"soundHitFoliage3",0.125,"soundHitFoliage4",0.125,"soundHitFoliage5",0.125,"soundHitFoliage6",0.125,"soundHitFoliage7",0.125,"soundHitFoliage8",0.125}; - hitWood[] = {"soundWood1",0.125,"soundWood2",0.125,"soundWood3",0.125,"soundWood4",0.125,"soundWood5",0.125,"soundWood6",0.125,"soundWood7",0.125,"soundWood8",0.125}; - hitGlass[] = {"soundGlass1",0.125,"soundGlass2",0.125,"soundGlass3",0.125,"soundGlass4",0.125,"soundGlass5",0.125,"soundGlass6",0.125,"soundGlass7",0.125,"soundGlass8",0.125}; - hitGlassArmored[] = {"soundGlassArmored1",0.125,"soundGlassArmored2",0.125,"soundGlassArmored3",0.125,"soundGlassArmored4",0.125,"soundGlassArmored5",0.125,"soundGlassArmored6",0.125,"soundGlassArmored7",0.125,"soundGlassArmored8",0.125}; - hitConcrete[] = {"soundConcrete1",0.125,"soundConcrete2",0.125,"soundConcrete3",0.125,"soundConcrete4",0.125,"soundConcrete5",0.125,"soundConcrete6",0.125,"soundConcrete7",0.125,"soundConcrete8",0.125}; - hitRubber[] = {"soundRubber1",0.125,"soundRubber2",0.125,"soundRubber3",0.125,"soundRubber4",0.125,"soundRubber5",0.125,"soundRubber6",0.125,"soundRubber7",0.125,"soundRubber8",0.125}; - hitPlastic[] = {"soundPlastic1",0.125,"soundPlastic2",0.125,"soundPlastic3",0.125,"soundPlastic4",0.125,"soundPlastic5",0.125,"soundPlastic6",0.125,"soundPlastic7",0.125,"soundPlastic8",0.125}; - hitDefault[] = {"soundDefault1",0.2,"soundDefault2",0.2,"soundDefault3",0.1,"soundDefault4",0.1,"soundDefault5",0.1,"soundDefault6",0.1,"soundDefault7",0.1,"soundDefault8",0.1}; - hitMetal[] = {"soundMetal1",0.125,"soundMetal2",0.125,"soundMetal3",0.125,"soundMetal4",0.125,"soundMetal5",0.125,"soundMetal6",0.125,"soundMetal7",0.125,"soundMetal8",0.125}; - hitMetalplate[] = {"soundVehiclePlate1",0.125,"soundVehiclePlate2",0.125,"soundVehiclePlate3",0.125,"soundVehiclePlate4",0.125,"soundVehiclePlate5",0.125,"soundVehiclePlate6",0.125,"soundVehiclePlate7",0.125,"soundVehiclePlate8",0.125}; - hitWater[] = {"soundWater1",0.125,"soundWater2",0.125,"soundWater3",0.125,"soundWater4",0.125,"soundWater5",0.125,"soundWater6",0.125,"soundWater7",0.125,"soundWater8",0.125}; - bulletFly1[] = {"A3\sounds_f\weapons\hits\bullet_by_1.wav",1,1,35}; - bulletFly2[] = {"A3\sounds_f\weapons\hits\bullet_by_2.wav",1,1,35}; - bulletFly3[] = {"A3\sounds_f\weapons\hits\bullet_by_3.wav",1,1,35}; - bulletFly4[] = {"A3\sounds_f\weapons\hits\bullet_by_4.wav",1,1,35}; - bulletFly5[] = {"A3\sounds_f\weapons\hits\bullet_by_5.wav",1,1,35}; - bulletFly6[] = {"A3\sounds_f\weapons\hits\bullet_by_6.wav",1,1,35}; - bulletFly7[] = {"A3\sounds_f\weapons\hits\bullet_by_7.wav",1,1,35}; - bulletFly8[] = {"A3\sounds_f\weapons\hits\bullet_by_8.wav",1,1,35}; - bulletFly[] = {"bulletFly1",0.166,"bulletFly2",0.166,"bulletFly3",0.166,"bulletFly4",0.166,"bulletFly5",0.166,"bulletFly6",0.167,"bulletFly7",0.166,"bulletFly8",0.167}; - supersonicCrackNear[] = {"A3\sounds_f\weapons\hits\sscrack1.wav",1,1,35}; - supersonicCrackFar[] = {"A3\sounds_f\weapons\hits\sscrack2.wav",1,1,135}; - }; - */ - - class B_65x39_Caseless; - class ACE_frag_base: B_65x39_Caseless { - timeToLive = 12; - typicalSpeed = 1500; - deflecting = 65; - }; - - class ACE_frag_tiny: ACE_frag_base { - hit = 6; - airFriction = BASE_DRAG; - caliber = 0.75; - }; - - class ACE_frag_tiny_HD: ACE_frag_base { - hit = 6; - airFriction = BASE_DRAG_HD; - caliber = 0.75; - }; - - class ACE_frag_small: ACE_frag_base { - hit = 12; - airFriction = BASE_DRAG*0.9; - }; - - class ACE_frag_small_HD: ACE_frag_base { - hit = 12; - airFriction = BASE_DRAG_HD*0.9; - }; - - class ACE_frag_medium: ACE_frag_base { - hit = 14; - airFriction = BASE_DRAG*0.75; - caliber = 1.2; - }; - - class ACE_frag_medium_HD: ACE_frag_base { - hit = 14; - airFriction = BASE_DRAG_HD*0.75; - caliber = 1.2; - }; - - class ACE_frag_large: ACE_frag_base { - hit = 28; - indirectHit = 2; - indirectHitRange = 0.25; - airFriction = BASE_DRAG*0.65; - caliber = 2; - explosive = 0; - - }; - - class ACE_frag_large_HD: ACE_frag_large { - hit = 28; - indirectHit = 2; - indirectHitRange = 0.25; - airFriction = BASE_DRAG_HD*0.65; - caliber = 2; - - - }; - - class ACE_frag_huge: ACE_frag_large { - hit = 40; - indirectHit = 4; - indirectHitRange = 0.5; - airFriction = BASE_DRAG*0.5; - caliber = 2.8; - }; - - class ACE_frag_huge_HD: ACE_frag_large { - hit = 40; - indirectHit = 4; - indirectHitRange = 0.5; - airFriction = BASE_DRAG_HD*0.5; - caliber = 2.8; - }; - - class ACE_frag_spall_small: ACE_frag_small { - timeToLive = 0.1; - }; - - class ACE_frag_spall_medium: ACE_frag_medium { - timeToLive = 0.15; - }; - - class ACE_frag_spall_large: ACE_frag_large { - timeToLive = 0.25; - }; - - class ACE_frag_spall_huge: ACE_frag_huge { - timeToLive = 0.3; - }; - - #include "CfgAmmoReflections.hpp" -}; +#define BASE_DRAG -0.01 +#define HD_MULT 5 +#define BASE_DRAG_HD (BASE_DRAG*HD_MULT) + +class CfgAmmo { + //class ace_arty_105mm_m1_m782_time; + //class ace_arty_105mm_m1_m782_prox: ace_arty_105mm_m1_m782_time {}; + //class ace_arty_105mm_m1_m782_delay: ace_arty_105mm_m1_m782_prox { + // GVAR(skip) = 1; + //}; + + class Bo_GBU12_LGB; + class ACE_GBU12 : Bo_GBU12_LGB { + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"}; + GVAR(metal) = 140000; + GVAR(charge) = 87000; + GVAR(gurney_c) = 2320; + GVAR(gurney_k) = 1/2; + sideAirFriction = 0.04; + airFriction = 0.04; + laserLock = 0; + }; + + class GrenadeBase; + class Grenade; + class GrenadeHand: Grenade { + GVAR(enabled) = 1; + + GVAR(skip) = 0; + GVAR(force) = 1; + // This is a good high-drag frag type for grenades. + GVAR(classes)[] = {"ACE_frag_tiny_HD"}; + /* + These values are based on the M67 Grenade, should be tweaked for + individual grenades. + */ + GVAR(metal) = 210; // metal in grams + GVAR(charge) = 185; // explosive in grams + GVAR(gurney_c) = 2843; // Gurney velocity constant for explosive type. See: http://en.wikipedia.org/wiki/Gurney_equations + GVAR(gurney_k) = 3/5; // Gurney shape factor, in this case a sphere. See: http://en.wikipedia.org/wiki/Gurney_equations + }; + class GrenadeHand_stone: GrenadeHand { + GVAR(skip) = 1; + }; + class SmokeShell: GrenadeHand { + GVAR(skip) = 1; + }; + + class RocketBase; + class R_Hydra_HE: RocketBase { + // Source: http://fas.org/man/dod-101/sys/missile/hydra-70.htm + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; + GVAR(metal) = 3850; + GVAR(charge) = 1040; + GVAR(gurney_c) = 2700; + GVAR(gurney_k) = 1/2; + }; + //class R_57mm_HE: RocketBase { + // GVAR(skip) = 1; + //}; + + class R_80mm_HE: RocketBase { + GVAR(skip) = 1; + }; + + //class R_S8T_AT: RocketBase { + // GVAR(skip) = 1; + //}; + + class BombCore; + class Bo_Mk82: BombCore { + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"}; + GVAR(metal) = 140000; + GVAR(charge) = 87000; + GVAR(gurney_c) = 2320; + GVAR(gurney_k) = 1/2; + }; + + class G_40mm_HE: GrenadeBase { + // Source: http://www.inetres.com/gp/military/infantry/grenade/40mm_ammo.html#M441 + GVAR(enabled) = 1; + GVAR(force) = 1; + + GVAR(classes)[] = {"ACE_frag_tiny_HD"}; + GVAR(metal) = 200; + GVAR(charge) = 32; + GVAR(gurney_c) = 2700; + GVAR(gurney_k) = 1/2; + }; + class G_40mm_HEDP: G_40mm_HE { + // Source: http://www.inetres.com/gp/military/infantry/grenade/40mm_ammo.html#M433 + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_tiny_HD"}; + GVAR(metal) = 200; + GVAR(charge) = 45; + GVAR(gurney_c) = 2830; + GVAR(gurney_k) = 1/2; + }; + + class ACE_G_40mm_HEDP: G_40mm_HEDP { + }; + class ACE_G_40mm_HE: G_40mm_HE { + }; + class ACE_G_40mm_Practice: ACE_G_40mm_HE { + GVAR(skip) = 1; + GVAR(force) = 0; + }; + class ACE_G40mm_HE_VOG25P: G_40mm_HE { + GVAR(skip) = 0; + GVAR(force) = 1; + }; + + // curator ammo entries + class ShellBase; + class Sh_125mm_HEAT; + class Sh_155mm_AMOS: ShellBase { + // Source: http://www.globalsecurity.org/military/systems/munitions/m795.htm + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"}; + GVAR(metal) = 36000; + GVAR(charge) = 9979; + GVAR(gurney_c) = 2440; + GVAR(gurney_k) = 1/2; + }; + class Sh_82mm_AMOS : Sh_155mm_AMOS { + // Source: http://www.arsenal-bg.com/defense_police/mortar_bombs_82mm.htm + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; + GVAR(metal) = 3200; + GVAR(charge) = 420; + GVAR(gurney_c) = 2440; + GVAR(gurney_k) = 1/2; + }; + class ModuleOrdnanceMortar_F_Ammo: Sh_82mm_AMOS { + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; + GVAR(metal) = 800; + GVAR(charge) = 4200; + GVAR(gurney_c) = 2320; + GVAR(gurney_k) = 1/2; + }; + class Sh_105mm_HEAT_MP : Sh_125mm_HEAT { + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; + GVAR(metal) = 11400; + GVAR(charge) = 7100; + GVAR(gurney_c) = 2800; + GVAR(gurney_k) = 1/2; + }; + class Sh_120mm_HE : ShellBase { + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; + GVAR(metal) = 23000; + GVAR(charge) = 3148; + GVAR(gurney_c) = 2830; + GVAR(gurney_k) = 1/2; + }; + class Sh_125mm_HE: Sh_120mm_HE { + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; + GVAR(metal) = 16000; + GVAR(charge) = 3200; + GVAR(gurney_c) = 2440; + GVAR(gurney_k) = 1/2; + }; + class ModuleOrdnanceHowitzer_F_ammo: Sh_155mm_AMOS { + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"}; + GVAR(metal) = 1950; + GVAR(charge) = 15800; + GVAR(gurney_c) = 2320; + GVAR(gurney_k) = 1/2; + }; + + //class R_230mm_HE; + //class ModuleOrdnanceRocket_F_ammo: R_230mm_HE { + //}; + + //class R_230mm_fly; + //class ModuleOrdnanceRocket_F_subammo: R_230mm_fly { + //}; + // end of curator ammo entries + + //class R_SMAW_HEDP; + //class R_MEEWS_HEDP : R_SMAW_HEDP { + // GVAR(force) = 1; + // GVAR(multiplier) = 1.2; + //}; + + class MissileBase; + class Missile_AGM_02_F : MissileBase { + // Source: http://fas.org/man/dod-101/sys/smart/agm-65.htm + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; + GVAR(metal) = 56250; + GVAR(charge) = 39000; + GVAR(gurney_c) = 2700; + GVAR(gurney_k) = 1/2; + }; + class M_Hellfire_AT: MissileBase { + // Source: http://www.designation-systems.net/dusrm/m-114.html + GVAR(enabled) = 1; + + GVAR(classes)[] = {"ACE_frag_medium", "ACE_frag_medium_HD"}; + GVAR(metal) = 8000; + GVAR(charge) = 2400; + GVAR(gurney_c) = 2700; + GVAR(gurney_k) = 1/2; + }; + + /* + class B_762x51_Ball; + class ACE_frag_base: B_762x51_Ball { ////TODO: B_762x45_Ball no longer exists, is this a valid replacement? + model = "\A3\Weapons_f\ammo\shell"; + timeToLive = 12; + typicalSpeed = 800; + // Fix sounds + effectFly = "AmmoClassic"; + soundDefault1[] = {"A3\sounds_f\weapons\hits\concrete_1.wav",0.158114,1,30}; + soundDefault2[] = {"A3\sounds_f\weapons\hits\concrete_2.wav",0.158114,1,30}; + soundDefault3[] = {"A3\sounds_f\weapons\hits\concrete_3.wav",0.158114,1,30}; + soundDefault4[] = {"A3\sounds_f\weapons\hits\concrete_4.wav",0.158114,1,30}; + soundDefault5[] = {"A3\sounds_f\weapons\hits\concrete_5.wav",0.158114,1,30}; + soundDefault6[] = {"A3\sounds_f\weapons\hits\concrete_6.wav",0.158114,1,30}; + soundDefault7[] = {"A3\sounds_f\weapons\hits\concrete_7.wav",0.158114,1,30}; + soundDefault8[] = {"A3\sounds_f\weapons\hits\concrete_8.wav",0.158114,1,30}; + soundGroundSoft1[] = {"A3\sounds_f\weapons\hits\soft_ground_1.wav",0.02811705,1,30}; + soundGroundSoft2[] = {"A3\sounds_f\weapons\hits\soft_ground_2.wav",0.02811705,1,30}; + soundGroundSoft3[] = {"A3\sounds_f\weapons\hits\soft_ground_3.wav",0.02811705,1,30}; + soundGroundSoft4[] = {"A3\sounds_f\weapons\hits\soft_ground_4.wav",0.02811705,1,30}; + soundGroundSoft5[] = {"A3\sounds_f\weapons\hits\soft_ground_5.wav",0.02811705,1,30}; + soundGroundSoft6[] = {"A3\sounds_f\weapons\hits\soft_ground_6.wav",0.02811705,1,30}; + soundGroundSoft7[] = {"A3\sounds_f\weapons\hits\soft_ground_7.wav",0.02811705,1,30}; + soundGroundSoft8[] = {"A3\sounds_f\weapons\hits\soft_ground_8.wav",0.02811705,1,30}; + soundGroundHard1[] = {"A3\sounds_f\weapons\hits\hard_ground_1.wav",0.62946,1,40}; + soundGroundHard2[] = {"A3\sounds_f\weapons\hits\hard_ground_2.wav",0.62946,1,40}; + soundGroundHard3[] = {"A3\sounds_f\weapons\hits\hard_ground_3.wav",0.62946,1,40}; + soundGroundHard4[] = {"A3\sounds_f\weapons\hits\hard_ground_4.wav",0.62946,1,40}; + soundGroundHard5[] = {"A3\sounds_f\weapons\hits\hard_ground_5.wav",0.62946,1,40}; + soundGroundHard6[] = {"A3\sounds_f\weapons\hits\hard_ground_6.wav",0.62946,1,40}; + soundGroundHard7[] = {"A3\sounds_f\weapons\hits\hard_ground_7.wav",0.62946,1,40}; + soundGroundHard8[] = {"A3\sounds_f\weapons\hits\hard_ground_8.wav",0.62946,1,40}; + soundMetal1[] = {"A3\sounds_f\weapons\hits\metal_1.wav",0.158114,1,45}; + soundMetal2[] = {"A3\sounds_f\weapons\hits\metal_2.wav",0.158114,1,45}; + soundMetal3[] = {"A3\sounds_f\weapons\hits\metal_3.wav",0.158114,1,45}; + soundMetal4[] = {"A3\sounds_f\weapons\hits\metal_4.wav",0.158114,1,45}; + soundMetal5[] = {"A3\sounds_f\weapons\hits\metal_5.wav",0.158114,1,45}; + soundMetal6[] = {"A3\sounds_f\weapons\hits\metal_6.wav",0.158114,1,45}; + soundMetal7[] = {"A3\sounds_f\weapons\hits\metal_7.wav",0.158114,1,45}; + soundMetal8[] = {"A3\sounds_f\weapons\hits\metal_8.wav",0.158114,1,45}; + soundGlass1[] = {"A3\sounds_f\weapons\hits\glass_1.wav",0.177828,1,25}; + soundGlass2[] = {"A3\sounds_f\weapons\hits\glass_2.wav",0.177828,1,25}; + soundGlass3[] = {"A3\sounds_f\weapons\hits\glass_3.wav",0.177828,1,25}; + soundGlass4[] = {"A3\sounds_f\weapons\hits\glass_4.wav",0.177828,1,25}; + soundGlass5[] = {"A3\sounds_f\weapons\hits\glass_5.wav",0.177828,1,25}; + soundGlass6[] = {"A3\sounds_f\weapons\hits\glass_6.wav",0.177828,1,25}; + soundGlass7[] = {"A3\sounds_f\weapons\hits\glass_7.wav",0.177828,1,25}; + soundGlass8[] = {"A3\sounds_f\weapons\hits\glass_8.wav",0.177828,1,25}; + soundGlassArmored1[] = {"A3\sounds_f\weapons\hits\glass_arm_1.wav",0.177828,1,30}; + soundGlassArmored2[] = {"A3\sounds_f\weapons\hits\glass_arm_2.wav",0.177828,1,30}; + soundGlassArmored3[] = {"A3\sounds_f\weapons\hits\glass_arm_3.wav",0.177828,1,30}; + soundGlassArmored4[] = {"A3\sounds_f\weapons\hits\glass_arm_4.wav",0.177828,1,30}; + soundGlassArmored5[] = {"A3\sounds_f\weapons\hits\glass_arm_5.wav",0.177828,1,30}; + soundGlassArmored6[] = {"A3\sounds_f\weapons\hits\glass_arm_6.wav",0.177828,1,30}; + soundGlassArmored7[] = {"A3\sounds_f\weapons\hits\glass_arm_7.wav",0.177828,1,30}; + soundGlassArmored8[] = {"A3\sounds_f\weapons\hits\glass_arm_8.wav",0.177828,1,30}; + soundVehiclePlate1[] = {"A3\sounds_f\weapons\hits\metal_plate_1.wav",0.281170,1,40}; + soundVehiclePlate2[] = {"A3\sounds_f\weapons\hits\metal_plate_2.wav",0.281170,1,40}; + soundVehiclePlate3[] = {"A3\sounds_f\weapons\hits\metal_plate_3.wav",0.281170,1,40}; + soundVehiclePlate4[] = {"A3\sounds_f\weapons\hits\metal_plate_4.wav",0.281170,1,40}; + soundVehiclePlate5[] = {"A3\sounds_f\weapons\hits\metal_plate_5.wav",0.281170,1,40}; + soundVehiclePlate6[] = {"A3\sounds_f\weapons\hits\metal_plate_6.wav",0.281170,1,40}; + soundVehiclePlate7[] = {"A3\sounds_f\weapons\hits\metal_plate_7.wav",0.281170,1,40}; + soundVehiclePlate8[] = {"A3\sounds_f\weapons\hits\metal_plate_8.wav",0.281170,1,40}; + soundWood1[] = {"A3\sounds_f\weapons\hits\wood_1.wav",0.158114,1,30}; + soundWood2[] = {"A3\sounds_f\weapons\hits\wood_2.wav",0.158114,1,30}; + soundWood3[] = {"A3\sounds_f\weapons\hits\wood_3.wav",0.158114,1,30}; + soundWood4[] = {"A3\sounds_f\weapons\hits\wood_4.wav",0.158114,1,30}; + soundWood5[] = {"A3\sounds_f\weapons\hits\wood_5.wav",0.158114,1,30}; + soundWood6[] = {"A3\sounds_f\weapons\hits\wood_6.wav",0.158114,1,30}; + soundWood7[] = {"A3\sounds_f\weapons\hits\wood_7.wav",0.158114,1,30}; + soundWood8[] = {"A3\sounds_f\weapons\hits\wood_8.wav",0.158114,1,30}; + soundHitBody1[] = {"A3\sounds_f\weapons\hits\body_1.wav",0.0177828,1,25}; + soundHitBody2[] = {"A3\sounds_f\weapons\hits\body_2.wav",0.0177828,1,25}; + soundHitBody3[] = {"A3\sounds_f\weapons\hits\body_3.wav",0.0177828,1,25}; + soundHitBody4[] = {"A3\sounds_f\weapons\hits\body_4.wav",0.0177828,1,25}; + soundHitBody5[] = {"A3\sounds_f\weapons\hits\body_5.wav",0.0177828,1,25}; + soundHitBody6[] = {"A3\sounds_f\weapons\hits\body_6.wav",0.0177828,1,25}; + soundHitBody7[] = {"A3\sounds_f\weapons\hits\body_7.wav",0.0177828,1,25}; + soundHitBody8[] = {"A3\sounds_f\weapons\hits\body_8.wav",0.0177828,1,25}; + soundHitBuilding1[] = {"A3\sounds_f\weapons\hits\building_1.wav",0.251189,1,30}; + soundHitBuilding2[] = {"A3\sounds_f\weapons\hits\building_2.wav",0.251189,1,30}; + soundHitBuilding3[] = {"A3\sounds_f\weapons\hits\building_3.wav",0.251189,1,30}; + soundHitBuilding4[] = {"A3\sounds_f\weapons\hits\building_4.wav",0.251189,1,30}; + soundHitBuilding5[] = {"A3\sounds_f\weapons\hits\building_5.wav",0.251189,1,30}; + soundHitBuilding6[] = {"A3\sounds_f\weapons\hits\building_6.wav",0.251189,1,30}; + soundHitBuilding7[] = {"A3\sounds_f\weapons\hits\building_7.wav",0.251189,1,30}; + soundHitBuilding8[] = {"A3\sounds_f\weapons\hits\building_8.wav",0.251189,1,30}; + soundHitFoliage1[] = {"A3\sounds_f\weapons\hits\foliage_1.wav",0.177828,1,25}; + soundHitFoliage2[] = {"A3\sounds_f\weapons\hits\foliage_2.wav",0.177828,1,25}; + soundHitFoliage3[] = {"A3\sounds_f\weapons\hits\foliage_3.wav",0.177828,1,25}; + soundHitFoliage4[] = {"A3\sounds_f\weapons\hits\foliage_4.wav",0.177828,1,25}; + soundHitFoliage5[] = {"A3\sounds_f\weapons\hits\foliage_5.wav",0.177828,1,25}; + soundHitFoliage6[] = {"A3\sounds_f\weapons\hits\foliage_6.wav",0.177828,1,25}; + soundHitFoliage7[] = {"A3\sounds_f\weapons\hits\foliage_7.wav",0.177828,1,25}; + soundHitFoliage8[] = {"A3\sounds_f\weapons\hits\foliage_8.wav",0.177828,1,25}; + soundPlastic1[] = {"A3\sounds_f\weapons\hits\plastic_1.wav",0.177828,1,25}; + soundPlastic2[] = {"A3\sounds_f\weapons\hits\plastic_2.wav",0.177828,1,25}; + soundPlastic3[] = {"A3\sounds_f\weapons\hits\plastic_3.wav",0.177828,1,25}; + soundPlastic4[] = {"A3\sounds_f\weapons\hits\plastic_4.wav",0.177828,1,25}; + soundPlastic5[] = {"A3\sounds_f\weapons\hits\plastic_5.wav",0.177828,1,25}; + soundPlastic6[] = {"A3\sounds_f\weapons\hits\plastic_6.wav",0.177828,1,25}; + soundPlastic7[] = {"A3\sounds_f\weapons\hits\plastic_7.wav",0.177828,1,25}; + soundPlastic8[] = {"A3\sounds_f\weapons\hits\plastic_8.wav",0.177828,1,25}; + soundConcrete1[] = {"A3\sounds_f\weapons\hits\concrete_1.wav",0.177828,1,35}; + soundConcrete2[] = {"A3\sounds_f\weapons\hits\concrete_2.wav",0.177828,1,35}; + soundConcrete3[] = {"A3\sounds_f\weapons\hits\concrete_3.wav",0.177828,1,35}; + soundConcrete4[] = {"A3\sounds_f\weapons\hits\concrete_4.wav",0.177828,1,35}; + soundConcrete5[] = {"A3\sounds_f\weapons\hits\concrete_5.wav",0.177828,1,35}; + soundConcrete6[] = {"A3\sounds_f\weapons\hits\concrete_6.wav",0.177828,1,35}; + soundConcrete7[] = {"A3\sounds_f\weapons\hits\concrete_7.wav",0.177828,1,35}; + soundConcrete8[] = {"A3\sounds_f\weapons\hits\concrete_8.wav",0.177828,1,35}; + soundRubber1[] = {"A3\sounds_f\weapons\hits\tyre_1.wav",0.158114,1,25}; + soundRubber2[] = {"A3\sounds_f\weapons\hits\tyre_2.wav",0.158114,1,25}; + soundRubber3[] = {"A3\sounds_f\weapons\hits\tyre_3.wav",0.158114,1,25}; + soundRubber4[] = {"A3\sounds_f\weapons\hits\tyre_4.wav",0.158114,1,25}; + soundRubber5[] = {"A3\sounds_f\weapons\hits\tyre_5.wav",0.158114,1,25}; + soundRubber6[] = {"A3\sounds_f\weapons\hits\tyre_6.wav",0.158114,1,25}; + soundRubber7[] = {"A3\sounds_f\weapons\hits\tyre_7.wav",0.158114,1,25}; + soundRubber8[] = {"A3\sounds_f\weapons\hits\tyre_8.wav",0.158114,1,25}; + soundWater1[] = {"A3\sounds_f\weapons\hits\water_01.wav",0.158114,1,25}; + soundWater2[] = {"A3\sounds_f\weapons\hits\water_02.wav",0.158114,1,25}; + soundWater3[] = {"A3\sounds_f\weapons\hits\water_03.wav",0.158114,1,25}; + soundWater4[] = {"A3\sounds_f\weapons\hits\water_04.wav",0.158114,1,25}; + soundWater5[] = {"A3\sounds_f\weapons\hits\water_05.wav",0.158114,1,25}; + soundWater6[] = {"A3\sounds_f\weapons\hits\water_06.wav",0.158114,1,25}; + soundWater7[] = {"A3\sounds_f\weapons\hits\water_07.wav",0.158114,1,25}; + soundWater8[] = {"A3\sounds_f\weapons\hits\water_08.wav",0.158114,1,25}; + hitGroundSoft[] = {"soundGroundSoft1",0.2,"soundGroundSoft2",0.2,"soundGroundSoft3",0.1,"soundGroundSoft4",0.1,"soundGroundSoft5",0.1,"soundGroundSoft6",0.1,"soundGroundSoft7",0.1,"soundGroundSoft8",0.1}; + hitGroundHard[] = {"soundGroundHard1",0.2,"soundGroundHard2",0.2,"soundGroundHard3",0.1,"soundGroundHard4",0.1,"soundGroundHard5",0.1,"soundGroundHard6",0.1,"soundGroundHard7",0.1,"soundGroundHard8",0.1}; + hitMan[] = {"soundHitBody1",0.125,"soundHitBody2",0.125,"soundHitBody3",0.125,"soundHitBody4",0.125,"soundHitBody5",0.125,"soundHitBody6",0.125,"soundHitBody7",0.125,"soundHitBody8",0.125}; + hitArmor[] = {"soundVehiclePlate1",0.125,"soundVehiclePlate2",0.125,"soundVehiclePlate3",0.125,"soundVehiclePlate4",0.125,"soundVehiclePlate5",0.125,"soundVehiclePlate6",0.125,"soundVehiclePlate7",0.125,"soundVehiclePlate8",0.125}; + hitBuilding[] = {"soundHitBuilding1",0.2,"soundHitBuilding2",0.2,"soundHitBuilding3",0.1,"soundHitBuilding4",0.1,"soundHitBuilding5",0.1,"soundHitBuilding6",0.1,"soundHitBuilding7",0.1,"soundHitBuilding8",0.1}; + hitFoliage[] = {"soundHitFoliage1",0.125,"soundHitFoliage2",0.125,"soundHitFoliage3",0.125,"soundHitFoliage4",0.125,"soundHitFoliage5",0.125,"soundHitFoliage6",0.125,"soundHitFoliage7",0.125,"soundHitFoliage8",0.125}; + hitWood[] = {"soundWood1",0.125,"soundWood2",0.125,"soundWood3",0.125,"soundWood4",0.125,"soundWood5",0.125,"soundWood6",0.125,"soundWood7",0.125,"soundWood8",0.125}; + hitGlass[] = {"soundGlass1",0.125,"soundGlass2",0.125,"soundGlass3",0.125,"soundGlass4",0.125,"soundGlass5",0.125,"soundGlass6",0.125,"soundGlass7",0.125,"soundGlass8",0.125}; + hitGlassArmored[] = {"soundGlassArmored1",0.125,"soundGlassArmored2",0.125,"soundGlassArmored3",0.125,"soundGlassArmored4",0.125,"soundGlassArmored5",0.125,"soundGlassArmored6",0.125,"soundGlassArmored7",0.125,"soundGlassArmored8",0.125}; + hitConcrete[] = {"soundConcrete1",0.125,"soundConcrete2",0.125,"soundConcrete3",0.125,"soundConcrete4",0.125,"soundConcrete5",0.125,"soundConcrete6",0.125,"soundConcrete7",0.125,"soundConcrete8",0.125}; + hitRubber[] = {"soundRubber1",0.125,"soundRubber2",0.125,"soundRubber3",0.125,"soundRubber4",0.125,"soundRubber5",0.125,"soundRubber6",0.125,"soundRubber7",0.125,"soundRubber8",0.125}; + hitPlastic[] = {"soundPlastic1",0.125,"soundPlastic2",0.125,"soundPlastic3",0.125,"soundPlastic4",0.125,"soundPlastic5",0.125,"soundPlastic6",0.125,"soundPlastic7",0.125,"soundPlastic8",0.125}; + hitDefault[] = {"soundDefault1",0.2,"soundDefault2",0.2,"soundDefault3",0.1,"soundDefault4",0.1,"soundDefault5",0.1,"soundDefault6",0.1,"soundDefault7",0.1,"soundDefault8",0.1}; + hitMetal[] = {"soundMetal1",0.125,"soundMetal2",0.125,"soundMetal3",0.125,"soundMetal4",0.125,"soundMetal5",0.125,"soundMetal6",0.125,"soundMetal7",0.125,"soundMetal8",0.125}; + hitMetalplate[] = {"soundVehiclePlate1",0.125,"soundVehiclePlate2",0.125,"soundVehiclePlate3",0.125,"soundVehiclePlate4",0.125,"soundVehiclePlate5",0.125,"soundVehiclePlate6",0.125,"soundVehiclePlate7",0.125,"soundVehiclePlate8",0.125}; + hitWater[] = {"soundWater1",0.125,"soundWater2",0.125,"soundWater3",0.125,"soundWater4",0.125,"soundWater5",0.125,"soundWater6",0.125,"soundWater7",0.125,"soundWater8",0.125}; + bulletFly1[] = {"A3\sounds_f\weapons\hits\bullet_by_1.wav",1,1,35}; + bulletFly2[] = {"A3\sounds_f\weapons\hits\bullet_by_2.wav",1,1,35}; + bulletFly3[] = {"A3\sounds_f\weapons\hits\bullet_by_3.wav",1,1,35}; + bulletFly4[] = {"A3\sounds_f\weapons\hits\bullet_by_4.wav",1,1,35}; + bulletFly5[] = {"A3\sounds_f\weapons\hits\bullet_by_5.wav",1,1,35}; + bulletFly6[] = {"A3\sounds_f\weapons\hits\bullet_by_6.wav",1,1,35}; + bulletFly7[] = {"A3\sounds_f\weapons\hits\bullet_by_7.wav",1,1,35}; + bulletFly8[] = {"A3\sounds_f\weapons\hits\bullet_by_8.wav",1,1,35}; + bulletFly[] = {"bulletFly1",0.166,"bulletFly2",0.166,"bulletFly3",0.166,"bulletFly4",0.166,"bulletFly5",0.166,"bulletFly6",0.167,"bulletFly7",0.166,"bulletFly8",0.167}; + supersonicCrackNear[] = {"A3\sounds_f\weapons\hits\sscrack1.wav",1,1,35}; + supersonicCrackFar[] = {"A3\sounds_f\weapons\hits\sscrack2.wav",1,1,135}; + }; + */ + + class B_65x39_Caseless; + class ACE_frag_base: B_65x39_Caseless { + timeToLive = 12; + typicalSpeed = 1500; + deflecting = 65; + }; + + class ACE_frag_tiny: ACE_frag_base { + hit = 6; + airFriction = BASE_DRAG; + caliber = 0.75; + }; + + class ACE_frag_tiny_HD: ACE_frag_base { + hit = 6; + airFriction = BASE_DRAG_HD; + caliber = 0.75; + }; + + class ACE_frag_small: ACE_frag_base { + hit = 12; + airFriction = BASE_DRAG*0.9; + }; + + class ACE_frag_small_HD: ACE_frag_base { + hit = 12; + airFriction = BASE_DRAG_HD*0.9; + }; + + class ACE_frag_medium: ACE_frag_base { + hit = 14; + airFriction = BASE_DRAG*0.75; + caliber = 1.2; + }; + + class ACE_frag_medium_HD: ACE_frag_base { + hit = 14; + airFriction = BASE_DRAG_HD*0.75; + caliber = 1.2; + }; + + class ACE_frag_large: ACE_frag_base { + hit = 28; + indirectHit = 2; + indirectHitRange = 0.25; + airFriction = BASE_DRAG*0.65; + caliber = 2; + explosive = 0; + + }; + + class ACE_frag_large_HD: ACE_frag_large { + hit = 28; + indirectHit = 2; + indirectHitRange = 0.25; + airFriction = BASE_DRAG_HD*0.65; + caliber = 2; + + + }; + + class ACE_frag_huge: ACE_frag_large { + hit = 40; + indirectHit = 4; + indirectHitRange = 0.5; + airFriction = BASE_DRAG*0.5; + caliber = 2.8; + }; + + class ACE_frag_huge_HD: ACE_frag_large { + hit = 40; + indirectHit = 4; + indirectHitRange = 0.5; + airFriction = BASE_DRAG_HD*0.5; + caliber = 2.8; + }; + + class ACE_frag_spall_small: ACE_frag_small { + timeToLive = 0.1; + }; + + class ACE_frag_spall_medium: ACE_frag_medium { + timeToLive = 0.15; + }; + + class ACE_frag_spall_large: ACE_frag_large { + timeToLive = 0.25; + }; + + class ACE_frag_spall_huge: ACE_frag_huge { + timeToLive = 0.3; + }; + + #include "CfgAmmoReflections.hpp" +}; diff --git a/addons/frag/CfgAmmoReflections.hpp b/addons/frag/CfgAmmoReflections.hpp index 0331dd41dd..fdaac6dd90 100644 --- a/addons/frag/CfgAmmoReflections.hpp +++ b/addons/frag/CfgAmmoReflections.hpp @@ -1,130 +1,130 @@ -//CfgAmmoReflections.hpp - -#define ACE_EXPLOSION_REFLECTION(range, hit)\ -class ace_explosion_reflection_##range##_##hit : ace_explosion_reflection_base {\ - indirectHitRange = range;\ - indirectHit = hit;\ - dangerRadiusHit = range*3;\ - suppressionRadiusHit = range*2;\ -} - -#define ACE_EXPLOSION_RANGE(range)\ - ACE_EXPLOSION_REFLECTION(range,10);\ - ACE_EXPLOSION_REFLECTION(range,20);\ - ACE_EXPLOSION_REFLECTION(range,30);\ - ACE_EXPLOSION_REFLECTION(range,40);\ - ACE_EXPLOSION_REFLECTION(range,50);\ - ACE_EXPLOSION_REFLECTION(range,60);\ - ACE_EXPLOSION_REFLECTION(range,70);\ - ACE_EXPLOSION_REFLECTION(range,80);\ - ACE_EXPLOSION_REFLECTION(range,90);\ - ACE_EXPLOSION_REFLECTION(range,100);\ - ACE_EXPLOSION_REFLECTION(range,110);\ - ACE_EXPLOSION_REFLECTION(range,120);\ - ACE_EXPLOSION_REFLECTION(range,130);\ - ACE_EXPLOSION_REFLECTION(range,140);\ - ACE_EXPLOSION_REFLECTION(range,150);\ - ACE_EXPLOSION_REFLECTION(range,160);\ - ACE_EXPLOSION_REFLECTION(range,170);\ - ACE_EXPLOSION_REFLECTION(range,180);\ - ACE_EXPLOSION_REFLECTION(range,190);\ - ACE_EXPLOSION_REFLECTION(range,200);\ - ACE_EXPLOSION_REFLECTION(range,210);\ - ACE_EXPLOSION_REFLECTION(range,220);\ - ACE_EXPLOSION_REFLECTION(range,230);\ - ACE_EXPLOSION_REFLECTION(range,240);\ - ACE_EXPLOSION_REFLECTION(range,250);\ - ACE_EXPLOSION_REFLECTION(range,260);\ - ACE_EXPLOSION_REFLECTION(range,270);\ - ACE_EXPLOSION_REFLECTION(range,280);\ - ACE_EXPLOSION_REFLECTION(range,290);\ - ACE_EXPLOSION_REFLECTION(range,300);\ - ACE_EXPLOSION_REFLECTION(range,310);\ - ACE_EXPLOSION_REFLECTION(range,320);\ - ACE_EXPLOSION_REFLECTION(range,330);\ - ACE_EXPLOSION_REFLECTION(range,340);\ - ACE_EXPLOSION_REFLECTION(range,350);\ - ACE_EXPLOSION_REFLECTION(range,360);\ - ACE_EXPLOSION_REFLECTION(range,370);\ - ACE_EXPLOSION_REFLECTION(range,380);\ - ACE_EXPLOSION_REFLECTION(range,390);\ - ACE_EXPLOSION_REFLECTION(range,400);\ - ACE_EXPLOSION_REFLECTION(range,410);\ - ACE_EXPLOSION_REFLECTION(range,420);\ - ACE_EXPLOSION_REFLECTION(range,430);\ - ACE_EXPLOSION_REFLECTION(range,440);\ - ACE_EXPLOSION_REFLECTION(range,450);\ - ACE_EXPLOSION_REFLECTION(range,460);\ - ACE_EXPLOSION_REFLECTION(range,470);\ - ACE_EXPLOSION_REFLECTION(range,480);\ - ACE_EXPLOSION_REFLECTION(range,490);\ - ACE_EXPLOSION_REFLECTION(range,500) - -class ace_explosion_reflection_base : Sh_120mm_HE { - CraterWaterEffects = ""; - CraterEffects = ""; - effectsMissile = ""; - ExplosionEffects = ""; - effectFlare = ""; - class HitEffects { - hitWater = ""; - }; - multiSoundHit[] = {}; - explosionTime = 0.0001; - explosive = 1; - soundFakeFall[] = {}; - typicalSpeed = 0; - model = "\A3\Weapons_F\empty.p3d"; - craterShape = "\A3\weapons_f\empty.p3d"; -}; - -ACE_EXPLOSION_RANGE(2); -ACE_EXPLOSION_RANGE(4); -ACE_EXPLOSION_RANGE(6); -ACE_EXPLOSION_RANGE(8); -ACE_EXPLOSION_RANGE(10); -ACE_EXPLOSION_RANGE(12); -ACE_EXPLOSION_RANGE(14); -ACE_EXPLOSION_RANGE(16); -ACE_EXPLOSION_RANGE(18); -ACE_EXPLOSION_RANGE(20); -ACE_EXPLOSION_RANGE(22); -ACE_EXPLOSION_RANGE(24); -ACE_EXPLOSION_RANGE(26); -ACE_EXPLOSION_RANGE(28); -ACE_EXPLOSION_RANGE(30); -ACE_EXPLOSION_RANGE(32); -ACE_EXPLOSION_RANGE(34); -ACE_EXPLOSION_RANGE(36); -ACE_EXPLOSION_RANGE(38); -ACE_EXPLOSION_RANGE(40); -ACE_EXPLOSION_RANGE(42); -ACE_EXPLOSION_RANGE(44); -ACE_EXPLOSION_RANGE(46); -ACE_EXPLOSION_RANGE(48); -ACE_EXPLOSION_RANGE(50); -ACE_EXPLOSION_RANGE(52); -ACE_EXPLOSION_RANGE(54); -ACE_EXPLOSION_RANGE(56); -ACE_EXPLOSION_RANGE(58); -ACE_EXPLOSION_RANGE(60); -ACE_EXPLOSION_RANGE(62); -ACE_EXPLOSION_RANGE(64); -ACE_EXPLOSION_RANGE(66); -ACE_EXPLOSION_RANGE(68); -ACE_EXPLOSION_RANGE(70); -ACE_EXPLOSION_RANGE(72); -ACE_EXPLOSION_RANGE(74); -ACE_EXPLOSION_RANGE(76); -ACE_EXPLOSION_RANGE(78); -ACE_EXPLOSION_RANGE(80); -ACE_EXPLOSION_RANGE(82); -ACE_EXPLOSION_RANGE(84); -ACE_EXPLOSION_RANGE(86); -ACE_EXPLOSION_RANGE(88); -ACE_EXPLOSION_RANGE(90); -ACE_EXPLOSION_RANGE(92); -ACE_EXPLOSION_RANGE(94); -ACE_EXPLOSION_RANGE(96); -ACE_EXPLOSION_RANGE(98); -ACE_EXPLOSION_RANGE(100); +//CfgAmmoReflections.hpp + +#define ACE_EXPLOSION_REFLECTION(range, hit)\ +class ace_explosion_reflection_##range##_##hit : ace_explosion_reflection_base {\ + indirectHitRange = range;\ + indirectHit = hit;\ + dangerRadiusHit = range*3;\ + suppressionRadiusHit = range*2;\ +} + +#define ACE_EXPLOSION_RANGE(range)\ + ACE_EXPLOSION_REFLECTION(range,10);\ + ACE_EXPLOSION_REFLECTION(range,20);\ + ACE_EXPLOSION_REFLECTION(range,30);\ + ACE_EXPLOSION_REFLECTION(range,40);\ + ACE_EXPLOSION_REFLECTION(range,50);\ + ACE_EXPLOSION_REFLECTION(range,60);\ + ACE_EXPLOSION_REFLECTION(range,70);\ + ACE_EXPLOSION_REFLECTION(range,80);\ + ACE_EXPLOSION_REFLECTION(range,90);\ + ACE_EXPLOSION_REFLECTION(range,100);\ + ACE_EXPLOSION_REFLECTION(range,110);\ + ACE_EXPLOSION_REFLECTION(range,120);\ + ACE_EXPLOSION_REFLECTION(range,130);\ + ACE_EXPLOSION_REFLECTION(range,140);\ + ACE_EXPLOSION_REFLECTION(range,150);\ + ACE_EXPLOSION_REFLECTION(range,160);\ + ACE_EXPLOSION_REFLECTION(range,170);\ + ACE_EXPLOSION_REFLECTION(range,180);\ + ACE_EXPLOSION_REFLECTION(range,190);\ + ACE_EXPLOSION_REFLECTION(range,200);\ + ACE_EXPLOSION_REFLECTION(range,210);\ + ACE_EXPLOSION_REFLECTION(range,220);\ + ACE_EXPLOSION_REFLECTION(range,230);\ + ACE_EXPLOSION_REFLECTION(range,240);\ + ACE_EXPLOSION_REFLECTION(range,250);\ + ACE_EXPLOSION_REFLECTION(range,260);\ + ACE_EXPLOSION_REFLECTION(range,270);\ + ACE_EXPLOSION_REFLECTION(range,280);\ + ACE_EXPLOSION_REFLECTION(range,290);\ + ACE_EXPLOSION_REFLECTION(range,300);\ + ACE_EXPLOSION_REFLECTION(range,310);\ + ACE_EXPLOSION_REFLECTION(range,320);\ + ACE_EXPLOSION_REFLECTION(range,330);\ + ACE_EXPLOSION_REFLECTION(range,340);\ + ACE_EXPLOSION_REFLECTION(range,350);\ + ACE_EXPLOSION_REFLECTION(range,360);\ + ACE_EXPLOSION_REFLECTION(range,370);\ + ACE_EXPLOSION_REFLECTION(range,380);\ + ACE_EXPLOSION_REFLECTION(range,390);\ + ACE_EXPLOSION_REFLECTION(range,400);\ + ACE_EXPLOSION_REFLECTION(range,410);\ + ACE_EXPLOSION_REFLECTION(range,420);\ + ACE_EXPLOSION_REFLECTION(range,430);\ + ACE_EXPLOSION_REFLECTION(range,440);\ + ACE_EXPLOSION_REFLECTION(range,450);\ + ACE_EXPLOSION_REFLECTION(range,460);\ + ACE_EXPLOSION_REFLECTION(range,470);\ + ACE_EXPLOSION_REFLECTION(range,480);\ + ACE_EXPLOSION_REFLECTION(range,490);\ + ACE_EXPLOSION_REFLECTION(range,500) + +class ace_explosion_reflection_base : Sh_120mm_HE { + CraterWaterEffects = ""; + CraterEffects = ""; + effectsMissile = ""; + ExplosionEffects = ""; + effectFlare = ""; + class HitEffects { + hitWater = ""; + }; + multiSoundHit[] = {}; + explosionTime = 0.0001; + explosive = 1; + soundFakeFall[] = {}; + typicalSpeed = 0; + model = "\A3\Weapons_F\empty.p3d"; + craterShape = "\A3\weapons_f\empty.p3d"; +}; + +ACE_EXPLOSION_RANGE(2); +ACE_EXPLOSION_RANGE(4); +ACE_EXPLOSION_RANGE(6); +ACE_EXPLOSION_RANGE(8); +ACE_EXPLOSION_RANGE(10); +ACE_EXPLOSION_RANGE(12); +ACE_EXPLOSION_RANGE(14); +ACE_EXPLOSION_RANGE(16); +ACE_EXPLOSION_RANGE(18); +ACE_EXPLOSION_RANGE(20); +ACE_EXPLOSION_RANGE(22); +ACE_EXPLOSION_RANGE(24); +ACE_EXPLOSION_RANGE(26); +ACE_EXPLOSION_RANGE(28); +ACE_EXPLOSION_RANGE(30); +ACE_EXPLOSION_RANGE(32); +ACE_EXPLOSION_RANGE(34); +ACE_EXPLOSION_RANGE(36); +ACE_EXPLOSION_RANGE(38); +ACE_EXPLOSION_RANGE(40); +ACE_EXPLOSION_RANGE(42); +ACE_EXPLOSION_RANGE(44); +ACE_EXPLOSION_RANGE(46); +ACE_EXPLOSION_RANGE(48); +ACE_EXPLOSION_RANGE(50); +ACE_EXPLOSION_RANGE(52); +ACE_EXPLOSION_RANGE(54); +ACE_EXPLOSION_RANGE(56); +ACE_EXPLOSION_RANGE(58); +ACE_EXPLOSION_RANGE(60); +ACE_EXPLOSION_RANGE(62); +ACE_EXPLOSION_RANGE(64); +ACE_EXPLOSION_RANGE(66); +ACE_EXPLOSION_RANGE(68); +ACE_EXPLOSION_RANGE(70); +ACE_EXPLOSION_RANGE(72); +ACE_EXPLOSION_RANGE(74); +ACE_EXPLOSION_RANGE(76); +ACE_EXPLOSION_RANGE(78); +ACE_EXPLOSION_RANGE(80); +ACE_EXPLOSION_RANGE(82); +ACE_EXPLOSION_RANGE(84); +ACE_EXPLOSION_RANGE(86); +ACE_EXPLOSION_RANGE(88); +ACE_EXPLOSION_RANGE(90); +ACE_EXPLOSION_RANGE(92); +ACE_EXPLOSION_RANGE(94); +ACE_EXPLOSION_RANGE(96); +ACE_EXPLOSION_RANGE(98); +ACE_EXPLOSION_RANGE(100); diff --git a/addons/frag/CfgEventhandlers.hpp b/addons/frag/CfgEventhandlers.hpp index 415e205fba..becf395052 100644 --- a/addons/frag/CfgEventhandlers.hpp +++ b/addons/frag/CfgEventhandlers.hpp @@ -1,18 +1,18 @@ - -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -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)); - }; -}; + +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +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)); + }; +}; diff --git a/addons/frag/XEH_postInit.sqf b/addons/frag/XEH_postInit.sqf index 977866e24e..f461010d69 100644 --- a/addons/frag/XEH_postInit.sqf +++ b/addons/frag/XEH_postInit.sqf @@ -1,30 +1,30 @@ -#include "script_component.hpp" - -if(GVAR(EnableDebugTrace) && !isMultiplayer) then { - GVAR(traceFrags) = true; - GVAR(autoTrace) = true; -}; - -if(isServer) then { - [QGVAR(frag_eh), { _this call FUNC(frago); }] call EFUNC(common,addEventHandler); -}; - -["SettingsInitialized", { - //If not enabled, exit - if (!GVAR(enabled)) exitWith {}; - - // Register fire event handler - ["firedPlayer", DFUNC(fired)] call EFUNC(common,addEventHandler); - ["firedPlayerNonLocal", DFUNC(fired)] call EFUNC(common,addEventHandler); - ["firedNonPlayer", DFUNC(fired)] call EFUNC(common,addEventHandler); - ["firedPlayerVehicle", DFUNC(fired)] call EFUNC(common,addEventHandler); - ["firedPlayerVehicleNonLocal", DFUNC(fired)] call EFUNC(common,addEventHandler); - ["firedNonPlayerVehicle", DFUNC(fired)] call EFUNC(common,addEventHandler); - - [FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler; - -}] call EFUNC(common,addEventHandler); - -//Cache for ammo type configs -GVAR(cacheRoundsTypesToTrack) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0]; -GVAR(cacheRoundsTypesToTrack) setText QGVAR(cacheRoundsTypesToTrack); +#include "script_component.hpp" + +if(GVAR(EnableDebugTrace) && !isMultiplayer) then { + GVAR(traceFrags) = true; + GVAR(autoTrace) = true; +}; + +if(isServer) then { + [QGVAR(frag_eh), { _this call FUNC(frago); }] call EFUNC(common,addEventHandler); +}; + +["SettingsInitialized", { + //If not enabled, exit + if (!GVAR(enabled)) exitWith {}; + + // Register fire event handler + ["firedPlayer", DFUNC(fired)] call EFUNC(common,addEventHandler); + ["firedPlayerNonLocal", DFUNC(fired)] call EFUNC(common,addEventHandler); + ["firedNonPlayer", DFUNC(fired)] call EFUNC(common,addEventHandler); + ["firedPlayerVehicle", DFUNC(fired)] call EFUNC(common,addEventHandler); + ["firedPlayerVehicleNonLocal", DFUNC(fired)] call EFUNC(common,addEventHandler); + ["firedNonPlayerVehicle", DFUNC(fired)] call EFUNC(common,addEventHandler); + + [FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler; + +}] call EFUNC(common,addEventHandler); + +//Cache for ammo type configs +GVAR(cacheRoundsTypesToTrack) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0]; +GVAR(cacheRoundsTypesToTrack) setText QGVAR(cacheRoundsTypesToTrack); diff --git a/addons/frag/XEH_preInit.sqf b/addons/frag/XEH_preInit.sqf index 1de9a467eb..9c03491a4e 100644 --- a/addons/frag/XEH_preInit.sqf +++ b/addons/frag/XEH_preInit.sqf @@ -1,25 +1,25 @@ -#include "script_component.hpp" - -ADDON = false; - -#include "XEH_PREP.hpp" - -GVAR(blackList) = []; -GVAR(traceFrags) = false; - -GVAR(TOTALFRAGS) = 0; - -GVAR(spallHPData) = []; -GVAR(spallIsTrackingCount) = 0; - -GVAR(autoTrace) = false; -GVAR(traceID) = -1; -GVAR(traces) = []; -GVAR(tracesStarted) = false; - -GVAR(lastIterationIndex) = 0; -GVAR(objects) = []; -GVAR(objectTypes) = []; -GVAR(arguments) = []; - -ADDON = true; +#include "script_component.hpp" + +ADDON = false; + +#include "XEH_PREP.hpp" + +GVAR(blackList) = []; +GVAR(traceFrags) = false; + +GVAR(TOTALFRAGS) = 0; + +GVAR(spallHPData) = []; +GVAR(spallIsTrackingCount) = 0; + +GVAR(autoTrace) = false; +GVAR(traceID) = -1; +GVAR(traces) = []; +GVAR(tracesStarted) = false; + +GVAR(lastIterationIndex) = 0; +GVAR(objects) = []; +GVAR(objectTypes) = []; +GVAR(arguments) = []; + +ADDON = true; diff --git a/addons/frag/config.cpp b/addons/frag/config.cpp index 16af88bfc4..688d369cf5 100644 --- a/addons/frag/config.cpp +++ b/addons/frag/config.cpp @@ -1,15 +1,15 @@ -#include "script_component.hpp" -class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"Nou"}; - VERSION_CONFIG; - }; -}; - -#include "CfgEventhandlers.hpp" -#include "CfgAmmo.hpp" +#include "script_component.hpp" +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Nou"}; + VERSION_CONFIG; + }; +}; + +#include "CfgEventhandlers.hpp" +#include "CfgAmmo.hpp" #include "ACE_Settings.hpp" \ No newline at end of file diff --git a/addons/frag/functions/fnc_addPfhRound.sqf b/addons/frag/functions/fnc_addPfhRound.sqf index 5d7857c67a..14f1e2f3ad 100644 --- a/addons/frag/functions/fnc_addPfhRound.sqf +++ b/addons/frag/functions/fnc_addPfhRound.sqf @@ -1,74 +1,74 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -private ["_enabled", "_doSpall", "_spallTrack", "_spallTrackID"]; -PARAMS_3(_gun,_type,_round); -DEFAULT_PARAM(3,_doFragTrack,false); - -if (!GVAR(enabled)) exitWith {}; - -//_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled)); -//if(_enabled < 1) exitWith {}; - -if(_round in GVAR(blackList)) exitWith { - GVAR(blackList) = GVAR(blackList) - [_round]; -}; - -// Exit on max track -if( (count GVAR(objects)) > GVAR(MaxTrack)) exitWith { }; - -if(_gun == ACE_player) then { - _doFragTrack = true; -} else { - if((gunner _gun) == ACE_player) then { - _doFragTrack = true; - } else { - if(local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}) then { - _doFragTrack = true; - }; - }; -}; - -_doSpall = false; -if(GVAR(SpallEnabled)) then { - if(GVAR(spallIsTrackingCount) <= 0) then { - GVAR(spallHPData) = []; - }; - if(GVAR(spallIsTrackingCount) > 5) then { - // ACE_player sideChat "LIMT!"; - } else { - _doSpall = true; - GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1; - }; -}; -// ACE_player sideChat format["c: %1", GVAR(spallIsTrackingCount)]; - -if(GVAR(autoTrace)) then { - [ACE_player, _round, [1,0,0,1]] call FUNC(addTrack); -}; - -// We only do the single track object check here. -// We should do an {!(_round in GVAR(objects))} -// But we leave that out here for optimization. So this cannot be a framework function -// Otherwise, it should only be added once and from the FiredEH -if(_doFragTrack && alive _round) then { - _spallTrack = []; - _spallTrackID = []; - - private["_args"]; - _args = [_round, (getPosASL _round), (velocity _round), _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID, - (getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip))), - (getNumber (configFile >> "CfgAmmo" >> _type >> "explosive")), - (getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")), - (getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force))), - (getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"))))) - ]; - TRACE_1("Initializing track", _round); - GVAR(objects) pushBack _round; - GVAR(arguments) pushBack _args; - - if(_doSpall) then { - [_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack); - }; - // ACE_player sideChat "WTF2"; -}; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +private ["_enabled", "_doSpall", "_spallTrack", "_spallTrackID"]; +PARAMS_3(_gun,_type,_round); +DEFAULT_PARAM(3,_doFragTrack,false); + +if (!GVAR(enabled)) exitWith {}; + +//_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled)); +//if(_enabled < 1) exitWith {}; + +if(_round in GVAR(blackList)) exitWith { + GVAR(blackList) = GVAR(blackList) - [_round]; +}; + +// Exit on max track +if( (count GVAR(objects)) > GVAR(MaxTrack)) exitWith { }; + +if(_gun == ACE_player) then { + _doFragTrack = true; +} else { + if((gunner _gun) == ACE_player) then { + _doFragTrack = true; + } else { + if(local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}) then { + _doFragTrack = true; + }; + }; +}; + +_doSpall = false; +if(GVAR(SpallEnabled)) then { + if(GVAR(spallIsTrackingCount) <= 0) then { + GVAR(spallHPData) = []; + }; + if(GVAR(spallIsTrackingCount) > 5) then { + // ACE_player sideChat "LIMT!"; + } else { + _doSpall = true; + GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1; + }; +}; +// ACE_player sideChat format["c: %1", GVAR(spallIsTrackingCount)]; + +if(GVAR(autoTrace)) then { + [ACE_player, _round, [1,0,0,1]] call FUNC(addTrack); +}; + +// We only do the single track object check here. +// We should do an {!(_round in GVAR(objects))} +// But we leave that out here for optimization. So this cannot be a framework function +// Otherwise, it should only be added once and from the FiredEH +if(_doFragTrack && alive _round) then { + _spallTrack = []; + _spallTrackID = []; + + private["_args"]; + _args = [_round, (getPosASL _round), (velocity _round), _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID, + (getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip))), + (getNumber (configFile >> "CfgAmmo" >> _type >> "explosive")), + (getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")), + (getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force))), + (getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"))))) + ]; + TRACE_1("Initializing track", _round); + GVAR(objects) pushBack _round; + GVAR(arguments) pushBack _args; + + if(_doSpall) then { + [_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack); + }; + // ACE_player sideChat "WTF2"; +}; diff --git a/addons/frag/functions/fnc_addTrack.sqf b/addons/frag/functions/fnc_addTrack.sqf index 680dc31c37..9a67d3fb73 100644 --- a/addons/frag/functions/fnc_addTrack.sqf +++ b/addons/frag/functions/fnc_addTrack.sqf @@ -1,23 +1,23 @@ -#include "script_component.hpp" - -private ["_color", "_data", "_index", "_obj", "_objSpd", "_origin", "_positions"]; - -if (GVAR(autoTrace)) then { - [] call FUNC(startTracing); -}; - -// setAccTime 0.05; -_index = (count GVAR(traces)); -_obj = _this select 1; -_origin = _this select 0; -_color = [1,0,0,1]; -if((count _this) > 2) then { - _color = _this select 2; -}; -_positions = []; -_objSpd = vectorMagnitude (velocity _obj); -_positions set[(count _positions), [(getPos _obj), _objSpd]]; -_data = [_origin, typeOf _origin, typeOf _obj, _objSpd, _positions, _color]; - -GVAR(traces) set[_index, _data]; -[DFUNC(trackTrace), 0, [_obj, _index, ACE_time]] call CBA_fnc_addPerFrameHandler; +#include "script_component.hpp" + +private ["_color", "_data", "_index", "_obj", "_objSpd", "_origin", "_positions"]; + +if (GVAR(autoTrace)) then { + [] call FUNC(startTracing); +}; + +// setAccTime 0.05; +_index = (count GVAR(traces)); +_obj = _this select 1; +_origin = _this select 0; +_color = [1,0,0,1]; +if((count _this) > 2) then { + _color = _this select 2; +}; +_positions = []; +_objSpd = vectorMagnitude (velocity _obj); +_positions set[(count _positions), [(getPos _obj), _objSpd]]; +_data = [_origin, typeOf _origin, typeOf _obj, _objSpd, _positions, _color]; + +GVAR(traces) set[_index, _data]; +[DFUNC(trackTrace), 0, [_obj, _index, ACE_time]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/frag/functions/fnc_doExplosions.sqf b/addons/frag/functions/fnc_doExplosions.sqf index f6daee1c06..41d546b78f 100644 --- a/addons/frag/functions/fnc_doExplosions.sqf +++ b/addons/frag/functions/fnc_doExplosions.sqf @@ -1,26 +1,26 @@ -//fnc_doExplosions.sqf -#include "script_component.hpp" - -private ["_params", "_explosions", "_index", "_i", "_exp", "_refExp", "_bpos", "_hit", "_distance", "_indirectHitRange", "_depth"]; -_params = _this select 0; -_explosions = _params select 0; -_index = _params select 1; -for "_i" from _index to ((_index+2) min (count _explosions)) do { - _exp = _explosions select _i; - _refExp = _exp select 0; - _bpos = _exp select 1; - _hit = _exp select 2; - _distance = _exp select 3; - _indirectHitRange = _exp select 4; - _depth = _exp select 5; - _refExp createVehicle (ASLtoATL _bpos); - // if(_hit >= 150 && _distance > _indirectHitRange) then { - // [_bpos, _refExp, _depth] call FUNC(doReflections); - // }; -}; -_index = _index + 2; -if(_index >= (count _explosions)) then { - [(_this select 1)] call CBA_fnc_removePerFrameHandler; -} else { - _params set[1, _index]; -}; +//fnc_doExplosions.sqf +#include "script_component.hpp" + +private ["_params", "_explosions", "_index", "_i", "_exp", "_refExp", "_bpos", "_hit", "_distance", "_indirectHitRange", "_depth"]; +_params = _this select 0; +_explosions = _params select 0; +_index = _params select 1; +for "_i" from _index to ((_index+2) min (count _explosions)) do { + _exp = _explosions select _i; + _refExp = _exp select 0; + _bpos = _exp select 1; + _hit = _exp select 2; + _distance = _exp select 3; + _indirectHitRange = _exp select 4; + _depth = _exp select 5; + _refExp createVehicle (ASLtoATL _bpos); + // if(_hit >= 150 && _distance > _indirectHitRange) then { + // [_bpos, _refExp, _depth] call FUNC(doReflections); + // }; +}; +_index = _index + 2; +if(_index >= (count _explosions)) then { + [(_this select 1)] call CBA_fnc_removePerFrameHandler; +} else { + _params set[1, _index]; +}; diff --git a/addons/frag/functions/fnc_doReflections.sqf b/addons/frag/functions/fnc_doReflections.sqf index 64d8ede26d..fa30aba95d 100644 --- a/addons/frag/functions/fnc_doReflections.sqf +++ b/addons/frag/functions/fnc_doReflections.sqf @@ -1,18 +1,18 @@ -//fnc_doReflections.sqf -#include "script_component.hpp" - -private ["_pos", "_ammo", "_depth", "_hit", "_range", "_hitFactor", "_indirectHitRange", "_indirectHit", "_testParams"]; - -_pos = _this select 0; -_ammo = _this select 1; -_depth = 1; -if(count _this > 2) then { - _depth = _this select 2; -}; -// TEST_ICONS pushBack [_pos, format["EXP!", _hit, _range, _hitFactor]]; -if(_depth <= 2) then { - _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"); - _indirectHit = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHit"); - _testParams = [_pos, [_indirectHitRange, _indirectHit], [], [], -4, _depth, 0]; - [DFUNC(findReflections), 0, _testParams] call CBA_fnc_addPerFrameHandler; -}; +//fnc_doReflections.sqf +#include "script_component.hpp" + +private ["_pos", "_ammo", "_depth", "_hit", "_range", "_hitFactor", "_indirectHitRange", "_indirectHit", "_testParams"]; + +_pos = _this select 0; +_ammo = _this select 1; +_depth = 1; +if(count _this > 2) then { + _depth = _this select 2; +}; +// TEST_ICONS pushBack [_pos, format["EXP!", _hit, _range, _hitFactor]]; +if(_depth <= 2) then { + _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"); + _indirectHit = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHit"); + _testParams = [_pos, [_indirectHitRange, _indirectHit], [], [], -4, _depth, 0]; + [DFUNC(findReflections), 0, _testParams] call CBA_fnc_addPerFrameHandler; +}; diff --git a/addons/frag/functions/fnc_doSpall.sqf b/addons/frag/functions/fnc_doSpall.sqf index 57b5d330c7..2c98e955eb 100644 --- a/addons/frag/functions/fnc_doSpall.sqf +++ b/addons/frag/functions/fnc_doSpall.sqf @@ -1,151 +1,151 @@ -//fnc_doSpall.sqf -#include "script_component.hpp" -// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA"; - -private ["_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"]; - -_hitData = _this select 0; -_initialData = GVAR(spallHPData) select (_hitData select 0); -_hpData = (_hitData select 1) select (_this select 1); - - -_object = _hpData select 0; -_object removeEventHandler ["hitPart", _initialData select 0]; -_foundObjects = _initialData select 7; -_index = _foundObjects find _object; -if(_index != -1) then { - _foundObjecsts set[_index, nil]; -}; - -_roundType = (_initialData select 2); -_round = (_initialData select 3); -_object = (_initialData select 1); - -_caliber = getNumber(configFile >> "CfgAmmo" >> _roundType >> "caliber"); -_explosive = getNumber(configFile >> "CfgAmmo" >> _roundType >> "explosive"); -_idh = getNumber(configFile >> "CfgAmmo" >> _roundType >> "indirectHitRange"); - -_alive = true; -if(!alive _round && (_initialData select 6) == 1) then { - _alive = false; -}; - -if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then { - // ACE_player sideChat format["BBBB"]; - _exit = false; - _vm = 1; - _velocity = _initialData select 5; - - _oldVelocity = vectorMagnitude _velocity; - _curVelocity = vectorMagnitude (velocity _round); - - if(alive _round) then { - _diff = _velocity vectorDiff (velocity _round); - _polar = _diff call CBA_fnc_vect2polar; - // ACE_player sideChat format["polar: %1", _polar]; - if((abs(_polar select 1) > 45 || abs(_polar select 2) > 45)) then { - if(_caliber < 2.5) then { - // ACE_player sideChat format["exit!"]; - _exit = true; - } else { - _vm = 1-(_curVelocity/_oldVelocity); - }; - }; - }; - if(!_exit) then { - _unitDir = vectorNormalized _velocity; - _pos = _hpData select 3; - _spallPos = nil; - for "_i" from 0 to 100 do { - _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i)); - _pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1))); - // _blah = [_object, "FIRE"] intersect [_object worldToModel (ASLtoATL _pos1), _object worldToModel (ASLtoATL _pos2)]; - // diag_log text format["b: %1", _blah]; - - // _data = [nil, nil, nil, 1, [[ASLtoATL _pos1, 1], [ASLtoATL _pos2, 1]]]; - // NOU_TRACES set[(count NOU_TRACES), _data]; - - if(!lineIntersects [_pos1, _pos2]) exitWith { - // ACE_player sideChat format["FOUND!"]; - _spallPos = _pos2; - }; - }; - if(!isNil "_spallPos") then { - _spallPolar = _velocity call CBA_fnc_vect2polar; - - if(_explosive > 0) then { - // ACE_player sideChat format["EXPLOSIVE!"]; - _warn = false; - _c = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_CHARGE"); - if(_c == 0) then { _c = 1; _warn = true;}; - _m = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_METAL"); - if(_m == 0) then { _m = 2; _warn = true;}; - _k = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_GURNEY_K"); - if(_k == 0) then { _k = 1/2; _warn = true;}; - _gC = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_GURNEY_C"); - if(_gC == 0) then { _gC = 2440; _warn = true;}; - - if(_warn) then { - ACE_LOGWARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_roundType); //TODO: turn this off when we get closer to release - }; - - _fragPower = (((_m/_c)+_k)^-(1/2))*_gC; - _spallPolar set[0, _fragPower*0.66]; - }; - - _fragTypes = [ - "ACE_frag_spall_small", "ACE_frag_spall_small", "ACE_frag_spall_small", - "ACE_frag_spall_small","ACE_frag_spall_medium","ACE_frag_spall_medium","ACE_frag_spall_medium", - "ACE_frag_spall_medium", "ACE_frag_spall_large", "ACE_frag_spall_large", "ACE_frag_spall_huge", - "ACE_frag_spall_huge" - - ]; - - // diag_log text format["SPALL POWER: %1", _spallPolar select 0]; - _spread = 15+(random 25); - _spallCount = 5+(random 10); - for "_i" from 1 to _spallCount do { - _elev = ((_spallPolar select 2)-_spread)+(random (_spread*2)); - _dir = ((_spallPolar select 1)-_spread)+(random (_spread*2)); - if(abs _elev > 90) then { - _dir = _dir + 180; - }; - _dir = _dir % 360; - _vel = (_spallPolar select 0)*0.33*_vm; - _vel = (_vel-(_vel*0.25))+(random (_vel*0.5)); - - _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect; - _fragType = round (random ((count _fragTypes)-1)); - _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; - _fragment setPosASL _spallPos; - _fragment setVelocity _spallFragVect; - - if(GVAR(traceFrags)) then { - [ACE_player, _fragment, [1,0.5,0,1]] call FUNC(addTrack); - }; - }; - _spread = 5+(random 5); - _spallCount = 3+(random 5); - for "_i" from 1 to _spallCount do { - _elev = ((_spallPolar select 2)-_spread)+(random (_spread*2)); - _dir = ((_spallPolar select 1)-_spread)+(random (_spread*2)); - if(abs _elev > 90) then { - _dir = _dir + 180; - }; - _dir = _dir % 360; - _vel = (_spallPolar select 0)*0.55*_vm; - _vel = (_vel-(_vel*0.25))+(random (_vel*0.5)); - - _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect; - _fragType = round (random ((count _fragTypes)-1)); - _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; - _fragment setPosASL _spallPos; - _fragment setVelocity _spallFragVect; - - if(GVAR(traceFrags)) then { - [ACE_player, _fragment, [1,0,0,1]] call FUNC(addTrack); - }; - }; - }; - }; -}; +//fnc_doSpall.sqf +#include "script_component.hpp" +// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA"; + +private ["_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"]; + +_hitData = _this select 0; +_initialData = GVAR(spallHPData) select (_hitData select 0); +_hpData = (_hitData select 1) select (_this select 1); + + +_object = _hpData select 0; +_object removeEventHandler ["hitPart", _initialData select 0]; +_foundObjects = _initialData select 7; +_index = _foundObjects find _object; +if(_index != -1) then { + _foundObjecsts set[_index, nil]; +}; + +_roundType = (_initialData select 2); +_round = (_initialData select 3); +_object = (_initialData select 1); + +_caliber = getNumber(configFile >> "CfgAmmo" >> _roundType >> "caliber"); +_explosive = getNumber(configFile >> "CfgAmmo" >> _roundType >> "explosive"); +_idh = getNumber(configFile >> "CfgAmmo" >> _roundType >> "indirectHitRange"); + +_alive = true; +if(!alive _round && (_initialData select 6) == 1) then { + _alive = false; +}; + +if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then { + // ACE_player sideChat format["BBBB"]; + _exit = false; + _vm = 1; + _velocity = _initialData select 5; + + _oldVelocity = vectorMagnitude _velocity; + _curVelocity = vectorMagnitude (velocity _round); + + if(alive _round) then { + _diff = _velocity vectorDiff (velocity _round); + _polar = _diff call CBA_fnc_vect2polar; + // ACE_player sideChat format["polar: %1", _polar]; + if((abs(_polar select 1) > 45 || abs(_polar select 2) > 45)) then { + if(_caliber < 2.5) then { + // ACE_player sideChat format["exit!"]; + _exit = true; + } else { + _vm = 1-(_curVelocity/_oldVelocity); + }; + }; + }; + if(!_exit) then { + _unitDir = vectorNormalized _velocity; + _pos = _hpData select 3; + _spallPos = nil; + for "_i" from 0 to 100 do { + _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i)); + _pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1))); + // _blah = [_object, "FIRE"] intersect [_object worldToModel (ASLtoATL _pos1), _object worldToModel (ASLtoATL _pos2)]; + // diag_log text format["b: %1", _blah]; + + // _data = [nil, nil, nil, 1, [[ASLtoATL _pos1, 1], [ASLtoATL _pos2, 1]]]; + // NOU_TRACES set[(count NOU_TRACES), _data]; + + if(!lineIntersects [_pos1, _pos2]) exitWith { + // ACE_player sideChat format["FOUND!"]; + _spallPos = _pos2; + }; + }; + if(!isNil "_spallPos") then { + _spallPolar = _velocity call CBA_fnc_vect2polar; + + if(_explosive > 0) then { + // ACE_player sideChat format["EXPLOSIVE!"]; + _warn = false; + _c = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_CHARGE"); + if(_c == 0) then { _c = 1; _warn = true;}; + _m = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_METAL"); + if(_m == 0) then { _m = 2; _warn = true;}; + _k = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_GURNEY_K"); + if(_k == 0) then { _k = 1/2; _warn = true;}; + _gC = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_GURNEY_C"); + if(_gC == 0) then { _gC = 2440; _warn = true;}; + + if(_warn) then { + ACE_LOGWARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_roundType); //TODO: turn this off when we get closer to release + }; + + _fragPower = (((_m/_c)+_k)^-(1/2))*_gC; + _spallPolar set[0, _fragPower*0.66]; + }; + + _fragTypes = [ + "ACE_frag_spall_small", "ACE_frag_spall_small", "ACE_frag_spall_small", + "ACE_frag_spall_small","ACE_frag_spall_medium","ACE_frag_spall_medium","ACE_frag_spall_medium", + "ACE_frag_spall_medium", "ACE_frag_spall_large", "ACE_frag_spall_large", "ACE_frag_spall_huge", + "ACE_frag_spall_huge" + + ]; + + // diag_log text format["SPALL POWER: %1", _spallPolar select 0]; + _spread = 15+(random 25); + _spallCount = 5+(random 10); + for "_i" from 1 to _spallCount do { + _elev = ((_spallPolar select 2)-_spread)+(random (_spread*2)); + _dir = ((_spallPolar select 1)-_spread)+(random (_spread*2)); + if(abs _elev > 90) then { + _dir = _dir + 180; + }; + _dir = _dir % 360; + _vel = (_spallPolar select 0)*0.33*_vm; + _vel = (_vel-(_vel*0.25))+(random (_vel*0.5)); + + _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect; + _fragType = round (random ((count _fragTypes)-1)); + _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; + _fragment setPosASL _spallPos; + _fragment setVelocity _spallFragVect; + + if(GVAR(traceFrags)) then { + [ACE_player, _fragment, [1,0.5,0,1]] call FUNC(addTrack); + }; + }; + _spread = 5+(random 5); + _spallCount = 3+(random 5); + for "_i" from 1 to _spallCount do { + _elev = ((_spallPolar select 2)-_spread)+(random (_spread*2)); + _dir = ((_spallPolar select 1)-_spread)+(random (_spread*2)); + if(abs _elev > 90) then { + _dir = _dir + 180; + }; + _dir = _dir % 360; + _vel = (_spallPolar select 0)*0.55*_vm; + _vel = (_vel-(_vel*0.25))+(random (_vel*0.5)); + + _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect; + _fragType = round (random ((count _fragTypes)-1)); + _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; + _fragment setPosASL _spallPos; + _fragment setVelocity _spallFragVect; + + if(GVAR(traceFrags)) then { + [ACE_player, _fragment, [1,0,0,1]] call FUNC(addTrack); + }; + }; + }; + }; +}; diff --git a/addons/frag/functions/fnc_drawTraces.sqf b/addons/frag/functions/fnc_drawTraces.sqf index 494a2af727..790d53491f 100644 --- a/addons/frag/functions/fnc_drawTraces.sqf +++ b/addons/frag/functions/fnc_drawTraces.sqf @@ -1,31 +1,31 @@ -#include "script_component.hpp" - -private ["_color", "_index", "_lastPos", "_lastSpd", "_max", "_positions", "_startSpeed"]; - -{ - _positions = _x select 4; - _color = _x select 5; - _index = 0; - _max = count _positions; - _startSpeed = 0.01 max ((_positions select 0) select 1); - _lastSpd = []; - _lastPos = []; - while {_index < _max} do { - _data1 = _positions select _index; - _data2 = nil; - if(_index + ACE_TRACE_DRAW_INC >= _max) then { - _data2 = _positions select (_max - 1); - } else { - _data2 = _positions select (_index + ACE_TRACE_DRAW_INC); - }; - - _pos1 = _data1 select 0; - _pos2 = _data2 select 0; - _index = _index + ACE_TRACE_DRAW_INC; - - drawLine3D [_pos1, _pos2, _color]; - _lastPos = _pos2; - _lastSpd = _data1 select 1; - }; - // drawIcon3D ["", [1,0,0,1], _lastPos, 0, 0, 0, format["%1m/s", _lastSpd], 1, 0.05, "RobotoCondensed"]; -} forEach GVAR(traces); +#include "script_component.hpp" + +private ["_color", "_index", "_lastPos", "_lastSpd", "_max", "_positions", "_startSpeed"]; + +{ + _positions = _x select 4; + _color = _x select 5; + _index = 0; + _max = count _positions; + _startSpeed = 0.01 max ((_positions select 0) select 1); + _lastSpd = []; + _lastPos = []; + while {_index < _max} do { + _data1 = _positions select _index; + _data2 = nil; + if(_index + ACE_TRACE_DRAW_INC >= _max) then { + _data2 = _positions select (_max - 1); + } else { + _data2 = _positions select (_index + ACE_TRACE_DRAW_INC); + }; + + _pos1 = _data1 select 0; + _pos2 = _data2 select 0; + _index = _index + ACE_TRACE_DRAW_INC; + + drawLine3D [_pos1, _pos2, _color]; + _lastPos = _pos2; + _lastSpd = _data1 select 1; + }; + // drawIcon3D ["", [1,0,0,1], _lastPos, 0, 0, 0, format["%1m/s", _lastSpd], 1, 0.05, "RobotoCondensed"]; +} forEach GVAR(traces); diff --git a/addons/frag/functions/fnc_findReflections.sqf b/addons/frag/functions/fnc_findReflections.sqf index 5e069ddd58..d0c5c1ceec 100644 --- a/addons/frag/functions/fnc_findReflections.sqf +++ b/addons/frag/functions/fnc_findReflections.sqf @@ -1,128 +1,128 @@ -//fnc_findReflections.sqf -#include "script_component.hpp" - -private ["_split", "_radi", "_params", "_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_indirectHitRange", "_indirectHit", "_distanceCount", "_lastPos", "_test", "_vec", "_testPos", "_buckets", "_excludes", "_bucketIndex", "_bucketPos", "_bucketList", "_c", "_index", "_blist", "_avgX", "_avgY", "_avgZ", "_bpos", "_distance", "_hitFactor", "_hit", "_range", "_refExp", "_rand", "_i", "_x", "_res", "_forEachIndex", "_explosions", "_can", "_dirvec", "_zAng"]; - -BEGIN_COUNTER(fnc_findReflections); -_params = _this select 0; -_pos = _params select 0; -_explosiveInfo = _params select 1; -_los = _params select 2; -_nlos = _params select 3; -_zIndex = _params select 4; -_depth = _params select 5; -_rand = _params select 6; - -_split = 15; -_radi = (360/_split*_depth); - -// player sideChat format["p: %1", _explosiveInfo]; -_indirectHitRange = _explosiveInfo select 0; -_indirectHit = _explosiveInfo select 1; -_distanceCount = (floor _indirectHitRange*4) min 100; - -if(_zIndex < 5) then { - _lastPos = _pos; - _zAng = _zIndex*20+2; - if(_zAng > 80) then { - _radi = 1; - _zAng = 90; - }; - for "_i" from 0 to _radi do { - _test = true; - _vec = [1, ((_i*_split)+_rand) mod 360, _zAng] call CBA_fnc_polar2vect; - for "_x" from 1 to _distanceCount do { - _testPos = _pos vectorAdd (_vec vectorMultiply _x); - // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; - _res = lineIntersectsWith [_pos, _testPos]; - if(count _res > 0) exitWith { - _test = false; - _nlos pushBack _lastPos; - // { - // _x addEventHandler ["HandleDamage", { diag_log text format["this: %1", _this]; }]; - // } forEach _res; - // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; - // TEST_PAIRS pushBack [_pos, _lastPos, [1,0,0,1]]; - - }; - // if(terrainIntersectASL [_pos, _testPos]) exitWith {}; - _lastPos = _testPos; - }; - }; - _params set[4, _zIndex+1]; -} else { - _depth = _depth + 1; - _buckets = []; - _excludes = []; - _bucketIndex = 0; - _bucketPos = nil; - _bucketList = nil; - _c = 0; - while { count(_nlos) != count(_excludes) && _c < (count _nlos) } do { - scopeName "mainSearch"; - { - if(!(_forEachIndex in _excludes)) then { - _index = _buckets pushBack [_x, [_x]]; - _excludes pushBack _forEachIndex; - _bucketPos = _x; - _bucketList = (_buckets select _index) select 1; - breakTo "mainSearch"; - }; - } forEach _nlos; - { - if(!(_forEachIndex in _excludes)) then { - _testPos = _x; - if(_testPos vectorDistanceSqr _bucketPos <= 30) then { - _bucketList pushBack _x; - _excludes pushBack _forEachIndex; - }; - }; - } forEach _nlos; - _c = _c + 1; - }; - - // player sideChat format["c: %1", count _buckets]; - _explosions = []; - { - _blist = _x select 1; - _avgX = 0; - _avgY = 0; - _avgZ = 0; - - { - _avgX = _avgX + (_x select 0); - _avgY = _avgY + (_x select 1); - _avgZ = _avgZ + (_x select 2); - } forEach _blist; - _c = count _blist; - _bpos = [_avgX/_c, _avgY/_c, _avgZ/_c]; - - _distance = _pos vectorDistance _bpos; - _hitFactor = 1-(((_distance/(_indirectHitRange*4)) min 1) max 0); - // _hitFactor = 1/(_distance^2); - _hit = _indirectHit*_hitFactor; - _hit = (floor (_hit/4)) min 500; - _hit = _hit - (_hit%10); - _range = (floor (_indirectHitRange-(_distance/4))) min 100; - _range = _range - (_range%2); - - if(_hit >= 10 && _range > 0) then { - // TEST_ICONS pushBack [_bpos, format["h: %1, r: %2, hf: %3 d: %4 ihr: %5", _hit, _range, _hitFactor, _distance, _indirectHitRange*4]]; - // TEST_PAIRS pushBack [_pos, _bpos, [1,0,0,1]]; - _refExp = format["ace_explosion_reflection_%1_%2", _range, _hit]; - // _refExp createVehicle (ASLtoATL _bpos); - // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _bpos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; - - _explosions pushBack [_refExp, _bpos, _hit, _distance, _indirectHitRange/4, _depth]; - - }; - if(count _explosions > (_radi*2)/_depth) exitWith {}; - } forEach _buckets; - // _can = "Land_Bricks_V4_F" createVehicle (ASLtoATL _pos); - // _dirvec = _pos vectorFromTo ((ATLtoASL (player modelToWorldVisual (player selectionPosition "Spine3")))); - // _dirvec = _dirvec vectorMultiply 100; - // _can setVelocity _dirvec; - [DFUNC(doExplosions), 0, [_explosions, 0]] call CBA_fnc_addPerFrameHandler; - [(_this select 1)] call CBA_fnc_removePerFrameHandler; -}; -END_COUNTER(fnc_findReflections); +//fnc_findReflections.sqf +#include "script_component.hpp" + +private ["_split", "_radi", "_params", "_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_indirectHitRange", "_indirectHit", "_distanceCount", "_lastPos", "_test", "_vec", "_testPos", "_buckets", "_excludes", "_bucketIndex", "_bucketPos", "_bucketList", "_c", "_index", "_blist", "_avgX", "_avgY", "_avgZ", "_bpos", "_distance", "_hitFactor", "_hit", "_range", "_refExp", "_rand", "_i", "_x", "_res", "_forEachIndex", "_explosions", "_can", "_dirvec", "_zAng"]; + +BEGIN_COUNTER(fnc_findReflections); +_params = _this select 0; +_pos = _params select 0; +_explosiveInfo = _params select 1; +_los = _params select 2; +_nlos = _params select 3; +_zIndex = _params select 4; +_depth = _params select 5; +_rand = _params select 6; + +_split = 15; +_radi = (360/_split*_depth); + +// player sideChat format["p: %1", _explosiveInfo]; +_indirectHitRange = _explosiveInfo select 0; +_indirectHit = _explosiveInfo select 1; +_distanceCount = (floor _indirectHitRange*4) min 100; + +if(_zIndex < 5) then { + _lastPos = _pos; + _zAng = _zIndex*20+2; + if(_zAng > 80) then { + _radi = 1; + _zAng = 90; + }; + for "_i" from 0 to _radi do { + _test = true; + _vec = [1, ((_i*_split)+_rand) mod 360, _zAng] call CBA_fnc_polar2vect; + for "_x" from 1 to _distanceCount do { + _testPos = _pos vectorAdd (_vec vectorMultiply _x); + // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; + _res = lineIntersectsWith [_pos, _testPos]; + if(count _res > 0) exitWith { + _test = false; + _nlos pushBack _lastPos; + // { + // _x addEventHandler ["HandleDamage", { diag_log text format["this: %1", _this]; }]; + // } forEach _res; + // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; + // TEST_PAIRS pushBack [_pos, _lastPos, [1,0,0,1]]; + + }; + // if(terrainIntersectASL [_pos, _testPos]) exitWith {}; + _lastPos = _testPos; + }; + }; + _params set[4, _zIndex+1]; +} else { + _depth = _depth + 1; + _buckets = []; + _excludes = []; + _bucketIndex = 0; + _bucketPos = nil; + _bucketList = nil; + _c = 0; + while { count(_nlos) != count(_excludes) && _c < (count _nlos) } do { + scopeName "mainSearch"; + { + if(!(_forEachIndex in _excludes)) then { + _index = _buckets pushBack [_x, [_x]]; + _excludes pushBack _forEachIndex; + _bucketPos = _x; + _bucketList = (_buckets select _index) select 1; + breakTo "mainSearch"; + }; + } forEach _nlos; + { + if(!(_forEachIndex in _excludes)) then { + _testPos = _x; + if(_testPos vectorDistanceSqr _bucketPos <= 30) then { + _bucketList pushBack _x; + _excludes pushBack _forEachIndex; + }; + }; + } forEach _nlos; + _c = _c + 1; + }; + + // player sideChat format["c: %1", count _buckets]; + _explosions = []; + { + _blist = _x select 1; + _avgX = 0; + _avgY = 0; + _avgZ = 0; + + { + _avgX = _avgX + (_x select 0); + _avgY = _avgY + (_x select 1); + _avgZ = _avgZ + (_x select 2); + } forEach _blist; + _c = count _blist; + _bpos = [_avgX/_c, _avgY/_c, _avgZ/_c]; + + _distance = _pos vectorDistance _bpos; + _hitFactor = 1-(((_distance/(_indirectHitRange*4)) min 1) max 0); + // _hitFactor = 1/(_distance^2); + _hit = _indirectHit*_hitFactor; + _hit = (floor (_hit/4)) min 500; + _hit = _hit - (_hit%10); + _range = (floor (_indirectHitRange-(_distance/4))) min 100; + _range = _range - (_range%2); + + if(_hit >= 10 && _range > 0) then { + // TEST_ICONS pushBack [_bpos, format["h: %1, r: %2, hf: %3 d: %4 ihr: %5", _hit, _range, _hitFactor, _distance, _indirectHitRange*4]]; + // TEST_PAIRS pushBack [_pos, _bpos, [1,0,0,1]]; + _refExp = format["ace_explosion_reflection_%1_%2", _range, _hit]; + // _refExp createVehicle (ASLtoATL _bpos); + // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _bpos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; + + _explosions pushBack [_refExp, _bpos, _hit, _distance, _indirectHitRange/4, _depth]; + + }; + if(count _explosions > (_radi*2)/_depth) exitWith {}; + } forEach _buckets; + // _can = "Land_Bricks_V4_F" createVehicle (ASLtoATL _pos); + // _dirvec = _pos vectorFromTo ((ATLtoASL (player modelToWorldVisual (player selectionPosition "Spine3")))); + // _dirvec = _dirvec vectorMultiply 100; + // _can setVelocity _dirvec; + [DFUNC(doExplosions), 0, [_explosions, 0]] call CBA_fnc_addPerFrameHandler; + [(_this select 1)] call CBA_fnc_removePerFrameHandler; +}; +END_COUNTER(fnc_findReflections); diff --git a/addons/frag/functions/fnc_frago.sqf b/addons/frag/functions/fnc_frago.sqf index 8c72ae8bac..362a9b8c78 100644 --- a/addons/frag/functions/fnc_frago.sqf +++ b/addons/frag/functions/fnc_frago.sqf @@ -1,218 +1,218 @@ -//fnc_frago.sqf -// #define DEBUG_MODE_FULL -#include "script_component.hpp" - -#define FRAG_VEC_VAR 0.004 - -#define MAX_FRAG_COUNT 50 - -if(!isServer) exitWith { }; - -BEGIN_COUNTER(frago); -// _startTime = ACE_diagTime; - -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; -_lastVel = _this select 2; -_shellType = _this select 3; -_gun = nil; -if((count _this) > 5) then { - _gun = _this select 5; -}; - -_fragTypes = [ - "ACE_frag_tiny", "ACE_frag_tiny", "ACE_frag_tiny", - "ACE_frag_tiny_HD", "ACE_frag_tiny_HD", "ACE_frag_tiny_HD", - "ACE_frag_small","ACE_frag_small","ACE_frag_small","ACE_frag_small", - "ACE_frag_small_HD","ACE_frag_small_HD","ACE_frag_small_HD","ACE_frag_small_HD", - "ACE_frag_medium_HD", "ACE_frag_medium_HD", "ACE_frag_medium_HD", "ACE_frag_medium_HD", "ACE_frag_medium_HD" - ]; - -_warn = false; -if(isArray (configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_CLASSES")) then { - _fragTypes = getArray (configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_CLASSES"); -} else { - _warn = true; -}; - -_atlPos = ASLtoATL _lastPos; - -_isArmed = true; -if(!isNil "_gun") then { - _fuseDist = getNumber(configFile >> "CfgAmmo" >> _shellType >> "fuseDistance"); - _isArmed = ((getPosASL _gun) distance _lastPos > _fuseDist); -}; - -_indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _shellType >> "indirecthitrange"); -_fragRange = 20*_indirectHitRange*4; -// _c = 185; // grams of comp-b -// _m = 210; // grams of fragmentating metal -// _k = 3/5; // spherical K factor -// _gC = 2843; // Gurney constant of comp-b in /ms - -// _c = 429; // grams of tritonal -// _m = 496; // grams of fragmentating metal -// _k = 1/2; // spherical K factor -// _gC = 2320; // Gurney constant of tritonal in /ms - - -_c = getNumber(configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_CHARGE"); -if(_c == 0) then { _c = 1; _warn = true;}; -_m = getNumber(configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_METAL"); -if(_m == 0) then { _m = 2; _warn = true;}; -_k = getNumber(configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_GURNEY_K"); -if(_k == 0) then { _k = 1/2; _warn = true;}; -_gC = getNumber(configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_GURNEY_C"); -if(_gC == 0) then { _gC = 2440; _warn = true;}; - -if(_warn) then { - ACE_LOGWARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_shellType); //TODO: turn this off when we get closer to release -}; - -_fragPower = (((_m/_c)+_k)^-(1/2))*_gC; -_fragPower = _fragPower*0.8; // Gunery equation is for a non-fragmenting metal, imperical value of 80% represents fragmentation - -_fragPowerRandom = _fragPower*0.5; -if((_atlPos select 2) < 0.5) then { - _lastPos set[2, (_lastPos select 2)+0.5]; -}; - -// _manObjects = _atlPos nearEntities ["CaManBase", _fragRange]; - -// setAccTime 0.01; - -//_objects = nearestObjects [_atlPos, ["AllVehicles"], _fragRange]; // Not sure if tracking "ReammoBox" is required, if so revert this change for _objects -_objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange]; - -// _objects = _manObjects; -// Target also people inside vehicles or manning weapons -_crew = []; -{ - { - _crew set [count _crew,_x] - } forEach (crew _x); -} forEach _objects; - -_objects = _objects - _crew; -_objects = _objects + _crew; - -_fragCount = 0; - -_fragArcs = []; -_fragArcs set[360, 0]; - -#ifdef DEBUG_MODE_FULL - ACE_player sideChat format["_fragRange: %1", _fragRange]; - ACE_player sideChat format["_objects: %1", _objects]; -#endif -_doRandom = true; -if(_isArmed && (count _objects) > 0) then { - if (GVAR(ReflectionsEnabled)) then { - [_lastPos, _shellType] call FUNC(doReflections); - }; - { - //if(random(1) > 0.5) then { - _target = _x; - if(alive _target) then { - _boundingBox = boundingBox _target; - _targetPos = (getPosASL _target); - _distance = _targetPos distance _lastPos; - _add = (((_boundingBox select 1) select 2)/2)+((((_distance-(_fragpower/8)) max 0)/_fragPower)*10); - _bbX = (abs((_boundingBox select 0) select 0))+((_boundingBox select 1) select 0); - _bbY = (abs((_boundingBox select 0) select 1))+((_boundingBox select 1) select 1); - _bbZ = (abs((_boundingBox select 0) select 2))+((_boundingBox select 1) select 2); - _cubic = _bbX*_bbY*_bbZ; - if(_cubic > 1) then { - _doRandom = true; - - _targetVel = (velocity _target); - - - _targetPos set[0, (_targetPos select 0)+((_targetVel select 0)*(_distance/_fragPower))]; - _targetPos set[1, (_targetPos select 1)+((_targetVel select 1)*(_distance/_fragPower))]; - _targetPos set[2, (_targetPos select 2)+_add]; - - _baseVec = _lastPos vectorFromTo _targetPos; - - _dir = floor(_baseVec call CBA_fnc_vectDir); - _currentCount = _fragArcs select _dir; - if(isNil "_currentCount") then { - _currentCount = 0; - }; - if(_currentCount < 20) then { - _count = ceil(random(sqrt(_m/1000))); - _vecVar = FRAG_VEC_VAR; - if(!(_target isKindOf "Man")) then { - _vecVar = ((sqrt _cubic)/2000)+FRAG_VEC_VAR; - if((count (crew _target)) == 0 && _count > 0) then { - _count = 0 max (_count/2); - }; - }; - for "_i" from 1 to _count do { - _vec = +_baseVec; - - _vec set[0, (_vec select 0)-(_vecVar/2)+(random _vecVar)]; - _vec set[1, (_vec select 1)-(_vecVar/2)+(random _vecVar)]; - _vec set[2, (_vec select 2)-(_vecVar/2)+(random _vecVar)]; - - _fp = (_fragPower-(random (_fragPowerRandom))); - _vel = _vec vectorMultiply _fp; - - _fragType = round (random ((count _fragTypes)-1)); - _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; - // diag_log text format["fp: %1 %2", _fp, typeOf _fragObj]; - _fragObj setPosASL _lastPos; - _fragObj setVectorDir _vec; - _fragObj setVelocity _vel; - if(GVAR(traceFrags)) then { - GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1; - [ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack); - }; - _fragCount = _fragCount + 1; - _currentCount = _currentCount + 1; - }; - _fragArcs set[_dir, _currentCount]; - }; - }; - }; - //}; - if(_fragCount > MAX_FRAG_COUNT) exitWith {}; - } forEach _objects; - if(_fragCount > MAX_FRAG_COUNT) exitWith {}; - _randomCount = ((ceil((MAX_FRAG_COUNT-_fragCount)*0.1)) max 0)+20; - _sectorSize = 360 / (_randomCount max 1); - // _doRandom = false; - if(_doRandom) then { - for "_i" from 1 to _randomCount do { - // Distribute evenly - _sectorOffset = 360 * (_i - 1) / (_randomCount max 1); - _randomDir = random(_sectorSize); - _vec = [cos(_sectorOffset + _randomDir), sin(_sectorOffset + _randomDir), sin(30 - (random 45))]; - - _fp = (_fragPower-(random (_fragPowerRandom))); - - _vel = _vec vectorMultiply _fp; - - _fragType = round (random ((count _fragTypes)-1)); - _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; - _fragObj setPosASL _lastPos; - _fragObj setVectorDir _vec; - _fragObj setVelocity _vel; - - if(GVAR(traceFrags)) then { - GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1; - [ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack); - }; - _fragCount = _fragCount + 1; - }; - }; - -}; -// #ifdef DEBUG_MODE_FULL - // ACE_player sideChat format["total frags: %1", GVAR(TOTALFRAGS)]; - // ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))]; -// #endif -// _endTime = ACE_diagTime; +//fnc_frago.sqf +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +#define FRAG_VEC_VAR 0.004 + +#define MAX_FRAG_COUNT 50 + +if(!isServer) exitWith { }; + +BEGIN_COUNTER(frago); +// _startTime = ACE_diagTime; + +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; +_lastVel = _this select 2; +_shellType = _this select 3; +_gun = nil; +if((count _this) > 5) then { + _gun = _this select 5; +}; + +_fragTypes = [ + "ACE_frag_tiny", "ACE_frag_tiny", "ACE_frag_tiny", + "ACE_frag_tiny_HD", "ACE_frag_tiny_HD", "ACE_frag_tiny_HD", + "ACE_frag_small","ACE_frag_small","ACE_frag_small","ACE_frag_small", + "ACE_frag_small_HD","ACE_frag_small_HD","ACE_frag_small_HD","ACE_frag_small_HD", + "ACE_frag_medium_HD", "ACE_frag_medium_HD", "ACE_frag_medium_HD", "ACE_frag_medium_HD", "ACE_frag_medium_HD" + ]; + +_warn = false; +if(isArray (configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_CLASSES")) then { + _fragTypes = getArray (configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_CLASSES"); +} else { + _warn = true; +}; + +_atlPos = ASLtoATL _lastPos; + +_isArmed = true; +if(!isNil "_gun") then { + _fuseDist = getNumber(configFile >> "CfgAmmo" >> _shellType >> "fuseDistance"); + _isArmed = ((getPosASL _gun) distance _lastPos > _fuseDist); +}; + +_indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _shellType >> "indirecthitrange"); +_fragRange = 20*_indirectHitRange*4; +// _c = 185; // grams of comp-b +// _m = 210; // grams of fragmentating metal +// _k = 3/5; // spherical K factor +// _gC = 2843; // Gurney constant of comp-b in /ms + +// _c = 429; // grams of tritonal +// _m = 496; // grams of fragmentating metal +// _k = 1/2; // spherical K factor +// _gC = 2320; // Gurney constant of tritonal in /ms + + +_c = getNumber(configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_CHARGE"); +if(_c == 0) then { _c = 1; _warn = true;}; +_m = getNumber(configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_METAL"); +if(_m == 0) then { _m = 2; _warn = true;}; +_k = getNumber(configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_GURNEY_K"); +if(_k == 0) then { _k = 1/2; _warn = true;}; +_gC = getNumber(configFile >> "CfgAmmo" >> _shellType >> "ACE_frag_GURNEY_C"); +if(_gC == 0) then { _gC = 2440; _warn = true;}; + +if(_warn) then { + ACE_LOGWARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_shellType); //TODO: turn this off when we get closer to release +}; + +_fragPower = (((_m/_c)+_k)^-(1/2))*_gC; +_fragPower = _fragPower*0.8; // Gunery equation is for a non-fragmenting metal, imperical value of 80% represents fragmentation + +_fragPowerRandom = _fragPower*0.5; +if((_atlPos select 2) < 0.5) then { + _lastPos set[2, (_lastPos select 2)+0.5]; +}; + +// _manObjects = _atlPos nearEntities ["CaManBase", _fragRange]; + +// setAccTime 0.01; + +//_objects = nearestObjects [_atlPos, ["AllVehicles"], _fragRange]; // Not sure if tracking "ReammoBox" is required, if so revert this change for _objects +_objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange]; + +// _objects = _manObjects; +// Target also people inside vehicles or manning weapons +_crew = []; +{ + { + _crew set [count _crew,_x] + } forEach (crew _x); +} forEach _objects; + +_objects = _objects - _crew; +_objects = _objects + _crew; + +_fragCount = 0; + +_fragArcs = []; +_fragArcs set[360, 0]; + +#ifdef DEBUG_MODE_FULL + ACE_player sideChat format["_fragRange: %1", _fragRange]; + ACE_player sideChat format["_objects: %1", _objects]; +#endif +_doRandom = true; +if(_isArmed && (count _objects) > 0) then { + if (GVAR(ReflectionsEnabled)) then { + [_lastPos, _shellType] call FUNC(doReflections); + }; + { + //if(random(1) > 0.5) then { + _target = _x; + if(alive _target) then { + _boundingBox = boundingBox _target; + _targetPos = (getPosASL _target); + _distance = _targetPos distance _lastPos; + _add = (((_boundingBox select 1) select 2)/2)+((((_distance-(_fragpower/8)) max 0)/_fragPower)*10); + _bbX = (abs((_boundingBox select 0) select 0))+((_boundingBox select 1) select 0); + _bbY = (abs((_boundingBox select 0) select 1))+((_boundingBox select 1) select 1); + _bbZ = (abs((_boundingBox select 0) select 2))+((_boundingBox select 1) select 2); + _cubic = _bbX*_bbY*_bbZ; + if(_cubic > 1) then { + _doRandom = true; + + _targetVel = (velocity _target); + + + _targetPos set[0, (_targetPos select 0)+((_targetVel select 0)*(_distance/_fragPower))]; + _targetPos set[1, (_targetPos select 1)+((_targetVel select 1)*(_distance/_fragPower))]; + _targetPos set[2, (_targetPos select 2)+_add]; + + _baseVec = _lastPos vectorFromTo _targetPos; + + _dir = floor(_baseVec call CBA_fnc_vectDir); + _currentCount = _fragArcs select _dir; + if(isNil "_currentCount") then { + _currentCount = 0; + }; + if(_currentCount < 20) then { + _count = ceil(random(sqrt(_m/1000))); + _vecVar = FRAG_VEC_VAR; + if(!(_target isKindOf "Man")) then { + _vecVar = ((sqrt _cubic)/2000)+FRAG_VEC_VAR; + if((count (crew _target)) == 0 && _count > 0) then { + _count = 0 max (_count/2); + }; + }; + for "_i" from 1 to _count do { + _vec = +_baseVec; + + _vec set[0, (_vec select 0)-(_vecVar/2)+(random _vecVar)]; + _vec set[1, (_vec select 1)-(_vecVar/2)+(random _vecVar)]; + _vec set[2, (_vec select 2)-(_vecVar/2)+(random _vecVar)]; + + _fp = (_fragPower-(random (_fragPowerRandom))); + _vel = _vec vectorMultiply _fp; + + _fragType = round (random ((count _fragTypes)-1)); + _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; + // diag_log text format["fp: %1 %2", _fp, typeOf _fragObj]; + _fragObj setPosASL _lastPos; + _fragObj setVectorDir _vec; + _fragObj setVelocity _vel; + if(GVAR(traceFrags)) then { + GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1; + [ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack); + }; + _fragCount = _fragCount + 1; + _currentCount = _currentCount + 1; + }; + _fragArcs set[_dir, _currentCount]; + }; + }; + }; + //}; + if(_fragCount > MAX_FRAG_COUNT) exitWith {}; + } forEach _objects; + if(_fragCount > MAX_FRAG_COUNT) exitWith {}; + _randomCount = ((ceil((MAX_FRAG_COUNT-_fragCount)*0.1)) max 0)+20; + _sectorSize = 360 / (_randomCount max 1); + // _doRandom = false; + if(_doRandom) then { + for "_i" from 1 to _randomCount do { + // Distribute evenly + _sectorOffset = 360 * (_i - 1) / (_randomCount max 1); + _randomDir = random(_sectorSize); + _vec = [cos(_sectorOffset + _randomDir), sin(_sectorOffset + _randomDir), sin(30 - (random 45))]; + + _fp = (_fragPower-(random (_fragPowerRandom))); + + _vel = _vec vectorMultiply _fp; + + _fragType = round (random ((count _fragTypes)-1)); + _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; + _fragObj setPosASL _lastPos; + _fragObj setVectorDir _vec; + _fragObj setVelocity _vel; + + if(GVAR(traceFrags)) then { + GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1; + [ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack); + }; + _fragCount = _fragCount + 1; + }; + }; + +}; +// #ifdef DEBUG_MODE_FULL + // ACE_player sideChat format["total frags: %1", GVAR(TOTALFRAGS)]; + // ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))]; +// #endif +// _endTime = ACE_diagTime; END_COUNTER(frago); \ No newline at end of file diff --git a/addons/frag/functions/fnc_masterPFH.sqf b/addons/frag/functions/fnc_masterPFH.sqf index 637cc02f81..6af62e3f21 100644 --- a/addons/frag/functions/fnc_masterPFH.sqf +++ b/addons/frag/functions/fnc_masterPFH.sqf @@ -1,50 +1,50 @@ -/* - * Author: jaynus - * - * Master single PFH abstraction for all rounds being tracked by frag/spall - * - * Arguments: - * - * - * Return Value: - * None - */ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -//PARAMS_2(_pfhArgs,_handle); - -if (!GVAR(enabled)) exitWith {}; - -private["_gcIndex", "_iter"]; -_gcIndex = []; - -_iter = 0; -while { (count GVAR(objects)) > 0 && { _iter < (GVAR(MaxTrackPerFrame) min (count GVAR(objects))) } } do { - private["_object", "_args"]; - if(GVAR(lastIterationIndex) >= (count GVAR(objects))) then { - GVAR(lastIterationIndex) = 0; - }; - _object = GVAR(objects) select GVAR(lastIterationIndex); - - if(!isNil "_object") then { - _args = GVAR(arguments) select GVAR(lastIterationIndex); - - if(!(_args call FUNC(pfhRound))) then { - _gcIndex pushBack GVAR(lastIterationIndex); // Add it to the GC if it returns false - }; - }; - _iter = _iter + 1; - GVAR(lastIterationIndex) = GVAR(lastIterationIndex) + 1; -}; - -// clean up dead object references -private["_deletionCount", "_deleteIndex"]; -_deletionCount = 0; -{ - TRACE_1("GC Projectile", _x); - _deleteIndex = _x - _deletionCount; - GVAR(objects) deleteAt _deleteIndex; - GVAR(arguments) deleteAt _deleteIndex; - - _deletionCount = _deletionCount + 1; -} forEach _gcIndex; +/* + * Author: jaynus + * + * Master single PFH abstraction for all rounds being tracked by frag/spall + * + * Arguments: + * + * + * Return Value: + * None + */ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +//PARAMS_2(_pfhArgs,_handle); + +if (!GVAR(enabled)) exitWith {}; + +private["_gcIndex", "_iter"]; +_gcIndex = []; + +_iter = 0; +while { (count GVAR(objects)) > 0 && { _iter < (GVAR(MaxTrackPerFrame) min (count GVAR(objects))) } } do { + private["_object", "_args"]; + if(GVAR(lastIterationIndex) >= (count GVAR(objects))) then { + GVAR(lastIterationIndex) = 0; + }; + _object = GVAR(objects) select GVAR(lastIterationIndex); + + if(!isNil "_object") then { + _args = GVAR(arguments) select GVAR(lastIterationIndex); + + if(!(_args call FUNC(pfhRound))) then { + _gcIndex pushBack GVAR(lastIterationIndex); // Add it to the GC if it returns false + }; + }; + _iter = _iter + 1; + GVAR(lastIterationIndex) = GVAR(lastIterationIndex) + 1; +}; + +// clean up dead object references +private["_deletionCount", "_deleteIndex"]; +_deletionCount = 0; +{ + TRACE_1("GC Projectile", _x); + _deleteIndex = _x - _deletionCount; + GVAR(objects) deleteAt _deleteIndex; + GVAR(arguments) deleteAt _deleteIndex; + + _deletionCount = _deletionCount + 1; +} forEach _gcIndex; diff --git a/addons/frag/functions/fnc_pfhRound.sqf b/addons/frag/functions/fnc_pfhRound.sqf index 8aa2303c0d..55dd646a2e 100644 --- a/addons/frag/functions/fnc_pfhRound.sqf +++ b/addons/frag/functions/fnc_pfhRound.sqf @@ -1,50 +1,50 @@ -#include "script_component.hpp" -private ["_round", "_lastPos", "_lastVel", "_type", "_firedFrame", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"]; -_round = _this select 0; -_lastPos = _this select 1; -_lastVel = _this select 2; -_type = _this select 3; -_firedFrame = _this select 4; -_doSpall = _this select 6; -_spallTrack = _this select 7; -_foundObjectHPIds = _this select 8; -_skip = _this select 9; -_explosive = _this select 10; -_indirectRange = _this select 11; -_force = _this select 12; -_fragPower = _this select 13; - -if(_round in GVAR(blackList)) exitWith { - false -}; - -if (!alive _round) exitWith { - if((diag_frameno - _firedFrame) > 1) then { //skip if deleted within a single frame - if(_skip == 0) then { - if((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1} ) then { - [QGVAR(frag_eh), _this] call EFUNC(common,serverEvent); - }; - }; - }; - if(_doSpall) then { - GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) - 1; - // diag_log text format["F: %1", _foundObjectHPIds]; - { - if(!isNil "_x") then { - _x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex]; - }; - } forEach _spallTrack; - }; - false -}; - -_this set[1, (getPosASL _round)]; -_this set[2, (velocity _round)]; - -if(_doSpall) then { - private["_scale"]; - _scale = ( (count GVAR(objects)) / GVAR(MaxTrackPerFrame) ) max 0.1; - [_round, _scale, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack); -}; - -true +#include "script_component.hpp" +private ["_round", "_lastPos", "_lastVel", "_type", "_firedFrame", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"]; +_round = _this select 0; +_lastPos = _this select 1; +_lastVel = _this select 2; +_type = _this select 3; +_firedFrame = _this select 4; +_doSpall = _this select 6; +_spallTrack = _this select 7; +_foundObjectHPIds = _this select 8; +_skip = _this select 9; +_explosive = _this select 10; +_indirectRange = _this select 11; +_force = _this select 12; +_fragPower = _this select 13; + +if(_round in GVAR(blackList)) exitWith { + false +}; + +if (!alive _round) exitWith { + if((diag_frameno - _firedFrame) > 1) then { //skip if deleted within a single frame + if(_skip == 0) then { + if((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1} ) then { + [QGVAR(frag_eh), _this] call EFUNC(common,serverEvent); + }; + }; + }; + if(_doSpall) then { + GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) - 1; + // diag_log text format["F: %1", _foundObjectHPIds]; + { + if(!isNil "_x") then { + _x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex]; + }; + } forEach _spallTrack; + }; + false +}; + +_this set[1, (getPosASL _round)]; +_this set[2, (velocity _round)]; + +if(_doSpall) then { + private["_scale"]; + _scale = ( (count GVAR(objects)) / GVAR(MaxTrackPerFrame) ) max 0.1; + [_round, _scale, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack); +}; + +true diff --git a/addons/frag/functions/fnc_removePfhRound.sqf b/addons/frag/functions/fnc_removePfhRound.sqf index 92b09aad6d..d186da1e17 100644 --- a/addons/frag/functions/fnc_removePfhRound.sqf +++ b/addons/frag/functions/fnc_removePfhRound.sqf @@ -1,11 +1,11 @@ -#include "script_component.hpp" - -// THIS FUNCTION SHOULD NOT BE USED BECAUSE IT CAUSES AN SEARCH AND REBUILD - -PARAMS_1(_round); - -if(_round in GVAR(blackList)) then { - GVAR(blackList) = GVAR(blackList) - [_round]; -}; - -GVAR(objects) = GVAR(objects) - [_round]; +#include "script_component.hpp" + +// THIS FUNCTION SHOULD NOT BE USED BECAUSE IT CAUSES AN SEARCH AND REBUILD + +PARAMS_1(_round); + +if(_round in GVAR(blackList)) then { + GVAR(blackList) = GVAR(blackList) - [_round]; +}; + +GVAR(objects) = GVAR(objects) - [_round]; diff --git a/addons/frag/functions/fnc_removeTrack.sqf b/addons/frag/functions/fnc_removeTrack.sqf index d14b55b172..914a90602c 100644 --- a/addons/frag/functions/fnc_removeTrack.sqf +++ b/addons/frag/functions/fnc_removeTrack.sqf @@ -1,14 +1,14 @@ -#include "script_component.hpp" - -private ["_ret"]; -_ret = true; -if(IS_ARRAY((_this select 0))) then { - _ret = false; -} else { - if((_this select 0) in GVAR(trackedObjects)) then { - GVAR(trackedObjects) = GVAR(trackedObjects) - [(_this select 0)]; - } else { - _ret = false; - }; -}; -_ret +#include "script_component.hpp" + +private ["_ret"]; +_ret = true; +if(IS_ARRAY((_this select 0))) then { + _ret = false; +} else { + if((_this select 0) in GVAR(trackedObjects)) then { + GVAR(trackedObjects) = GVAR(trackedObjects) - [(_this select 0)]; + } else { + _ret = false; + }; +}; +_ret diff --git a/addons/frag/functions/fnc_spallHP.sqf b/addons/frag/functions/fnc_spallHP.sqf index 3756bb1416..f4e980d1de 100644 --- a/addons/frag/functions/fnc_spallHP.sqf +++ b/addons/frag/functions/fnc_spallHP.sqf @@ -1,29 +1,29 @@ -#include "script_component.hpp" - -private ["_initialData", "_hpData", "_round", "_hpRound", "_hpDirect"]; -//player sideChat format["f: %1 c: %2", (_this select 0), (count GVAR(spallHPData))]; - -if ((_this select 0) <= (count GVAR(spallHPData))) then { - _initialData = GVAR(spallHPData) select (_this select 0); - if (!isNil "_initialData") then { - _hpRound = ((_this select 1) select 0) select 2; - _round = _initialData select 3; - _hpDirect = ((_this select 1) select 0) select 10; - if (_hpDirect && {_round == _hpRound}) then { - { - _hpData = _x; - _round = _initialData select 3; - // diag_log text format["HPDUMP-------------------------------------"]; - // { - // _hp = _x; - // diag_log text format["%1 --", _forEachIndex]; - // { - // diag_log text format["%1: %2", _forEachIndex, _x]; - // } forEach _hp; - // } forEach (_this select 1); - [DFUNC(doSpall), [_this, _forEachIndex]] call EFUNC(common,execNextFrame); - // player sideChat "WEEE"; - } forEach (_this select 1); - }; - }; -}; +#include "script_component.hpp" + +private ["_initialData", "_hpData", "_round", "_hpRound", "_hpDirect"]; +//player sideChat format["f: %1 c: %2", (_this select 0), (count GVAR(spallHPData))]; + +if ((_this select 0) <= (count GVAR(spallHPData))) then { + _initialData = GVAR(spallHPData) select (_this select 0); + if (!isNil "_initialData") then { + _hpRound = ((_this select 1) select 0) select 2; + _round = _initialData select 3; + _hpDirect = ((_this select 1) select 0) select 10; + if (_hpDirect && {_round == _hpRound}) then { + { + _hpData = _x; + _round = _initialData select 3; + // diag_log text format["HPDUMP-------------------------------------"]; + // { + // _hp = _x; + // diag_log text format["%1 --", _forEachIndex]; + // { + // diag_log text format["%1: %2", _forEachIndex, _x]; + // } forEach _hp; + // } forEach (_this select 1); + [DFUNC(doSpall), [_this, _forEachIndex]] call EFUNC(common,execNextFrame); + // player sideChat "WEEE"; + } forEach (_this select 1); + }; + }; +}; diff --git a/addons/frag/functions/fnc_spallTrack.sqf b/addons/frag/functions/fnc_spallTrack.sqf index afe4bc1931..5ffc6a05ed 100644 --- a/addons/frag/functions/fnc_spallTrack.sqf +++ b/addons/frag/functions/fnc_spallTrack.sqf @@ -1,32 +1,32 @@ -//fnc_spallTrack.sqf -#include "script_component.hpp" - -private ["_round", "_multiplier", "_foundObjects", "_foundObjectHPIds", "_delta", "_curPos", "_velocity", "_velocityStep", "_forwardPos", "_intersectsWith", "_index", "_hpId", "_data"]; -_round = _this select 0; -_multiplier = _this select 1; -_foundObjects = _this select 2; -_foundObjectHPIds = _this select 3; - -_delta = (1/diag_fps) * _multiplier; -_curPos = getPosASL _round; -_velocity = velocity _round; - -_velocityStep = _velocity vectorMultiply _delta; -_forwardPos = _curPos vectorAdd _velocityStep; - -_intersectsWith = lineIntersectsWith [_curPos, _forwardPos]; - -if (count _intersectsWith > 0) then { - // player sideChat format["inter: %1", _intersectsWith]; - { - if(!(_x in _foundObjects)) then { - // diag_log text format["Adding HP: %1", _x]; - _index = (count GVAR(spallHPData)); - _hpId = _x addEventHandler ["hitPart", compile format["[%1, _this] call " + QUOTE(FUNC(spallHP)), _index]]; - _foundObjects set[(count _foundObjects), _x]; - _foundObjectHPIds set[(count _foundObjectHPIds), _hpId]; - _data = [_hpId, _x, typeOf _round, _round, _curPos, _velocity, 0, _foundObjects, _foundObjectHPIds]; - GVAR(spallHPData) set[_index, _data]; - }; - } forEach _intersectsWith; -}; +//fnc_spallTrack.sqf +#include "script_component.hpp" + +private ["_round", "_multiplier", "_foundObjects", "_foundObjectHPIds", "_delta", "_curPos", "_velocity", "_velocityStep", "_forwardPos", "_intersectsWith", "_index", "_hpId", "_data"]; +_round = _this select 0; +_multiplier = _this select 1; +_foundObjects = _this select 2; +_foundObjectHPIds = _this select 3; + +_delta = (1/diag_fps) * _multiplier; +_curPos = getPosASL _round; +_velocity = velocity _round; + +_velocityStep = _velocity vectorMultiply _delta; +_forwardPos = _curPos vectorAdd _velocityStep; + +_intersectsWith = lineIntersectsWith [_curPos, _forwardPos]; + +if (count _intersectsWith > 0) then { + // player sideChat format["inter: %1", _intersectsWith]; + { + if(!(_x in _foundObjects)) then { + // diag_log text format["Adding HP: %1", _x]; + _index = (count GVAR(spallHPData)); + _hpId = _x addEventHandler ["hitPart", compile format["[%1, _this] call " + QUOTE(FUNC(spallHP)), _index]]; + _foundObjects set[(count _foundObjects), _x]; + _foundObjectHPIds set[(count _foundObjectHPIds), _hpId]; + _data = [_hpId, _x, typeOf _round, _round, _curPos, _velocity, 0, _foundObjects, _foundObjectHPIds]; + GVAR(spallHPData) set[_index, _data]; + }; + } forEach _intersectsWith; +}; diff --git a/addons/frag/functions/fnc_startTracing.sqf b/addons/frag/functions/fnc_startTracing.sqf index 5c0c8aaf77..ca9aa8c84e 100644 --- a/addons/frag/functions/fnc_startTracing.sqf +++ b/addons/frag/functions/fnc_startTracing.sqf @@ -1,5 +1,5 @@ -#include "script_component.hpp" -if(!GVAR(tracesStarted)) then { - GVAR(tracesStarted) = true; - GVAR(traceID) = [FUNC(drawTraces), 0, []] call CBA_fnc_addPerFrameHandler; -}; +#include "script_component.hpp" +if(!GVAR(tracesStarted)) then { + GVAR(tracesStarted) = true; + GVAR(traceID) = [FUNC(drawTraces), 0, []] call CBA_fnc_addPerFrameHandler; +}; diff --git a/addons/frag/functions/fnc_stopTracing.sqf b/addons/frag/functions/fnc_stopTracing.sqf index f8ddf42084..b58352c897 100644 --- a/addons/frag/functions/fnc_stopTracing.sqf +++ b/addons/frag/functions/fnc_stopTracing.sqf @@ -1,5 +1,5 @@ -#include "script_component.hpp" -if(GVAR(tracesStarted)) then { - GVAR(tracesStarted) = false; - [GVAR(traceID)] call CBA_fnc_removePerFrameHandler; -}; +#include "script_component.hpp" +if(GVAR(tracesStarted)) then { + GVAR(tracesStarted) = false; + [GVAR(traceID)] call CBA_fnc_removePerFrameHandler; +}; diff --git a/addons/frag/functions/fnc_trackTrace.sqf b/addons/frag/functions/fnc_trackTrace.sqf index 24910db163..d9407c3f8d 100644 --- a/addons/frag/functions/fnc_trackTrace.sqf +++ b/addons/frag/functions/fnc_trackTrace.sqf @@ -1,14 +1,14 @@ -#include "script_component.hpp" - -private ["_params", "_tracerObj", "_index", "_positions", "_data"]; -_params = _this select 0; -_tracerObj = _params select 0; -_index = _params select 1; - -if (alive _tracerObj && (count GVAR(traces)) > 0) then { - _data = GVAR(traces) select _index; - _positions = _data select 4; - _positions set [(count _positions), [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]]; -} else { - [(_this select 1)] call CBA_fnc_removePerFrameHandler; -}; +#include "script_component.hpp" + +private ["_params", "_tracerObj", "_index", "_positions", "_data"]; +_params = _this select 0; +_tracerObj = _params select 0; +_index = _params select 1; + +if (alive _tracerObj && (count GVAR(traces)) > 0) then { + _data = GVAR(traces) select _index; + _positions = _data select 4; + _positions set [(count _positions), [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]]; +} else { + [(_this select 1)] call CBA_fnc_removePerFrameHandler; +}; diff --git a/addons/frag/script_component.hpp b/addons/frag/script_component.hpp index 1faa440294..b75c58452a 100644 --- a/addons/frag/script_component.hpp +++ b/addons/frag/script_component.hpp @@ -1,20 +1,20 @@ -#define COMPONENT frag -#include "\z\ace\addons\main\script_mod.hpp" - -//#define DEBUG_ENABLED_FRAG -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS -// #define ENABLE_PERFORMANCE_COUNTERS - -#ifdef DEBUG_ENABLED_FRAG - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_FRAG - #define DEBUG_SETTINGS DEBUG_SETTINGS_FRAG -#endif - -#include "\z\ace\addons\main\script_macros.hpp" - +#define COMPONENT frag +#include "\z\ace\addons\main\script_mod.hpp" + +//#define DEBUG_ENABLED_FRAG +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_FRAG + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_FRAG + #define DEBUG_SETTINGS DEBUG_SETTINGS_FRAG +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + #define ACE_TRACE_DRAW_INC 1 \ No newline at end of file diff --git a/addons/interact_menu/XEH_clientInit.sqf b/addons/interact_menu/XEH_clientInit.sqf index 4e4e6025a3..50169bf6b4 100644 --- a/addons/interact_menu/XEH_clientInit.sqf +++ b/addons/interact_menu/XEH_clientInit.sqf @@ -1,67 +1,67 @@ -//XEH_clientInit.sqf -#include "script_component.hpp" - -if (!hasInterface) exitWith {}; - -GVAR(cachedBuildingTypes) = []; -GVAR(cachedBuildingActionPairs) = []; - -GVAR(ParsedTextCached) = []; - -["SettingChanged", { - params ["_name"]; - if (({_x == _name} count [QGVAR(colorTextMax), QGVAR(colorTextMin), QGVAR(colorShadowMax), QGVAR(colorShadowMin), QGVAR(textSize), QGVAR(shadowSetting)]) == 1) then { - [] call FUNC(setupTextColors); - }; -}] call EFUNC(common,addEventhandler); - -["SettingsInitialized", { - //Setup text/shadow/size/color settings matrix - [] call FUNC(setupTextColors); - // Install the render EH on the main display - addMissionEventHandler ["Draw3D", DFUNC(render)]; -}] call EFUNC(common,addEventHandler); - -//Add Actions to Houses: -["interactMenuOpened", {_this call FUNC(userActions_addHouseActions)}] call EFUNC(common,addEventHandler); - -["ACE3 Common", QGVAR(InteractKey), (localize LSTRING(InteractKey)), -{ - // Statement - [0] call FUNC(keyDown) -},{[0,false] call FUNC(keyUp)}, -[219, [false, false, false]], false] call CBA_fnc_addKeybind; //Left Windows Key - -["ACE3 Common", QGVAR(SelfInteractKey), (localize LSTRING(SelfInteractKey)), -{ - // Statement - [1] call FUNC(keyDown) -},{[1,false] call FUNC(keyUp)}, -[219, [false, true, false]], false] call CBA_fnc_addKeybind; //Left Windows Key + Ctrl/Strg - - -// Listens for the falling unconscious event, just in case the menu needs to be closed -["medical_onUnconscious", { - // If no menu is open just quit - if (GVAR(openedMenuType) < 0) exitWith {}; - - params ["_unit", "_isUnconscious"]; - - if (_unit != ACE_player || !_isUnconscious) exitWith {}; - - GVAR(actionSelected) = false; - [GVAR(openedMenuType), false] call FUNC(keyUp); -}] call EFUNC(common,addEventhandler); - -// disable firing while the interact menu is is is opened -["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventHandler); - -// background options -["interactMenuOpened", { - if (GVAR(menuBackground)==1) then {[QGVAR(menuBackground), true] call EFUNC(common,blurScreen);}; - if (GVAR(menuBackground)==2) then {0 cutRsc[QGVAR(menuBackground), "PLAIN", 1, false];}; -}] call EFUNC(common,addEventHandler); -["interactMenuClosed", { - if (GVAR(menuBackground)==1) then {[QGVAR(menuBackground), false] call EFUNC(common,blurScreen);}; - if (GVAR(menuBackground)==2) then {(uiNamespace getVariable [QGVAR(menuBackground), displayNull]) closeDisplay 0;}; -}] call EFUNC(common,addEventHandler); +//XEH_clientInit.sqf +#include "script_component.hpp" + +if (!hasInterface) exitWith {}; + +GVAR(cachedBuildingTypes) = []; +GVAR(cachedBuildingActionPairs) = []; + +GVAR(ParsedTextCached) = []; + +["SettingChanged", { + params ["_name"]; + if (({_x == _name} count [QGVAR(colorTextMax), QGVAR(colorTextMin), QGVAR(colorShadowMax), QGVAR(colorShadowMin), QGVAR(textSize), QGVAR(shadowSetting)]) == 1) then { + [] call FUNC(setupTextColors); + }; +}] call EFUNC(common,addEventhandler); + +["SettingsInitialized", { + //Setup text/shadow/size/color settings matrix + [] call FUNC(setupTextColors); + // Install the render EH on the main display + addMissionEventHandler ["Draw3D", DFUNC(render)]; +}] call EFUNC(common,addEventHandler); + +//Add Actions to Houses: +["interactMenuOpened", {_this call FUNC(userActions_addHouseActions)}] call EFUNC(common,addEventHandler); + +["ACE3 Common", QGVAR(InteractKey), (localize LSTRING(InteractKey)), +{ + // Statement + [0] call FUNC(keyDown) +},{[0,false] call FUNC(keyUp)}, +[219, [false, false, false]], false] call CBA_fnc_addKeybind; //Left Windows Key + +["ACE3 Common", QGVAR(SelfInteractKey), (localize LSTRING(SelfInteractKey)), +{ + // Statement + [1] call FUNC(keyDown) +},{[1,false] call FUNC(keyUp)}, +[219, [false, true, false]], false] call CBA_fnc_addKeybind; //Left Windows Key + Ctrl/Strg + + +// Listens for the falling unconscious event, just in case the menu needs to be closed +["medical_onUnconscious", { + // If no menu is open just quit + if (GVAR(openedMenuType) < 0) exitWith {}; + + params ["_unit", "_isUnconscious"]; + + if (_unit != ACE_player || !_isUnconscious) exitWith {}; + + GVAR(actionSelected) = false; + [GVAR(openedMenuType), false] call FUNC(keyUp); +}] call EFUNC(common,addEventhandler); + +// disable firing while the interact menu is is is opened +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventHandler); + +// background options +["interactMenuOpened", { + if (GVAR(menuBackground)==1) then {[QGVAR(menuBackground), true] call EFUNC(common,blurScreen);}; + if (GVAR(menuBackground)==2) then {0 cutRsc[QGVAR(menuBackground), "PLAIN", 1, false];}; +}] call EFUNC(common,addEventHandler); +["interactMenuClosed", { + if (GVAR(menuBackground)==1) then {[QGVAR(menuBackground), false] call EFUNC(common,blurScreen);}; + if (GVAR(menuBackground)==2) then {(uiNamespace getVariable [QGVAR(menuBackground), displayNull]) closeDisplay 0;}; +}] call EFUNC(common,addEventHandler); diff --git a/addons/javelin/CfgEventhandlers.hpp b/addons/javelin/CfgEventhandlers.hpp index 9c0c367ba6..7b76e00d43 100644 --- a/addons/javelin/CfgEventhandlers.hpp +++ b/addons/javelin/CfgEventhandlers.hpp @@ -1,25 +1,25 @@ - -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_pre_init)); - }; -}; - -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_post_init)); - clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit)); - }; -}; - -class Extended_FiredBIS_EventHandlers { - class All { - ADDON = QUOTE(_this call FUNC(onFired)); - }; -}; + +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_pre_init)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_post_init)); + clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit)); + }; +}; + +class Extended_FiredBIS_EventHandlers { + class All { + ADDON = QUOTE(_this call FUNC(onFired)); + }; +}; diff --git a/addons/javelin/CfgSounds.hpp b/addons/javelin/CfgSounds.hpp index a5002409ff..9cd2627fa2 100644 --- a/addons/javelin/CfgSounds.hpp +++ b/addons/javelin/CfgSounds.hpp @@ -1,13 +1,13 @@ - -class CfgSounds { - class ACE_Javelin_Locking { - name = "ACE_Javelin_Locking"; - sound[] = {PATHTOF(data\sounds\javelin_locking.ogg), db+0, 1.0}; - titles[] = {}; - }; - class ACE_Javelin_Locked { - name = "ACE_Javelin_Locked"; - sound[] = {PATHTOF(data\sounds\javelin_locked.ogg), db+0, 1.0}; - titles[] = {}; - }; -}; + +class CfgSounds { + class ACE_Javelin_Locking { + name = "ACE_Javelin_Locking"; + sound[] = {PATHTOF(data\sounds\javelin_locking.ogg), db+0, 1.0}; + titles[] = {}; + }; + class ACE_Javelin_Locked { + name = "ACE_Javelin_Locked"; + sound[] = {PATHTOF(data\sounds\javelin_locked.ogg), db+0, 1.0}; + titles[] = {}; + }; +}; diff --git a/addons/javelin/CfgVehicles.hpp b/addons/javelin/CfgVehicles.hpp index 74863ef08f..e038c69812 100644 --- a/addons/javelin/CfgVehicles.hpp +++ b/addons/javelin/CfgVehicles.hpp @@ -1,68 +1,68 @@ -class CfgVehicles { - class LandVehicle; - class StaticWeapon : LandVehicle { - class Turrets; - }; - - class StaticMGWeapon : StaticWeapon { - class Turrets : Turrets { - class MainTurret; - }; - }; - class AT_01_base_F: StaticMGWeapon {}; - - class B_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; - opticsZoomMax = 0.04167; - opticsZoomInit = 0.08333; - opticsPPEffects[] = {"OpticsCHAbera1","OpticsBlur1"}; - opticsFlare = 0; - discretefov[] = {0.08333,0.04167}; - discreteInitIndex = 0; - }; - }; - }; - 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; - opticsZoomMax = 0.04167; - opticsZoomInit = 0.08333; - opticsPPEffects[] = {"OpticsCHAbera1","OpticsBlur1"}; - opticsFlare = 0; - discretefov[] = {0.08333,0.04167}; - discreteInitIndex = 0; - }; - }; - }; - 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; - opticsZoomMax = 0.04167; - opticsZoomInit = 0.08333; - opticsPPEffects[] = {"OpticsCHAbera1","OpticsBlur1"}; - opticsFlare = 0; - discretefov[] = {0.08333,0.04167}; - discreteInitIndex = 0; - }; - }; - }; -}; +class CfgVehicles { + class LandVehicle; + class StaticWeapon : LandVehicle { + class Turrets; + }; + + class StaticMGWeapon : StaticWeapon { + class Turrets : Turrets { + class MainTurret; + }; + }; + class AT_01_base_F: StaticMGWeapon {}; + + class B_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; + opticsZoomMax = 0.04167; + opticsZoomInit = 0.08333; + opticsPPEffects[] = {"OpticsCHAbera1","OpticsBlur1"}; + opticsFlare = 0; + discretefov[] = {0.08333,0.04167}; + discreteInitIndex = 0; + }; + }; + }; + 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; + opticsZoomMax = 0.04167; + opticsZoomInit = 0.08333; + opticsPPEffects[] = {"OpticsCHAbera1","OpticsBlur1"}; + opticsFlare = 0; + discretefov[] = {0.08333,0.04167}; + discreteInitIndex = 0; + }; + }; + }; + 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; + opticsZoomMax = 0.04167; + opticsZoomInit = 0.08333; + opticsPPEffects[] = {"OpticsCHAbera1","OpticsBlur1"}; + opticsFlare = 0; + discretefov[] = {0.08333,0.04167}; + discreteInitIndex = 0; + }; + }; + }; +}; diff --git a/addons/javelin/CfgWeapons.hpp b/addons/javelin/CfgWeapons.hpp index 1e32752145..5d15a246fd 100644 --- a/addons/javelin/CfgWeapons.hpp +++ b/addons/javelin/CfgWeapons.hpp @@ -1,72 +1,72 @@ -class CfgWeapons { - class Launcher; - class MissileLauncher; - - class Launcher_Base_F : Launcher { - class WeaponSlotsInfo; - }; - - // @TODO: AA by default, motherfuckers - class missiles_titan : MissileLauncher { - - }; - - class missiles_titan_at : missiles_titan { }; - class GVAR(Titan_Static) : missiles_titan_at { - GVAR(enabled) = 1; - weaponInfoType = "ACE_RscOptics_javelin"; - modelOptics = PATHTOF(data\reticle_titan.p3d); - - canLock = 0; - magazines[] = {"1Rnd_GAT_missiles"}; - lockingTargetSound[] = {"",0,1}; - lockedTargetSound[] = {"",0,1}; - }; - - // @TODO: AA by default, motherfuckers - class launch_Titan_base : Launcher_Base_F {}; - - class launch_Titan_short_base : launch_Titan_base { }; - - class launch_B_Titan_short_F: launch_Titan_short_base { - GVAR(enabled) = 1; - weaponInfoType = "ACE_RscOptics_javelin"; - modelOptics = PATHTOF(data\reticle_titan.p3d); - - canLock = 0; - - lockingTargetSound[] = {"",0,1}; - lockedTargetSound[] = {"",0,1}; - }; - class launch_I_Titan_short_F: launch_Titan_short_base { - GVAR(enabled) = 1; - weaponInfoType = "ACE_RscOptics_javelin"; - modelOptics = PATHTOF(data\reticle_titan.p3d); - - canLock = 0; - - lockingTargetSound[] = {"",0,1}; - lockedTargetSound[] = {"",0,1}; - }; - class launch_O_Titan_short_F: launch_Titan_short_base { - GVAR(enabled) = 1; - weaponInfoType = "ACE_RscOptics_javelin"; - modelOptics = PATHTOF(data\reticle_titan.p3d); - - canLock = 0; - - - lockingTargetSound[] = {"",0,1}; - lockedTargetSound[] = {"",0,1}; - }; - class launch_Titan_short_F: launch_Titan_short_base { - GVAR(enabled) = 1; - weaponInfoType = "ACE_RscOptics_javelin"; - modelOptics = PATHTOF(data\reticle_titan.p3d); - - canLock = 0; - - lockingTargetSound[] = {"",0,1}; - lockedTargetSound[] = {"",0,1}; - }; -}; +class CfgWeapons { + class Launcher; + class MissileLauncher; + + class Launcher_Base_F : Launcher { + class WeaponSlotsInfo; + }; + + // @TODO: AA by default, motherfuckers + class missiles_titan : MissileLauncher { + + }; + + class missiles_titan_at : missiles_titan { }; + class GVAR(Titan_Static) : missiles_titan_at { + GVAR(enabled) = 1; + weaponInfoType = "ACE_RscOptics_javelin"; + modelOptics = PATHTOF(data\reticle_titan.p3d); + + canLock = 0; + magazines[] = {"1Rnd_GAT_missiles"}; + lockingTargetSound[] = {"",0,1}; + lockedTargetSound[] = {"",0,1}; + }; + + // @TODO: AA by default, motherfuckers + class launch_Titan_base : Launcher_Base_F {}; + + class launch_Titan_short_base : launch_Titan_base { }; + + class launch_B_Titan_short_F: launch_Titan_short_base { + GVAR(enabled) = 1; + weaponInfoType = "ACE_RscOptics_javelin"; + modelOptics = PATHTOF(data\reticle_titan.p3d); + + canLock = 0; + + lockingTargetSound[] = {"",0,1}; + lockedTargetSound[] = {"",0,1}; + }; + class launch_I_Titan_short_F: launch_Titan_short_base { + GVAR(enabled) = 1; + weaponInfoType = "ACE_RscOptics_javelin"; + modelOptics = PATHTOF(data\reticle_titan.p3d); + + canLock = 0; + + lockingTargetSound[] = {"",0,1}; + lockedTargetSound[] = {"",0,1}; + }; + class launch_O_Titan_short_F: launch_Titan_short_base { + GVAR(enabled) = 1; + weaponInfoType = "ACE_RscOptics_javelin"; + modelOptics = PATHTOF(data\reticle_titan.p3d); + + canLock = 0; + + + lockingTargetSound[] = {"",0,1}; + lockedTargetSound[] = {"",0,1}; + }; + class launch_Titan_short_F: launch_Titan_short_base { + GVAR(enabled) = 1; + weaponInfoType = "ACE_RscOptics_javelin"; + modelOptics = PATHTOF(data\reticle_titan.p3d); + + canLock = 0; + + lockingTargetSound[] = {"",0,1}; + lockedTargetSound[] = {"",0,1}; + }; +}; diff --git a/addons/javelin/RscInGameUI.hpp b/addons/javelin/RscInGameUI.hpp index d3fff71db0..f33aaffbb4 100644 --- a/addons/javelin/RscInGameUI.hpp +++ b/addons/javelin/RscInGameUI.hpp @@ -1,454 +1,454 @@ -class RscOpticsValue; -class RscControlsGroup; -class RscPicture; -class RscMapControl; -class VScrollbar; -class HScrollbar; -class RscLine; - - -// Taken from AGM for optics management. - -class RscInGameUI { - class ACE_RscOptics_javelin { - idd = 300; - controls[] = { "ACE_javelin_elements_group", "ACE_Targeting" }; //, "ACE_TargetingConstrains", "ACE_TargetingGate", "ACE_TargetingLines"}; - onLoad = QUOTE(_this call FUNC(onOpticLoad)); - onUnload = QUOTE(_this call FUNC(onOpticUnload)); - - class ACE_javelin_elements_group: RscControlsGroup - { - x = "SafezoneX"; - y = "SafezoneY"; - w = "SafezoneW"; - h = "SafezoneH"; - idc = 170; - class VScrollbar { - autoScrollSpeed = -1; - autoScrollDelay = 5; - autoScrollRewind = 0; - color[] = {1,1,1,0}; - width = 0.001; - }; - class HScrollbar { - color[] = {1,1,1,0}; - height = 0.001; - }; - class Controls { - class CA_Distance: RscOpticsValue { - idc = 151; - sizeEx = "0"; - colorText[] = {0,0,0,0}; - x = 0; - y = 0; - w = 0; - h = 0; - }; - - class ACE_javelin_Day_mode_off: RscPicture { - idc = 1001; - x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.03/4)*3*SafezoneH - SafezoneX"; - y = "SafezoneY+SafezoneH*0.031 - SafezoneY"; - w = "0.1045752* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; - h = "SafezoneH*0.1045752"; - colorText[] = {0.2941,0.2941,0.2941,1}; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\day_co.paa"; - }; - class ACE_javelin_Day_mode: ACE_javelin_Day_mode_off { - idc = 160; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class CA_Javelin_WFOV_mode_off : ACE_javelin_Day_mode_off { - idc = 1004; - x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.307/4)*3*SafezoneH - SafezoneX"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\wfov_co.paa"; - }; - class ACE_javelin_WFOV_mode_group: RscControlsGroup { - x = "SafezoneX"; - y = "SafezoneY"; - w = "SafezoneW"; - h = "SafezoneH"; - idc = 163; - class VScrollbar { - autoScrollSpeed = -1; - autoScrollDelay = 5; - autoScrollRewind = 0; - color[] = {1,1,1,0}; - width = 0.001; - }; - class HScrollbar { - color[] = {1,1,1,0}; - height = 0.001; - }; - class Controls { - class StadiaL: RscLine { - x = "0.4899*SafezoneW - SafezoneX"; - y = "0.171*SafezoneH - SafezoneY"; - w = 0; - h = "0.049*SafezoneH"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class StadiaR: RscLine { - x = "0.5109*SafezoneW- SafezoneX"; - y = "0.171*SafezoneH - SafezoneY"; - w = 0; - h = "0.049*SafezoneH"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class BracketL: RscLine { - x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.293/4)*3*SafezoneH - SafezoneX"; - y = "0.4677*SafezoneH - SafezoneY"; - w = 0; - h = "0.0646*SafezoneH"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class BracketR: RscLine { - x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.70/4)*3*SafezoneH - SafezoneX"; - y = "0.4677*SafezoneH - SafezoneY"; - w = 0; - h = "0.0646*SafezoneH"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class BracketT: RscLine { - x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.467/4)*3*SafezoneH - SafezoneX"; - y = "0.3535*SafezoneH - SafezoneY"; - w = "0.065* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; - h = 0; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class BracketB: RscLine { - x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.467/4)*3*SafezoneH - SafezoneX"; - y = "0.6465*SafezoneH - SafezoneY"; - w = "0.065* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; - h = 0; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - - }; - }; - class CA_Javelin_NFOV_mode_off: ACE_javelin_Day_mode_off { - idc = 1003; - x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.586/4)*3*SafezoneH - SafezoneX"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\nfov_co.paa"; - }; - class ACE_javelin_NFOV_mode_group: RscControlsGroup { - x = "SafezoneX"; - y = "SafezoneY"; - w = "SafezoneW-SafezoneX"; - h = "SafezoneH-SafezoneY"; - idc = 162; - class VScrollbar { - autoScrollSpeed = -1; - autoScrollDelay = 5; - autoScrollRewind = 0; - color[] = {1,1,1,0}; - width = 0.001; - }; - class HScrollbar { - color[] = {1,1,1,0}; - height = 0.001; - }; - class Controls { - class StadiaL: RscLine { - x = "0.4788*SafezoneW - SafezoneX"; - y = "0.171*SafezoneH - SafezoneY"; - w = 0; - h = "0.049*SafezoneH"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class StadiaR: RscLine { - x = "0.5212*SafezoneW - SafezoneX"; - y = "0.171*SafezoneH - SafezoneY"; - w = 0; - h = "0.049*SafezoneH"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class LineHL: RscLine { - x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.01/4)*3*SafezoneH - SafezoneX"; - y = "SafezoneH*0.5 - SafezoneY"; - w = "0.29* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; - h = "SafezoneH*0.0"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class LineHR: RscLine { - x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.695/4)*3*SafezoneH - SafezoneX"; - y = "SafezoneH*0.5 - SafezoneY"; - w = "0.29* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; - h = "SafezoneH*0.0"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class LineVT: RscLine { - x = "0.5*SafezoneW - SafezoneX"; - y = "0.171*SafezoneH - SafezoneY"; - w = 0; - h = "0.1825*SafezoneH"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class LineVB: RscLine { - x = "0.5*SafezoneW - SafezoneX"; - y = "0.6465*SafezoneH - SafezoneY"; - w = 0; - h = "0.1895*SafezoneH"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - - }; - }; - - class ACE_javelin_SEEK_off: ACE_javelin_Day_mode_off { - idc = 699000; - x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.863/4)*3*SafezoneH - SafezoneX"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\seek_co.paa"; - }; - class ACE_javelin_SEEK: ACE_javelin_SEEK_off { - idc = 166; - colorText[] = {0.2941,0.8745,0.2157,0}; - }; - class ACE_javelin_Missle_off: ACE_javelin_Day_mode_off { - idc = 1032; - x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (-0.134/4)*3*SafezoneH - SafezoneX"; - y = "(SafezoneY + 0.208*SafezoneH) - SafezoneY"; - colorText[] = {0.2941,0.2941,0.2941,1}; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\missle_co.paa"; - }; - class ACE_javelin_Missle: ACE_javelin_Missle_off { - idc = 167; - colorText[] = {0.9255,0.5216,0.1216,0}; - }; - class ACE_javelin_CLU_off: ACE_javelin_Missle_off { - idc = 1027; - y = "(SafezoneY + 0.436*SafezoneH) - SafezoneY"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\clu_co.paa"; - }; - class ACE_javelin_HangFire_off: ACE_javelin_Missle_off { - idc = 1028; - y = "(SafezoneY + 0.669*SafezoneH) - SafezoneY"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\hangfire_co.paa"; - }; - class ACE_javelin_TOP_off: ACE_javelin_Day_mode_off { - idc = 699001; - x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (1.023/4)*3*SafezoneH - SafezoneX"; - y = "(SafezoneY + 0.208*SafezoneH) - SafezoneY"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\top_co.paa"; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - class ACE_javelin_DIR: ACE_javelin_Day_mode { - idc = 699002; - x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (1.023/4)*3*SafezoneH - SafezoneX"; - y = "(SafezoneY + 0.436*SafezoneH) - SafezoneY"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\dir_co.paa"; - colorText[] = {0.2941,0.2941,0.2941,1}; - }; - class ACE_javelin_FLTR_mode_off: ACE_javelin_Day_mode_off { - idc = 1002; - x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (1.023/4)*3*SafezoneH - SafezoneX"; - y = "(SafezoneY + 0.669*SafezoneH) - SafezoneY"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\fltr_co.paa"; - }; - class ACE_javelin_FLTR_mode: ACE_javelin_FLTR_mode_off { - idc = 161; - colorText[] = {0.2941,0.8745,0.2157,1}; - }; - }; - }; - class ACE_Targeting : RscControlsGroup { - idc = 6999; - - x = "SafezoneX"; - y = "SafezoneY"; - w = "SafezoneW"; - h = "SafezoneH"; - - enabled = 0; - class Controls { - class ACE_TargetingConstrains: RscControlsGroup { - x = "SafezoneX"; - y = "SafezoneY"; - w = "SafezoneW-SafezoneX"; - h = "SafezoneH-SafezoneY"; - - enabled = 0; - class VScrollbar { - autoScrollSpeed = -1; - autoScrollDelay = 5; - autoScrollRewind = 0; - color[] = {1,1,1,0}; - width = 0.001; - }; - class HScrollbar { - color[] = {1,1,1,0}; - height = 0.001; - }; - class Controls { - class Top: RscPicture { - idc = 699101; - text = "#(argb,8,8,3)color(1,1,1,1)"; - colorText[] = {0.2941,0.2941,0.2941,1}; - x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; - y = "0.15*SafezoneH-SafezoneY"; - w = "(3/4)*SafezoneH"; - h = "0.21*SafezoneH"; - }; - class Bottom: Top { - idc = 699102; - y = "0.64*SafezoneH-SafezoneY"; - }; - class Left: Top { - idc = 699103; - x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; - y = "0.36*SafezoneH-SafezoneY"; - w = "0.31*(3/4)*SafezoneH"; - h = "0.28*SafezoneH"; - }; - class Right: Left { - idc = 699104; - x = "((SafezoneW -(3/4)*SafezoneH)/2)+ 0.69*(3/4)*SafezoneH - SafezoneX"; - }; - class OpticsBorders: RscPicture { - idc = 699105; - text = PATHTOF(data\javelin_ui_border_ca.paa); - colorText[] = {0,0,0,1}; - x = "((SafezoneW -(3.1/4)*SafezoneH)/2) - SafezoneX"; - y = "0.15*SafezoneH-SafezoneY"; - w = "(3.1/4)*SafezoneH"; - h = "0.7*SafezoneH"; - }; - }; - }; - - class ACE_TargetingGate : ACE_TargetingConstrains { - idc = 699200; - class Controls { - class TargetingGateTL: ACE_TargetingConstrains { - x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; - y = "0.15*SafezoneH - SafezoneY"; - idc = 699201; - class Controls { - class LineH: RscLine { - idc = 699210; - x = "0"; - y = "0"; - w = "0.025*(3/4)*SafezoneH"; - h = "0"; - colorText[] = {0.8745,0.8745,0.8745,1}; - }; - class LineV: LineH { - idc = 699211; - w = "0"; - h = "0.025*SafezoneH"; - }; - }; - }; - class TargetingGateTR: TargetingGateTL { - x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX + 0.975*(3/4)*SafezoneH"; - y = "0.15*SafezoneH - SafezoneY"; - idc = 699202; - class Controls { - class LineH: RscLine { - idc = 699220; - x = "0"; - y = "0"; - w = "0.025*(3/4)*SafezoneH"; - h = "0"; - colorText[] = {0.8745,0.8745,0.8745,1}; - }; - class LineV: LineH { - idc = 699221; - x = "0.025*(3/4)*SafezoneH"; - w = "0"; - h = "0.025*SafezoneH"; - }; - }; - }; - class TargetingGateBL: TargetingGateTL { - x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; - y = "0.825*SafezoneH - SafezoneY"; - idc = 699203; - class Controls { - class LineH: RscLine { - x = "0"; - y = "0.025*SafezoneH"; - w = "0.025*(3/4)*SafezoneH"; - h = "0"; - colorText[] = {0.8745,0.8745,0.8745,1}; - }; - class LineV: LineH { - y = "0"; - w = "0"; - h = "0.025*SafezoneH"; - }; - }; - }; - class TargetingGateBR: TargetingGateBL { - x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX + 0.975*(3/4)*SafezoneH"; - y = "0.825*SafezoneH - SafezoneY"; - idc = 699204; - class Controls { - class LineH: RscLine { - x = "0"; - y = "0.025*SafezoneH"; - w = "0.025*(3/4)*SafezoneH"; - h = "0"; - colorText[] = {0.8745,0.8745,0.8745,1}; - }; - class LineV: LineH { - x = "0.025*(3/4)*SafezoneH"; - y = "0"; - w = "0"; - h = "0.025*SafezoneH"; - }; - }; - }; - }; - }; - - - class ACE_TargetingLines: ACE_TargetingConstrains { - idc = 699300; - class Controls { - class LineH: RscLine { - idc = 699301; - x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; - y = "0.5*SafezoneH - SafezoneY"; - w = "(3/4)*SafezoneH"; - h = "0"; - colorText[] = {0.8745,0.8745,0.8745,1}; - }; - class LineV: RscLine { - idc = 699302; - x = "0.5*SafezoneW - SafezoneX"; - y = "0.15*SafezoneH - SafezoneY"; - w = "0"; - h = "0.7*SafezoneH"; - colorText[] = {0.8745,0.8745,0.8745,1}; - }; - }; - }; - }; - }; - }; -}; - -// on colorText[] = {0.2941, 0.8745, 0.2157, 1.0}; -// off colorText[] = {0.2941, 0.2941, 0.2941, 1.0}; -// orange colorText[] = {0.9255, 0.5216, 0.1216, 1.0}; - -/* -ACE_Titan_elements_group: 170 -ACE_Titan_Day_mode_off: 1001 -ACE_Titan_Day_mode: 160 -ACE_Titan_WFOV_mode_off: 1004 -ACE_Titan_WFOV_mode_group: 163 -ACE_Titan_NFOV_mode_off: 1003 -ACE_Titan_NFOV_mode_group: 162 -ACE_Titan_SEEK_off: 1005 //1001 -ACE_Titan_SEEK: 166 -ACE_Titan_Missle_off: 1032 -ACE_Titan_Missle: 167 -ACE_Titan_CLU_off: 1027 -ACE_Titan_HangFire_off: 1028 -ACE_Titan_TOP_off: 1006 -ACE_Titan_DIR: 1007 -ACE_Titan_FLTR_mode_off: 1002 -ACE_Titan_FLTR_mode: 161 -*/ +class RscOpticsValue; +class RscControlsGroup; +class RscPicture; +class RscMapControl; +class VScrollbar; +class HScrollbar; +class RscLine; + + +// Taken from AGM for optics management. + +class RscInGameUI { + class ACE_RscOptics_javelin { + idd = 300; + controls[] = { "ACE_javelin_elements_group", "ACE_Targeting" }; //, "ACE_TargetingConstrains", "ACE_TargetingGate", "ACE_TargetingLines"}; + onLoad = QUOTE(_this call FUNC(onOpticLoad)); + onUnload = QUOTE(_this call FUNC(onOpticUnload)); + + class ACE_javelin_elements_group: RscControlsGroup + { + x = "SafezoneX"; + y = "SafezoneY"; + w = "SafezoneW"; + h = "SafezoneH"; + idc = 170; + class VScrollbar { + autoScrollSpeed = -1; + autoScrollDelay = 5; + autoScrollRewind = 0; + color[] = {1,1,1,0}; + width = 0.001; + }; + class HScrollbar { + color[] = {1,1,1,0}; + height = 0.001; + }; + class Controls { + class CA_Distance: RscOpticsValue { + idc = 151; + sizeEx = "0"; + colorText[] = {0,0,0,0}; + x = 0; + y = 0; + w = 0; + h = 0; + }; + + class ACE_javelin_Day_mode_off: RscPicture { + idc = 1001; + x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.03/4)*3*SafezoneH - SafezoneX"; + y = "SafezoneY+SafezoneH*0.031 - SafezoneY"; + w = "0.1045752* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; + h = "SafezoneH*0.1045752"; + colorText[] = {0.2941,0.2941,0.2941,1}; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\day_co.paa"; + }; + class ACE_javelin_Day_mode: ACE_javelin_Day_mode_off { + idc = 160; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class CA_Javelin_WFOV_mode_off : ACE_javelin_Day_mode_off { + idc = 1004; + x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.307/4)*3*SafezoneH - SafezoneX"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\wfov_co.paa"; + }; + class ACE_javelin_WFOV_mode_group: RscControlsGroup { + x = "SafezoneX"; + y = "SafezoneY"; + w = "SafezoneW"; + h = "SafezoneH"; + idc = 163; + class VScrollbar { + autoScrollSpeed = -1; + autoScrollDelay = 5; + autoScrollRewind = 0; + color[] = {1,1,1,0}; + width = 0.001; + }; + class HScrollbar { + color[] = {1,1,1,0}; + height = 0.001; + }; + class Controls { + class StadiaL: RscLine { + x = "0.4899*SafezoneW - SafezoneX"; + y = "0.171*SafezoneH - SafezoneY"; + w = 0; + h = "0.049*SafezoneH"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class StadiaR: RscLine { + x = "0.5109*SafezoneW- SafezoneX"; + y = "0.171*SafezoneH - SafezoneY"; + w = 0; + h = "0.049*SafezoneH"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class BracketL: RscLine { + x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.293/4)*3*SafezoneH - SafezoneX"; + y = "0.4677*SafezoneH - SafezoneY"; + w = 0; + h = "0.0646*SafezoneH"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class BracketR: RscLine { + x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.70/4)*3*SafezoneH - SafezoneX"; + y = "0.4677*SafezoneH - SafezoneY"; + w = 0; + h = "0.0646*SafezoneH"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class BracketT: RscLine { + x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.467/4)*3*SafezoneH - SafezoneX"; + y = "0.3535*SafezoneH - SafezoneY"; + w = "0.065* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; + h = 0; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class BracketB: RscLine { + x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.467/4)*3*SafezoneH - SafezoneX"; + y = "0.6465*SafezoneH - SafezoneY"; + w = "0.065* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; + h = 0; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + + }; + }; + class CA_Javelin_NFOV_mode_off: ACE_javelin_Day_mode_off { + idc = 1003; + x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.586/4)*3*SafezoneH - SafezoneX"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\nfov_co.paa"; + }; + class ACE_javelin_NFOV_mode_group: RscControlsGroup { + x = "SafezoneX"; + y = "SafezoneY"; + w = "SafezoneW-SafezoneX"; + h = "SafezoneH-SafezoneY"; + idc = 162; + class VScrollbar { + autoScrollSpeed = -1; + autoScrollDelay = 5; + autoScrollRewind = 0; + color[] = {1,1,1,0}; + width = 0.001; + }; + class HScrollbar { + color[] = {1,1,1,0}; + height = 0.001; + }; + class Controls { + class StadiaL: RscLine { + x = "0.4788*SafezoneW - SafezoneX"; + y = "0.171*SafezoneH - SafezoneY"; + w = 0; + h = "0.049*SafezoneH"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class StadiaR: RscLine { + x = "0.5212*SafezoneW - SafezoneX"; + y = "0.171*SafezoneH - SafezoneY"; + w = 0; + h = "0.049*SafezoneH"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class LineHL: RscLine { + x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.01/4)*3*SafezoneH - SafezoneX"; + y = "SafezoneH*0.5 - SafezoneY"; + w = "0.29* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; + h = "SafezoneH*0.0"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class LineHR: RscLine { + x = "((SafezoneW -SafezoneH*3/4)/2)+ (0.695/4)*3*SafezoneH - SafezoneX"; + y = "SafezoneH*0.5 - SafezoneY"; + w = "0.29* (((SafezoneW*3)/4)/SafezoneW)/(1/SafezoneH)"; + h = "SafezoneH*0.0"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class LineVT: RscLine { + x = "0.5*SafezoneW - SafezoneX"; + y = "0.171*SafezoneH - SafezoneY"; + w = 0; + h = "0.1825*SafezoneH"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class LineVB: RscLine { + x = "0.5*SafezoneW - SafezoneX"; + y = "0.6465*SafezoneH - SafezoneY"; + w = 0; + h = "0.1895*SafezoneH"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + + }; + }; + + class ACE_javelin_SEEK_off: ACE_javelin_Day_mode_off { + idc = 699000; + x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.863/4)*3*SafezoneH - SafezoneX"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\seek_co.paa"; + }; + class ACE_javelin_SEEK: ACE_javelin_SEEK_off { + idc = 166; + colorText[] = {0.2941,0.8745,0.2157,0}; + }; + class ACE_javelin_Missle_off: ACE_javelin_Day_mode_off { + idc = 1032; + x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (-0.134/4)*3*SafezoneH - SafezoneX"; + y = "(SafezoneY + 0.208*SafezoneH) - SafezoneY"; + colorText[] = {0.2941,0.2941,0.2941,1}; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\missle_co.paa"; + }; + class ACE_javelin_Missle: ACE_javelin_Missle_off { + idc = 167; + colorText[] = {0.9255,0.5216,0.1216,0}; + }; + class ACE_javelin_CLU_off: ACE_javelin_Missle_off { + idc = 1027; + y = "(SafezoneY + 0.436*SafezoneH) - SafezoneY"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\clu_co.paa"; + }; + class ACE_javelin_HangFire_off: ACE_javelin_Missle_off { + idc = 1028; + y = "(SafezoneY + 0.669*SafezoneH) - SafezoneY"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\hangfire_co.paa"; + }; + class ACE_javelin_TOP_off: ACE_javelin_Day_mode_off { + idc = 699001; + x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (1.023/4)*3*SafezoneH - SafezoneX"; + y = "(SafezoneY + 0.208*SafezoneH) - SafezoneY"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\top_co.paa"; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + class ACE_javelin_DIR: ACE_javelin_Day_mode { + idc = 699002; + x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (1.023/4)*3*SafezoneH - SafezoneX"; + y = "(SafezoneY + 0.436*SafezoneH) - SafezoneY"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\dir_co.paa"; + colorText[] = {0.2941,0.2941,0.2941,1}; + }; + class ACE_javelin_FLTR_mode_off: ACE_javelin_Day_mode_off { + idc = 1002; + x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (1.023/4)*3*SafezoneH - SafezoneX"; + y = "(SafezoneY + 0.669*SafezoneH) - SafezoneY"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics_titan\fltr_co.paa"; + }; + class ACE_javelin_FLTR_mode: ACE_javelin_FLTR_mode_off { + idc = 161; + colorText[] = {0.2941,0.8745,0.2157,1}; + }; + }; + }; + class ACE_Targeting : RscControlsGroup { + idc = 6999; + + x = "SafezoneX"; + y = "SafezoneY"; + w = "SafezoneW"; + h = "SafezoneH"; + + enabled = 0; + class Controls { + class ACE_TargetingConstrains: RscControlsGroup { + x = "SafezoneX"; + y = "SafezoneY"; + w = "SafezoneW-SafezoneX"; + h = "SafezoneH-SafezoneY"; + + enabled = 0; + class VScrollbar { + autoScrollSpeed = -1; + autoScrollDelay = 5; + autoScrollRewind = 0; + color[] = {1,1,1,0}; + width = 0.001; + }; + class HScrollbar { + color[] = {1,1,1,0}; + height = 0.001; + }; + class Controls { + class Top: RscPicture { + idc = 699101; + text = "#(argb,8,8,3)color(1,1,1,1)"; + colorText[] = {0.2941,0.2941,0.2941,1}; + x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; + y = "0.15*SafezoneH-SafezoneY"; + w = "(3/4)*SafezoneH"; + h = "0.21*SafezoneH"; + }; + class Bottom: Top { + idc = 699102; + y = "0.64*SafezoneH-SafezoneY"; + }; + class Left: Top { + idc = 699103; + x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; + y = "0.36*SafezoneH-SafezoneY"; + w = "0.31*(3/4)*SafezoneH"; + h = "0.28*SafezoneH"; + }; + class Right: Left { + idc = 699104; + x = "((SafezoneW -(3/4)*SafezoneH)/2)+ 0.69*(3/4)*SafezoneH - SafezoneX"; + }; + class OpticsBorders: RscPicture { + idc = 699105; + text = PATHTOF(data\javelin_ui_border_ca.paa); + colorText[] = {0,0,0,1}; + x = "((SafezoneW -(3.1/4)*SafezoneH)/2) - SafezoneX"; + y = "0.15*SafezoneH-SafezoneY"; + w = "(3.1/4)*SafezoneH"; + h = "0.7*SafezoneH"; + }; + }; + }; + + class ACE_TargetingGate : ACE_TargetingConstrains { + idc = 699200; + class Controls { + class TargetingGateTL: ACE_TargetingConstrains { + x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; + y = "0.15*SafezoneH - SafezoneY"; + idc = 699201; + class Controls { + class LineH: RscLine { + idc = 699210; + x = "0"; + y = "0"; + w = "0.025*(3/4)*SafezoneH"; + h = "0"; + colorText[] = {0.8745,0.8745,0.8745,1}; + }; + class LineV: LineH { + idc = 699211; + w = "0"; + h = "0.025*SafezoneH"; + }; + }; + }; + class TargetingGateTR: TargetingGateTL { + x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX + 0.975*(3/4)*SafezoneH"; + y = "0.15*SafezoneH - SafezoneY"; + idc = 699202; + class Controls { + class LineH: RscLine { + idc = 699220; + x = "0"; + y = "0"; + w = "0.025*(3/4)*SafezoneH"; + h = "0"; + colorText[] = {0.8745,0.8745,0.8745,1}; + }; + class LineV: LineH { + idc = 699221; + x = "0.025*(3/4)*SafezoneH"; + w = "0"; + h = "0.025*SafezoneH"; + }; + }; + }; + class TargetingGateBL: TargetingGateTL { + x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; + y = "0.825*SafezoneH - SafezoneY"; + idc = 699203; + class Controls { + class LineH: RscLine { + x = "0"; + y = "0.025*SafezoneH"; + w = "0.025*(3/4)*SafezoneH"; + h = "0"; + colorText[] = {0.8745,0.8745,0.8745,1}; + }; + class LineV: LineH { + y = "0"; + w = "0"; + h = "0.025*SafezoneH"; + }; + }; + }; + class TargetingGateBR: TargetingGateBL { + x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX + 0.975*(3/4)*SafezoneH"; + y = "0.825*SafezoneH - SafezoneY"; + idc = 699204; + class Controls { + class LineH: RscLine { + x = "0"; + y = "0.025*SafezoneH"; + w = "0.025*(3/4)*SafezoneH"; + h = "0"; + colorText[] = {0.8745,0.8745,0.8745,1}; + }; + class LineV: LineH { + x = "0.025*(3/4)*SafezoneH"; + y = "0"; + w = "0"; + h = "0.025*SafezoneH"; + }; + }; + }; + }; + }; + + + class ACE_TargetingLines: ACE_TargetingConstrains { + idc = 699300; + class Controls { + class LineH: RscLine { + idc = 699301; + x = "((SafezoneW -(3/4)*SafezoneH)/2) - SafezoneX"; + y = "0.5*SafezoneH - SafezoneY"; + w = "(3/4)*SafezoneH"; + h = "0"; + colorText[] = {0.8745,0.8745,0.8745,1}; + }; + class LineV: RscLine { + idc = 699302; + x = "0.5*SafezoneW - SafezoneX"; + y = "0.15*SafezoneH - SafezoneY"; + w = "0"; + h = "0.7*SafezoneH"; + colorText[] = {0.8745,0.8745,0.8745,1}; + }; + }; + }; + }; + }; + }; +}; + +// on colorText[] = {0.2941, 0.8745, 0.2157, 1.0}; +// off colorText[] = {0.2941, 0.2941, 0.2941, 1.0}; +// orange colorText[] = {0.9255, 0.5216, 0.1216, 1.0}; + +/* +ACE_Titan_elements_group: 170 +ACE_Titan_Day_mode_off: 1001 +ACE_Titan_Day_mode: 160 +ACE_Titan_WFOV_mode_off: 1004 +ACE_Titan_WFOV_mode_group: 163 +ACE_Titan_NFOV_mode_off: 1003 +ACE_Titan_NFOV_mode_group: 162 +ACE_Titan_SEEK_off: 1005 //1001 +ACE_Titan_SEEK: 166 +ACE_Titan_Missle_off: 1032 +ACE_Titan_Missle: 167 +ACE_Titan_CLU_off: 1027 +ACE_Titan_HangFire_off: 1028 +ACE_Titan_TOP_off: 1006 +ACE_Titan_DIR: 1007 +ACE_Titan_FLTR_mode_off: 1002 +ACE_Titan_FLTR_mode: 161 +*/ diff --git a/addons/javelin/XEH_clientInit.sqf b/addons/javelin/XEH_clientInit.sqf index 38b006ca24..1286be3697 100644 --- a/addons/javelin/XEH_clientInit.sqf +++ b/addons/javelin/XEH_clientInit.sqf @@ -1,5 +1,5 @@ -#include "script_component.hpp" - -if (!hasInterface) exitWith {}; - +#include "script_component.hpp" + +if (!hasInterface) exitWith {}; + #include "initKeybinds.sqf" \ No newline at end of file diff --git a/addons/javelin/XEH_post_init.sqf b/addons/javelin/XEH_post_init.sqf index dc30361926..6eccf9d1dd 100644 --- a/addons/javelin/XEH_post_init.sqf +++ b/addons/javelin/XEH_post_init.sqf @@ -1,2 +1,2 @@ -#include "script_component.hpp" - +#include "script_component.hpp" + diff --git a/addons/javelin/XEH_pre_init.sqf b/addons/javelin/XEH_pre_init.sqf index 045e4a46aa..b092e92359 100644 --- a/addons/javelin/XEH_pre_init.sqf +++ b/addons/javelin/XEH_pre_init.sqf @@ -1,10 +1,10 @@ -#include "script_component.hpp" - -ADDON = false; - -#include "XEH_PREP.hpp" - -GVAR(isLockKeyDown) = false; -GVAR(pfehID) = -1; - -ADDON = true; +#include "script_component.hpp" + +ADDON = false; + +#include "XEH_PREP.hpp" + +GVAR(isLockKeyDown) = false; +GVAR(pfehID) = -1; + +ADDON = true; diff --git a/addons/javelin/config.cpp b/addons/javelin/config.cpp index 8dfc970902..4ce34caa5e 100644 --- a/addons/javelin/config.cpp +++ b/addons/javelin/config.cpp @@ -1,18 +1,18 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = { "ace_main", "ace_common", "ace_missileguidance" }; - VERSION_CONFIG; - }; -}; - -#include "CfgEventhandlers.hpp" -#include "RscInGameUI.hpp" -#include "CfgSounds.hpp" -#include "CfgWeapons.hpp" -#include "CfgVehicles.hpp" -#include "CfgMagazines.hpp" +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { "ace_main", "ace_common", "ace_missileguidance" }; + VERSION_CONFIG; + }; +}; + +#include "CfgEventhandlers.hpp" +#include "RscInGameUI.hpp" +#include "CfgSounds.hpp" +#include "CfgWeapons.hpp" +#include "CfgVehicles.hpp" +#include "CfgMagazines.hpp" diff --git a/addons/javelin/functions/fnc_cycleFireMode.sqf b/addons/javelin/functions/fnc_cycleFireMode.sqf index 2245bb71e5..d14c0cdee5 100644 --- a/addons/javelin/functions/fnc_cycleFireMode.sqf +++ b/addons/javelin/functions/fnc_cycleFireMode.sqf @@ -1,13 +1,13 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -TRACE_1("enter", _this); - -private["_player", "_currentFireMode"]; - -_currentFireMode = ACE_player getVariable["ace_missileguidance_attackProfile", "JAV_TOP"]; -if(_currentFireMode == "JAV_DIR") then { - _currentFireMode = "JAV_TOP"; -} else { - _currentFireMode = "JAV_DIR"; -}; -ACE_player setVariable["ace_missileguidance_attackProfile", _currentFireMode, false]; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +TRACE_1("enter", _this); + +private["_player", "_currentFireMode"]; + +_currentFireMode = ACE_player getVariable["ace_missileguidance_attackProfile", "JAV_TOP"]; +if(_currentFireMode == "JAV_DIR") then { + _currentFireMode = "JAV_TOP"; +} else { + _currentFireMode = "JAV_DIR"; +}; +ACE_player setVariable["ace_missileguidance_attackProfile", _currentFireMode, false]; diff --git a/addons/javelin/functions/fnc_lockKeyDown.sqf b/addons/javelin/functions/fnc_lockKeyDown.sqf index 2a537e2ae9..3eabbd9c28 100644 --- a/addons/javelin/functions/fnc_lockKeyDown.sqf +++ b/addons/javelin/functions/fnc_lockKeyDown.sqf @@ -1,3 +1,3 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" +//#define DEBUG_MODE_FULL +#include "script_component.hpp" TRACE_1("enter", _this); \ No newline at end of file diff --git a/addons/javelin/functions/fnc_lockKeyUp.sqf b/addons/javelin/functions/fnc_lockKeyUp.sqf index 2a537e2ae9..3eabbd9c28 100644 --- a/addons/javelin/functions/fnc_lockKeyUp.sqf +++ b/addons/javelin/functions/fnc_lockKeyUp.sqf @@ -1,3 +1,3 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" +//#define DEBUG_MODE_FULL +#include "script_component.hpp" TRACE_1("enter", _this); \ No newline at end of file diff --git a/addons/javelin/functions/fnc_onFired.sqf b/addons/javelin/functions/fnc_onFired.sqf index fce170fde9..9cc8b95ad4 100644 --- a/addons/javelin/functions/fnc_onFired.sqf +++ b/addons/javelin/functions/fnc_onFired.sqf @@ -1,17 +1,17 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -PARAMS_2(_shooter,_weapon); - -// Bail on not missile or javelin PFEH not running -if ((_shooter != ACE_player) || {(GVAR(pfehID) == -1)}) exitWith { false }; - -private ["_configs"]; - -_configs = configProperties [configFile >> "CfgWeapons" >> _weapon, QUOTE(configName _x == QUOTE(QGVAR(enabled))), false]; -if (((count _configs) < 1) || {(getNumber (_configs select 0)) != 1}) exitWith {}; - -__JavelinIGUITargeting ctrlShow false; -__JavelinIGUITargetingGate ctrlShow false; -__JavelinIGUITargetingLines ctrlShow false; -__JavelinIGUITargetingConstraints ctrlShow false; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +PARAMS_2(_shooter,_weapon); + +// Bail on not missile or javelin PFEH not running +if ((_shooter != ACE_player) || {(GVAR(pfehID) == -1)}) exitWith { false }; + +private ["_configs"]; + +_configs = configProperties [configFile >> "CfgWeapons" >> _weapon, QUOTE(configName _x == QUOTE(QGVAR(enabled))), false]; +if (((count _configs) < 1) || {(getNumber (_configs select 0)) != 1}) exitWith {}; + +__JavelinIGUITargeting ctrlShow false; +__JavelinIGUITargetingGate ctrlShow false; +__JavelinIGUITargetingLines ctrlShow false; +__JavelinIGUITargetingConstraints ctrlShow false; diff --git a/addons/javelin/functions/fnc_onOpticDraw.sqf b/addons/javelin/functions/fnc_onOpticDraw.sqf index 67e337291b..3424072290 100644 --- a/addons/javelin/functions/fnc_onOpticDraw.sqf +++ b/addons/javelin/functions/fnc_onOpticDraw.sqf @@ -1,313 +1,313 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -TRACE_1("enter", _this); - -#define __TRACKINTERVAL 0 // how frequent the check should be. -#define __LOCKONTIME 3 // Lock on won't occur sooner - -private["_apos", "_aposX", "_aposY", "_args", "_boundsInput", "_bpos", "_canFire", "_constraintBottom"]; -private["_constraintLeft", "_constraintRight", "_constraintTop", "_currentTarget", "_fireDisabledEH"]; -private["_firedEH", "_fov", "_lastTick", "_lockTime", "_maxX", "_maxY", "_minX", "_minY", "_newTarget"]; -private["_offsetX", "_offsetY", "_pos", "_randomLockInterval", "_randomPosWithinBounds", "_range"]; -private["_runTime", "_soundTime", "_targetArray", "_zamerny", "_currentShooter"]; - -_currentShooter = (vehicle ACE_player); - -#define __OffsetX ((ctrlPosition __JavelinIGUITargetingLineV) select 0) - 0.5 -#define __OffsetY ((ctrlPosition __JavelinIGUITargetingLineH) select 1) - 0.5 - -// Reset arguments if we havnt rendered in over a second -_args = uiNamespace getVariable[QGVAR(arguments), [] ]; -if( (count _args) > 0) then { - _lastTick = _args select 0; - if(ACE_diagTime - _lastTick > 1) then { - [] call FUNC(onOpticLoad); - }; -}; - -TRACE_1("Running", "Running"); - -// Pull the arguments -_currentTarget = _args select 1; -_runTime = _args select 2; -_lockTime = _args select 3; -_soundTime = _args select 4; -_randomLockInterval = _args select 5; -_fireDisabledEH = _args select 6; - -private["_ammo", "_magazineConfig", "_weaponConfig"]; -_weaponConfig = configProperties [configFile >> "CfgWeapons" >> (currentWeapon _currentShooter), QUOTE(configName _x == QUOTE(QGVAR(enabled))), false]; -_magazineConfig = if ((currentMagazine _currentShooter) != "") then { - _ammo = getText (configFile >> "CfgMagazines" >> (currentMagazine _currentShooter) >> "ammo"); - configProperties [(configFile >> "CfgAmmo" >> _ammo), "(configName _x) == 'ace_missileguidance'", false]; -} else { - [] -}; - -//If weapon does not have "javelin enabled", then exit PFEH -if (((count _weaponConfig) < 1) || {(getNumber (_weaponConfig select 0)) != 1}) exitWith { - __JavelinIGUITargeting ctrlShow false; - __JavelinIGUITargetingGate ctrlShow false; - __JavelinIGUITargetingLines ctrlShow false; - __JavelinIGUITargetingConstraints ctrlShow false; - - if(!isNil "_fireDisabledEH") then { - _fireDisabledEH = [_fireDisabledEH] call FUNC(enableFire); - }; - - [(_this select 1)] call CBA_fnc_removePerFrameHandler; - GVAR(pfehID) = -1; -}; - -// Find a target within the optic range -_newTarget = objNull; - -// Bail on fast movement -if ((velocity ACE_player) distance [0,0,0] > 0.5 && {cameraView == "GUNNER"} && {cameraOn == ACE_player}) exitWith { // keep it steady. - ACE_player switchCamera "INTERNAL"; - if (player != ACE_player) then { - TRACE_2("Zeus, manually reseting RC after switchCamera",player,ACE_player); - player remoteControl ACE_player; - }; -}; - -// Refresh the firemode -[] call FUNC(showFireMode); - -_ammo = _currentShooter ammo (currentWeapon _currentShooter); -// not loaded or not "javelin enabled" for magazine, hide targeting and enable firing -if ((_ammo == 0) || {(count _magazineConfig) < 1} || {(getNumber ((_magazineConfig select 0) >> "enabled")) != 1}) exitWith { - __JavelinIGUITargeting ctrlShow false; - __JavelinIGUITargetingGate ctrlShow false; - __JavelinIGUITargetingLines ctrlShow false; - __JavelinIGUITargetingConstraints ctrlShow false; - - if(!isNil "_fireDisabledEH") then { - _fireDisabledEH = [_fireDisabledEH] call FUNC(enableFire); - }; -}; - -_range = parseNumber (ctrlText __JavelinIGUIRangefinder); -TRACE_1("Viewing range", _range); -if (_range > 50 && {_range < 2500}) then { - _pos = positionCameraToWorld [0,0,_range]; - _targetArray = _pos nearEntities ["AllVehicles", _range/100]; - TRACE_1("Searching at range", _targetArray); - if (count (_targetArray) > 0) then { - _newTarget = _targetArray select 0; - }; -}; - -if ((isNull _newTarget) && {cursorObject isKindOf "AllVehicles"}) then { - private _intersectionsToCursorTarget = lineIntersectsSurfaces [(AGLtoASL positionCameraToWorld [0,0,0]), aimPos cursorObject, ace_player, cursorObject, true, 1]; - if (_intersectionsToCursorTarget isEqualTo []) then { - _newTarget = cursorObject; - }; -}; -if ((isNull _newTarget) && {cursorTarget isKindOf "AllVehicles"}) then { - private _intersectionsToCursorTarget = lineIntersectsSurfaces [(AGLtoASL positionCameraToWorld [0,0,0]), aimPos cursorTarget, ace_player, cursorTarget, true, 1]; - if (_intersectionsToCursorTarget isEqualTo []) then { - _newTarget = cursorTarget; - }; -}; - -// Create constants -_constraintTop = __ConstraintTop; -_constraintLeft = __ConstraintLeft; -_constraintBottom = __ConstraintBottom; -_constraintRight = __ConstraintRight; - -_offsetX = __OffsetX; -_offsetY = __OffsetY; - -__JavelinIGUITargeting ctrlShow true; -__JavelinIGUITargetingConstrains ctrlShow true; - -_zamerny = if (_currentTarget isKindOf "CAManBase") then {_currentTarget selectionPosition "body"} else {_currentTarget selectionPosition "zamerny"}; -_randomPosWithinBounds = [(_zamerny select 0) + 1 - (random 2.0),(_zamerny select 1) + 1 - (random 2.0),(_zamerny select 2) + 0.5 - (random 1.0)]; - -_apos = worldToScreen (_currentTarget modelToWorld _randomPosWithinBounds); - -_aposX = 0; -_aposY = 0; -if (count _apos < 2) then { - _aposX = 1; - _aposY = 0; -} else { - _aposX = (_apos select 0) + _offsetX; - _aposY = (_apos select 1) + _offsetY; -}; - -if((call CBA_fnc_getFoV) select 1 > 9) then { - __JavelinIGUINFOV ctrlSetTextColor __ColorGreen; - __JavelinIGUIWFOV ctrlSetTextColor __ColorGray; -} else { - __JavelinIGUINFOV ctrlSetTextColor __ColorGray; - __JavelinIGUIWFOV ctrlSetTextColor __ColorGreen; -}; - -FUNC(disableFire) = { - _firedEH = _this select 0; - - if(_firedEH < 0 && difficulty > 0) then { - _firedEH = [ACE_player, "DefaultAction", {true}, { - _canFire = (_this select 1) getVariable["ace_missileguidance_target", nil]; - if(!isNil "_canFire") exitWith { false }; - true - }] call EFUNC(common,addActionEventHandler); - }; - _firedEH -}; -FUNC(enableFire) = { - _firedEH = _this select 0; - - if(_firedEH > 0 && difficulty > 0) then { - [ACE_player, "DefaultAction", _firedEH] call EFUNC(common,removeActionEventHandler); - }; - -1 -}; - -if (isNull _newTarget) then { - // No targets found - _currentTarget = objNull; - _lockTime = 0; - - __JavelinIGUISeek ctrlSetTextColor __ColorGray; - __JavelinIGUITargeting ctrlShow false; - __JavelinIGUITargetingGate ctrlShow false; - __JavelinIGUITargetingLines ctrlShow false; - __JavelinIGUITargetingConstraints ctrlShow false; - - _currentShooter setVariable ["ace_missileguidance_target",nil, false]; - - // Disallow fire - _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); -} else { - _fov = [] call CBA_fnc_getFoV; - TRACE_1("FOV", _fov); - if (_newTarget distance ACE_player < 2500 - && {(call CBA_fnc_getFoV) select 1 > 9} - && { (currentVisionMode ACE_player == 2)} - && GVAR(isLockKeyDown) - ) then { - // Lock on after 3 seconds - if(_currentTarget != _newTarget) then { - TRACE_1("New Target, reseting locking", _newTarget); - _lockTime = ACE_diagTime; - _currentTarget = _newTarget; - - playSound "ACE_Javelin_Locking"; - } else { - if(ACE_diagTime - _lockTime > __LOCKONTIME + _randomLockInterval) then { - TRACE_2("LOCKED!", _currentTarget, _lockTime); - - __JavelinIGUISeek ctrlSetTextColor __ColorGreen; - - __JavelinIGUITargeting ctrlShow true; - __JavelinIGUITargetingConstrains ctrlShow false; - __JavelinIGUITargetingGate ctrlShow true; - __JavelinIGUITargetingLines ctrlShow true; - - // Move target marker to coords. - //__JavelinIGUITargetingLineV ctrlSetPosition [_aposX,ctrlPosition __JavelinIGUITargetingLineV select 1]; - //__JavelinIGUITargetingLineH ctrlSetPosition [ctrlPosition __JavelinIGUITargetingLineH select 0,_aposY]; - //{_x ctrlCommit __TRACKINTERVAL} forEach [__JavelinIGUITargetingLineH,__JavelinIGUITargetingLineV]; - - _boundsInput = if (_currentTarget isKindOf "CAManBase") then { - [_currentTarget,[-1,-1,-2],_currentTarget selectionPosition "body"]; - } else { - [_currentTarget,[-1,-1,-2],_currentTarget selectionPosition "zamerny"]; - }; - - _bpos = _boundsInput call EFUNC(common,worldToScreenBounds); - - _minX = ((_bpos select 0) + _offsetX) max _constraintLeft; - _minY = ((_bpos select 1) + _offsetY) max _constraintTop; - _maxX = ((_bpos select 2) + _offsetX) min (_constraintRight - 0.025*(3/4)*SafezoneH); - _maxY = ((_bpos select 3) + _offsetY) min (_constraintBottom - 0.025*SafezoneH); - - TRACE_4("", _boundsInput, _bpos, _minX, _minY); - - __JavelinIGUITargetingGateTL ctrlSetPosition [_minX,_minY]; - __JavelinIGUITargetingGateTR ctrlSetPosition [_maxX,_minY]; - __JavelinIGUITargetingGateBL ctrlSetPosition [_minX,_maxY]; - __JavelinIGUITargetingGateBR ctrlSetPosition [_maxX,_maxY]; - - {_x ctrlCommit __TRACKINTERVAL} forEach [__JavelinIGUITargetingGateTL,__JavelinIGUITargetingGateTR,__JavelinIGUITargetingGateBL,__JavelinIGUITargetingGateBR]; - - _currentShooter setVariable["ace_missileguidance_target", _currentTarget, false]; - - // Allow fire - _fireDisabledEH = [_fireDisabledEH] call FUNC(enableFire); - - if(ACE_diagTime > _soundTime) then { - playSound "ACE_Javelin_Locked"; - _soundTime = ACE_diagTime + 0.25; - }; - } else { - __JavelinIGUITargeting ctrlShow true; - __JavelinIGUITargetingGate ctrlShow true; - __JavelinIGUITargetingConstrains ctrlShow true; - __JavelinIGUITargetingLines ctrlShow false; - - _currentShooter setVariable["ace_missileguidance_target", nil, false]; - - _boundsInput = if (_currentTarget isKindOf "CAManBase") then { - [_newTarget,[-1,-1,-2],_currentTarget selectionPosition "body"]; - } else { - [_newTarget,[-1,-1,-1],_currentTarget selectionPosition "zamerny"]; - }; - - _bpos = _boundsInput call EFUNC(common,worldToScreenBounds); - - _minX = ((_bpos select 0) + _offsetX) max _constraintLeft; - _minY = ((_bpos select 1) + _offsetY) max _constraintTop; - _maxX = ((_bpos select 2) + _offsetX) min (_constraintRight - 0.025*(3/4)*SafezoneH); - _maxY = ((_bpos select 3) + _offsetY) min (_constraintBottom - 0.025*SafezoneH); - - TRACE_4("", _boundsInput, _bpos, _minX, _minY); - - __JavelinIGUITargetingGateTL ctrlSetPosition [_minX,_minY]; - __JavelinIGUITargetingGateTR ctrlSetPosition [_maxX,_minY]; - __JavelinIGUITargetingGateBL ctrlSetPosition [_minX,_maxY]; - __JavelinIGUITargetingGateBR ctrlSetPosition [_maxX,_maxY]; - - {_x ctrlCommit __TRACKINTERVAL} forEach [__JavelinIGUITargetingGateTL,__JavelinIGUITargetingGateTR,__JavelinIGUITargetingGateBL,__JavelinIGUITargetingGateBR]; - - if(ACE_diagTime > _soundTime) then { - playSound "ACE_Javelin_Locking"; - _soundTime = ACE_diagTime + 0.25; - }; - // Disallow fire - _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); - }; - }; - } else { - // No targets found - _currentTarget = objNull; - _lockTime = 0; - - __JavelinIGUISeek ctrlSetTextColor __ColorGray; - __JavelinIGUITargeting ctrlShow false; - __JavelinIGUITargetingGate ctrlShow false; - __JavelinIGUITargetingLines ctrlShow false; - __JavelinIGUITargetingConstraints ctrlShow false; - - _currentShooter setVariable ["ace_missileguidance_target",nil, false]; - - // Disallow fire - _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); - }; -}; - -//TRACE_2("", _newTarget, _currentTarget); - -// Save arguments for next run -_args set[0, ACE_diagTime]; -_args set[1, _currentTarget]; -_args set[2, _runTime]; -_args set[3, _lockTime]; -_args set[4, _soundTime]; -_args set[6, _fireDisabledEH]; - -uiNamespace setVariable[QGVAR(arguments), _args ]; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +TRACE_1("enter", _this); + +#define __TRACKINTERVAL 0 // how frequent the check should be. +#define __LOCKONTIME 3 // Lock on won't occur sooner + +private["_apos", "_aposX", "_aposY", "_args", "_boundsInput", "_bpos", "_canFire", "_constraintBottom"]; +private["_constraintLeft", "_constraintRight", "_constraintTop", "_currentTarget", "_fireDisabledEH"]; +private["_firedEH", "_fov", "_lastTick", "_lockTime", "_maxX", "_maxY", "_minX", "_minY", "_newTarget"]; +private["_offsetX", "_offsetY", "_pos", "_randomLockInterval", "_randomPosWithinBounds", "_range"]; +private["_runTime", "_soundTime", "_targetArray", "_zamerny", "_currentShooter"]; + +_currentShooter = (vehicle ACE_player); + +#define __OffsetX ((ctrlPosition __JavelinIGUITargetingLineV) select 0) - 0.5 +#define __OffsetY ((ctrlPosition __JavelinIGUITargetingLineH) select 1) - 0.5 + +// Reset arguments if we havnt rendered in over a second +_args = uiNamespace getVariable[QGVAR(arguments), [] ]; +if( (count _args) > 0) then { + _lastTick = _args select 0; + if(ACE_diagTime - _lastTick > 1) then { + [] call FUNC(onOpticLoad); + }; +}; + +TRACE_1("Running", "Running"); + +// Pull the arguments +_currentTarget = _args select 1; +_runTime = _args select 2; +_lockTime = _args select 3; +_soundTime = _args select 4; +_randomLockInterval = _args select 5; +_fireDisabledEH = _args select 6; + +private["_ammo", "_magazineConfig", "_weaponConfig"]; +_weaponConfig = configProperties [configFile >> "CfgWeapons" >> (currentWeapon _currentShooter), QUOTE(configName _x == QUOTE(QGVAR(enabled))), false]; +_magazineConfig = if ((currentMagazine _currentShooter) != "") then { + _ammo = getText (configFile >> "CfgMagazines" >> (currentMagazine _currentShooter) >> "ammo"); + configProperties [(configFile >> "CfgAmmo" >> _ammo), "(configName _x) == 'ace_missileguidance'", false]; +} else { + [] +}; + +//If weapon does not have "javelin enabled", then exit PFEH +if (((count _weaponConfig) < 1) || {(getNumber (_weaponConfig select 0)) != 1}) exitWith { + __JavelinIGUITargeting ctrlShow false; + __JavelinIGUITargetingGate ctrlShow false; + __JavelinIGUITargetingLines ctrlShow false; + __JavelinIGUITargetingConstraints ctrlShow false; + + if(!isNil "_fireDisabledEH") then { + _fireDisabledEH = [_fireDisabledEH] call FUNC(enableFire); + }; + + [(_this select 1)] call CBA_fnc_removePerFrameHandler; + GVAR(pfehID) = -1; +}; + +// Find a target within the optic range +_newTarget = objNull; + +// Bail on fast movement +if ((velocity ACE_player) distance [0,0,0] > 0.5 && {cameraView == "GUNNER"} && {cameraOn == ACE_player}) exitWith { // keep it steady. + ACE_player switchCamera "INTERNAL"; + if (player != ACE_player) then { + TRACE_2("Zeus, manually reseting RC after switchCamera",player,ACE_player); + player remoteControl ACE_player; + }; +}; + +// Refresh the firemode +[] call FUNC(showFireMode); + +_ammo = _currentShooter ammo (currentWeapon _currentShooter); +// not loaded or not "javelin enabled" for magazine, hide targeting and enable firing +if ((_ammo == 0) || {(count _magazineConfig) < 1} || {(getNumber ((_magazineConfig select 0) >> "enabled")) != 1}) exitWith { + __JavelinIGUITargeting ctrlShow false; + __JavelinIGUITargetingGate ctrlShow false; + __JavelinIGUITargetingLines ctrlShow false; + __JavelinIGUITargetingConstraints ctrlShow false; + + if(!isNil "_fireDisabledEH") then { + _fireDisabledEH = [_fireDisabledEH] call FUNC(enableFire); + }; +}; + +_range = parseNumber (ctrlText __JavelinIGUIRangefinder); +TRACE_1("Viewing range", _range); +if (_range > 50 && {_range < 2500}) then { + _pos = positionCameraToWorld [0,0,_range]; + _targetArray = _pos nearEntities ["AllVehicles", _range/100]; + TRACE_1("Searching at range", _targetArray); + if (count (_targetArray) > 0) then { + _newTarget = _targetArray select 0; + }; +}; + +if ((isNull _newTarget) && {cursorObject isKindOf "AllVehicles"}) then { + private _intersectionsToCursorTarget = lineIntersectsSurfaces [(AGLtoASL positionCameraToWorld [0,0,0]), aimPos cursorObject, ace_player, cursorObject, true, 1]; + if (_intersectionsToCursorTarget isEqualTo []) then { + _newTarget = cursorObject; + }; +}; +if ((isNull _newTarget) && {cursorTarget isKindOf "AllVehicles"}) then { + private _intersectionsToCursorTarget = lineIntersectsSurfaces [(AGLtoASL positionCameraToWorld [0,0,0]), aimPos cursorTarget, ace_player, cursorTarget, true, 1]; + if (_intersectionsToCursorTarget isEqualTo []) then { + _newTarget = cursorTarget; + }; +}; + +// Create constants +_constraintTop = __ConstraintTop; +_constraintLeft = __ConstraintLeft; +_constraintBottom = __ConstraintBottom; +_constraintRight = __ConstraintRight; + +_offsetX = __OffsetX; +_offsetY = __OffsetY; + +__JavelinIGUITargeting ctrlShow true; +__JavelinIGUITargetingConstrains ctrlShow true; + +_zamerny = if (_currentTarget isKindOf "CAManBase") then {_currentTarget selectionPosition "body"} else {_currentTarget selectionPosition "zamerny"}; +_randomPosWithinBounds = [(_zamerny select 0) + 1 - (random 2.0),(_zamerny select 1) + 1 - (random 2.0),(_zamerny select 2) + 0.5 - (random 1.0)]; + +_apos = worldToScreen (_currentTarget modelToWorld _randomPosWithinBounds); + +_aposX = 0; +_aposY = 0; +if (count _apos < 2) then { + _aposX = 1; + _aposY = 0; +} else { + _aposX = (_apos select 0) + _offsetX; + _aposY = (_apos select 1) + _offsetY; +}; + +if((call CBA_fnc_getFoV) select 1 > 9) then { + __JavelinIGUINFOV ctrlSetTextColor __ColorGreen; + __JavelinIGUIWFOV ctrlSetTextColor __ColorGray; +} else { + __JavelinIGUINFOV ctrlSetTextColor __ColorGray; + __JavelinIGUIWFOV ctrlSetTextColor __ColorGreen; +}; + +FUNC(disableFire) = { + _firedEH = _this select 0; + + if(_firedEH < 0 && difficulty > 0) then { + _firedEH = [ACE_player, "DefaultAction", {true}, { + _canFire = (_this select 1) getVariable["ace_missileguidance_target", nil]; + if(!isNil "_canFire") exitWith { false }; + true + }] call EFUNC(common,addActionEventHandler); + }; + _firedEH +}; +FUNC(enableFire) = { + _firedEH = _this select 0; + + if(_firedEH > 0 && difficulty > 0) then { + [ACE_player, "DefaultAction", _firedEH] call EFUNC(common,removeActionEventHandler); + }; + -1 +}; + +if (isNull _newTarget) then { + // No targets found + _currentTarget = objNull; + _lockTime = 0; + + __JavelinIGUISeek ctrlSetTextColor __ColorGray; + __JavelinIGUITargeting ctrlShow false; + __JavelinIGUITargetingGate ctrlShow false; + __JavelinIGUITargetingLines ctrlShow false; + __JavelinIGUITargetingConstraints ctrlShow false; + + _currentShooter setVariable ["ace_missileguidance_target",nil, false]; + + // Disallow fire + _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); +} else { + _fov = [] call CBA_fnc_getFoV; + TRACE_1("FOV", _fov); + if (_newTarget distance ACE_player < 2500 + && {(call CBA_fnc_getFoV) select 1 > 9} + && { (currentVisionMode ACE_player == 2)} + && GVAR(isLockKeyDown) + ) then { + // Lock on after 3 seconds + if(_currentTarget != _newTarget) then { + TRACE_1("New Target, reseting locking", _newTarget); + _lockTime = ACE_diagTime; + _currentTarget = _newTarget; + + playSound "ACE_Javelin_Locking"; + } else { + if(ACE_diagTime - _lockTime > __LOCKONTIME + _randomLockInterval) then { + TRACE_2("LOCKED!", _currentTarget, _lockTime); + + __JavelinIGUISeek ctrlSetTextColor __ColorGreen; + + __JavelinIGUITargeting ctrlShow true; + __JavelinIGUITargetingConstrains ctrlShow false; + __JavelinIGUITargetingGate ctrlShow true; + __JavelinIGUITargetingLines ctrlShow true; + + // Move target marker to coords. + //__JavelinIGUITargetingLineV ctrlSetPosition [_aposX,ctrlPosition __JavelinIGUITargetingLineV select 1]; + //__JavelinIGUITargetingLineH ctrlSetPosition [ctrlPosition __JavelinIGUITargetingLineH select 0,_aposY]; + //{_x ctrlCommit __TRACKINTERVAL} forEach [__JavelinIGUITargetingLineH,__JavelinIGUITargetingLineV]; + + _boundsInput = if (_currentTarget isKindOf "CAManBase") then { + [_currentTarget,[-1,-1,-2],_currentTarget selectionPosition "body"]; + } else { + [_currentTarget,[-1,-1,-2],_currentTarget selectionPosition "zamerny"]; + }; + + _bpos = _boundsInput call EFUNC(common,worldToScreenBounds); + + _minX = ((_bpos select 0) + _offsetX) max _constraintLeft; + _minY = ((_bpos select 1) + _offsetY) max _constraintTop; + _maxX = ((_bpos select 2) + _offsetX) min (_constraintRight - 0.025*(3/4)*SafezoneH); + _maxY = ((_bpos select 3) + _offsetY) min (_constraintBottom - 0.025*SafezoneH); + + TRACE_4("", _boundsInput, _bpos, _minX, _minY); + + __JavelinIGUITargetingGateTL ctrlSetPosition [_minX,_minY]; + __JavelinIGUITargetingGateTR ctrlSetPosition [_maxX,_minY]; + __JavelinIGUITargetingGateBL ctrlSetPosition [_minX,_maxY]; + __JavelinIGUITargetingGateBR ctrlSetPosition [_maxX,_maxY]; + + {_x ctrlCommit __TRACKINTERVAL} forEach [__JavelinIGUITargetingGateTL,__JavelinIGUITargetingGateTR,__JavelinIGUITargetingGateBL,__JavelinIGUITargetingGateBR]; + + _currentShooter setVariable["ace_missileguidance_target", _currentTarget, false]; + + // Allow fire + _fireDisabledEH = [_fireDisabledEH] call FUNC(enableFire); + + if(ACE_diagTime > _soundTime) then { + playSound "ACE_Javelin_Locked"; + _soundTime = ACE_diagTime + 0.25; + }; + } else { + __JavelinIGUITargeting ctrlShow true; + __JavelinIGUITargetingGate ctrlShow true; + __JavelinIGUITargetingConstrains ctrlShow true; + __JavelinIGUITargetingLines ctrlShow false; + + _currentShooter setVariable["ace_missileguidance_target", nil, false]; + + _boundsInput = if (_currentTarget isKindOf "CAManBase") then { + [_newTarget,[-1,-1,-2],_currentTarget selectionPosition "body"]; + } else { + [_newTarget,[-1,-1,-1],_currentTarget selectionPosition "zamerny"]; + }; + + _bpos = _boundsInput call EFUNC(common,worldToScreenBounds); + + _minX = ((_bpos select 0) + _offsetX) max _constraintLeft; + _minY = ((_bpos select 1) + _offsetY) max _constraintTop; + _maxX = ((_bpos select 2) + _offsetX) min (_constraintRight - 0.025*(3/4)*SafezoneH); + _maxY = ((_bpos select 3) + _offsetY) min (_constraintBottom - 0.025*SafezoneH); + + TRACE_4("", _boundsInput, _bpos, _minX, _minY); + + __JavelinIGUITargetingGateTL ctrlSetPosition [_minX,_minY]; + __JavelinIGUITargetingGateTR ctrlSetPosition [_maxX,_minY]; + __JavelinIGUITargetingGateBL ctrlSetPosition [_minX,_maxY]; + __JavelinIGUITargetingGateBR ctrlSetPosition [_maxX,_maxY]; + + {_x ctrlCommit __TRACKINTERVAL} forEach [__JavelinIGUITargetingGateTL,__JavelinIGUITargetingGateTR,__JavelinIGUITargetingGateBL,__JavelinIGUITargetingGateBR]; + + if(ACE_diagTime > _soundTime) then { + playSound "ACE_Javelin_Locking"; + _soundTime = ACE_diagTime + 0.25; + }; + // Disallow fire + _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); + }; + }; + } else { + // No targets found + _currentTarget = objNull; + _lockTime = 0; + + __JavelinIGUISeek ctrlSetTextColor __ColorGray; + __JavelinIGUITargeting ctrlShow false; + __JavelinIGUITargetingGate ctrlShow false; + __JavelinIGUITargetingLines ctrlShow false; + __JavelinIGUITargetingConstraints ctrlShow false; + + _currentShooter setVariable ["ace_missileguidance_target",nil, false]; + + // Disallow fire + _fireDisabledEH = [_fireDisabledEH] call FUNC(disableFire); + }; +}; + +//TRACE_2("", _newTarget, _currentTarget); + +// Save arguments for next run +_args set[0, ACE_diagTime]; +_args set[1, _currentTarget]; +_args set[2, _runTime]; +_args set[3, _lockTime]; +_args set[4, _soundTime]; +_args set[6, _fireDisabledEH]; + +uiNamespace setVariable[QGVAR(arguments), _args ]; diff --git a/addons/javelin/functions/fnc_onOpticLoad.sqf b/addons/javelin/functions/fnc_onOpticLoad.sqf index cb4eac74f9..9ab574df32 100644 --- a/addons/javelin/functions/fnc_onOpticLoad.sqf +++ b/addons/javelin/functions/fnc_onOpticLoad.sqf @@ -1,37 +1,37 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -TRACE_1("enter", _this); - -#define __LOCKONTIMERANDOM 2 // Deviation in lock on time - -if((count _this) > 0) then { - uiNameSpace setVariable ['ACE_RscOptics_javelin',_this select 0]; -}; - -ACE_player setVariable ["ace_missileguidance_target",nil, false]; - -__JavelinIGUISeek ctrlSetTextColor __ColorGray; -__JavelinIGUINFOV ctrlSetTextColor __ColorGray; - -__JavelinIGUITargeting ctrlShow false; -__JavelinIGUITargetingConstrains ctrlShow false; -__JavelinIGUITargetingGate ctrlShow false; -__JavelinIGUITargetingLines ctrlShow false; - -if(GVAR(pfehID) != -1) then { - [] call FUNC(onOpticUnload); // Unload optic if it was already loaded -}; - -uiNameSpace setVariable [QGVAR(arguments), - [ - ACE_diagTime, // Last runtime - objNull, // currentTargetObject - 0, // Run Time - 0, // Lock Time - 0, // Sound timer - (random __LOCKONTIMERANDOM), // random lock time addition - -1 - ] -]; - -GVAR(pfehID) = [FUNC(onOpticDraw), 0, []] call CBA_fnc_addPerFrameHandler; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +TRACE_1("enter", _this); + +#define __LOCKONTIMERANDOM 2 // Deviation in lock on time + +if((count _this) > 0) then { + uiNameSpace setVariable ['ACE_RscOptics_javelin',_this select 0]; +}; + +ACE_player setVariable ["ace_missileguidance_target",nil, false]; + +__JavelinIGUISeek ctrlSetTextColor __ColorGray; +__JavelinIGUINFOV ctrlSetTextColor __ColorGray; + +__JavelinIGUITargeting ctrlShow false; +__JavelinIGUITargetingConstrains ctrlShow false; +__JavelinIGUITargetingGate ctrlShow false; +__JavelinIGUITargetingLines ctrlShow false; + +if(GVAR(pfehID) != -1) then { + [] call FUNC(onOpticUnload); // Unload optic if it was already loaded +}; + +uiNameSpace setVariable [QGVAR(arguments), + [ + ACE_diagTime, // Last runtime + objNull, // currentTargetObject + 0, // Run Time + 0, // Lock Time + 0, // Sound timer + (random __LOCKONTIMERANDOM), // random lock time addition + -1 + ] +]; + +GVAR(pfehID) = [FUNC(onOpticDraw), 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/javelin/functions/fnc_onOpticUnload.sqf b/addons/javelin/functions/fnc_onOpticUnload.sqf index 714a3e7748..ef5394cb6c 100644 --- a/addons/javelin/functions/fnc_onOpticUnload.sqf +++ b/addons/javelin/functions/fnc_onOpticUnload.sqf @@ -1,20 +1,20 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -TRACE_1("enter", _this); -private["_args", "_disableFireEH"]; - -// uiNameSpace setVariable ['ACE_RscOptics_javelin',nil]; - -if(GVAR(pfehID) != -1) then { - [GVAR(pfehID)] call CBA_fnc_removePerFrameHandler; - GVAR(pfehID) = -1; -}; - -_args = uiNamespace getVariable[QGVAR(arguments), nil ]; -if(!isNil "_args") then { - _disableFireEH = _args select 6; - if(_disableFireEH > 0 && difficulty > 0) then { - [ACE_player, "DefaultAction", _disableFireEH] call EFUNC(common,removeActionEventHandler); - }; - uiNameSpace setVariable [QGVAR(arguments),nil]; -}; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +TRACE_1("enter", _this); +private["_args", "_disableFireEH"]; + +// uiNameSpace setVariable ['ACE_RscOptics_javelin',nil]; + +if(GVAR(pfehID) != -1) then { + [GVAR(pfehID)] call CBA_fnc_removePerFrameHandler; + GVAR(pfehID) = -1; +}; + +_args = uiNamespace getVariable[QGVAR(arguments), nil ]; +if(!isNil "_args") then { + _disableFireEH = _args select 6; + if(_disableFireEH > 0 && difficulty > 0) then { + [ACE_player, "DefaultAction", _disableFireEH] call EFUNC(common,removeActionEventHandler); + }; + uiNameSpace setVariable [QGVAR(arguments),nil]; +}; diff --git a/addons/javelin/functions/fnc_showFireMode.sqf b/addons/javelin/functions/fnc_showFireMode.sqf index 88374548c0..5b4f8d7814 100644 --- a/addons/javelin/functions/fnc_showFireMode.sqf +++ b/addons/javelin/functions/fnc_showFireMode.sqf @@ -1,14 +1,14 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -TRACE_1("enter", _this); - -private["_player", "_currentFireMode"]; - -_currentFireMode = ACE_player getVariable["ace_missileguidance_attackProfile", "JAV_TOP"]; -if(_currentFireMode == "JAV_TOP") then { - __JavelinIGUITop ctrlSetTextColor __ColorGreen; - __JavelinIGUIDir ctrlSetTextColor __ColorGray; -} else { - __JavelinIGUITop ctrlSetTextColor __ColorGray; - __JavelinIGUIDir ctrlSetTextColor __ColorGreen; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +TRACE_1("enter", _this); + +private["_player", "_currentFireMode"]; + +_currentFireMode = ACE_player getVariable["ace_missileguidance_attackProfile", "JAV_TOP"]; +if(_currentFireMode == "JAV_TOP") then { + __JavelinIGUITop ctrlSetTextColor __ColorGreen; + __JavelinIGUIDir ctrlSetTextColor __ColorGray; +} else { + __JavelinIGUITop ctrlSetTextColor __ColorGray; + __JavelinIGUIDir ctrlSetTextColor __ColorGreen; }; \ No newline at end of file diff --git a/addons/javelin/initKeybinds.sqf b/addons/javelin/initKeybinds.sqf index 10b5e2813d..cbfafa326d 100644 --- a/addons/javelin/initKeybinds.sqf +++ b/addons/javelin/initKeybinds.sqf @@ -1,30 +1,30 @@ -// by commy2 - -["ACE3 Weapons", QGVAR(lockTarget), localize LSTRING(LockTarget), -{ - if (GETGVAR(isLockKeyDown,false)) exitWith {false}; - - GVAR(isLockKeyDown) = true; - - // Statement - [ACE_player] call FUNC(lockKeyDown); - // Return false so it doesn't block the rest weapon action - false -}, -{ - // prevent holding down - GVAR(isLockKeyDown) = false; - - // Statement - [ACE_player] call FUNC(lockKeyUp); - false -}, -[15, [false, false, false]], false] call CBA_fnc_addKeybind; //Tab Key - -["ACE3 Weapons", QGVAR(cycleFireMode), localize LSTRING(CycleFireMode), -{ false }, -{ - [ACE_player] call FUNC(cycleFireMode); - false -}, +// by commy2 + +["ACE3 Weapons", QGVAR(lockTarget), localize LSTRING(LockTarget), +{ + if (GETGVAR(isLockKeyDown,false)) exitWith {false}; + + GVAR(isLockKeyDown) = true; + + // Statement + [ACE_player] call FUNC(lockKeyDown); + // Return false so it doesn't block the rest weapon action + false +}, +{ + // prevent holding down + GVAR(isLockKeyDown) = false; + + // Statement + [ACE_player] call FUNC(lockKeyUp); + false +}, +[15, [false, false, false]], false] call CBA_fnc_addKeybind; //Tab Key + +["ACE3 Weapons", QGVAR(cycleFireMode), localize LSTRING(CycleFireMode), +{ false }, +{ + [ACE_player] call FUNC(cycleFireMode); + false +}, [15, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key \ No newline at end of file diff --git a/addons/javelin/script_component.hpp b/addons/javelin/script_component.hpp index e252ed1cbb..81b6bcb8c1 100644 --- a/addons/javelin/script_component.hpp +++ b/addons/javelin/script_component.hpp @@ -1,67 +1,67 @@ -#define COMPONENT javelin -#include "\z\ace\addons\main\script_mod.hpp" - -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS -// #define ENABLE_PERFORMANCE_COUNTERS - -#ifdef DEBUG_ENABLED_JAVELIN - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_JAVELIN - #define DEBUG_SETTINGS DEBUG_SETTINGS_JAVELIN -#endif - -#include "\z\ace\addons\main\script_macros.hpp" - -#define ACE_JAV_FIREMODE_DIR 1 -#define ACE_JAV_FIREMODE_TOP 2 - - -// Javelin IGUI defines -#define __JavelinIGUI (uinamespace getVariable "ACE_RscOptics_javelin") - -// Custom controls -#define __JavelinIGUITargeting (__JavelinIGUI displayCtrl 6999) - -#define __JavelinIGUISeek (__JavelinIGUI displayCtrl 699000) -#define __JavelinIGUITop (__JavelinIGUI displayCtrl 699001) -#define __JavelinIGUIDir (__JavelinIGUI displayCtrl 699002) -#define __JavelinIGUINFOV (__JavelinIGUI displayCtrl 1003) -#define __JavelinIGUIWFOV (__JavelinIGUI displayCtrl 1004) -#define __JavelinIGUIRangefinder (__JavelinIGUI displayCtrl 151) - -// Constrains -#define __JavelinIGUITargetingConstrains (__JavelinIGUI displayCtrl 699100) -#define __JavelinIGUITargetingConstrainTop (__JavelinIGUI displayCtrl 699101) -#define __JavelinIGUITargetingConstrainBottom (__JavelinIGUI displayCtrl 699102) -#define __JavelinIGUITargetingConstrainLeft (__JavelinIGUI displayCtrl 699103) -#define __JavelinIGUITargetingConstrainRight (__JavelinIGUI displayCtrl 699104) - -// Targeting gate -#define __JavelinIGUITargetingGate (__JavelinIGUI displayCtrl 699200) -#define __JavelinIGUITargetingGateTL (__JavelinIGUI displayCtrl 699201) -#define __JavelinIGUITargetingGateTR (__JavelinIGUI displayCtrl 699202) -#define __JavelinIGUITargetingGateBL (__JavelinIGUI displayCtrl 699203) -#define __JavelinIGUITargetingGateBR (__JavelinIGUI displayCtrl 699204) - -// Rangefinder -#define __JavelinIGUIRangefinder (__JavelinIGUI displayCtrl 151) - -// Targeting lines -#define __JavelinIGUITargetingLines (__JavelinIGUI displayCtrl 699300) -#define __JavelinIGUITargetingLineH (__JavelinIGUI displayCtrl 699301) -#define __JavelinIGUITargetingLineV (__JavelinIGUI displayCtrl 699302) - -#define __ConstraintTop (((ctrlPosition __JavelinIGUITargetingConstrainTop) select 1) + ((ctrlPosition (__JavelinIGUITargetingConstrainTop)) select 3)) -#define __ConstraintBottom ((ctrlPosition __JavelinIGUITargetingConstrainBottom) select 1) -#define __ConstraintLeft (((ctrlPosition __JavelinIGUITargetingConstrainLeft) select 0) + ((ctrlPosition (__JavelinIGUITargetingConstrainLeft)) select 2)) -#define __ConstraintRight ((ctrlPosition __JavelinIGUITargetingConstrainRight) select 0) - -// Colors for controls -#define __ColorOrange [0.9255,0.5216,0.1216,1] -#define __ColorGreen [0.2941,0.8745,0.2157,1] -#define __ColorGray [0.2941,0.2941,0.2941,1] +#define COMPONENT javelin +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_JAVELIN + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_JAVELIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_JAVELIN +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + +#define ACE_JAV_FIREMODE_DIR 1 +#define ACE_JAV_FIREMODE_TOP 2 + + +// Javelin IGUI defines +#define __JavelinIGUI (uinamespace getVariable "ACE_RscOptics_javelin") + +// Custom controls +#define __JavelinIGUITargeting (__JavelinIGUI displayCtrl 6999) + +#define __JavelinIGUISeek (__JavelinIGUI displayCtrl 699000) +#define __JavelinIGUITop (__JavelinIGUI displayCtrl 699001) +#define __JavelinIGUIDir (__JavelinIGUI displayCtrl 699002) +#define __JavelinIGUINFOV (__JavelinIGUI displayCtrl 1003) +#define __JavelinIGUIWFOV (__JavelinIGUI displayCtrl 1004) +#define __JavelinIGUIRangefinder (__JavelinIGUI displayCtrl 151) + +// Constrains +#define __JavelinIGUITargetingConstrains (__JavelinIGUI displayCtrl 699100) +#define __JavelinIGUITargetingConstrainTop (__JavelinIGUI displayCtrl 699101) +#define __JavelinIGUITargetingConstrainBottom (__JavelinIGUI displayCtrl 699102) +#define __JavelinIGUITargetingConstrainLeft (__JavelinIGUI displayCtrl 699103) +#define __JavelinIGUITargetingConstrainRight (__JavelinIGUI displayCtrl 699104) + +// Targeting gate +#define __JavelinIGUITargetingGate (__JavelinIGUI displayCtrl 699200) +#define __JavelinIGUITargetingGateTL (__JavelinIGUI displayCtrl 699201) +#define __JavelinIGUITargetingGateTR (__JavelinIGUI displayCtrl 699202) +#define __JavelinIGUITargetingGateBL (__JavelinIGUI displayCtrl 699203) +#define __JavelinIGUITargetingGateBR (__JavelinIGUI displayCtrl 699204) + +// Rangefinder +#define __JavelinIGUIRangefinder (__JavelinIGUI displayCtrl 151) + +// Targeting lines +#define __JavelinIGUITargetingLines (__JavelinIGUI displayCtrl 699300) +#define __JavelinIGUITargetingLineH (__JavelinIGUI displayCtrl 699301) +#define __JavelinIGUITargetingLineV (__JavelinIGUI displayCtrl 699302) + +#define __ConstraintTop (((ctrlPosition __JavelinIGUITargetingConstrainTop) select 1) + ((ctrlPosition (__JavelinIGUITargetingConstrainTop)) select 3)) +#define __ConstraintBottom ((ctrlPosition __JavelinIGUITargetingConstrainBottom) select 1) +#define __ConstraintLeft (((ctrlPosition __JavelinIGUITargetingConstrainLeft) select 0) + ((ctrlPosition (__JavelinIGUITargetingConstrainLeft)) select 2)) +#define __ConstraintRight ((ctrlPosition __JavelinIGUITargetingConstrainRight) select 0) + +// Colors for controls +#define __ColorOrange [0.9255,0.5216,0.1216,1] +#define __ColorGreen [0.2941,0.8745,0.2157,1] +#define __ColorGray [0.2941,0.2941,0.2941,1] #define __ColorNull [0,0,0,0] \ No newline at end of file diff --git a/addons/kestrel4500/functions/fnc_onCloseDialog.sqf b/addons/kestrel4500/functions/fnc_onCloseDialog.sqf index 2474f30d94..f8531f0e39 100644 --- a/addons/kestrel4500/functions/fnc_onCloseDialog.sqf +++ b/addons/kestrel4500/functions/fnc_onCloseDialog.sqf @@ -1,19 +1,19 @@ -/* - * Author: Ruthberg - * Called if Kestrel Dialog is closed - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * call ace_kestrel4500_fnc_onCloseDialog - * - * Public: No - */ -#include "script_component.hpp" - -uiNamespace setVariable ['Kestrel4500_Display', nil]; -GVAR(Kestrel4500) = false; +/* + * Author: Ruthberg + * Called if Kestrel Dialog is closed + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_kestrel4500_fnc_onCloseDialog + * + * Public: No + */ +#include "script_component.hpp" + +uiNamespace setVariable ['Kestrel4500_Display', nil]; +GVAR(Kestrel4500) = false; diff --git a/addons/kestrel4500/functions/fnc_onCloseDisplay.sqf b/addons/kestrel4500/functions/fnc_onCloseDisplay.sqf index bdc701ddb1..549c22e275 100644 --- a/addons/kestrel4500/functions/fnc_onCloseDisplay.sqf +++ b/addons/kestrel4500/functions/fnc_onCloseDisplay.sqf @@ -1,19 +1,19 @@ -/* - * Author: Ruthberg - * Called if Kestrel Display is closed - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * call ace_kestrel4500_fnc_onCloseDisplay - * - * Public: No - */ -#include "script_component.hpp" - -uiNamespace setVariable ['RscKestrel4500', nil]; -GVAR(Overlay) = false; +/* + * Author: Ruthberg + * Called if Kestrel Display is closed + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_kestrel4500_fnc_onCloseDisplay + * + * Public: No + */ +#include "script_component.hpp" + +uiNamespace setVariable ['RscKestrel4500', nil]; +GVAR(Overlay) = false; diff --git a/addons/laser/CfgEventhandlers.hpp b/addons/laser/CfgEventhandlers.hpp index 2abad68362..e8fb763b8b 100644 --- a/addons/laser/CfgEventhandlers.hpp +++ b/addons/laser/CfgEventhandlers.hpp @@ -1,26 +1,26 @@ - -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_pre_init)); - }; -}; - -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_post_init)); - }; -}; - -class Extended_Init_EventHandlers { - class LaserTargetBase { - class ADDON { - init = QUOTE(_this call DFUNC(laser_init)); - }; - }; -}; + +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_pre_init)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_post_init)); + }; +}; + +class Extended_Init_EventHandlers { + class LaserTargetBase { + class ADDON { + init = QUOTE(_this call DFUNC(laser_init)); + }; + }; +}; diff --git a/addons/laser/CfgVehicles.hpp b/addons/laser/CfgVehicles.hpp index 780107fdf7..ed752cee42 100644 --- a/addons/laser/CfgVehicles.hpp +++ b/addons/laser/CfgVehicles.hpp @@ -1,45 +1,45 @@ -class CfgVehicles { - class All; - - class LaserTarget: All { - // @TODO: Changing the model and simulation hides it, but THEN IT DOESNT SPAWN WTF!? - model = "\A3\Weapons_F\empty.p3d"; - destrType = "DestructNo"; - simulation = "LaserTarget"; - - class EventHandlers { - init = QUOTE(_this call FUNC(laser_init)); - }; - }; - - // Visual laserTarget override - class ACE_LaserTarget_Visual : LaserTarget { - simulation = "LaserTarget"; - model = "\A3\Weapons_f\laserTgt.p3d"; - }; - - // Vehicle lockable configurations - - class AllVehicles; - class Air: AllVehicles { - class Turrets; - }; - - class Helicopter: Air { - class Turrets { - class MainTurret; - }; - }; - - class Helicopter_Base_F: Helicopter {}; - - class Heli_Attack_01_base_F: Helicopter_Base_F {}; - - class B_Heli_Attack_01_F: Heli_Attack_01_base_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - GVAR(CanLockLaser) = 1; // Enable laser locking selection - }; - }; - }; -}; +class CfgVehicles { + class All; + + class LaserTarget: All { + // @TODO: Changing the model and simulation hides it, but THEN IT DOESNT SPAWN WTF!? + model = "\A3\Weapons_F\empty.p3d"; + destrType = "DestructNo"; + simulation = "LaserTarget"; + + class EventHandlers { + init = QUOTE(_this call FUNC(laser_init)); + }; + }; + + // Visual laserTarget override + class ACE_LaserTarget_Visual : LaserTarget { + simulation = "LaserTarget"; + model = "\A3\Weapons_f\laserTgt.p3d"; + }; + + // Vehicle lockable configurations + + class AllVehicles; + class Air: AllVehicles { + class Turrets; + }; + + class Helicopter: Air { + class Turrets { + class MainTurret; + }; + }; + + class Helicopter_Base_F: Helicopter {}; + + class Heli_Attack_01_base_F: Helicopter_Base_F {}; + + class B_Heli_Attack_01_F: Heli_Attack_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(CanLockLaser) = 1; // Enable laser locking selection + }; + }; + }; +}; diff --git a/addons/laser/CfgWeapons.hpp b/addons/laser/CfgWeapons.hpp index 6dff36a4e8..385f842a59 100644 --- a/addons/laser/CfgWeapons.hpp +++ b/addons/laser/CfgWeapons.hpp @@ -1,7 +1,7 @@ - -class CfgWeapons { - class Binocular; - class Laserdesignator : Binocular { - visionMode[] = {"Normal","NVG"}; - }; -}; + +class CfgWeapons { + class Binocular; + class Laserdesignator : Binocular { + visionMode[] = {"Normal","NVG"}; + }; +}; diff --git a/addons/laser/RscInGameUI.hpp b/addons/laser/RscInGameUI.hpp index 08f0a794be..ca57f56f6f 100644 --- a/addons/laser/RscInGameUI.hpp +++ b/addons/laser/RscInGameUI.hpp @@ -1,143 +1,143 @@ -class RscControlsGroup; -class VScrollbar; -class HScrollbar; -class RscText; -class RscMapControl; - -class RscInGameUI { - class RscOptics_LaserDesignator { - idd = 300; - controls[] = {"CA_IGUI_elements_group"}; - - onLoad = "uiNameSpace setVariable ['ACE_RscOptics_LaserDesignator',(_this select 0)];"; - onUnload = "uiNameSpace setVariable ['ACE_RscOptics_LaserDesignator',nil];"; - - class CA_IGUI_elements_group: RscControlsGroup { - idc = 170; - - x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; - y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; - w = "53.5 * (0.01875 * SafezoneH)"; - h = "40 * (0.025 * SafezoneH)"; - class VScrollbar: VScrollbar { - width = 0; - }; - class HScrollbar: HScrollbar { - height = 0; - }; - class controls { - class CA_OpticsZoom: RscText { - idc = 180; - style = 1; - colorText[] = {0.706,0.0745,0.0196,1}; - sizeEx = "0.038*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "4.5"; - x = "43.85 * (0.01875 * SafezoneH)"; - y = "19.6 * (0.025 * SafezoneH)"; - w = "4.5 * (0.01875 * SafezoneH)"; - h = "1.1 * (0.025 * SafezoneH)"; - }; - class ACE_Distance: RscText { - idc = 123002; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "2456"; - x = "24.6 * (0.01875 * SafezoneH)"; - y = "3 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.5 * (0.025 * SafezoneH)"; - }; - class CA_Distance: RscText { - idc = 151; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "2456"; - x = 0; - y = 0; - w = 0; - h = 0; - }; - class CA_Elev: RscText { - idc = 175; - style = 1; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "80.5"; - x = "32.7 * (0.01875 * SafezoneH)"; - y = "3 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "1.5 * (0.025 * SafezoneH)"; - }; - class CA_VisionMode: RscText { - idc = 179; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "VIS"; - x = "6.5 * (0.01875 * SafezoneH)"; - y = "19.6 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.1 * (0.025 * SafezoneH)"; - }; - class CA_Laser: RscText { - idc = 158; - style = "0x30 + 0x800"; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics\laser_designator_iconLaserOn.paa"; - x = "29.2 * (0.01875 * SafezoneH)"; - y = "3 * (0.025 * SafezoneH)"; - w = "3.5 * (0.01875 * SafezoneH)"; - h = "1.5 * (0.025 * SafezoneH)"; - }; - class CA_Heading: RscText { - idc = 156; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "023"; - x = "16.1 * (0.01875 * SafezoneH)"; - y = "3 * (0.025 * SafezoneH)"; - w = "3.5 * (0.01875 * SafezoneH)"; - h = "1.6 * (0.025 * SafezoneH)"; - }; - - class ACE_LaserCode_Helper : RscMapControl { - idc = -1; - onDraw = QUOTE(_this call FUNC(onLaserDesignatorDraw)); - w = 0; - h = 0; - }; - class ACE_LaserCode : RscText { - idc = 123001; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "Code: 1001"; - x = "32.7 * (0.01875 * SafezoneH)"; - y = "35.5 * (0.025 * SafezoneH)"; - w = "12 * (0.01875 * SafezoneH)"; - h = "1.6 * (0.025 * SafezoneH)"; - }; - }; - }; - }; -}; +class RscControlsGroup; +class VScrollbar; +class HScrollbar; +class RscText; +class RscMapControl; + +class RscInGameUI { + class RscOptics_LaserDesignator { + idd = 300; + controls[] = {"CA_IGUI_elements_group"}; + + onLoad = "uiNameSpace setVariable ['ACE_RscOptics_LaserDesignator',(_this select 0)];"; + onUnload = "uiNameSpace setVariable ['ACE_RscOptics_LaserDesignator',nil];"; + + class CA_IGUI_elements_group: RscControlsGroup { + idc = 170; + + x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; + y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; + w = "53.5 * (0.01875 * SafezoneH)"; + h = "40 * (0.025 * SafezoneH)"; + class VScrollbar: VScrollbar { + width = 0; + }; + class HScrollbar: HScrollbar { + height = 0; + }; + class controls { + class CA_OpticsZoom: RscText { + idc = 180; + style = 1; + colorText[] = {0.706,0.0745,0.0196,1}; + sizeEx = "0.038*SafezoneH"; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "4.5"; + x = "43.85 * (0.01875 * SafezoneH)"; + y = "19.6 * (0.025 * SafezoneH)"; + w = "4.5 * (0.01875 * SafezoneH)"; + h = "1.1 * (0.025 * SafezoneH)"; + }; + class ACE_Distance: RscText { + idc = 123002; + style = 0; + sizeEx = "0.038*SafezoneH"; + colorText[] = {0.706,0.0745,0.0196,1}; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "2456"; + x = "24.6 * (0.01875 * SafezoneH)"; + y = "3 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.5 * (0.025 * SafezoneH)"; + }; + class CA_Distance: RscText { + idc = 151; + style = 0; + sizeEx = "0.038*SafezoneH"; + colorText[] = {0.706,0.0745,0.0196,1}; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "2456"; + x = 0; + y = 0; + w = 0; + h = 0; + }; + class CA_Elev: RscText { + idc = 175; + style = 1; + sizeEx = "0.038*SafezoneH"; + colorText[] = {0.706,0.0745,0.0196,1}; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "80.5"; + x = "32.7 * (0.01875 * SafezoneH)"; + y = "3 * (0.025 * SafezoneH)"; + w = "5 * (0.01875 * SafezoneH)"; + h = "1.5 * (0.025 * SafezoneH)"; + }; + class CA_VisionMode: RscText { + idc = 179; + style = 0; + sizeEx = "0.038*SafezoneH"; + colorText[] = {0.706,0.0745,0.0196,1}; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "VIS"; + x = "6.5 * (0.01875 * SafezoneH)"; + y = "19.6 * (0.025 * SafezoneH)"; + w = "4 * (0.01875 * SafezoneH)"; + h = "1.1 * (0.025 * SafezoneH)"; + }; + class CA_Laser: RscText { + idc = 158; + style = "0x30 + 0x800"; + sizeEx = "0.038*SafezoneH"; + colorText[] = {0.706,0.0745,0.0196,1}; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "\A3\ui_f\data\igui\rscingameui\rscoptics\laser_designator_iconLaserOn.paa"; + x = "29.2 * (0.01875 * SafezoneH)"; + y = "3 * (0.025 * SafezoneH)"; + w = "3.5 * (0.01875 * SafezoneH)"; + h = "1.5 * (0.025 * SafezoneH)"; + }; + class CA_Heading: RscText { + idc = 156; + style = 0; + sizeEx = "0.038*SafezoneH"; + colorText[] = {0.706,0.0745,0.0196,1}; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "023"; + x = "16.1 * (0.01875 * SafezoneH)"; + y = "3 * (0.025 * SafezoneH)"; + w = "3.5 * (0.01875 * SafezoneH)"; + h = "1.6 * (0.025 * SafezoneH)"; + }; + + class ACE_LaserCode_Helper : RscMapControl { + idc = -1; + onDraw = QUOTE(_this call FUNC(onLaserDesignatorDraw)); + w = 0; + h = 0; + }; + class ACE_LaserCode : RscText { + idc = 123001; + style = 0; + sizeEx = "0.038*SafezoneH"; + colorText[] = {0.706,0.0745,0.0196,1}; + shadow = 0; + font = "EtelkaMonospacePro"; + text = "Code: 1001"; + x = "32.7 * (0.01875 * SafezoneH)"; + y = "35.5 * (0.025 * SafezoneH)"; + w = "12 * (0.01875 * SafezoneH)"; + h = "1.6 * (0.025 * SafezoneH)"; + }; + }; + }; + }; +}; diff --git a/addons/laser/XEH_post_init.sqf b/addons/laser/XEH_post_init.sqf index a9f0e82be3..c3c1f3f3cb 100644 --- a/addons/laser/XEH_post_init.sqf +++ b/addons/laser/XEH_post_init.sqf @@ -1,7 +1,7 @@ -#include "script_component.hpp" - -#include "initKeybinds.sqf" - -["laser_laserOn", {_this call DFUNC(handleLaserOn)}] call EFUNC(common,addEventHandler); -["laser_laserOff", {_this call DFUNC(handleLaserOff)}] call EFUNC(common,addEventHandler); - +#include "script_component.hpp" + +#include "initKeybinds.sqf" + +["laser_laserOn", {_this call DFUNC(handleLaserOn)}] call EFUNC(common,addEventHandler); +["laser_laserOff", {_this call DFUNC(handleLaserOff)}] call EFUNC(common,addEventHandler); + diff --git a/addons/laser/XEH_pre_init.sqf b/addons/laser/XEH_pre_init.sqf index 502f47a9dc..b13ea4b665 100644 --- a/addons/laser/XEH_pre_init.sqf +++ b/addons/laser/XEH_pre_init.sqf @@ -1,16 +1,16 @@ -#include "script_component.hpp" - -ADDON = false; - -#include "XEH_PREP.hpp" - -GVAR(VanillaLasers) = []; - -// Laser default variables -ACE_DEFAULT_LASER_CODE = 1001; -ACE_DEFAULT_LASER_WAVELENGTH = 1550; -ACE_DEFAULT_LASER_BEAMSPREAD = 1; - -GVAR(laserEmitters) = HASH_CREATE; - -ADDON = true; +#include "script_component.hpp" + +ADDON = false; + +#include "XEH_PREP.hpp" + +GVAR(VanillaLasers) = []; + +// Laser default variables +ACE_DEFAULT_LASER_CODE = 1001; +ACE_DEFAULT_LASER_WAVELENGTH = 1550; +ACE_DEFAULT_LASER_BEAMSPREAD = 1; + +GVAR(laserEmitters) = HASH_CREATE; + +ADDON = true; diff --git a/addons/laser/config.cpp b/addons/laser/config.cpp index ad368cdc2d..79e3115023 100644 --- a/addons/laser/config.cpp +++ b/addons/laser/config.cpp @@ -1,16 +1,16 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = { "ace_common" }; - VERSION_CONFIG; - }; -}; - -#include "CfgEventhandlers.hpp" -#include "CfgVehicles.hpp" -#include "CfgWeapons.hpp" +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { "ace_common" }; + VERSION_CONFIG; + }; +}; + +#include "CfgEventhandlers.hpp" +#include "CfgVehicles.hpp" +#include "CfgWeapons.hpp" #include "RscInGameUI.hpp" \ No newline at end of file diff --git a/addons/laser/functions/fnc_checkLos.sqf b/addons/laser/functions/fnc_checkLos.sqf index 9888642a80..0cbeffaea2 100644 --- a/addons/laser/functions/fnc_checkLos.sqf +++ b/addons/laser/functions/fnc_checkLos.sqf @@ -1,31 +1,31 @@ -#include "script_component.hpp" - -private ["_pos1", "_pos2", "_spacing", "_vectorTo", "_x", "_y", "_z", "_distance", "_count", "_return", "_alt", "_pos", "_designator", "_seeker"]; -_pos1 = _this select 0; -_pos2 = _this select 1; -_designator = _this select 2; -_seeker = _this select 3; -_spacing = 100; -if((count _this) > 4) then { - _spacing = _this select 4; -}; - -_return = true; -_vectorTo = [_pos2, _pos1] call BIS_fnc_vectorFromXToY; - -_x = (_vectorTo select 0)*0.25; -_y = (_vectorTo select 1)*0.25; -_z = (_vectorTo select 2)*0.25; - -_pos2 = [(_pos2 select 0) + _x, (_pos2 select 1) + _y, (_pos2 select 2) + _z]; - -// player sideChat format["new los check"]; -if(terrainIntersect [_pos2, _pos1]) then { - _return = false; -} else { - if(lineIntersects [_pos2, _pos1]) then { // should take as arguments and add to this command objects to exclude - target and observer - // player sideChat format["with: %1", lineIntersectsWith [_pos1, _pos2]]; - _return = false; - }; -}; +#include "script_component.hpp" + +private ["_pos1", "_pos2", "_spacing", "_vectorTo", "_x", "_y", "_z", "_distance", "_count", "_return", "_alt", "_pos", "_designator", "_seeker"]; +_pos1 = _this select 0; +_pos2 = _this select 1; +_designator = _this select 2; +_seeker = _this select 3; +_spacing = 100; +if((count _this) > 4) then { + _spacing = _this select 4; +}; + +_return = true; +_vectorTo = [_pos2, _pos1] call BIS_fnc_vectorFromXToY; + +_x = (_vectorTo select 0)*0.25; +_y = (_vectorTo select 1)*0.25; +_z = (_vectorTo select 2)*0.25; + +_pos2 = [(_pos2 select 0) + _x, (_pos2 select 1) + _y, (_pos2 select 2) + _z]; + +// player sideChat format["new los check"]; +if(terrainIntersect [_pos2, _pos1]) then { + _return = false; +} else { + if(lineIntersects [_pos2, _pos1]) then { // should take as arguments and add to this command objects to exclude - target and observer + // player sideChat format["with: %1", lineIntersectsWith [_pos1, _pos2]]; + _return = false; + }; +}; _return; \ No newline at end of file diff --git a/addons/laser/functions/fnc_drawVisibleLaserTargets.sqf b/addons/laser/functions/fnc_drawVisibleLaserTargets.sqf index 8cdb497267..2f73236454 100644 --- a/addons/laser/functions/fnc_drawVisibleLaserTargets.sqf +++ b/addons/laser/functions/fnc_drawVisibleLaserTargets.sqf @@ -1,9 +1,9 @@ -// This is a debug function for displaying visible lasers for ourselves -#include "script_component.hpp" - -ACE_LOGINFO("Laser Emitter Dump"); - -{ - ACE_LOGINFO_1(" %1", _x); - ACE_LOGINFO_1(" %1",HASH_GET(GVAR(laserEmitters),_x)); -} forEach GVAR(laserEmitters) select 0; +// This is a debug function for displaying visible lasers for ourselves +#include "script_component.hpp" + +ACE_LOGINFO("Laser Emitter Dump"); + +{ + ACE_LOGINFO_1(" %1", _x); + ACE_LOGINFO_1(" %1",HASH_GET(GVAR(laserEmitters),_x)); +} forEach GVAR(laserEmitters) select 0; diff --git a/addons/laser/functions/fnc_findStrongestRay.sqf b/addons/laser/functions/fnc_findStrongestRay.sqf index 811b75d351..cd29768fd3 100644 --- a/addons/laser/functions/fnc_findStrongestRay.sqf +++ b/addons/laser/functions/fnc_findStrongestRay.sqf @@ -1,49 +1,49 @@ -#include "script_component.hpp" -private["_checkPos", "_i", "_largest", "_largestSpot", "_list", "_outliers", "_remainingSpots", "_samplePos", "_spot", "_spots", "_testPos"]; -_list = _this select 0; -_checkPos = _this select 1; -_spots = []; -_outliers = []; -_spot = []; -_testPos = (_list select 0) select 0; -{ - _samplePos = _x select 0; - if(!lineIntersects [_samplePos, _checkPos] && {!terrainIntersectASL [_samplePos, _checkPos]}) then { - if(_samplePos distance _testPos < 2) then { - _spot pushBack _samplePos; - } else { - _outliers pushBack _samplePos; - }; - }; -} forEach _list; -_spots pushBack _spot; - -if(count _outliers > 0) then { - for "_i" from 1 to 3 do { - _remainingSpots = _outliers; - _outliers = []; - _spot = []; - _testPos = (_remainingSpots select 0); - { - _samplePos = _x; - if(!lineIntersects [_samplePos, _checkPos] && {!terrainIntersectASL [_samplePos, _checkPos]}) then { - if(_samplePos distance _testPos < 2) then { - _spot pushBack _samplePos; - } else { - _outliers pushBack _samplePos; - }; - }; - } forEach _remainingSpots; - _spots pushBack _spot; - }; -}; -_largest = 0; -_largestSpot = []; -{ - if((count _x) > _largest) then { - _largest = (count _x); - _largestSpot = _x; - }; -} forEach _spots; -// player sideChat format["g: %1", _spots]; +#include "script_component.hpp" +private["_checkPos", "_i", "_largest", "_largestSpot", "_list", "_outliers", "_remainingSpots", "_samplePos", "_spot", "_spots", "_testPos"]; +_list = _this select 0; +_checkPos = _this select 1; +_spots = []; +_outliers = []; +_spot = []; +_testPos = (_list select 0) select 0; +{ + _samplePos = _x select 0; + if(!lineIntersects [_samplePos, _checkPos] && {!terrainIntersectASL [_samplePos, _checkPos]}) then { + if(_samplePos distance _testPos < 2) then { + _spot pushBack _samplePos; + } else { + _outliers pushBack _samplePos; + }; + }; +} forEach _list; +_spots pushBack _spot; + +if(count _outliers > 0) then { + for "_i" from 1 to 3 do { + _remainingSpots = _outliers; + _outliers = []; + _spot = []; + _testPos = (_remainingSpots select 0); + { + _samplePos = _x; + if(!lineIntersects [_samplePos, _checkPos] && {!terrainIntersectASL [_samplePos, _checkPos]}) then { + if(_samplePos distance _testPos < 2) then { + _spot pushBack _samplePos; + } else { + _outliers pushBack _samplePos; + }; + }; + } forEach _remainingSpots; + _spots pushBack _spot; + }; +}; +_largest = 0; +_largestSpot = []; +{ + if((count _x) > _largest) then { + _largest = (count _x); + _largestSpot = _x; + }; +} forEach _spots; +// player sideChat format["g: %1", _spots]; _largestSpot select (random (floor(count _largestSpot))); \ No newline at end of file diff --git a/addons/laser/functions/fnc_handleLaserOff.sqf b/addons/laser/functions/fnc_handleLaserOff.sqf index 573bd8197b..73235592a1 100644 --- a/addons/laser/functions/fnc_handleLaserOff.sqf +++ b/addons/laser/functions/fnc_handleLaserOff.sqf @@ -2,7 +2,7 @@ #include "script_component.hpp" private ["_uuid"]; -_uuid = _this select 0; -if(HASH_HASKEY(GVAR(laserEmitters), _uuid)) then { - HASH_REM(GVAR(laserEmitters), _uuid); -}; +_uuid = _this select 0; +if(HASH_HASKEY(GVAR(laserEmitters), _uuid)) then { + HASH_REM(GVAR(laserEmitters), _uuid); +}; diff --git a/addons/laser/functions/fnc_handleLaserOn.sqf b/addons/laser/functions/fnc_handleLaserOn.sqf index bac53a8957..0fe2b0fa44 100644 --- a/addons/laser/functions/fnc_handleLaserOn.sqf +++ b/addons/laser/functions/fnc_handleLaserOn.sqf @@ -2,6 +2,6 @@ #include "script_component.hpp" private ["_uuid", "_args"]; -_uuid = _this select 0; -_args = _this select 1; -HASH_SET(GVAR(laserEmitters), _uuid, _args); +_uuid = _this select 0; +_args = _this select 1; +HASH_SET(GVAR(laserEmitters), _uuid, _args); diff --git a/addons/laser/functions/fnc_keyLaserCodeDown.sqf b/addons/laser/functions/fnc_keyLaserCodeDown.sqf index f833c477c6..d428a3b81c 100644 --- a/addons/laser/functions/fnc_keyLaserCodeDown.sqf +++ b/addons/laser/functions/fnc_keyLaserCodeDown.sqf @@ -1,12 +1,12 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -private["_oldLaserCode", "_laserCode"]; - -_oldLaserCode = ACE_player getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; -if(_oldLaserCode > ACE_DEFAULT_LASER_CODE) then { - _laserCode = _oldLaserCode - 1; - ACE_player setVariable [QGVAR(code), _laserCode, false]; -}; -if(_laserCode != _oldLaserCode) then { - [format ["%1: %2", localize LSTRING(laserCode), _laserCode]] call EFUNC(common,displayTextStructured); +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +private["_oldLaserCode", "_laserCode"]; + +_oldLaserCode = ACE_player getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; +if(_oldLaserCode > ACE_DEFAULT_LASER_CODE) then { + _laserCode = _oldLaserCode - 1; + ACE_player setVariable [QGVAR(code), _laserCode, false]; +}; +if(_laserCode != _oldLaserCode) then { + [format ["%1: %2", localize LSTRING(laserCode), _laserCode]] call EFUNC(common,displayTextStructured); }; \ No newline at end of file diff --git a/addons/laser/functions/fnc_keyLaserCodeUp.sqf b/addons/laser/functions/fnc_keyLaserCodeUp.sqf index 5357cec14c..926bce5c26 100644 --- a/addons/laser/functions/fnc_keyLaserCodeUp.sqf +++ b/addons/laser/functions/fnc_keyLaserCodeUp.sqf @@ -1,10 +1,10 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -private["_oldLaserCode", "_laserCode"]; - -_oldLaserCode = ACE_player getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; -_laserCode = _oldLaserCode + 1; -ACE_player setVariable [QGVAR(code), _laserCode, false]; -if(_laserCode != _oldLaserCode) then { -[format ["%1: %2", localize LSTRING(laserCode), _laserCode]] call EFUNC(common,displayTextStructured); +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +private["_oldLaserCode", "_laserCode"]; + +_oldLaserCode = ACE_player getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; +_laserCode = _oldLaserCode + 1; +ACE_player setVariable [QGVAR(code), _laserCode, false]; +if(_laserCode != _oldLaserCode) then { +[format ["%1: %2", localize LSTRING(laserCode), _laserCode]] call EFUNC(common,displayTextStructured); }; \ No newline at end of file diff --git a/addons/laser/functions/fnc_laserOff.sqf b/addons/laser/functions/fnc_laserOff.sqf index 7899ec1253..32f78bafd5 100644 --- a/addons/laser/functions/fnc_laserOff.sqf +++ b/addons/laser/functions/fnc_laserOff.sqf @@ -12,5 +12,5 @@ #include "script_component.hpp" private ["_uuid"]; -_uuid = _this select 0; -["laser_laserOff", [_uuid]] call EFUNC(common,globalEvent); +_uuid = _this select 0; +["laser_laserOff", [_uuid]] call EFUNC(common,globalEvent); diff --git a/addons/laser/functions/fnc_laserOn.sqf b/addons/laser/functions/fnc_laserOn.sqf index 901fa04b9a..b49b123c95 100644 --- a/addons/laser/functions/fnc_laserOn.sqf +++ b/addons/laser/functions/fnc_laserOn.sqf @@ -17,7 +17,7 @@ #include "script_component.hpp" private ["_uuid", "_args"]; -_uuid = format["%1%2%3", floor ACE_diagTime, floor random 1000, floor random 10000]; -_args = [_uuid, _this]; -["laser_laserOn", _args] call EFUNC(common,globalEvent); -_uuid; +_uuid = format["%1%2%3", floor ACE_diagTime, floor random 1000, floor random 10000]; +_args = [_uuid, _this]; +["laser_laserOn", _args] call EFUNC(common,globalEvent); +_uuid; diff --git a/addons/laser/functions/fnc_laserTargetPFH.sqf b/addons/laser/functions/fnc_laserTargetPFH.sqf index 8726ce4201..ba3df3376a 100644 --- a/addons/laser/functions/fnc_laserTargetPFH.sqf +++ b/addons/laser/functions/fnc_laserTargetPFH.sqf @@ -1,30 +1,30 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -TRACE_1("enter", _this); - -private["_args", "_laserTarget", "_pos", "_shooter", "_uuid"]; -//TRACE_1("enter", _this); -_args = _this select 0; -_laserTarget = _args select 0; -_shooter = _args select 1; -_uuid = _args select 2; - -if(isNull _laserTarget || !alive _shooter) exitWith { - [(_this select 1)] call CBA_fnc_removePerFrameHandler; - REM(GVAR(VanillaLasers), _laserTarget); - - // Remove laseron - [_uuid] call FUNC(laserOff); -}; - -#ifdef DEBUG_MODE_FULL -// Iconize the location of the actual laserTarget -_pos = getPosASL _laserTarget; -drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,0,1], (ASLtoATL _pos), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; - -{ - drawLine3D [ASLtoATL (_x select 0), ASLtoATL (_x select 1), (_x select 2)]; - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", (_x select 2), ASLtoATL (_x select 1), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; -} forEach DRAW_LINES; -DRAW_LINES = []; -#endif +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +TRACE_1("enter", _this); + +private["_args", "_laserTarget", "_pos", "_shooter", "_uuid"]; +//TRACE_1("enter", _this); +_args = _this select 0; +_laserTarget = _args select 0; +_shooter = _args select 1; +_uuid = _args select 2; + +if(isNull _laserTarget || !alive _shooter) exitWith { + [(_this select 1)] call CBA_fnc_removePerFrameHandler; + REM(GVAR(VanillaLasers), _laserTarget); + + // Remove laseron + [_uuid] call FUNC(laserOff); +}; + +#ifdef DEBUG_MODE_FULL +// Iconize the location of the actual laserTarget +_pos = getPosASL _laserTarget; +drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,0,1], (ASLtoATL _pos), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; + +{ + drawLine3D [ASLtoATL (_x select 0), ASLtoATL (_x select 1), (_x select 2)]; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", (_x select 2), ASLtoATL (_x select 1), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"]; +} forEach DRAW_LINES; +DRAW_LINES = []; +#endif diff --git a/addons/laser/functions/fnc_laser_init.sqf b/addons/laser/functions/fnc_laser_init.sqf index 304cd5938a..2e61eb3587 100644 --- a/addons/laser/functions/fnc_laser_init.sqf +++ b/addons/laser/functions/fnc_laser_init.sqf @@ -1,33 +1,33 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -TRACE_1("enter", _this); - -PARAMS_1(_laserTarget); -private["_uuid"]; - -// Add the target to the global targets array -// Everyone tracks them -// Add the laser localized to the laser array, and give it the default localized code -PUSH(GVAR(VanillaLasers), _laserTarget); - -// Check the vehicle, otherwise use the default -_laserTarget setVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE, false]; -_laserTarget setVariable [QGVAR(beamSpread), ACE_DEFAULT_LASER_BEAMSPREAD, false]; -_laserTarget setVariable [QGVAR(waveLength), ACE_DEFAULT_LASER_WAVELENGTH, false]; - -// Clean the lasers of any null objects while we are here -REM(GVAR(VanillaLasers), objNull); - -if(!(local _laserTarget)) exitWith { }; - -// The target is local, so its on this client -if(!isDedicated) then { - // @TODO: Get ownership variables and set them on the vehicle - - _uuid = [(vehicle ACE_player), ACE_player, QFUNC(vanillaLaserSeekerHandler), ACE_DEFAULT_LASER_WAVELENGTH, ACE_DEFAULT_LASER_CODE, ACE_DEFAULT_LASER_BEAMSPREAD] call FUNC(laserOn); - _laserTarget setVariable [QGVAR(uuid), _uuid, false]; - [FUNC(laserTargetPFH), 0, [_laserTarget, ACE_player, _uuid]] call CBA_fnc_addPerFrameHandler; -} else { - // server side ownership of laser - _laserTarget setVariable [QGVAR(owner), nil, true]; -}; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +TRACE_1("enter", _this); + +PARAMS_1(_laserTarget); +private["_uuid"]; + +// Add the target to the global targets array +// Everyone tracks them +// Add the laser localized to the laser array, and give it the default localized code +PUSH(GVAR(VanillaLasers), _laserTarget); + +// Check the vehicle, otherwise use the default +_laserTarget setVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE, false]; +_laserTarget setVariable [QGVAR(beamSpread), ACE_DEFAULT_LASER_BEAMSPREAD, false]; +_laserTarget setVariable [QGVAR(waveLength), ACE_DEFAULT_LASER_WAVELENGTH, false]; + +// Clean the lasers of any null objects while we are here +REM(GVAR(VanillaLasers), objNull); + +if(!(local _laserTarget)) exitWith { }; + +// The target is local, so its on this client +if(!isDedicated) then { + // @TODO: Get ownership variables and set them on the vehicle + + _uuid = [(vehicle ACE_player), ACE_player, QFUNC(vanillaLaserSeekerHandler), ACE_DEFAULT_LASER_WAVELENGTH, ACE_DEFAULT_LASER_CODE, ACE_DEFAULT_LASER_BEAMSPREAD] call FUNC(laserOn); + _laserTarget setVariable [QGVAR(uuid), _uuid, false]; + [FUNC(laserTargetPFH), 0, [_laserTarget, ACE_player, _uuid]] call CBA_fnc_addPerFrameHandler; +} else { + // server side ownership of laser + _laserTarget setVariable [QGVAR(owner), nil, true]; +}; diff --git a/addons/laser/functions/fnc_onLaserDesignatorDraw.sqf b/addons/laser/functions/fnc_onLaserDesignatorDraw.sqf index 7f8537ab9b..8c60cd3c33 100644 --- a/addons/laser/functions/fnc_onLaserDesignatorDraw.sqf +++ b/addons/laser/functions/fnc_onLaserDesignatorDraw.sqf @@ -1,15 +1,15 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -private["_laserCode"]; - -_laserCode = ACE_player getVariable[QGVAR(code), ACE_DEFAULT_LASER_CODE]; -if(!isNil "_laserCode") then { - __LaserDesignatorIGUI_LaserCode ctrlSetText format["Code: %1", [_laserCode, 4, 0, false] call CBA_fnc_formatNumber]; -}; - -if(! (ctrlShown __LaserDesignatorIGUI_LaserOn) ) then { - // TODO: hide distance - __LaserDesignatorIGUI_ACE_Distance ctrlSetText "----"; -} else { - __LaserDesignatorIGUI_ACE_Distance ctrlSetText (ctrlText __LaserDesignatorIGUI_CA_Distance); +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +private["_laserCode"]; + +_laserCode = ACE_player getVariable[QGVAR(code), ACE_DEFAULT_LASER_CODE]; +if(!isNil "_laserCode") then { + __LaserDesignatorIGUI_LaserCode ctrlSetText format["Code: %1", [_laserCode, 4, 0, false] call CBA_fnc_formatNumber]; +}; + +if(! (ctrlShown __LaserDesignatorIGUI_LaserOn) ) then { + // TODO: hide distance + __LaserDesignatorIGUI_ACE_Distance ctrlSetText "----"; +} else { + __LaserDesignatorIGUI_ACE_Distance ctrlSetText (ctrlText __LaserDesignatorIGUI_CA_Distance); }; \ No newline at end of file diff --git a/addons/laser/functions/fnc_rotateVectLine.sqf b/addons/laser/functions/fnc_rotateVectLine.sqf index 8bae491c4e..f748975dab 100644 --- a/addons/laser/functions/fnc_rotateVectLine.sqf +++ b/addons/laser/functions/fnc_rotateVectLine.sqf @@ -1,36 +1,36 @@ -#include "script_component.hpp" -private["_d", "_map", "_p", "_theta", "_u"]; -_map = _this select 0; -_theta = _this select 1; - -_p = _map select 0; -_p1 = _map select 1; -_p2 = _map select 2; - -_q1 = +(_map select 3); -_q2 = +(_map select 4); -_u = _map select 5; -_d = _map select 6; - -/* Step 4 */ -_q2 set[0, (_q1 select 0) * cos(_theta) - (_q1 select 1) * sin(_theta)]; -_q2 set[1, (_q1 select 0) * sin(_theta) + (_q1 select 1) * cos(_theta)]; -_q2 set[2, (_q1 select 2)]; - -/* Inverse of step 3 */ -_q1 set[0, (_q2 select 0) * _d + (_q2 select 2) * (_u select 0)]; -_q1 set[1, (_q2 select 1)]; -_q1 set[2, - (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; - -/* Inverse of step 2 */ -if (_d != 0) then { - _q2 set[0, (_q1 select 0)]; - _q2 set[1, (_q1 select 1) * (_u select 2) / _d + (_q1 select 2) * (_u select 1) / _d]; - _q2 set[2, - (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; -} else { - _q2 = _q1; -}; - -/* Inverse of step 1 */ -_q1 = _q2 vectorAdd _p1; +#include "script_component.hpp" +private["_d", "_map", "_p", "_theta", "_u"]; +_map = _this select 0; +_theta = _this select 1; + +_p = _map select 0; +_p1 = _map select 1; +_p2 = _map select 2; + +_q1 = +(_map select 3); +_q2 = +(_map select 4); +_u = _map select 5; +_d = _map select 6; + +/* Step 4 */ +_q2 set[0, (_q1 select 0) * cos(_theta) - (_q1 select 1) * sin(_theta)]; +_q2 set[1, (_q1 select 0) * sin(_theta) + (_q1 select 1) * cos(_theta)]; +_q2 set[2, (_q1 select 2)]; + +/* Inverse of step 3 */ +_q1 set[0, (_q2 select 0) * _d + (_q2 select 2) * (_u select 0)]; +_q1 set[1, (_q2 select 1)]; +_q1 set[2, - (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; + +/* Inverse of step 2 */ +if (_d != 0) then { + _q2 set[0, (_q1 select 0)]; + _q2 set[1, (_q1 select 1) * (_u select 2) / _d + (_q1 select 2) * (_u select 1) / _d]; + _q2 set[2, - (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; +} else { + _q2 = _q1; +}; + +/* Inverse of step 1 */ +_q1 = _q2 vectorAdd _p1; _q1; \ No newline at end of file diff --git a/addons/laser/functions/fnc_rotateVectLineGetMap.sqf b/addons/laser/functions/fnc_rotateVectLineGetMap.sqf index dc4b1b54c3..53ee35a288 100644 --- a/addons/laser/functions/fnc_rotateVectLineGetMap.sqf +++ b/addons/laser/functions/fnc_rotateVectLineGetMap.sqf @@ -1,30 +1,30 @@ -#include "script_component.hpp" - -private ["_p", "_theta", "_p1", "_p2", "_q1", "_q2", "_u", "_d"]; -_p = _this select 0; -_p1 = _this select 1; -_p2 = _this select 2; - -_q2 = []; - -/* Step 1 */ -_q1 = _p vectorDiff _p1; -_u = _p2 vectorDiff _p1; -_u = vectorNormalized _u; -_d = sqrt((_u select 1)*(_u select 1) + (_u select 2)*(_u select 2)); - -/* Step 2 */ -if (_d != 0) then { - _q2 set[0, (_q1 select 0)]; - _q2 set[1, (_q1 select 1) * (_u select 2) / _d - (_q1 select 2) * (_u select 1) / _d]; - _q2 set[2, (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; -} else { - _q2 = _q1; -}; - -/* Step 3 */ -_q1 set[0, (_q2 select 0) * _d - (_q2 select 2) * (_u select 0)]; -_q1 set[1, (_q2 select 1)]; -_q1 set[2, (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; - +#include "script_component.hpp" + +private ["_p", "_theta", "_p1", "_p2", "_q1", "_q2", "_u", "_d"]; +_p = _this select 0; +_p1 = _this select 1; +_p2 = _this select 2; + +_q2 = []; + +/* Step 1 */ +_q1 = _p vectorDiff _p1; +_u = _p2 vectorDiff _p1; +_u = vectorNormalized _u; +_d = sqrt((_u select 1)*(_u select 1) + (_u select 2)*(_u select 2)); + +/* Step 2 */ +if (_d != 0) then { + _q2 set[0, (_q1 select 0)]; + _q2 set[1, (_q1 select 1) * (_u select 2) / _d - (_q1 select 2) * (_u select 1) / _d]; + _q2 set[2, (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; +} else { + _q2 = _q1; +}; + +/* Step 3 */ +_q1 set[0, (_q2 select 0) * _d - (_q2 select 2) * (_u select 0)]; +_q1 set[1, (_q2 select 1)]; +_q1 set[2, (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; + [_p, _p1, _p2, _q1, _q2, _u, _d] \ No newline at end of file diff --git a/addons/laser/functions/fnc_seekerFindLaserSpot.sqf b/addons/laser/functions/fnc_seekerFindLaserSpot.sqf index 45b60a69c1..a5d3e2714c 100644 --- a/addons/laser/functions/fnc_seekerFindLaserSpot.sqf +++ b/addons/laser/functions/fnc_seekerFindLaserSpot.sqf @@ -1,158 +1,158 @@ -/* - * 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", "_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; - - -_seekerCos = cos _seekerFov; - -_spots = []; -_buckets = []; -_excludes = []; -_bucketIndex = 0; -_finalPos = nil; -_finalOwner = nil; - -{ - _obj = _x select 0; - _owner = _x select 1; - _method = _x select 2; - _emitterWavelength = _x select 3; - _laserCode = _x select 4; - _divergence = _x select 5; - if(alive _obj && {_emitterWavelength >= (_seekerWavelengths select 0)} && {_emitterWavelength <= (_seekerWavelengths select 1)} && {_laserCode == _seekerCode}) then { - _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_ARRAY(_method)) then { - if(count _method == 2) then { - _laser = [ATLtoASL (_obj modelToWorldVisual (_method select 0)), _obj weaponDirection (_method select 1)]; - } else { - if(count _method == 3) then { - _laser = [ATLtoASL (_obj modelToWorldVisual (_method select 0)), (ATLtoASL (_obj modelToWorldVisual (_method select 1))) vectorFromTo (ATLtoASL (_obj modelToWorldVisual (_method select 2)))]; - }; - }; - }; - }; - }; - - //Handle Weird Data Return - if (_laser params [["_laserPos", [], [[]], 3], ["_laserDir", [], [[]], 3]]) then { - _res = [_laserPos, _laserDir, _divergence] call FUNC(shootCone); - { - _testPoint = _x select 0; - _testPointVector = vectorNormalized (_testPoint vectorDiff _pos); - _testDotProduct = _dir vectorDotProduct _testPointVector; - if(_testDotProduct > _seekerCos) then { - _spots pushBack [_testPoint, _owner]; - }; - } forEach (_res select 2); - }; - }; -} forEach (GVAR(laserEmitters) select 1); - -if((count _spots) > 0) then { - _bucketPos = nil; - _bucketList = nil; - _c = 0; - while { count(_spots) != count(_excludes) && _c < (count _spots) } do { - scopeName "mainSearch"; - { - if(!(_forEachIndex in _excludes)) then { - _index = _buckets pushBack [_x, [_x]]; - _excludes pushBack _forEachIndex; - _bucketPos = _x select 0; - _bucketList = (_buckets select _index) select 1; - breakTo "mainSearch"; - }; - } forEach _spots; - { - if(!(_forEachIndex in _excludes)) then { - _testPos = (_x select 0); - if(_testPos vectorDistanceSqr _bucketPos <= 100) then { - _bucketList pushBack _x; - _excludes pushBack _forEachIndex; - }; - }; - } forEach _spots; - _c = _c + 1; - }; - _finalBuckets = []; - _largest = -1; - _largestIndex = 0; - { - _index = _finalBuckets pushBack []; - _bucketList = _finalBuckets select _index; - { - _testPos = (_x select 0); - if(!terrainIntersectASL [_pos, _testPos] && {!lineIntersects [_pos, _testPos]}) then { - _bucketList pushBack _x; - }; - } forEach (_x select 1); - if((count _bucketList) > _largest) then { - _largest = (count _bucketList); - _largestIndex = _index; - }; - } forEach _buckets; - - _finalBucket = _finalBuckets select _largestIndex; - _owners = HASH_CREATE; - - if(count _finalBucket > 0) then { - _avgX = 0; - _avgY = 0; - _avgZ = 0; - { - //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); - _owner = _x select 1; - if(HASH_HASKEY(_owners, _owner)) then { - _count = HASH_GET(_owners, _owner); - HASH_SET(_owners, _owner, _count+1); - } else { - HASH_SET(_owners, _owner, 1); - }; - } forEach _finalBucket; - _count = count _finalBucket; - _finalPos = [_avgX/_count, _avgY/_count, _avgZ/_count]; - _maxOwner = -1; - _maxOwnerIndex = 0; - { - if((_owners select 1) select _forEachIndex > _maxOwner) then { - _maxOwner = (_owners select 1) select _forEachIndex; - _maxOwnerIndex = _forEachIndex; - }; - } forEach (_owners select 0); - _finalOwner = (_owners select 0) select _maxOwnerIndex; - }; -}; -[_finalPos, _owner]; +/* + * 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", "_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; + + +_seekerCos = cos _seekerFov; + +_spots = []; +_buckets = []; +_excludes = []; +_bucketIndex = 0; +_finalPos = nil; +_finalOwner = nil; + +{ + _obj = _x select 0; + _owner = _x select 1; + _method = _x select 2; + _emitterWavelength = _x select 3; + _laserCode = _x select 4; + _divergence = _x select 5; + if(alive _obj && {_emitterWavelength >= (_seekerWavelengths select 0)} && {_emitterWavelength <= (_seekerWavelengths select 1)} && {_laserCode == _seekerCode}) then { + _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_ARRAY(_method)) then { + if(count _method == 2) then { + _laser = [ATLtoASL (_obj modelToWorldVisual (_method select 0)), _obj weaponDirection (_method select 1)]; + } else { + if(count _method == 3) then { + _laser = [ATLtoASL (_obj modelToWorldVisual (_method select 0)), (ATLtoASL (_obj modelToWorldVisual (_method select 1))) vectorFromTo (ATLtoASL (_obj modelToWorldVisual (_method select 2)))]; + }; + }; + }; + }; + }; + + //Handle Weird Data Return + if (_laser params [["_laserPos", [], [[]], 3], ["_laserDir", [], [[]], 3]]) then { + _res = [_laserPos, _laserDir, _divergence] call FUNC(shootCone); + { + _testPoint = _x select 0; + _testPointVector = vectorNormalized (_testPoint vectorDiff _pos); + _testDotProduct = _dir vectorDotProduct _testPointVector; + if(_testDotProduct > _seekerCos) then { + _spots pushBack [_testPoint, _owner]; + }; + } forEach (_res select 2); + }; + }; +} forEach (GVAR(laserEmitters) select 1); + +if((count _spots) > 0) then { + _bucketPos = nil; + _bucketList = nil; + _c = 0; + while { count(_spots) != count(_excludes) && _c < (count _spots) } do { + scopeName "mainSearch"; + { + if(!(_forEachIndex in _excludes)) then { + _index = _buckets pushBack [_x, [_x]]; + _excludes pushBack _forEachIndex; + _bucketPos = _x select 0; + _bucketList = (_buckets select _index) select 1; + breakTo "mainSearch"; + }; + } forEach _spots; + { + if(!(_forEachIndex in _excludes)) then { + _testPos = (_x select 0); + if(_testPos vectorDistanceSqr _bucketPos <= 100) then { + _bucketList pushBack _x; + _excludes pushBack _forEachIndex; + }; + }; + } forEach _spots; + _c = _c + 1; + }; + _finalBuckets = []; + _largest = -1; + _largestIndex = 0; + { + _index = _finalBuckets pushBack []; + _bucketList = _finalBuckets select _index; + { + _testPos = (_x select 0); + if(!terrainIntersectASL [_pos, _testPos] && {!lineIntersects [_pos, _testPos]}) then { + _bucketList pushBack _x; + }; + } forEach (_x select 1); + if((count _bucketList) > _largest) then { + _largest = (count _bucketList); + _largestIndex = _index; + }; + } forEach _buckets; + + _finalBucket = _finalBuckets select _largestIndex; + _owners = HASH_CREATE; + + if(count _finalBucket > 0) then { + _avgX = 0; + _avgY = 0; + _avgZ = 0; + { + //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); + _owner = _x select 1; + if(HASH_HASKEY(_owners, _owner)) then { + _count = HASH_GET(_owners, _owner); + HASH_SET(_owners, _owner, _count+1); + } else { + HASH_SET(_owners, _owner, 1); + }; + } forEach _finalBucket; + _count = count _finalBucket; + _finalPos = [_avgX/_count, _avgY/_count, _avgZ/_count]; + _maxOwner = -1; + _maxOwnerIndex = 0; + { + if((_owners select 1) select _forEachIndex > _maxOwner) then { + _maxOwner = (_owners select 1) select _forEachIndex; + _maxOwnerIndex = _forEachIndex; + }; + } forEach (_owners select 0); + _finalOwner = (_owners select 0) select _maxOwnerIndex; + }; +}; +[_finalPos, _owner]; diff --git a/addons/laser/functions/fnc_shootCone.sqf b/addons/laser/functions/fnc_shootCone.sqf index a7187aa0e4..a9e1f3e50d 100644 --- a/addons/laser/functions/fnc_shootCone.sqf +++ b/addons/laser/functions/fnc_shootCone.sqf @@ -1,68 +1,68 @@ -#include "script_component.hpp" -//#define DEBUG_MODE_FULL -private ["_i", "_divergence","_pos","_vec","_longestReturn","_shortestReturn","_resultPositions","_p1","_p2","_p","_v","_cp","_vecRotateMap","_result", "_resultPos","_distance","_count","_pos2","_radOffset","_offset","_offsetPos","_offsetVector"]; -_divergence = 0.3; -_pos = _this select 0; -_vec = _this select 1; -if(count _this > 2) then { - _divergence = _this select 2; -}; -_count = 3; -if(count _this > 3) then { - _count = _this select 3; -}; -_longestReturn = -1000000000; -_shortestReturn = 1000000000; -_resultPositions = []; -_p1 = [0,0,0]; -_p2 = +_vec; -_p = (_vec call CBA_fnc_vect2polar); -_v = [(_p select 0), (_p select 1), (_p select 2)+90] call CBA_fnc_polar2vect; -_cp = _vec vectorCrossProduct _v; - -_vecRotateMap = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap); - -_result = [_pos, _vec] call FUNC(shootRay); -_resultPos = _result select 0; -if(!isNil "_resultPos") then { - _distance = _result select 1; - if(_distance < _shortestReturn) then { - _shortestReturn = _distance; - }; - if(_distance > _longestReturn) then { - _longestReturn = _distance; - }; - _resultPositions pushBack _result; -#ifdef DEBUG_MODE_FULL - // DRAW_LINES set[(count DRAW_LINES), [_pos, _resultPos, [0, 1, 0, 1]]]; - drawLine3D [ASLtoATL _pos, ASLtoATL _resultPos, [1,0,0,1]]; -#endif -}; - - -_pos2 = _pos vectorAdd (_vec vectorMultiply 1000); -{ - for "_i" from 0 to ceil(_count*_x) do { - _radOffset = random 360; - _offset = [_vecRotateMap, (((360/_count)*_i)+_radOffset) mod 360] call FUNC(rotateVectLine); - _offsetPos = _pos2 vectorAdd (_offset vectorMultiply (_divergence*_x)); - _offsetVector = _pos vectorFromTo _offsetPos; - _result = [_pos, _offsetVector] call FUNC(shootRay); - _resultPos = _result select 0; - if(!isNil "_resultPos") then { - _distance = _result select 1; - if(_distance < _shortestReturn) then { - _shortestReturn = _distance; - }; - if(_distance > _longestReturn) then { - _longestReturn = _distance; - }; - _resultPositions pushBack _result; -#ifdef DEBUG_MODE_FULL - // DRAW_LINES set[(count DRAW_LINES), [_pos, _resultPos, [0, 1, 0, 1]]]; - drawLine3D [ASLtoATL _pos, ASLtoATL _resultPos, [1,0,0,1]]; -#endif - }; - }; -} forEach [1,0.5,0.25]; +#include "script_component.hpp" +//#define DEBUG_MODE_FULL +private ["_i", "_divergence","_pos","_vec","_longestReturn","_shortestReturn","_resultPositions","_p1","_p2","_p","_v","_cp","_vecRotateMap","_result", "_resultPos","_distance","_count","_pos2","_radOffset","_offset","_offsetPos","_offsetVector"]; +_divergence = 0.3; +_pos = _this select 0; +_vec = _this select 1; +if(count _this > 2) then { + _divergence = _this select 2; +}; +_count = 3; +if(count _this > 3) then { + _count = _this select 3; +}; +_longestReturn = -1000000000; +_shortestReturn = 1000000000; +_resultPositions = []; +_p1 = [0,0,0]; +_p2 = +_vec; +_p = (_vec call CBA_fnc_vect2polar); +_v = [(_p select 0), (_p select 1), (_p select 2)+90] call CBA_fnc_polar2vect; +_cp = _vec vectorCrossProduct _v; + +_vecRotateMap = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap); + +_result = [_pos, _vec] call FUNC(shootRay); +_resultPos = _result select 0; +if(!isNil "_resultPos") then { + _distance = _result select 1; + if(_distance < _shortestReturn) then { + _shortestReturn = _distance; + }; + if(_distance > _longestReturn) then { + _longestReturn = _distance; + }; + _resultPositions pushBack _result; +#ifdef DEBUG_MODE_FULL + // DRAW_LINES set[(count DRAW_LINES), [_pos, _resultPos, [0, 1, 0, 1]]]; + drawLine3D [ASLtoATL _pos, ASLtoATL _resultPos, [1,0,0,1]]; +#endif +}; + + +_pos2 = _pos vectorAdd (_vec vectorMultiply 1000); +{ + for "_i" from 0 to ceil(_count*_x) do { + _radOffset = random 360; + _offset = [_vecRotateMap, (((360/_count)*_i)+_radOffset) mod 360] call FUNC(rotateVectLine); + _offsetPos = _pos2 vectorAdd (_offset vectorMultiply (_divergence*_x)); + _offsetVector = _pos vectorFromTo _offsetPos; + _result = [_pos, _offsetVector] call FUNC(shootRay); + _resultPos = _result select 0; + if(!isNil "_resultPos") then { + _distance = _result select 1; + if(_distance < _shortestReturn) then { + _shortestReturn = _distance; + }; + if(_distance > _longestReturn) then { + _longestReturn = _distance; + }; + _resultPositions pushBack _result; +#ifdef DEBUG_MODE_FULL + // DRAW_LINES set[(count DRAW_LINES), [_pos, _resultPos, [0, 1, 0, 1]]]; + drawLine3D [ASLtoATL _pos, ASLtoATL _resultPos, [1,0,0,1]]; +#endif + }; + }; +} forEach [1,0.5,0.25]; [_longestReturn, _shortestReturn, _resultPositions]; \ No newline at end of file diff --git a/addons/laser/functions/fnc_shootRay.sqf b/addons/laser/functions/fnc_shootRay.sqf index 83b257ed7b..51b5e55f17 100644 --- a/addons/laser/functions/fnc_shootRay.sqf +++ b/addons/laser/functions/fnc_shootRay.sqf @@ -1,24 +1,24 @@ -#include "script_component.hpp" - -private ["_pos", "_vec", "_distance", "_resultPos", "_fidelity", "_lastPos", "_i", "_nextPos"]; -scopeName "main"; -_pos = _this select 0; -_vec = _this select 1; -_distance = 0; -_resultPos = nil; -_fidelity = [1000,100,10,1,0.1]; -_lastPos = +_pos; -{ - scopeName "mainSearch"; - for "_i" from 1 to 10 do { - _nextPos = _lastPos vectorAdd (_vec vectorMultiply _x); - if(terrainIntersectASL [_lastPos, _nextPos] || {lineIntersects [_lastPos, _nextPos]}) then { - _resultPos = _lastPos; - breakTo "mainSearch"; - } else { - _distance = _distance + _x; - _lastPos = _nextPos; - }; - }; -} forEach _fidelity; +#include "script_component.hpp" + +private ["_pos", "_vec", "_distance", "_resultPos", "_fidelity", "_lastPos", "_i", "_nextPos"]; +scopeName "main"; +_pos = _this select 0; +_vec = _this select 1; +_distance = 0; +_resultPos = nil; +_fidelity = [1000,100,10,1,0.1]; +_lastPos = +_pos; +{ + scopeName "mainSearch"; + for "_i" from 1 to 10 do { + _nextPos = _lastPos vectorAdd (_vec vectorMultiply _x); + if(terrainIntersectASL [_lastPos, _nextPos] || {lineIntersects [_lastPos, _nextPos]}) then { + _resultPos = _lastPos; + breakTo "mainSearch"; + } else { + _distance = _distance + _x; + _lastPos = _nextPos; + }; + }; +} forEach _fidelity; [_resultPos, _distance]; \ No newline at end of file diff --git a/addons/laser/functions/fnc_vanillaLaserSeekerHandler.sqf b/addons/laser/functions/fnc_vanillaLaserSeekerHandler.sqf index 091c4f7acf..16e9a7a159 100644 --- a/addons/laser/functions/fnc_vanillaLaserSeekerHandler.sqf +++ b/addons/laser/functions/fnc_vanillaLaserSeekerHandler.sqf @@ -1,26 +1,26 @@ -/* - * Author: jaynus - * Handler function for laser network code. - * - * Argument: - * 0: Emitter - * 1: Owner - * - * Return value: - * [position, direction] - */ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -private["_emmiter", "_owner", "_gunnerInfo", "_turretInfo", "_povPos", "_povDir"]; - -_emmiter = _this select 0; -_owner = _this select 1; - -// Not in a vehicle.... -// @TODO: handle lasering from turrets -if( (vehicle _emmiter) == _emmiter && alive _emmiter && (currentWeapon _emmiter) == "LaserDesignator") exitWith { - [(eyePos _emmiter), (eyeDirection _emmiter)] -}; - +/* + * Author: jaynus + * Handler function for laser network code. + * + * Argument: + * 0: Emitter + * 1: Owner + * + * Return value: + * [position, direction] + */ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +private["_emmiter", "_owner", "_gunnerInfo", "_turretInfo", "_povPos", "_povDir"]; + +_emmiter = _this select 0; +_owner = _this select 1; + +// Not in a vehicle.... +// @TODO: handle lasering from turrets +if( (vehicle _emmiter) == _emmiter && alive _emmiter && (currentWeapon _emmiter) == "LaserDesignator") exitWith { + [(eyePos _emmiter), (eyeDirection _emmiter)] +}; + [-1,-1] \ No newline at end of file diff --git a/addons/laser/initKeybinds.sqf b/addons/laser/initKeybinds.sqf index 25fdd2ddcc..8ae9d05e9f 100644 --- a/addons/laser/initKeybinds.sqf +++ b/addons/laser/initKeybinds.sqf @@ -1,27 +1,27 @@ -["ACE3 Equipment", QGVAR(LaserCodeUp), localize LSTRING(laserCodeUp), -{ - if( EGVAR(laser_selfdesignate,active) - || - { (currentWeapon ACE_player) == "Laserdesignator" && (call CBA_fnc_getFoV) select 1 > 5 } // If laserdesignator & FOV, we are in scope. - || - { [ACE_player] call FUNC(unitTurretCanLockLaser) } - ) then { - [] call FUNC(keyLaserCodeUp); - }; -}, -{false}, -[16, [false, true, true]], false, 0] call CBA_fnc_addKeybind; // (ALT+CTRL+Q) - -["ACE3 Equipment", QGVAR(LaserCodeDown), localize LSTRING(laserCodeDown), -{ - if( EGVAR(laser_selfdesignate,active) - || - { (currentWeapon ACE_player) == "Laserdesignator" && (call CBA_fnc_getFoV) select 1 > 5 } // If laserdesignator & FOV, we are in scope. - || - { [ACE_player] call FUNC(unitTurretCanLockLaser) } - ) then { - [] call FUNC(keyLaserCodeDown); - }; -}, -{false}, -[18, [false, true, true]], false, 0] call CBA_fnc_addKeybind; // (ALT+CTRL+E) +["ACE3 Equipment", QGVAR(LaserCodeUp), localize LSTRING(laserCodeUp), +{ + if( EGVAR(laser_selfdesignate,active) + || + { (currentWeapon ACE_player) == "Laserdesignator" && (call CBA_fnc_getFoV) select 1 > 5 } // If laserdesignator & FOV, we are in scope. + || + { [ACE_player] call FUNC(unitTurretCanLockLaser) } + ) then { + [] call FUNC(keyLaserCodeUp); + }; +}, +{false}, +[16, [false, true, true]], false, 0] call CBA_fnc_addKeybind; // (ALT+CTRL+Q) + +["ACE3 Equipment", QGVAR(LaserCodeDown), localize LSTRING(laserCodeDown), +{ + if( EGVAR(laser_selfdesignate,active) + || + { (currentWeapon ACE_player) == "Laserdesignator" && (call CBA_fnc_getFoV) select 1 > 5 } // If laserdesignator & FOV, we are in scope. + || + { [ACE_player] call FUNC(unitTurretCanLockLaser) } + ) then { + [] call FUNC(keyLaserCodeDown); + }; +}, +{false}, +[18, [false, true, true]], false, 0] call CBA_fnc_addKeybind; // (ALT+CTRL+E) diff --git a/addons/laser/script_component.hpp b/addons/laser/script_component.hpp index f3542f686f..3ff3f48c49 100644 --- a/addons/laser/script_component.hpp +++ b/addons/laser/script_component.hpp @@ -1,27 +1,27 @@ -#define COMPONENT laser -#include "\z\ace\addons\main\script_mod.hpp" - -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS -// #define ENABLE_PERFORMANCE_COUNTERS - -#ifdef DEBUG_ENABLED_LASER - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_LASER - #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER -#endif - -#include "\z\ace\addons\main\script_macros.hpp" - - -#define FIREMODE_DIRECT_LOAL 1 - - -#define __LaserDesignatorIGUI (uiNamespace getVariable ["ACE_RscOptics_LaserDesignator", nil]) -#define __LaserDesignatorIGUI_LaserCode (__LaserDesignatorIGUI displayCtrl 123001) -#define __LaserDesignatorIGUI_ACE_Distance (__LaserDesignatorIGUI displayCtrl 123002) -#define __LaserDesignatorIGUI_CA_Distance (__LaserDesignatorIGUI displayCtrl 151) +#define COMPONENT laser +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_LASER + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_LASER + #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + + +#define FIREMODE_DIRECT_LOAL 1 + + +#define __LaserDesignatorIGUI (uiNamespace getVariable ["ACE_RscOptics_LaserDesignator", nil]) +#define __LaserDesignatorIGUI_LaserCode (__LaserDesignatorIGUI displayCtrl 123001) +#define __LaserDesignatorIGUI_ACE_Distance (__LaserDesignatorIGUI displayCtrl 123002) +#define __LaserDesignatorIGUI_CA_Distance (__LaserDesignatorIGUI displayCtrl 151) #define __LaserDesignatorIGUI_LaserOn (__LaserDesignatorIGUI displayCtrl 158) \ No newline at end of file diff --git a/addons/laser_selfdesignate/CfgEventhandlers.hpp b/addons/laser_selfdesignate/CfgEventhandlers.hpp index cfa8d65d7c..0458ace904 100644 --- a/addons/laser_selfdesignate/CfgEventhandlers.hpp +++ b/addons/laser_selfdesignate/CfgEventhandlers.hpp @@ -1,26 +1,26 @@ - -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_pre_init)); - }; -}; - -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_post_init)); - }; -}; - -class Extended_Init_EventHandlers { - class Helicopter { - class ADDON { - init = QUOTE(_this call DFUNC(initDesignatorActions)); - }; - }; -}; + +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_pre_init)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_post_init)); + }; +}; + +class Extended_Init_EventHandlers { + class Helicopter { + class ADDON { + init = QUOTE(_this call DFUNC(initDesignatorActions)); + }; + }; +}; diff --git a/addons/laser_selfdesignate/CfgVehicles.hpp b/addons/laser_selfdesignate/CfgVehicles.hpp index 3e47e13ffd..8eb84326c5 100644 --- a/addons/laser_selfdesignate/CfgVehicles.hpp +++ b/addons/laser_selfdesignate/CfgVehicles.hpp @@ -1,49 +1,49 @@ -class CfgVehicles { - class AllVehicles; - class Air: AllVehicles { - class Turrets; - }; - - class Helicopter: Air { - class Turrets { - class MainTurret; - }; - }; - - class Helicopter_Base_F: Helicopter {}; - - class Heli_Attack_01_base_F: Helicopter_Base_F {}; - - class B_Heli_Attack_01_F: Heli_Attack_01_base_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - GVAR(Enabled) = 0; // Enable laser self-designation - }; - }; - }; - - class Plane: Air {}; - class Plane_Base_F: Plane { - class Turrets { - class CopilotTurret; - }; - }; - - /* @TODO: LGB GBU - class Plane_CAS_01_base_F: Plane_Base_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - GVAR(Enabled) = 1; // Enable laser self-designation - }; - }; - }; - - class Plane_CAS_02_base_F: Plane_Base_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - GVAR(Enabled) = 1; // Enable laser self-designation - }; - }; - }; - */ -}; +class CfgVehicles { + class AllVehicles; + class Air: AllVehicles { + class Turrets; + }; + + class Helicopter: Air { + class Turrets { + class MainTurret; + }; + }; + + class Helicopter_Base_F: Helicopter {}; + + class Heli_Attack_01_base_F: Helicopter_Base_F {}; + + class B_Heli_Attack_01_F: Heli_Attack_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 0; // Enable laser self-designation + }; + }; + }; + + class Plane: Air {}; + class Plane_Base_F: Plane { + class Turrets { + class CopilotTurret; + }; + }; + + /* @TODO: LGB GBU + class Plane_CAS_01_base_F: Plane_Base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 1; // Enable laser self-designation + }; + }; + }; + + class Plane_CAS_02_base_F: Plane_Base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 1; // Enable laser self-designation + }; + }; + }; + */ +}; diff --git a/addons/laser_selfdesignate/CfgWeapons.hpp b/addons/laser_selfdesignate/CfgWeapons.hpp index 70e1afde88..4ef2ee4692 100644 --- a/addons/laser_selfdesignate/CfgWeapons.hpp +++ b/addons/laser_selfdesignate/CfgWeapons.hpp @@ -1,11 +1,11 @@ -class CfgWeapons { - // Disable locking unless newb mode - class LauncherCore; - class RocketPods: LauncherCore { - // canLock = 1; - }; - - class missiles_DAGR: RocketPods { - canLock = 1; - }; -}; +class CfgWeapons { + // Disable locking unless newb mode + class LauncherCore; + class RocketPods: LauncherCore { + // canLock = 1; + }; + + class missiles_DAGR: RocketPods { + canLock = 1; + }; +}; diff --git a/addons/laser_selfdesignate/XEH_post_init.sqf b/addons/laser_selfdesignate/XEH_post_init.sqf index dc30361926..6eccf9d1dd 100644 --- a/addons/laser_selfdesignate/XEH_post_init.sqf +++ b/addons/laser_selfdesignate/XEH_post_init.sqf @@ -1,2 +1,2 @@ -#include "script_component.hpp" - +#include "script_component.hpp" + diff --git a/addons/laser_selfdesignate/XEH_pre_init.sqf b/addons/laser_selfdesignate/XEH_pre_init.sqf index aa41d7e9bb..f957638ba2 100644 --- a/addons/laser_selfdesignate/XEH_pre_init.sqf +++ b/addons/laser_selfdesignate/XEH_pre_init.sqf @@ -1,11 +1,11 @@ -#include "script_component.hpp" - -ADDON = false; - -#include "XEH_PREP.hpp" - -GVAR(active) = false; - -FUNC(getPosASL) = {visiblePositionASL (_this select 0)}; - -ADDON = true; +#include "script_component.hpp" + +ADDON = false; + +#include "XEH_PREP.hpp" + +GVAR(active) = false; + +FUNC(getPosASL) = {visiblePositionASL (_this select 0)}; + +ADDON = true; diff --git a/addons/laser_selfdesignate/config.cpp b/addons/laser_selfdesignate/config.cpp index 597500caf6..dfa663e483 100644 --- a/addons/laser_selfdesignate/config.cpp +++ b/addons/laser_selfdesignate/config.cpp @@ -1,15 +1,15 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_laser"}; - VERSION_CONFIG; - }; -}; - -#include "CfgEventhandlers.hpp" -#include "CfgWeapons.hpp" -#include "CfgVehicles.hpp" +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_laser"}; + VERSION_CONFIG; + }; +}; + +#include "CfgEventhandlers.hpp" +#include "CfgWeapons.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/laser_selfdesignate/functions/fnc_findLaserSource.sqf b/addons/laser_selfdesignate/functions/fnc_findLaserSource.sqf index 955f1ea51d..092fff214b 100644 --- a/addons/laser_selfdesignate/functions/fnc_findLaserSource.sqf +++ b/addons/laser_selfdesignate/functions/fnc_findLaserSource.sqf @@ -1,23 +1,23 @@ -/* - * Author: jaynus - * Handler function for laser network code. - * - * Argument: - * 0: Emitter - * - * Return Value: - * 0: position - * 1: direction - * - * Public: No - */ -#include "script_component.hpp" - -private["_gunnerInfo", "_turretInfo"]; -params ["_emmiter"]; - -_gunnerInfo = [_emmiter, (currentWeapon _emmiter)] call CBA_fnc_getFirer; -_turretInfo = [_emmiter, _gunnerInfo select 1] call EFUNC(common,getTurretDirection); -_turretInfo params [["_povPos", -1], ["_povDir", -1]]; - -[_povPos, _povDir] +/* + * Author: jaynus + * Handler function for laser network code. + * + * Argument: + * 0: Emitter + * + * Return Value: + * 0: position + * 1: direction + * + * Public: No + */ +#include "script_component.hpp" + +private["_gunnerInfo", "_turretInfo"]; +params ["_emmiter"]; + +_gunnerInfo = [_emmiter, (currentWeapon _emmiter)] call CBA_fnc_getFirer; +_turretInfo = [_emmiter, _gunnerInfo select 1] call EFUNC(common,getTurretDirection); +_turretInfo params [["_povPos", -1], ["_povDir", -1]]; + +[_povPos, _povDir] diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf index 300811cba2..2e4b745946 100644 --- a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOff.sqf @@ -1,29 +1,29 @@ -/* - * Author: jaynus - * Turns off passed laser self designation. - * - * Argument: - * 0: Shooter, player shooting the laser - * 1: LaserUUID, the UUID of the laser returned by EFUNC(laser,laserOn) - * 2: Local laser target, unused. - * - * Return Value: - * True - */ -#include "script_component.hpp" - -if( (count _this) > 2) then { - params ["", "_laserUuid"]; - [_laserUuid] call EFUNC(laser,laserOff); - // @TODO: Nou gets to field all tickets about missing lasers. - //deleteVehicle _localLaserTarget; -}; - -GVAR(active) = false; - -if(!isNil QGVAR(selfDesignateHandle)) then { - [GVAR(selfDesignateHandle)] call CBA_fnc_removePerFrameHandler; - GVAR(selfDesignateHandle) = nil; -}; - -true +/* + * Author: jaynus + * Turns off passed laser self designation. + * + * Argument: + * 0: Shooter, player shooting the laser + * 1: LaserUUID, the UUID of the laser returned by EFUNC(laser,laserOn) + * 2: Local laser target, unused. + * + * Return Value: + * True + */ +#include "script_component.hpp" + +if( (count _this) > 2) then { + params ["", "_laserUuid"]; + [_laserUuid] call EFUNC(laser,laserOff); + // @TODO: Nou gets to field all tickets about missing lasers. + //deleteVehicle _localLaserTarget; +}; + +GVAR(active) = false; + +if(!isNil QGVAR(selfDesignateHandle)) then { + [GVAR(selfDesignateHandle)] call CBA_fnc_removePerFrameHandler; + GVAR(selfDesignateHandle) = nil; +}; + +true diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf index e585a409ff..5a67e6cb08 100644 --- a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf @@ -1,90 +1,90 @@ -/* - * Author: jaynus - * Turns on laser self designation from this vehicle based on the turret. - * There are no arguments, because it is all strictly based on the users vehicle. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -TRACE_1("enter", _this); - -#define FCS_UPDATE_DELAY 1 - -FUNC(laserHudDesignatePFH) = { - private["_strongestResultPos", "_args", "_localLaserTarget", "_laserResultPosition", "_laserResult", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turretInfo", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult", "_forceUpdateTime"]; - params ["_args"]; - _args params ["_shooter", "_localLaserTarget"]; - _vehicle = vehicle _shooter; - TRACE_1("", _args); - - if((vehicle _shooter) == _shooter || {!alive _shooter} || {isNull _vehicle} || {!GVAR(active)} ) exitWith { - _args call FUNC(laserHudDesignateOff); - }; - if(!([_shooter] call FUNC(unitTurretHasDesignator)) ) exitWith { - _args call FUNC(laserHudDesignateOff); - }; - - if( (count _args) < 4) then { - _args set[3, ACE_diagTime + FCS_UPDATE_DELAY]; - }; - _forceUpdateTime = _args select 3; - - // @TODO: We don't have anything here we need to do the calculations for right now - /* - - _gunnerInfo = [_vehicle, (currentWeapon _vehicle)] call CBA_fnc_getFirer; - _turretInfo = [_vehicle, _gunnerInfo select 1] call EFUNC(common,getTurretDirection); - _povPos = _turretInfo select 0; - - _laserCode = (vehicle ACE_player) getVariable["ace_laser_code", ACE_DEFAULT_LASER_CODE]; - _waveLength = (vehicle ACE_player) getVariable["ace_laser_waveLength", ACE_DEFAULT_LASER_WAVELENGTH]; - - - _laserResult = [_povPos, [_waveLength,_waveLength], _laserCode] call EFUNC(laser,seekerFindLaserSpot); - _laserResultPosition = _laserResult select 0; - TRACE_1("Search", _laserResult); - - if((count _laserResult) > 0) then { - // @TODO: Nou gets to field all tickets about missing lasers. - //_localLaserTarget setPosASL _laserResultPosition; - }; - */ - - if(ACE_diagTime > _forceUpdateTime) then { - ["ace_fcs_forceUpdate", []] call ace_common_fnc_localEvent; - _args set[3, ACE_diagTime + FCS_UPDATE_DELAY]; - }; - - _this set[0, _args]; -}; - -private ["_laserTarget", "_handle", "_vehicle", "_laserUuid", "_waveLength", "_beamSpread", "_laserCode"]; - -if(!GVAR(active)) then { - GVAR(active) = true; - - TRACE_1("Activating laser", ""); - - // Get the self-designation variables, or use defaults - _laserCode = (vehicle ACE_player) getVariable["ace_laser_code", ACE_DEFAULT_LASER_CODE]; - _waveLength = (vehicle ACE_player) getVariable["ace_laser_waveLength", ACE_DEFAULT_LASER_WAVELENGTH]; - _beamSpread = (vehicle ACE_player) getVariable["ace_laser_beamSpread", ACE_DEFAULT_LASER_BEAMSPREAD]; - - _laserUuid = [(vehicle ACE_player), ACE_player, QFUNC(findLaserSource), _waveLength, _laserCode, _beamSpread] call EFUNC(laser,laserOn); - - // @TODO: Create the local target for the players side - // @TODO: Nou gets to field all tickets about missing lasers. - //_localLaserTarget = "LaserTargetW" createVehicleLocal (getpos ACE_player); - - GVAR(selfDesignateHandle) = [FUNC(laserHudDesignatePFH), 0.1, [ACE_player, _laserUuid, nil]] call CBA_fnc_addPerFrameHandler; -} else { - [] call FUNC(laserHudDesignateOff); - [] call FUNC(laserHudDesignateOn); -}; +/* + * Author: jaynus + * Turns on laser self designation from this vehicle based on the turret. + * There are no arguments, because it is all strictly based on the users vehicle. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +TRACE_1("enter", _this); + +#define FCS_UPDATE_DELAY 1 + +FUNC(laserHudDesignatePFH) = { + private["_strongestResultPos", "_args", "_localLaserTarget", "_laserResultPosition", "_laserResult", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turretInfo", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult", "_forceUpdateTime"]; + params ["_args"]; + _args params ["_shooter", "_localLaserTarget"]; + _vehicle = vehicle _shooter; + TRACE_1("", _args); + + if((vehicle _shooter) == _shooter || {!alive _shooter} || {isNull _vehicle} || {!GVAR(active)} ) exitWith { + _args call FUNC(laserHudDesignateOff); + }; + if(!([_shooter] call FUNC(unitTurretHasDesignator)) ) exitWith { + _args call FUNC(laserHudDesignateOff); + }; + + if( (count _args) < 4) then { + _args set[3, ACE_diagTime + FCS_UPDATE_DELAY]; + }; + _forceUpdateTime = _args select 3; + + // @TODO: We don't have anything here we need to do the calculations for right now + /* + + _gunnerInfo = [_vehicle, (currentWeapon _vehicle)] call CBA_fnc_getFirer; + _turretInfo = [_vehicle, _gunnerInfo select 1] call EFUNC(common,getTurretDirection); + _povPos = _turretInfo select 0; + + _laserCode = (vehicle ACE_player) getVariable["ace_laser_code", ACE_DEFAULT_LASER_CODE]; + _waveLength = (vehicle ACE_player) getVariable["ace_laser_waveLength", ACE_DEFAULT_LASER_WAVELENGTH]; + + + _laserResult = [_povPos, [_waveLength,_waveLength], _laserCode] call EFUNC(laser,seekerFindLaserSpot); + _laserResultPosition = _laserResult select 0; + TRACE_1("Search", _laserResult); + + if((count _laserResult) > 0) then { + // @TODO: Nou gets to field all tickets about missing lasers. + //_localLaserTarget setPosASL _laserResultPosition; + }; + */ + + if(ACE_diagTime > _forceUpdateTime) then { + ["ace_fcs_forceUpdate", []] call ace_common_fnc_localEvent; + _args set[3, ACE_diagTime + FCS_UPDATE_DELAY]; + }; + + _this set[0, _args]; +}; + +private ["_laserTarget", "_handle", "_vehicle", "_laserUuid", "_waveLength", "_beamSpread", "_laserCode"]; + +if(!GVAR(active)) then { + GVAR(active) = true; + + TRACE_1("Activating laser", ""); + + // Get the self-designation variables, or use defaults + _laserCode = (vehicle ACE_player) getVariable["ace_laser_code", ACE_DEFAULT_LASER_CODE]; + _waveLength = (vehicle ACE_player) getVariable["ace_laser_waveLength", ACE_DEFAULT_LASER_WAVELENGTH]; + _beamSpread = (vehicle ACE_player) getVariable["ace_laser_beamSpread", ACE_DEFAULT_LASER_BEAMSPREAD]; + + _laserUuid = [(vehicle ACE_player), ACE_player, QFUNC(findLaserSource), _waveLength, _laserCode, _beamSpread] call EFUNC(laser,laserOn); + + // @TODO: Create the local target for the players side + // @TODO: Nou gets to field all tickets about missing lasers. + //_localLaserTarget = "LaserTargetW" createVehicleLocal (getpos ACE_player); + + GVAR(selfDesignateHandle) = [FUNC(laserHudDesignatePFH), 0.1, [ACE_player, _laserUuid, nil]] call CBA_fnc_addPerFrameHandler; +} else { + [] call FUNC(laserHudDesignateOff); + [] call FUNC(laserHudDesignateOn); +}; diff --git a/addons/laser_selfdesignate/functions/script_component.hpp b/addons/laser_selfdesignate/functions/script_component.hpp index 320dc825c7..845a51c186 100644 --- a/addons/laser_selfdesignate/functions/script_component.hpp +++ b/addons/laser_selfdesignate/functions/script_component.hpp @@ -1 +1 @@ -#include "\z\ace\addons\laser_selfdesignate\script_component.hpp" +#include "\z\ace\addons\laser_selfdesignate\script_component.hpp" diff --git a/addons/laser_selfdesignate/script_component.hpp b/addons/laser_selfdesignate/script_component.hpp index fc0d608e32..f7032720e0 100644 --- a/addons/laser_selfdesignate/script_component.hpp +++ b/addons/laser_selfdesignate/script_component.hpp @@ -1,17 +1,17 @@ -#define COMPONENT laser_selfdesignate -#include "\z\ace\addons\main\script_mod.hpp" - -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS -// #define ENABLE_PERFORMANCE_COUNTERS - -#ifdef DEBUG_ENABLED_LASER_SELFDESIGNATE - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_LASER_SELFDESIGNATE - #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER_SELFDESIGNATE -#endif - -#include "\z\ace\addons\main\script_macros.hpp" +#define COMPONENT laser_selfdesignate +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_LASER_SELFDESIGNATE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_LASER_SELFDESIGNATE + #define DEBUG_SETTINGS DEBUG_SETTINGS_LASER_SELFDESIGNATE +#endif + +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/main/config.cpp b/addons/main/config.cpp index 7b15f0c8f0..95b530c7c9 100644 --- a/addons/main/config.cpp +++ b/addons/main/config.cpp @@ -1,591 +1,591 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = { - // Vanilla - "3den", - "a3_air_f", - "a3_air_f_beta", - "a3_air_f_beta_heli_attack_01", - "a3_air_f_beta_heli_attack_02", - "a3_air_f_beta_heli_transport_01", - "a3_air_f_beta_heli_transport_02", - "a3_air_f_beta_parachute_01", - "a3_air_f_beta_parachute_02", - "a3_air_f_epb_heli_light_03", - "a3_air_f_epc_plane_cas_01", - "a3_air_f_epc_plane_cas_02", - "a3_air_f_epc_plane_fighter_03", - "a3_air_f_gamma_plane_fighter_03", - "a3_air_f_gamma_uav_01", - "a3_air_f_gamma_uav_02", - "a3_air_f_heli", - "a3_air_f_heli_heli_attack_01", - "a3_air_f_heli_heli_attack_02", - "a3_air_f_heli_heli_light_01", - "a3_air_f_heli_heli_light_02", - "a3_air_f_heli_heli_light_03", - "a3_air_f_heli_heli_transport_01", - "a3_air_f_heli_heli_transport_02", - "a3_air_f_heli_heli_transport_03", - "a3_air_f_heli_heli_transport_04", - "a3_air_f_heli_light_01", - "a3_air_f_heli_light_02", - "a3_animals_f", - "a3_animals_f_animconfig", - "a3_animals_f_chicken", - "a3_animals_f_dog", - "a3_animals_f_fishes", - "a3_animals_f_goat", - "a3_animals_f_kestrel", - "a3_animals_f_rabbit", - "a3_animals_f_seagull", - "a3_animals_f_sheep", - "a3_animals_f_snakes", - "a3_animals_f_turtle", - "a3_anims_f", - "a3_anims_f_config_sdr", - "a3_anims_f_epa", - "a3_anims_f_epc", - "a3_anims_f_exp_a", - "a3_anims_f_heli", - "a3_anims_f_kart", - "a3_anims_f_mark_deployment", - "a3_armor_f", - "a3_armor_f_amv", - "a3_armor_f_apc_wheeled_03", - "a3_armor_f_beta", - "a3_armor_f_beta_apc_tracked_02", - "a3_armor_f_epb_apc_tracked_03", - "a3_armor_f_epb_mbt_03", - "a3_armor_f_epc_mbt_01", - "a3_armor_f_marid", - "a3_armor_f_panther", - "a3_armor_f_slammer", - "a3_armor_f_t100k", - "a3_baseconfig_f", - "a3_boat_f", - "a3_boat_f_beta_boat_armed_01", - "a3_boat_f_beta_boat_transport_01", - "a3_boat_f_boat_armed_01", - "a3_boat_f_boat_transport_01", - "a3_boat_f_civilian_boat", - "a3_boat_f_epc_submarine_01_f", - "a3_boat_f_gamma_boat_transport_01", - "a3_boat_f_heli_boat_armed_01", - "a3_boat_f_heli_sdv_01", - "a3_boat_f_sdv_01", - "a3_boat_f_trawler", - "a3_cargoposes_f", - "a3_cargoposes_f_heli", - "a3_characters_f", - "a3_characters_f_beta", - "a3_characters_f_blufor", - "a3_characters_f_bootcamp", - "a3_characters_f_bootcamp_common", - "a3_characters_f_civil", - "a3_characters_f_common", - "a3_characters_f_epa", - "a3_characters_f_epb", - "a3_characters_f_epb_heads", - "a3_characters_f_epc", - "a3_characters_f_gamma", - "a3_characters_f_heads", - "a3_characters_f_indep", - "a3_characters_f_kart", - "a3_characters_f_mark", - "a3_characters_f_opfor", - "a3_characters_f_proxies", - "a3_data_f", - "a3_data_f_bootcamp", - "a3_data_f_curator", - "a3_data_f_curator_characters", - "a3_data_f_curator_eagle", - "a3_data_f_curator_intel", - "a3_data_f_curator_misc", - "a3_data_f_curator_respawn", - "a3_data_f_curator_virtual", - "a3_data_f_exp_a", - "a3_data_f_exp_a_virtual", - "a3_data_f_exp_b", - "a3_data_f_heli", - "a3_data_f_hook", - "a3_data_f_kart", - "a3_data_f_kart_particleeffects", - "a3_data_f_mark", - "a3_data_f_particleeffects", - "a3_dubbing_radio_f", - "a3_editor_f", - "a3_functions_f", - "a3_functions_f_bootcamp", - "a3_functions_f_curator", - "a3_functions_f_epa", - "a3_functions_f_epc", - "a3_functions_f_exp_a", - "a3_functions_f_heli", - "a3_functions_f_mark", - "a3_functions_f_mp_mark", - "a3_language_f", - "a3_language_f_beta", - "a3_language_f_bootcamp", - "a3_language_f_curator", - "a3_language_f_epa", - "a3_language_f_epb", - "a3_language_f_epc", - "a3_language_f_exp_a", - "a3_language_f_gamma", - "a3_language_f_heli", - "a3_language_f_kart", - "a3_language_f_mark", - "a3_language_f_mp_mark", - "a3_languagemissions_f", - "a3_languagemissions_f_beta", - "a3_languagemissions_f_gamma", - "a3_languagemissions_f_kart", - "a3_languagemissions_f_mp_mark", - "a3_map_altis", - "a3_map_altis_scenes", - "a3_map_data", - "a3_map_stratis", - "a3_map_stratis_scenes", - "a3_map_vr_scenes", - "a3_misc_f", - "a3_misc_f_helpers", - "a3_missions_f", - "a3_missions_f_beta", - "a3_missions_f_bootcamp", - "a3_missions_f_curator", - "a3_missions_f_epa", - "a3_missions_f_epb", - "a3_missions_f_epc", - "a3_missions_f_exp_a", - "a3_missions_f_gamma", - "a3_missions_f_heli", - "a3_missions_f_kart", - "a3_missions_f_mark", - "a3_missions_f_mp_mark", - "a3_modules_f", - "a3_modules_f_beta", - "a3_modules_f_beta_firingdrills", - "a3_modules_f_bootcamp", - "a3_modules_f_bootcamp_misc", - "a3_modules_f_curator", - "a3_modules_f_curator_animals", - "a3_modules_f_curator_cas", - "a3_modules_f_curator_chemlights", - "a3_modules_f_curator_curator", - "a3_modules_f_curator_effects", - "a3_modules_f_curator_environment", - "a3_modules_f_curator_flares", - "a3_modules_f_curator_intel", - "a3_modules_f_curator_lightning", - "a3_modules_f_curator_mines", - "a3_modules_f_curator_misc", - "a3_modules_f_curator_multiplayer", - "a3_modules_f_curator_objectives", - "a3_modules_f_curator_ordnance", - "a3_modules_f_curator_respawn", - "a3_modules_f_curator_smokeshells", - "a3_modules_f_dyno", - "a3_modules_f_effects", - "a3_modules_f_epb", - "a3_modules_f_epb_misc", - "a3_modules_f_events", - "a3_modules_f_exp_a", - "a3_modules_f_groupmodifiers", - "a3_modules_f_hc", - "a3_modules_f_heli", - "a3_modules_f_heli_spawnai", - "a3_modules_f_intel", - "a3_modules_f_kart", - "a3_modules_f_kart_timetrials", - "a3_modules_f_livefeed", - "a3_modules_f_mark", - "a3_modules_f_mark_firingdrills", - "a3_modules_f_mark_objectives", - "a3_modules_f_marta", - "a3_modules_f_misc", - "a3_modules_f_mp_mark", - "a3_modules_f_multiplayer", - "a3_modules_f_objectmodifiers", - "a3_modules_f_sites", - "a3_modules_f_skirmish", - "a3_modules_f_strategicmap", - "a3_modules_f_supports", - "a3_modules_f_uav", - "a3_music_f", - "a3_music_f_bootcamp", - "a3_music_f_epa", - "a3_music_f_epb", - "a3_music_f_epc", - "a3_music_f_heli", - "a3_music_f_mark", - "a3_plants_f_bush", - "a3_props_f_exp_a", - "a3_props_f_exp_a_military", - "a3_props_f_exp_a_military_equipment", - "a3_roads_f", - "a3_rocks_f", - "a3_signs_f", - "a3_signs_f_ad", - "a3_soft_f", - "a3_soft_f_beta_quadbike", - "a3_soft_f_bootcamp_offroad_01", - "a3_soft_f_bootcamp_quadbike", - "a3_soft_f_bootcamp_truck", - "a3_soft_f_car", - "a3_soft_f_crusher_ugv", - "a3_soft_f_epc_truck_03", - "a3_soft_f_gamma_hemtt", - "a3_soft_f_gamma_offroad", - "a3_soft_f_gamma_quadbike", - "a3_soft_f_gamma_truckheavy", - "a3_soft_f_heli_car", - "a3_soft_f_heli_crusher_ugv", - "a3_soft_f_heli_mrap_01", - "a3_soft_f_heli_mrap_02", - "a3_soft_f_heli_mrap_03", - "a3_soft_f_heli_quadbike", - "a3_soft_f_heli_suv", - "a3_soft_f_heli_truck", - "a3_soft_f_hemtt", - "a3_soft_f_kart_kart_01", - "a3_soft_f_mrap_01", - "a3_soft_f_mrap_02", - "a3_soft_f_mrap_03", - "a3_soft_f_offroad_01", - "a3_soft_f_quadbike", - "a3_soft_f_suv", - "a3_soft_f_truck", - "a3_soft_f_truckheavy", - "a3_sounds_f", - "a3_sounds_f_bootcamp", - "a3_sounds_f_epb", - "a3_sounds_f_epc", - "a3_sounds_f_exp_a", - "a3_sounds_f_mark", - "a3_static_f", - "a3_static_f_beta_mortar_01", - "a3_static_f_gamma", - "a3_static_f_gamma_aa", - "a3_static_f_gamma_at", - "a3_static_f_gamma_mortar_01", - "a3_static_f_mark_designator_01", - "a3_static_f_mark_designator_02", - "a3_static_f_mortar_01", - "a3_structures_f", - "a3_structures_f_bootcamp_civ_camping", - "a3_structures_f_bootcamp_civ_sportsgrounds", - "a3_structures_f_bootcamp_ind_cargo", - "a3_structures_f_bootcamp_items_electronics", - "a3_structures_f_bootcamp_items_food", - "a3_structures_f_bootcamp_items_sport", - "a3_structures_f_bootcamp_system", - "a3_structures_f_bootcamp_training", - "a3_structures_f_bootcamp_vr_blocks", - "a3_structures_f_bootcamp_vr_coverobjects", - "a3_structures_f_bootcamp_vr_helpers", - "a3_structures_f_bridges", - "a3_structures_f_civ", - "a3_structures_f_civ_accessories", - "a3_structures_f_civ_ancient", - "a3_structures_f_civ_belltowers", - "a3_structures_f_civ_calvaries", - "a3_structures_f_civ_camping", - "a3_structures_f_civ_chapels", - "a3_structures_f_civ_constructions", - "a3_structures_f_civ_dead", - "a3_structures_f_civ_garbage", - "a3_structures_f_civ_graffiti", - "a3_structures_f_civ_infoboards", - "a3_structures_f_civ_kiosks", - "a3_structures_f_civ_lamps", - "a3_structures_f_civ_market", - "a3_structures_f_civ_offices", - "a3_structures_f_civ_pavements", - "a3_structures_f_civ_playground", - "a3_structures_f_civ_sportsgrounds", - "a3_structures_f_civ_statues", - "a3_structures_f_civ_tourism", - "a3_structures_f_dominants", - "a3_structures_f_dominants_amphitheater", - "a3_structures_f_dominants_castle", - "a3_structures_f_dominants_church", - "a3_structures_f_dominants_hospital", - "a3_structures_f_dominants_lighthouse", - "a3_structures_f_dominants_wip", - "a3_structures_f_epa_civ_camping", - "a3_structures_f_epa_civ_constructions", - "a3_structures_f_epa_items_electronics", - "a3_structures_f_epa_items_food", - "a3_structures_f_epa_items_medical", - "a3_structures_f_epa_items_tools", - "a3_structures_f_epa_items_vessels", - "a3_structures_f_epa_mil_scrapyard", - "a3_structures_f_epa_walls", - "a3_structures_f_epb_civ_accessories", - "a3_structures_f_epb_civ_camping", - "a3_structures_f_epb_civ_dead", - "a3_structures_f_epb_civ_garbage", - "a3_structures_f_epb_civ_graffiti", - "a3_structures_f_epb_civ_playground", - "a3_structures_f_epb_furniture", - "a3_structures_f_epb_items_documents", - "a3_structures_f_epb_items_luggage", - "a3_structures_f_epb_items_military", - "a3_structures_f_epb_items_vessels", - "a3_structures_f_epb_naval_fishing", - "a3_structures_f_epc_civ_accessories", - "a3_structures_f_epc_civ_camping", - "a3_structures_f_epc_civ_garbage", - "a3_structures_f_epc_civ_infoboards", - "a3_structures_f_epc_civ_kiosks", - "a3_structures_f_epc_civ_playground", - "a3_structures_f_epc_civ_tourism", - "a3_structures_f_epc_dominants_ghosthotel", - "a3_structures_f_epc_dominants_stadium", - "a3_structures_f_epc_furniture", - "a3_structures_f_epc_items_documents", - "a3_structures_f_epc_items_electronics", - "a3_structures_f_epc_walls", - "a3_structures_f_exp_a", - "a3_structures_f_exp_a_vr_blocks", - "a3_structures_f_exp_a_vr_helpers", - "a3_structures_f_furniture", - "a3_structures_f_heli_civ_accessories", - "a3_structures_f_heli_civ_constructions", - "a3_structures_f_heli_civ_garbage", - "a3_structures_f_heli_civ_market", - "a3_structures_f_heli_furniture", - "a3_structures_f_heli_ind_airport", - "a3_structures_f_heli_ind_cargo", - "a3_structures_f_heli_ind_machines", - "a3_structures_f_heli_items_airport", - "a3_structures_f_heli_items_electronics", - "a3_structures_f_heli_items_food", - "a3_structures_f_heli_items_luggage", - "a3_structures_f_heli_items_sport", - "a3_structures_f_heli_items_tools", - "a3_structures_f_heli_vr_helpers", - "a3_structures_f_households", - "a3_structures_f_households_addons", - "a3_structures_f_households_house_big01", - "a3_structures_f_households_house_big02", - "a3_structures_f_households_house_shop01", - "a3_structures_f_households_house_shop02", - "a3_structures_f_households_house_small01", - "a3_structures_f_households_house_small02", - "a3_structures_f_households_house_small03", - "a3_structures_f_households_slum", - "a3_structures_f_households_stone_big", - "a3_structures_f_households_stone_shed", - "a3_structures_f_households_stone_small", - "a3_structures_f_households_wip", - "a3_structures_f_ind", - "a3_structures_f_ind_airport", - "a3_structures_f_ind_cargo", - "a3_structures_f_ind_carservice", - "a3_structures_f_ind_concretemixingplant", - "a3_structures_f_ind_crane", - "a3_structures_f_ind_dieselpowerplant", - "a3_structures_f_ind_factory", - "a3_structures_f_ind_fuelstation", - "a3_structures_f_ind_fuelstation_small", - "a3_structures_f_ind_pipes", - "a3_structures_f_ind_powerlines", - "a3_structures_f_ind_reservoirtank", - "a3_structures_f_ind_shed", - "a3_structures_f_ind_solarpowerplant", - "a3_structures_f_ind_tank", - "a3_structures_f_ind_transmitter_tower", - "a3_structures_f_ind_wavepowerplant", - "a3_structures_f_ind_windmill", - "a3_structures_f_ind_windpowerplant", - "a3_structures_f_items", - "a3_structures_f_items_cans", - "a3_structures_f_items_documents", - "a3_structures_f_items_electronics", - "a3_structures_f_items_gadgets", - "a3_structures_f_items_luggage", - "a3_structures_f_items_medical", - "a3_structures_f_items_military", - "a3_structures_f_items_stationery", - "a3_structures_f_items_tools", - "a3_structures_f_items_valuables", - "a3_structures_f_items_vessels", - "a3_structures_f_kart_civ_sportsgrounds", - "a3_structures_f_kart_mil_flags", - "a3_structures_f_kart_signs_companies", - "a3_structures_f_mark_items_military", - "a3_structures_f_mark_items_sport", - "a3_structures_f_mark_mil_flags", - "a3_structures_f_mark_training", - "a3_structures_f_mark_vr_helpers", - "a3_structures_f_mark_vr_shapes", - "a3_structures_f_mark_vr_targets", - "a3_structures_f_mil", - "a3_structures_f_mil_bagbunker", - "a3_structures_f_mil_bagfence", - "a3_structures_f_mil_barracks", - "a3_structures_f_mil_bunker", - "a3_structures_f_mil_cargo", - "a3_structures_f_mil_flags", - "a3_structures_f_mil_fortification", - "a3_structures_f_mil_helipads", - "a3_structures_f_mil_offices", - "a3_structures_f_mil_radar", - "a3_structures_f_mil_scrapyard", - "a3_structures_f_mil_shelters", - "a3_structures_f_mil_tenthangar", - "a3_structures_f_naval", - "a3_structures_f_naval_buoys", - "a3_structures_f_naval_fishing", - "a3_structures_f_naval_piers", - "a3_structures_f_naval_rowboats", - "a3_structures_f_research", - "a3_structures_f_signs_companies", - "a3_structures_f_system", - "a3_structures_f_training", - "a3_structures_f_training_invisibletarget", - "a3_structures_f_walls", - "a3_structures_f_wrecks", - "a3_supplies_f_heli", - "a3_supplies_f_heli_bladders", - "a3_supplies_f_heli_cargonets", - "a3_supplies_f_heli_fuel", - "a3_supplies_f_heli_slingload", - "a3_supplies_f_mark", - "a3_uav_f_characters_f_gamma", - "a3_uav_f_weapons_f_gamma_ammoboxes", - "a3_ui_f", - "a3_ui_f_bootcamp", - "a3_ui_f_curator", - "a3_ui_f_exp_a", - "a3_ui_f_heli", - "a3_ui_f_kart", - "a3_ui_f_mark", - "a3_ui_f_mp_mark", - "a3_uifonts_f", - "a3_weapons_f", - "a3_weapons_f_aaf", - "a3_weapons_f_acc", - "a3_weapons_f_ammoboxes", - "a3_weapons_f_beta", - "a3_weapons_f_beta_acc", - "a3_weapons_f_beta_ammoboxes", - "a3_weapons_f_beta_ebr", - "a3_weapons_f_beta_rifles_khaybar", - "a3_weapons_f_beta_rifles_mx", - "a3_weapons_f_beta_rifles_trg20", - "a3_weapons_f_bootcamp", - "a3_weapons_f_bootcamp_ammoboxes", - "a3_weapons_f_bootcamp_longrangerifles_gm6", - "a3_weapons_f_bootcamp_longrangerifles_m320", - "a3_weapons_f_csat", - "a3_weapons_f_dummyweapons", - "a3_weapons_f_ebr", - "a3_weapons_f_epa", - "a3_weapons_f_epa_acc", - "a3_weapons_f_epa_ammoboxes", - "a3_weapons_f_epa_ebr", - "a3_weapons_f_epa_longrangerifles_dmr_01", - "a3_weapons_f_epa_longrangerifles_gm6", - "a3_weapons_f_epa_rifles_mx", - "a3_weapons_f_epb", - "a3_weapons_f_epb_acc", - "a3_weapons_f_epb_ammoboxes", - "a3_weapons_f_epb_longrangerifles_gm3", - "a3_weapons_f_epb_longrangerifles_m320", - "a3_weapons_f_epb_rifles_mx_black", - "a3_weapons_f_epc", - "a3_weapons_f_explosives", - "a3_weapons_f_fia", - "a3_weapons_f_gamma", - "a3_weapons_f_gamma_acc", - "a3_weapons_f_gamma_ammoboxes", - "a3_weapons_f_gamma_items", - "a3_weapons_f_headgear", - "a3_weapons_f_itemholders", - "a3_weapons_f_items", - "a3_weapons_f_kart", - "a3_weapons_f_kart_pistols_pistol_signal_f", - "a3_weapons_f_launchers_law", - "a3_weapons_f_launchers_nlaw", - "a3_weapons_f_launchers_titan", - "a3_weapons_f_longrangerifles_gm6", - "a3_weapons_f_longrangerifles_m320", - "a3_weapons_f_machineguns_m200", - "a3_weapons_f_machineguns_zafir", - "a3_weapons_f_mark", - "a3_weapons_f_mark_acc", - "a3_weapons_f_mark_ebr", - "a3_weapons_f_mark_longrangerifles_dmr_01", - "a3_weapons_f_mark_longrangerifles_dmr_02", - "a3_weapons_f_mark_longrangerifles_dmr_03", - "a3_weapons_f_mark_longrangerifles_dmr_04", - "a3_weapons_f_mark_longrangerifles_dmr_05", - "a3_weapons_f_mark_longrangerifles_dmr_06", - "a3_weapons_f_mark_longrangerifles_gm6", - "a3_weapons_f_mark_longrangerifles_gm6_camo", - "a3_weapons_f_mark_longrangerifles_m320", - "a3_weapons_f_mark_longrangerifles_m320_camo", - "a3_weapons_f_mark_machineguns_m200", - "a3_weapons_f_mark_machineguns_mmg_01", - "a3_weapons_f_mark_machineguns_mmg_02", - "a3_weapons_f_mark_machineguns_zafir", - "a3_weapons_f_mark_rifles_khaybar", - "a3_weapons_f_mark_rifles_mk20", - "a3_weapons_f_mark_rifles_mx", - "a3_weapons_f_mark_rifles_sdar", - "a3_weapons_f_mark_rifles_trg20", - "a3_weapons_f_nato", - "a3_weapons_f_pistols_acpc2", - "a3_weapons_f_pistols_p07", - "a3_weapons_f_pistols_pdw2000", - "a3_weapons_f_pistols_pistol_heavy_01", - "a3_weapons_f_pistols_pistol_heavy_02", - "a3_weapons_f_pistols_rook40", - "a3_weapons_f_rifles_khaybar", - "a3_weapons_f_rifles_mk20", - "a3_weapons_f_rifles_mx", - "a3_weapons_f_rifles_sdar", - "a3_weapons_f_rifles_smg_02", - "a3_weapons_f_rifles_trg20", - "a3_weapons_f_rifles_vector", - "a3_weapons_f_uniforms", - "a3_weapons_f_vests", - "a3data", - "map_vr", - // CBA - "extended_eventhandlers", - "cba_ui", - "cba_xeh", - "cba_xeh_a3", - "cba_jr" - }; - author[] = {ECSTRING(common,ACETeam)}; - authorUrl = "http://ace3mod.com/"; - VERSION_CONFIG; - }; -}; - -class CfgMods { - class PREFIX { - dir = "@ace"; - name = "Advanced Combat Environment 3"; - picture = "A3\Ui_f\data\Logos\arma3_expansion_alpha_ca"; - hidePicture = "true"; - hideName = "true"; - actionName = "Website"; - action = "http://ace3mod.com/"; - description = "Issue Tracker: https://github.com/acemod/ACE3/issues"; - }; -}; - -#include "CfgSettings.hpp" -#include "CfgModuleCategories.hpp" -#include "CfgVehicleClasses.hpp" +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { + // Vanilla + "3den", + "a3_air_f", + "a3_air_f_beta", + "a3_air_f_beta_heli_attack_01", + "a3_air_f_beta_heli_attack_02", + "a3_air_f_beta_heli_transport_01", + "a3_air_f_beta_heli_transport_02", + "a3_air_f_beta_parachute_01", + "a3_air_f_beta_parachute_02", + "a3_air_f_epb_heli_light_03", + "a3_air_f_epc_plane_cas_01", + "a3_air_f_epc_plane_cas_02", + "a3_air_f_epc_plane_fighter_03", + "a3_air_f_gamma_plane_fighter_03", + "a3_air_f_gamma_uav_01", + "a3_air_f_gamma_uav_02", + "a3_air_f_heli", + "a3_air_f_heli_heli_attack_01", + "a3_air_f_heli_heli_attack_02", + "a3_air_f_heli_heli_light_01", + "a3_air_f_heli_heli_light_02", + "a3_air_f_heli_heli_light_03", + "a3_air_f_heli_heli_transport_01", + "a3_air_f_heli_heli_transport_02", + "a3_air_f_heli_heli_transport_03", + "a3_air_f_heli_heli_transport_04", + "a3_air_f_heli_light_01", + "a3_air_f_heli_light_02", + "a3_animals_f", + "a3_animals_f_animconfig", + "a3_animals_f_chicken", + "a3_animals_f_dog", + "a3_animals_f_fishes", + "a3_animals_f_goat", + "a3_animals_f_kestrel", + "a3_animals_f_rabbit", + "a3_animals_f_seagull", + "a3_animals_f_sheep", + "a3_animals_f_snakes", + "a3_animals_f_turtle", + "a3_anims_f", + "a3_anims_f_config_sdr", + "a3_anims_f_epa", + "a3_anims_f_epc", + "a3_anims_f_exp_a", + "a3_anims_f_heli", + "a3_anims_f_kart", + "a3_anims_f_mark_deployment", + "a3_armor_f", + "a3_armor_f_amv", + "a3_armor_f_apc_wheeled_03", + "a3_armor_f_beta", + "a3_armor_f_beta_apc_tracked_02", + "a3_armor_f_epb_apc_tracked_03", + "a3_armor_f_epb_mbt_03", + "a3_armor_f_epc_mbt_01", + "a3_armor_f_marid", + "a3_armor_f_panther", + "a3_armor_f_slammer", + "a3_armor_f_t100k", + "a3_baseconfig_f", + "a3_boat_f", + "a3_boat_f_beta_boat_armed_01", + "a3_boat_f_beta_boat_transport_01", + "a3_boat_f_boat_armed_01", + "a3_boat_f_boat_transport_01", + "a3_boat_f_civilian_boat", + "a3_boat_f_epc_submarine_01_f", + "a3_boat_f_gamma_boat_transport_01", + "a3_boat_f_heli_boat_armed_01", + "a3_boat_f_heli_sdv_01", + "a3_boat_f_sdv_01", + "a3_boat_f_trawler", + "a3_cargoposes_f", + "a3_cargoposes_f_heli", + "a3_characters_f", + "a3_characters_f_beta", + "a3_characters_f_blufor", + "a3_characters_f_bootcamp", + "a3_characters_f_bootcamp_common", + "a3_characters_f_civil", + "a3_characters_f_common", + "a3_characters_f_epa", + "a3_characters_f_epb", + "a3_characters_f_epb_heads", + "a3_characters_f_epc", + "a3_characters_f_gamma", + "a3_characters_f_heads", + "a3_characters_f_indep", + "a3_characters_f_kart", + "a3_characters_f_mark", + "a3_characters_f_opfor", + "a3_characters_f_proxies", + "a3_data_f", + "a3_data_f_bootcamp", + "a3_data_f_curator", + "a3_data_f_curator_characters", + "a3_data_f_curator_eagle", + "a3_data_f_curator_intel", + "a3_data_f_curator_misc", + "a3_data_f_curator_respawn", + "a3_data_f_curator_virtual", + "a3_data_f_exp_a", + "a3_data_f_exp_a_virtual", + "a3_data_f_exp_b", + "a3_data_f_heli", + "a3_data_f_hook", + "a3_data_f_kart", + "a3_data_f_kart_particleeffects", + "a3_data_f_mark", + "a3_data_f_particleeffects", + "a3_dubbing_radio_f", + "a3_editor_f", + "a3_functions_f", + "a3_functions_f_bootcamp", + "a3_functions_f_curator", + "a3_functions_f_epa", + "a3_functions_f_epc", + "a3_functions_f_exp_a", + "a3_functions_f_heli", + "a3_functions_f_mark", + "a3_functions_f_mp_mark", + "a3_language_f", + "a3_language_f_beta", + "a3_language_f_bootcamp", + "a3_language_f_curator", + "a3_language_f_epa", + "a3_language_f_epb", + "a3_language_f_epc", + "a3_language_f_exp_a", + "a3_language_f_gamma", + "a3_language_f_heli", + "a3_language_f_kart", + "a3_language_f_mark", + "a3_language_f_mp_mark", + "a3_languagemissions_f", + "a3_languagemissions_f_beta", + "a3_languagemissions_f_gamma", + "a3_languagemissions_f_kart", + "a3_languagemissions_f_mp_mark", + "a3_map_altis", + "a3_map_altis_scenes", + "a3_map_data", + "a3_map_stratis", + "a3_map_stratis_scenes", + "a3_map_vr_scenes", + "a3_misc_f", + "a3_misc_f_helpers", + "a3_missions_f", + "a3_missions_f_beta", + "a3_missions_f_bootcamp", + "a3_missions_f_curator", + "a3_missions_f_epa", + "a3_missions_f_epb", + "a3_missions_f_epc", + "a3_missions_f_exp_a", + "a3_missions_f_gamma", + "a3_missions_f_heli", + "a3_missions_f_kart", + "a3_missions_f_mark", + "a3_missions_f_mp_mark", + "a3_modules_f", + "a3_modules_f_beta", + "a3_modules_f_beta_firingdrills", + "a3_modules_f_bootcamp", + "a3_modules_f_bootcamp_misc", + "a3_modules_f_curator", + "a3_modules_f_curator_animals", + "a3_modules_f_curator_cas", + "a3_modules_f_curator_chemlights", + "a3_modules_f_curator_curator", + "a3_modules_f_curator_effects", + "a3_modules_f_curator_environment", + "a3_modules_f_curator_flares", + "a3_modules_f_curator_intel", + "a3_modules_f_curator_lightning", + "a3_modules_f_curator_mines", + "a3_modules_f_curator_misc", + "a3_modules_f_curator_multiplayer", + "a3_modules_f_curator_objectives", + "a3_modules_f_curator_ordnance", + "a3_modules_f_curator_respawn", + "a3_modules_f_curator_smokeshells", + "a3_modules_f_dyno", + "a3_modules_f_effects", + "a3_modules_f_epb", + "a3_modules_f_epb_misc", + "a3_modules_f_events", + "a3_modules_f_exp_a", + "a3_modules_f_groupmodifiers", + "a3_modules_f_hc", + "a3_modules_f_heli", + "a3_modules_f_heli_spawnai", + "a3_modules_f_intel", + "a3_modules_f_kart", + "a3_modules_f_kart_timetrials", + "a3_modules_f_livefeed", + "a3_modules_f_mark", + "a3_modules_f_mark_firingdrills", + "a3_modules_f_mark_objectives", + "a3_modules_f_marta", + "a3_modules_f_misc", + "a3_modules_f_mp_mark", + "a3_modules_f_multiplayer", + "a3_modules_f_objectmodifiers", + "a3_modules_f_sites", + "a3_modules_f_skirmish", + "a3_modules_f_strategicmap", + "a3_modules_f_supports", + "a3_modules_f_uav", + "a3_music_f", + "a3_music_f_bootcamp", + "a3_music_f_epa", + "a3_music_f_epb", + "a3_music_f_epc", + "a3_music_f_heli", + "a3_music_f_mark", + "a3_plants_f_bush", + "a3_props_f_exp_a", + "a3_props_f_exp_a_military", + "a3_props_f_exp_a_military_equipment", + "a3_roads_f", + "a3_rocks_f", + "a3_signs_f", + "a3_signs_f_ad", + "a3_soft_f", + "a3_soft_f_beta_quadbike", + "a3_soft_f_bootcamp_offroad_01", + "a3_soft_f_bootcamp_quadbike", + "a3_soft_f_bootcamp_truck", + "a3_soft_f_car", + "a3_soft_f_crusher_ugv", + "a3_soft_f_epc_truck_03", + "a3_soft_f_gamma_hemtt", + "a3_soft_f_gamma_offroad", + "a3_soft_f_gamma_quadbike", + "a3_soft_f_gamma_truckheavy", + "a3_soft_f_heli_car", + "a3_soft_f_heli_crusher_ugv", + "a3_soft_f_heli_mrap_01", + "a3_soft_f_heli_mrap_02", + "a3_soft_f_heli_mrap_03", + "a3_soft_f_heli_quadbike", + "a3_soft_f_heli_suv", + "a3_soft_f_heli_truck", + "a3_soft_f_hemtt", + "a3_soft_f_kart_kart_01", + "a3_soft_f_mrap_01", + "a3_soft_f_mrap_02", + "a3_soft_f_mrap_03", + "a3_soft_f_offroad_01", + "a3_soft_f_quadbike", + "a3_soft_f_suv", + "a3_soft_f_truck", + "a3_soft_f_truckheavy", + "a3_sounds_f", + "a3_sounds_f_bootcamp", + "a3_sounds_f_epb", + "a3_sounds_f_epc", + "a3_sounds_f_exp_a", + "a3_sounds_f_mark", + "a3_static_f", + "a3_static_f_beta_mortar_01", + "a3_static_f_gamma", + "a3_static_f_gamma_aa", + "a3_static_f_gamma_at", + "a3_static_f_gamma_mortar_01", + "a3_static_f_mark_designator_01", + "a3_static_f_mark_designator_02", + "a3_static_f_mortar_01", + "a3_structures_f", + "a3_structures_f_bootcamp_civ_camping", + "a3_structures_f_bootcamp_civ_sportsgrounds", + "a3_structures_f_bootcamp_ind_cargo", + "a3_structures_f_bootcamp_items_electronics", + "a3_structures_f_bootcamp_items_food", + "a3_structures_f_bootcamp_items_sport", + "a3_structures_f_bootcamp_system", + "a3_structures_f_bootcamp_training", + "a3_structures_f_bootcamp_vr_blocks", + "a3_structures_f_bootcamp_vr_coverobjects", + "a3_structures_f_bootcamp_vr_helpers", + "a3_structures_f_bridges", + "a3_structures_f_civ", + "a3_structures_f_civ_accessories", + "a3_structures_f_civ_ancient", + "a3_structures_f_civ_belltowers", + "a3_structures_f_civ_calvaries", + "a3_structures_f_civ_camping", + "a3_structures_f_civ_chapels", + "a3_structures_f_civ_constructions", + "a3_structures_f_civ_dead", + "a3_structures_f_civ_garbage", + "a3_structures_f_civ_graffiti", + "a3_structures_f_civ_infoboards", + "a3_structures_f_civ_kiosks", + "a3_structures_f_civ_lamps", + "a3_structures_f_civ_market", + "a3_structures_f_civ_offices", + "a3_structures_f_civ_pavements", + "a3_structures_f_civ_playground", + "a3_structures_f_civ_sportsgrounds", + "a3_structures_f_civ_statues", + "a3_structures_f_civ_tourism", + "a3_structures_f_dominants", + "a3_structures_f_dominants_amphitheater", + "a3_structures_f_dominants_castle", + "a3_structures_f_dominants_church", + "a3_structures_f_dominants_hospital", + "a3_structures_f_dominants_lighthouse", + "a3_structures_f_dominants_wip", + "a3_structures_f_epa_civ_camping", + "a3_structures_f_epa_civ_constructions", + "a3_structures_f_epa_items_electronics", + "a3_structures_f_epa_items_food", + "a3_structures_f_epa_items_medical", + "a3_structures_f_epa_items_tools", + "a3_structures_f_epa_items_vessels", + "a3_structures_f_epa_mil_scrapyard", + "a3_structures_f_epa_walls", + "a3_structures_f_epb_civ_accessories", + "a3_structures_f_epb_civ_camping", + "a3_structures_f_epb_civ_dead", + "a3_structures_f_epb_civ_garbage", + "a3_structures_f_epb_civ_graffiti", + "a3_structures_f_epb_civ_playground", + "a3_structures_f_epb_furniture", + "a3_structures_f_epb_items_documents", + "a3_structures_f_epb_items_luggage", + "a3_structures_f_epb_items_military", + "a3_structures_f_epb_items_vessels", + "a3_structures_f_epb_naval_fishing", + "a3_structures_f_epc_civ_accessories", + "a3_structures_f_epc_civ_camping", + "a3_structures_f_epc_civ_garbage", + "a3_structures_f_epc_civ_infoboards", + "a3_structures_f_epc_civ_kiosks", + "a3_structures_f_epc_civ_playground", + "a3_structures_f_epc_civ_tourism", + "a3_structures_f_epc_dominants_ghosthotel", + "a3_structures_f_epc_dominants_stadium", + "a3_structures_f_epc_furniture", + "a3_structures_f_epc_items_documents", + "a3_structures_f_epc_items_electronics", + "a3_structures_f_epc_walls", + "a3_structures_f_exp_a", + "a3_structures_f_exp_a_vr_blocks", + "a3_structures_f_exp_a_vr_helpers", + "a3_structures_f_furniture", + "a3_structures_f_heli_civ_accessories", + "a3_structures_f_heli_civ_constructions", + "a3_structures_f_heli_civ_garbage", + "a3_structures_f_heli_civ_market", + "a3_structures_f_heli_furniture", + "a3_structures_f_heli_ind_airport", + "a3_structures_f_heli_ind_cargo", + "a3_structures_f_heli_ind_machines", + "a3_structures_f_heli_items_airport", + "a3_structures_f_heli_items_electronics", + "a3_structures_f_heli_items_food", + "a3_structures_f_heli_items_luggage", + "a3_structures_f_heli_items_sport", + "a3_structures_f_heli_items_tools", + "a3_structures_f_heli_vr_helpers", + "a3_structures_f_households", + "a3_structures_f_households_addons", + "a3_structures_f_households_house_big01", + "a3_structures_f_households_house_big02", + "a3_structures_f_households_house_shop01", + "a3_structures_f_households_house_shop02", + "a3_structures_f_households_house_small01", + "a3_structures_f_households_house_small02", + "a3_structures_f_households_house_small03", + "a3_structures_f_households_slum", + "a3_structures_f_households_stone_big", + "a3_structures_f_households_stone_shed", + "a3_structures_f_households_stone_small", + "a3_structures_f_households_wip", + "a3_structures_f_ind", + "a3_structures_f_ind_airport", + "a3_structures_f_ind_cargo", + "a3_structures_f_ind_carservice", + "a3_structures_f_ind_concretemixingplant", + "a3_structures_f_ind_crane", + "a3_structures_f_ind_dieselpowerplant", + "a3_structures_f_ind_factory", + "a3_structures_f_ind_fuelstation", + "a3_structures_f_ind_fuelstation_small", + "a3_structures_f_ind_pipes", + "a3_structures_f_ind_powerlines", + "a3_structures_f_ind_reservoirtank", + "a3_structures_f_ind_shed", + "a3_structures_f_ind_solarpowerplant", + "a3_structures_f_ind_tank", + "a3_structures_f_ind_transmitter_tower", + "a3_structures_f_ind_wavepowerplant", + "a3_structures_f_ind_windmill", + "a3_structures_f_ind_windpowerplant", + "a3_structures_f_items", + "a3_structures_f_items_cans", + "a3_structures_f_items_documents", + "a3_structures_f_items_electronics", + "a3_structures_f_items_gadgets", + "a3_structures_f_items_luggage", + "a3_structures_f_items_medical", + "a3_structures_f_items_military", + "a3_structures_f_items_stationery", + "a3_structures_f_items_tools", + "a3_structures_f_items_valuables", + "a3_structures_f_items_vessels", + "a3_structures_f_kart_civ_sportsgrounds", + "a3_structures_f_kart_mil_flags", + "a3_structures_f_kart_signs_companies", + "a3_structures_f_mark_items_military", + "a3_structures_f_mark_items_sport", + "a3_structures_f_mark_mil_flags", + "a3_structures_f_mark_training", + "a3_structures_f_mark_vr_helpers", + "a3_structures_f_mark_vr_shapes", + "a3_structures_f_mark_vr_targets", + "a3_structures_f_mil", + "a3_structures_f_mil_bagbunker", + "a3_structures_f_mil_bagfence", + "a3_structures_f_mil_barracks", + "a3_structures_f_mil_bunker", + "a3_structures_f_mil_cargo", + "a3_structures_f_mil_flags", + "a3_structures_f_mil_fortification", + "a3_structures_f_mil_helipads", + "a3_structures_f_mil_offices", + "a3_structures_f_mil_radar", + "a3_structures_f_mil_scrapyard", + "a3_structures_f_mil_shelters", + "a3_structures_f_mil_tenthangar", + "a3_structures_f_naval", + "a3_structures_f_naval_buoys", + "a3_structures_f_naval_fishing", + "a3_structures_f_naval_piers", + "a3_structures_f_naval_rowboats", + "a3_structures_f_research", + "a3_structures_f_signs_companies", + "a3_structures_f_system", + "a3_structures_f_training", + "a3_structures_f_training_invisibletarget", + "a3_structures_f_walls", + "a3_structures_f_wrecks", + "a3_supplies_f_heli", + "a3_supplies_f_heli_bladders", + "a3_supplies_f_heli_cargonets", + "a3_supplies_f_heli_fuel", + "a3_supplies_f_heli_slingload", + "a3_supplies_f_mark", + "a3_uav_f_characters_f_gamma", + "a3_uav_f_weapons_f_gamma_ammoboxes", + "a3_ui_f", + "a3_ui_f_bootcamp", + "a3_ui_f_curator", + "a3_ui_f_exp_a", + "a3_ui_f_heli", + "a3_ui_f_kart", + "a3_ui_f_mark", + "a3_ui_f_mp_mark", + "a3_uifonts_f", + "a3_weapons_f", + "a3_weapons_f_aaf", + "a3_weapons_f_acc", + "a3_weapons_f_ammoboxes", + "a3_weapons_f_beta", + "a3_weapons_f_beta_acc", + "a3_weapons_f_beta_ammoboxes", + "a3_weapons_f_beta_ebr", + "a3_weapons_f_beta_rifles_khaybar", + "a3_weapons_f_beta_rifles_mx", + "a3_weapons_f_beta_rifles_trg20", + "a3_weapons_f_bootcamp", + "a3_weapons_f_bootcamp_ammoboxes", + "a3_weapons_f_bootcamp_longrangerifles_gm6", + "a3_weapons_f_bootcamp_longrangerifles_m320", + "a3_weapons_f_csat", + "a3_weapons_f_dummyweapons", + "a3_weapons_f_ebr", + "a3_weapons_f_epa", + "a3_weapons_f_epa_acc", + "a3_weapons_f_epa_ammoboxes", + "a3_weapons_f_epa_ebr", + "a3_weapons_f_epa_longrangerifles_dmr_01", + "a3_weapons_f_epa_longrangerifles_gm6", + "a3_weapons_f_epa_rifles_mx", + "a3_weapons_f_epb", + "a3_weapons_f_epb_acc", + "a3_weapons_f_epb_ammoboxes", + "a3_weapons_f_epb_longrangerifles_gm3", + "a3_weapons_f_epb_longrangerifles_m320", + "a3_weapons_f_epb_rifles_mx_black", + "a3_weapons_f_epc", + "a3_weapons_f_explosives", + "a3_weapons_f_fia", + "a3_weapons_f_gamma", + "a3_weapons_f_gamma_acc", + "a3_weapons_f_gamma_ammoboxes", + "a3_weapons_f_gamma_items", + "a3_weapons_f_headgear", + "a3_weapons_f_itemholders", + "a3_weapons_f_items", + "a3_weapons_f_kart", + "a3_weapons_f_kart_pistols_pistol_signal_f", + "a3_weapons_f_launchers_law", + "a3_weapons_f_launchers_nlaw", + "a3_weapons_f_launchers_titan", + "a3_weapons_f_longrangerifles_gm6", + "a3_weapons_f_longrangerifles_m320", + "a3_weapons_f_machineguns_m200", + "a3_weapons_f_machineguns_zafir", + "a3_weapons_f_mark", + "a3_weapons_f_mark_acc", + "a3_weapons_f_mark_ebr", + "a3_weapons_f_mark_longrangerifles_dmr_01", + "a3_weapons_f_mark_longrangerifles_dmr_02", + "a3_weapons_f_mark_longrangerifles_dmr_03", + "a3_weapons_f_mark_longrangerifles_dmr_04", + "a3_weapons_f_mark_longrangerifles_dmr_05", + "a3_weapons_f_mark_longrangerifles_dmr_06", + "a3_weapons_f_mark_longrangerifles_gm6", + "a3_weapons_f_mark_longrangerifles_gm6_camo", + "a3_weapons_f_mark_longrangerifles_m320", + "a3_weapons_f_mark_longrangerifles_m320_camo", + "a3_weapons_f_mark_machineguns_m200", + "a3_weapons_f_mark_machineguns_mmg_01", + "a3_weapons_f_mark_machineguns_mmg_02", + "a3_weapons_f_mark_machineguns_zafir", + "a3_weapons_f_mark_rifles_khaybar", + "a3_weapons_f_mark_rifles_mk20", + "a3_weapons_f_mark_rifles_mx", + "a3_weapons_f_mark_rifles_sdar", + "a3_weapons_f_mark_rifles_trg20", + "a3_weapons_f_nato", + "a3_weapons_f_pistols_acpc2", + "a3_weapons_f_pistols_p07", + "a3_weapons_f_pistols_pdw2000", + "a3_weapons_f_pistols_pistol_heavy_01", + "a3_weapons_f_pistols_pistol_heavy_02", + "a3_weapons_f_pistols_rook40", + "a3_weapons_f_rifles_khaybar", + "a3_weapons_f_rifles_mk20", + "a3_weapons_f_rifles_mx", + "a3_weapons_f_rifles_sdar", + "a3_weapons_f_rifles_smg_02", + "a3_weapons_f_rifles_trg20", + "a3_weapons_f_rifles_vector", + "a3_weapons_f_uniforms", + "a3_weapons_f_vests", + "a3data", + "map_vr", + // CBA + "extended_eventhandlers", + "cba_ui", + "cba_xeh", + "cba_xeh_a3", + "cba_jr" + }; + author[] = {ECSTRING(common,ACETeam)}; + authorUrl = "http://ace3mod.com/"; + VERSION_CONFIG; + }; +}; + +class CfgMods { + class PREFIX { + dir = "@ace"; + name = "Advanced Combat Environment 3"; + picture = "A3\Ui_f\data\Logos\arma3_expansion_alpha_ca"; + hidePicture = "true"; + hideName = "true"; + actionName = "Website"; + action = "http://ace3mod.com/"; + description = "Issue Tracker: https://github.com/acemod/ACE3/issues"; + }; +}; + +#include "CfgSettings.hpp" +#include "CfgModuleCategories.hpp" +#include "CfgVehicleClasses.hpp" diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp index dd7f17429e..99069a4911 100644 --- a/addons/main/script_component.hpp +++ b/addons/main/script_component.hpp @@ -1,17 +1,17 @@ -#define COMPONENT main -#include "\z\ace\addons\main\script_mod.hpp" - -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS -// #define ENABLE_PERFORMANCE_COUNTERS - -#ifdef DEBUG_ENABLED_MAIN - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_MAIN - #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN -#endif - -#include "\z\ace\addons\main\script_macros.hpp" +#define COMPONENT main +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/main/script_debug.hpp b/addons/main/script_debug.hpp index 315a26a65f..92f58e1f96 100644 --- a/addons/main/script_debug.hpp +++ b/addons/main/script_debug.hpp @@ -1,40 +1,40 @@ -/** -STACK TRACING -**/ -//#define ENABLE_CALLSTACK -//#define ENABLE_PERFORMANCE_COUNTERS -//#define DEBUG_EVENTS - -#ifdef ENABLE_CALLSTACK - #define CALLSTACK(function) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'ANON', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'ANON'; _ret = _this call ##function; ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;} - #define CALLSTACK_NAMED(function, functionName) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, functionName, _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = functionName; _ret = _this call ##function; ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;} - #define DUMPSTACK ([__FILE__, __LINE__] call ACE_DUMPSTACK_FNC) - - #define FUNC(var1) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'TRIPLES(ADDON,fnc,var1)', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'TRIPLES(ADDON,fnc,var1)'; _ret = _this call TRIPLES(ADDON,fnc,var1); ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;} - #define EFUNC(var1,var2) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)'; _ret = _this call TRIPLES(DOUBLES(PREFIX,var1),fnc,var2); ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;} -#else - #define CALLSTACK(function) function - #define CALLSTACK_NAMED(function, functionName) function - #define DUMPSTACK -#endif - - -/** -PERFORMANCE COUNTERS SECTION -**/ -//#define ENABLE_PERFORMANCE_COUNTERS - -#ifdef ENABLE_PERFORMANCE_COUNTERS - #define CBA_fnc_addPerFrameHandler { _ret = [(_this select 0), (_this select 1), (_this select 2), #function] call CBA_fnc_addPerFrameHandler; if(isNil "ACE_PFH_COUNTER" ) then { ACE_PFH_COUNTER=[]; }; ACE_PFH_COUNTER pushBack [[_ret, __FILE__, __LINE__], [(_this select 0), (_this select 1), (_this select 2)]]; _ret } - - #define CREATE_COUNTER(x) if(isNil "ACE_COUNTERS" ) then { ACE_COUNTERS=[]; }; GVAR(DOUBLES(x,counter))=[]; GVAR(DOUBLES(x,counter)) set[0, QUOTE(GVAR(DOUBLES(x,counter)))]; GVAR(DOUBLES(x,counter)) set[1, diag_tickTime]; ACE_COUNTERS pushBack GVAR(DOUBLES(x,counter)); - #define BEGIN_COUNTER(x) if(isNil QUOTE(GVAR(DOUBLES(x,counter)))) then { CREATE_COUNTER(x) }; GVAR(DOUBLES(x,counter)) set[2, diag_tickTime]; - #define END_COUNTER(x) GVAR(DOUBLES(x,counter)) pushBack [(GVAR(DOUBLES(x,counter)) select 2), diag_tickTime]; - - #define DUMP_COUNTERS ([__FILE__, __LINE__] call ACE_DUMPCOUNTERS_FNC) -#else - #define CREATE_COUNTER(x) /* disabled */ - #define BEGIN_COUNTER(x) /* disabled */ - #define END_COUNTER(x) /* disabled */ - #define DUMP_COUNTERS /* disabled */ -#endif +/** +STACK TRACING +**/ +//#define ENABLE_CALLSTACK +//#define ENABLE_PERFORMANCE_COUNTERS +//#define DEBUG_EVENTS + +#ifdef ENABLE_CALLSTACK + #define CALLSTACK(function) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'ANON', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'ANON'; _ret = _this call ##function; ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;} + #define CALLSTACK_NAMED(function, functionName) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, functionName, _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = functionName; _ret = _this call ##function; ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;} + #define DUMPSTACK ([__FILE__, __LINE__] call ACE_DUMPSTACK_FNC) + + #define FUNC(var1) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'TRIPLES(ADDON,fnc,var1)', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'TRIPLES(ADDON,fnc,var1)'; _ret = _this call TRIPLES(ADDON,fnc,var1); ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;} + #define EFUNC(var1,var2) {private ['_ret']; if(ACE_IS_ERRORED) then { ['AUTO','AUTO'] call ACE_DUMPSTACK_FNC; ACE_IS_ERRORED = false; }; ACE_IS_ERRORED = true; ACE_STACK_TRACE set [ACE_STACK_DEPTH, [diag_tickTime, __FILE__, __LINE__, ACE_CURRENT_FUNCTION, 'TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)', _this]]; ACE_STACK_DEPTH = ACE_STACK_DEPTH + 1; ACE_CURRENT_FUNCTION = 'TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)'; _ret = _this call TRIPLES(DOUBLES(PREFIX,var1),fnc,var2); ACE_STACK_DEPTH = ACE_STACK_DEPTH - 1; ACE_IS_ERRORED = false; _ret;} +#else + #define CALLSTACK(function) function + #define CALLSTACK_NAMED(function, functionName) function + #define DUMPSTACK +#endif + + +/** +PERFORMANCE COUNTERS SECTION +**/ +//#define ENABLE_PERFORMANCE_COUNTERS + +#ifdef ENABLE_PERFORMANCE_COUNTERS + #define CBA_fnc_addPerFrameHandler { _ret = [(_this select 0), (_this select 1), (_this select 2), #function] call CBA_fnc_addPerFrameHandler; if(isNil "ACE_PFH_COUNTER" ) then { ACE_PFH_COUNTER=[]; }; ACE_PFH_COUNTER pushBack [[_ret, __FILE__, __LINE__], [(_this select 0), (_this select 1), (_this select 2)]]; _ret } + + #define CREATE_COUNTER(x) if(isNil "ACE_COUNTERS" ) then { ACE_COUNTERS=[]; }; GVAR(DOUBLES(x,counter))=[]; GVAR(DOUBLES(x,counter)) set[0, QUOTE(GVAR(DOUBLES(x,counter)))]; GVAR(DOUBLES(x,counter)) set[1, diag_tickTime]; ACE_COUNTERS pushBack GVAR(DOUBLES(x,counter)); + #define BEGIN_COUNTER(x) if(isNil QUOTE(GVAR(DOUBLES(x,counter)))) then { CREATE_COUNTER(x) }; GVAR(DOUBLES(x,counter)) set[2, diag_tickTime]; + #define END_COUNTER(x) GVAR(DOUBLES(x,counter)) pushBack [(GVAR(DOUBLES(x,counter)) select 2), diag_tickTime]; + + #define DUMP_COUNTERS ([__FILE__, __LINE__] call ACE_DUMPCOUNTERS_FNC) +#else + #define CREATE_COUNTER(x) /* disabled */ + #define BEGIN_COUNTER(x) /* disabled */ + #define END_COUNTER(x) /* disabled */ + #define DUMP_COUNTERS /* disabled */ +#endif diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index a64c8e014d..dc06424727 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -1,210 +1,210 @@ -#include "\x\cba\addons\main\script_macros_common.hpp" -#include "\x\cba\addons\xeh\script_xeh.hpp" - -// Default versioning level -#define DEFAULT_VERSIONING_LEVEL 2 - -#define DGVAR(varName) if(isNil "ACE_DEBUG_NAMESPACE") then { ACE_DEBUG_NAMESPACE = []; }; if(!(QUOTE(GVAR(varName)) in ACE_DEBUG_NAMESPACE)) then { PUSH(ACE_DEBUG_NAMESPACE, QUOTE(GVAR(varName))); }; GVAR(varName) -#define DVAR(varName) if(isNil "ACE_DEBUG_NAMESPACE") then { ACE_DEBUG_NAMESPACE = []; }; if(!(QUOTE(varName) in ACE_DEBUG_NAMESPACE)) then { PUSH(ACE_DEBUG_NAMESPACE, QUOTE(varName)); }; varName -#define DFUNC(var1) TRIPLES(ADDON,fnc,var1) -#define DEFUNC(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2) - -#define QFUNC(var1) QUOTE(DFUNC(var1)) -#define QEFUNC(var1,var2) QUOTE(DEFUNC(var1,var2)) - -#define PATHTOEF(var1,var2) PATHTOF_SYS(PREFIX,var1,var2) - -#define GETVAR_SYS(var1,var2) getVariable [ARR_2(QUOTE(var1),var2)] -#define SETVAR_SYS(var1,var2) setVariable [ARR_2(QUOTE(var1),var2)] -#define SETPVAR_SYS(var1,var2) setVariable [ARR_3(QUOTE(var1),var2,true)] - -#define GETVAR(var1,var2,var3) var1 GETVAR_SYS(var2,var3) -#define GETMVAR(var1,var2) missionNamespace GETVAR_SYS(var1,var2) -#define GETUVAR(var1,var2) uiNamespace GETVAR_SYS(var1,var2) -#define GETPRVAR(var1,var2) profileNamespace GETVAR_SYS(var1,var2) -#define GETPAVAR(var1,var2) parsingNamespace GETVAR_SYS(var1,var2) - -#define SETVAR(var1,var2,var3) var1 SETVAR_SYS(var2,var3) -#define SETPVAR(var1,var2,var3) var1 SETPVAR_SYS(var2,var3) -#define SETMVAR(var1,var2) missionNamespace SETVAR_SYS(var1,var2) -#define SETUVAR(var1,var2) uiNamespace SETVAR_SYS(var1,var2) -#define SETPRVAR(var1,var2) profileNamespace SETVAR_SYS(var1,var2) -#define SETPAVAR(var1,var2) parsingNamespace SETVAR_SYS(var1,var2) - -#define GETGVAR(var1,var2) GETMVAR(GVAR(var1),var2) -#define GETEGVAR(var1,var2,var3) GETMVAR(EGVAR(var1,var2),var3) - -#define ARR_SELECT(ARRAY,INDEX,DEFAULT) if (count ARRAY > INDEX) then {ARRAY select INDEX} else {DEFAULT} - - -#define MACRO_ADDWEAPON(WEAPON,COUNT) class _xx_##WEAPON { \ - weapon = #WEAPON; \ - count = COUNT; \ -} - -#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ - name = #ITEM; \ - count = COUNT; \ -} - -#define MACRO_ADDMAGAZINE(MAGAZINE,COUNT) class _xx_##MAGAZINE { \ - magazine = #MAGAZINE; \ - count = COUNT; \ -} - -#define MACRO_ADDBACKPACK(BACKPACK,COUNT) class _xx_##BACKPACK { \ - backpack = #BACKPACK; \ - count = COUNT; \ -} - -// item types -#define TYPE_DEFAULT 0 -#define TYPE_MUZZLE 101 -#define TYPE_OPTICS 201 -#define TYPE_FLASHLIGHT 301 -#define TYPE_BIPOD 302 -#define TYPE_FIRST_AID_KIT 401 -#define TYPE_FINS 501 // not implemented -#define TYPE_BREATHING_BOMB 601 // not implemented -#define TYPE_NVG 602 -#define TYPE_GOGGLE 603 -#define TYPE_SCUBA 604 // not implemented -#define TYPE_HEADGEAR 605 -#define TYPE_FACTOR 607 -#define TYPE_RADIO 611 -#define TYPE_HMD 616 -#define TYPE_BINOCULAR 617 -#define TYPE_MEDIKIT 619 -#define TYPE_TOOLKIT 620 -#define TYPE_UAV_TERMINAL 621 -#define TYPE_VEST 701 -#define TYPE_UNIFORM 801 -#define TYPE_BACKPACK 901 - -#ifdef DISABLE_COMPILE_CACHE - #define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)) -#else - #define PREP(fncName) [QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)), QFUNC(fncName)] call CBA_fnc_compileFunction -#endif - -#define PREP_MODULE(folder) [] call compile preprocessFileLineNumbers QUOTE(PATHTOF(folder\__PREP__.sqf)) - -#define HASH_CREATE ([] call EFUNC(common,hashCreate)) -#define HASH_SET(hash, key, val) ([hash, key, val, __FILE__, __LINE__] call EFUNC(common,hashSet)) -#define HASH_GET(hash, key) ([hash, key, __FILE__, __LINE__] call EFUNC(common,hashGet)) -#define HASH_REM(hash, key) ([hash, key, __FILE__, __LINE__] call EFUNC(common,hashRem)) -#define HASH_HASKEY(hash, key) ([hash, key, __FILE__, __LINE__] call EFUNC(common,hashHasKey)) - -#define HASHLIST_CREATELIST(keys) ([keys] call EFUNC(common,hashListCreateList)) -#define HASHLIST_CREATEHASH(hashList) ([hashList] call EFUNC(common,hashListCreateHash)) -#define HASHLIST_SELECT(hashList, index) ([hashList, index, __FILE__, __LINE__] call EFUNC(common,hashListSelect)) -#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)) - -#define ACE_isHC (!hasInterface && !isDedicated) - -#define IDC_STAMINA_BAR 193 - -//By default CBA's TRACE/LOG/WARNING spawn a buffer, which can cause messages to be logged out of order: -#ifdef CBA_DEBUG_SYNCHRONOUS - #define CBA_fnc_log { params ["_file","_lineNum","_message"]; diag_log [diag_frameNo, diag_tickTime, time, _file + ":"+str(_lineNum + 1), _message]; } -#endif - -#define ACE_LOG(module,level,message) diag_log text ACE_LOGFORMAT(module,level,message) -#define ACE_LOGFORMAT(module,level,message) FORMAT_2(QUOTE([ACE] (module) %1: %2),level,message) - -#define ACE_LOGERROR(message) ACE_LOG(COMPONENT,"ERROR",message) -#define ACE_LOGERROR_1(message,arg1) ACE_LOGERROR(FORMAT_1(message,arg1)) -#define ACE_LOGERROR_2(message,arg1,arg2) ACE_LOGERROR(FORMAT_2(message,arg1,arg2)) -#define ACE_LOGERROR_3(message,arg1,arg2,arg3) ACE_LOGERROR(FORMAT_3(message,arg1,arg2,arg3)) -#define ACE_LOGERROR_4(message,arg1,arg2,arg3,arg4) ACE_LOGERROR(FORMAT_4(message,arg1,arg2,arg3,arg4)) -#define ACE_LOGERROR_5(message,arg1,arg2,arg3,arg4,arg5) ACE_LOGERROR(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) -#define ACE_LOGERROR_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_LOGERROR(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) -#define ACE_LOGERROR_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_LOGERROR(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) -#define ACE_LOGERROR_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_LOGERROR(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) - -#define ACE_ERRORFORMAT(message) ACE_LOGFORMAT(COMPONENT,"ERROR",message) -#define ACE_ERRORFORMAT_1(message,arg1) ACE_ERRORFORMAT(FORMAT_1(message,arg1)) -#define ACE_ERRORFORMAT_2(message,arg1,arg2) ACE_ERRORFORMAT(FORMAT_2(message,arg1,arg2)) -#define ACE_ERRORFORMAT_3(message,arg1,arg2,arg3) ACE_ERRORFORMAT(FORMAT_3(message,arg1,arg2,arg3)) -#define ACE_ERRORFORMAT_4(message,arg1,arg2,arg3,arg4) ACE_ERRORFORMAT(FORMAT_4(message,arg1,arg2,arg3,arg4)) -#define ACE_ERRORFORMAT_5(message,arg1,arg2,arg3,arg4,arg5) ACE_ERRORFORMAT(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) -#define ACE_ERRORFORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_ERRORFORMAT(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) -#define ACE_ERRORFORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_ERRORFORMAT(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) -#define ACE_ERRORFORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_ERRORFORMAT(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) - -#define ACE_LOGWARNING(message) ACE_LOG(COMPONENT,"WARNING",message) -#define ACE_LOGWARNING_1(message,arg1) ACE_LOGWARNING(FORMAT_1(message,arg1)) -#define ACE_LOGWARNING_2(message,arg1,arg2) ACE_LOGWARNING(FORMAT_2(message,arg1,arg2)) -#define ACE_LOGWARNING_3(message,arg1,arg2,arg3) ACE_LOGWARNING(FORMAT_3(message,arg1,arg2,arg3)) -#define ACE_LOGWARNING_4(message,arg1,arg2,arg3,arg4) ACE_LOGWARNING(FORMAT_4(message,arg1,arg2,arg3,arg4)) -#define ACE_LOGWARNING_5(message,arg1,arg2,arg3,arg4,arg5) ACE_LOGWARNING(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) -#define ACE_LOGWARNING_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_LOGWARNING(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) -#define ACE_LOGWARNING_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_LOGWARNING(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) -#define ACE_LOGWARNING_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_LOGWARNING(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) - -#define ACE_WARNINGFORMAT(message) ACE_LOGFORMAT(COMPONENT,"WARNING",message) -#define ACE_WARNINGFORMAT_1(message,arg1) ACE_WARNINGFORMAT(FORMAT_1(message,arg1)) -#define ACE_WARNINGFORMAT_2(message,arg1,arg2) ACE_WARNINGFORMAT(FORMAT_2(message,arg1,arg2)) -#define ACE_WARNINGFORMAT_3(message,arg1,arg2,arg3) ACE_WARNINGFORMAT(FORMAT_3(message,arg1,arg2,arg3)) -#define ACE_WARNINGFORMAT_4(message,arg1,arg2,arg3,arg4) ACE_WARNINGFORMAT(FORMAT_4(message,arg1,arg2,arg3,arg4)) -#define ACE_WARNINGFORMAT_5(message,arg1,arg2,arg3,arg4,arg5) ACE_WARNINGFORMAT(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) -#define ACE_WARNINGFORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_WARNINGFORMAT(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) -#define ACE_WARNINGFORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_WARNINGFORMAT(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) -#define ACE_WARNINGFORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_WARNINGFORMAT(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) - -#define ACE_LOGINFO(message) ACE_LOG(COMPONENT,"INFO",message) -#define ACE_LOGINFO_1(message,arg1) ACE_LOGINFO(FORMAT_1(message,arg1)) -#define ACE_LOGINFO_2(message,arg1,arg2) ACE_LOGINFO(FORMAT_2(message,arg1,arg2)) -#define ACE_LOGINFO_3(message,arg1,arg2,arg3) ACE_LOGINFO(FORMAT_3(message,arg1,arg2,arg3)) -#define ACE_LOGINFO_4(message,arg1,arg2,arg3,arg4) ACE_LOGINFO(FORMAT_4(message,arg1,arg2,arg3,arg4)) -#define ACE_LOGINFO_5(message,arg1,arg2,arg3,arg4,arg5) ACE_LOGINFO(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) -#define ACE_LOGINFO_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_LOGINFO(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) -#define ACE_LOGINFO_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_LOGINFO(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) -#define ACE_LOGINFO_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_LOGINFO(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) - -#define ACE_INFOFORMAT(message) ACE_LOGFORMAT(COMPONENT,"INFO",message) -#define ACE_INFOFORMAT_1(message,arg1) ACE_INFOFORMAT(FORMAT_1(message,arg1)) -#define ACE_INFOFORMAT_2(message,arg1,arg2) ACE_INFOFORMAT(FORMAT_2(message,arg1,arg2)) -#define ACE_INFOFORMAT_3(message,arg1,arg2,arg3) ACE_INFOFORMAT(FORMAT_3(message,arg1,arg2,arg3)) -#define ACE_INFOFORMAT_4(message,arg1,arg2,arg3,arg4) ACE_INFOFORMAT(FORMAT_4(message,arg1,arg2,arg3,arg4)) -#define ACE_INFOFORMAT_5(message,arg1,arg2,arg3,arg4,arg5) ACE_INFOFORMAT(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) -#define ACE_INFOFORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_INFOFORMAT(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) -#define ACE_INFOFORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_INFOFORMAT(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) -#define ACE_INFOFORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_INFOFORMAT(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) - -#define ACE_LOGDEBUG(message) ACE_LOG(COMPONENT,"DEBUG",message) -#define ACE_LOGDEBUG_1(message,arg1) ACE_LOGDEBUG(FORMAT_1(message,arg1)) -#define ACE_LOGDEBUG_2(message,arg1,arg2) ACE_LOGDEBUG(FORMAT_2(message,arg1,arg2)) -#define ACE_LOGDEBUG_3(message,arg1,arg2,arg3) ACE_LOGDEBUG(FORMAT_3(message,arg1,arg2,arg3)) -#define ACE_LOGDEBUG_4(message,arg1,arg2,arg3,arg4) ACE_LOGDEBUG(FORMAT_4(message,arg1,arg2,arg3,arg4)) -#define ACE_LOGDEBUG_5(message,arg1,arg2,arg3,arg4,arg5) ACE_LOGDEBUG(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) -#define ACE_LOGDEBUG_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_LOGDEBUG(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) -#define ACE_LOGDEBUG_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_LOGDEBUG(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) -#define ACE_LOGDEBUG_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_LOGDEBUG(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) - -#define ACE_DEBUGFORMAT(message) ACE_LOGFORMAT(COMPONENT,"DEBUG",message) -#define ACE_DEBUGFORMAT_1(message,arg1) ACE_DEBUGFORMAT(FORMAT_1(message,arg1)) -#define ACE_DEBUGFORMAT_2(message,arg1,arg2) ACE_DEBUGFORMAT(FORMAT_2(message,arg1,arg2)) -#define ACE_DEBUGFORMAT_3(message,arg1,arg2,arg3) ACE_DEBUGFORMAT(FORMAT_3(message,arg1,arg2,arg3)) -#define ACE_DEBUGFORMAT_4(message,arg1,arg2,arg3,arg4) ACE_DEBUGFORMAT(FORMAT_4(message,arg1,arg2,arg3,arg4)) -#define ACE_DEBUGFORMAT_5(message,arg1,arg2,arg3,arg4,arg5) ACE_DEBUGFORMAT(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) -#define ACE_DEBUGFORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_DEBUGFORMAT(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) -#define ACE_DEBUGFORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_DEBUGFORMAT(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) -#define ACE_DEBUGFORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_DEBUGFORMAT(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) - -#define ACE_DEPRECATED(arg1,arg2,arg3) ACE_LOGWARNING_3("%1 is deprecated. Support will be dropped in version %2. Replaced by: %3",arg1,arg2,arg3) - -#define PFORMAT_10(MESSAGE,A,B,C,D,E,F,G,H,I,J) \ - format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8, H=%9, I=%10 J=%11', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G), RETNIL(H), RETNIL(I), RETNIL(J)] -#ifdef DEBUG_MODE_FULL -#define TRACE_10(MESSAGE,A,B,C,D,E,F,G,H,I,J) \ - [THIS_FILE_, __LINE__, PFORMAT_10(MESSAGE,A,B,C,D,E,F,G,H,I,J)] call CBA_fnc_log -#else - #define TRACE_10(MESSAGE,A,B,C,D,E,F,G,H,I,J) /* disabled */ -#endif - -#include "script_debug.hpp" +#include "\x\cba\addons\main\script_macros_common.hpp" +#include "\x\cba\addons\xeh\script_xeh.hpp" + +// Default versioning level +#define DEFAULT_VERSIONING_LEVEL 2 + +#define DGVAR(varName) if(isNil "ACE_DEBUG_NAMESPACE") then { ACE_DEBUG_NAMESPACE = []; }; if(!(QUOTE(GVAR(varName)) in ACE_DEBUG_NAMESPACE)) then { PUSH(ACE_DEBUG_NAMESPACE, QUOTE(GVAR(varName))); }; GVAR(varName) +#define DVAR(varName) if(isNil "ACE_DEBUG_NAMESPACE") then { ACE_DEBUG_NAMESPACE = []; }; if(!(QUOTE(varName) in ACE_DEBUG_NAMESPACE)) then { PUSH(ACE_DEBUG_NAMESPACE, QUOTE(varName)); }; varName +#define DFUNC(var1) TRIPLES(ADDON,fnc,var1) +#define DEFUNC(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2) + +#define QFUNC(var1) QUOTE(DFUNC(var1)) +#define QEFUNC(var1,var2) QUOTE(DEFUNC(var1,var2)) + +#define PATHTOEF(var1,var2) PATHTOF_SYS(PREFIX,var1,var2) + +#define GETVAR_SYS(var1,var2) getVariable [ARR_2(QUOTE(var1),var2)] +#define SETVAR_SYS(var1,var2) setVariable [ARR_2(QUOTE(var1),var2)] +#define SETPVAR_SYS(var1,var2) setVariable [ARR_3(QUOTE(var1),var2,true)] + +#define GETVAR(var1,var2,var3) var1 GETVAR_SYS(var2,var3) +#define GETMVAR(var1,var2) missionNamespace GETVAR_SYS(var1,var2) +#define GETUVAR(var1,var2) uiNamespace GETVAR_SYS(var1,var2) +#define GETPRVAR(var1,var2) profileNamespace GETVAR_SYS(var1,var2) +#define GETPAVAR(var1,var2) parsingNamespace GETVAR_SYS(var1,var2) + +#define SETVAR(var1,var2,var3) var1 SETVAR_SYS(var2,var3) +#define SETPVAR(var1,var2,var3) var1 SETPVAR_SYS(var2,var3) +#define SETMVAR(var1,var2) missionNamespace SETVAR_SYS(var1,var2) +#define SETUVAR(var1,var2) uiNamespace SETVAR_SYS(var1,var2) +#define SETPRVAR(var1,var2) profileNamespace SETVAR_SYS(var1,var2) +#define SETPAVAR(var1,var2) parsingNamespace SETVAR_SYS(var1,var2) + +#define GETGVAR(var1,var2) GETMVAR(GVAR(var1),var2) +#define GETEGVAR(var1,var2,var3) GETMVAR(EGVAR(var1,var2),var3) + +#define ARR_SELECT(ARRAY,INDEX,DEFAULT) if (count ARRAY > INDEX) then {ARRAY select INDEX} else {DEFAULT} + + +#define MACRO_ADDWEAPON(WEAPON,COUNT) class _xx_##WEAPON { \ + weapon = #WEAPON; \ + count = COUNT; \ +} + +#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ + name = #ITEM; \ + count = COUNT; \ +} + +#define MACRO_ADDMAGAZINE(MAGAZINE,COUNT) class _xx_##MAGAZINE { \ + magazine = #MAGAZINE; \ + count = COUNT; \ +} + +#define MACRO_ADDBACKPACK(BACKPACK,COUNT) class _xx_##BACKPACK { \ + backpack = #BACKPACK; \ + count = COUNT; \ +} + +// item types +#define TYPE_DEFAULT 0 +#define TYPE_MUZZLE 101 +#define TYPE_OPTICS 201 +#define TYPE_FLASHLIGHT 301 +#define TYPE_BIPOD 302 +#define TYPE_FIRST_AID_KIT 401 +#define TYPE_FINS 501 // not implemented +#define TYPE_BREATHING_BOMB 601 // not implemented +#define TYPE_NVG 602 +#define TYPE_GOGGLE 603 +#define TYPE_SCUBA 604 // not implemented +#define TYPE_HEADGEAR 605 +#define TYPE_FACTOR 607 +#define TYPE_RADIO 611 +#define TYPE_HMD 616 +#define TYPE_BINOCULAR 617 +#define TYPE_MEDIKIT 619 +#define TYPE_TOOLKIT 620 +#define TYPE_UAV_TERMINAL 621 +#define TYPE_VEST 701 +#define TYPE_UNIFORM 801 +#define TYPE_BACKPACK 901 + +#ifdef DISABLE_COMPILE_CACHE + #define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)) +#else + #define PREP(fncName) [QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)), QFUNC(fncName)] call CBA_fnc_compileFunction +#endif + +#define PREP_MODULE(folder) [] call compile preprocessFileLineNumbers QUOTE(PATHTOF(folder\__PREP__.sqf)) + +#define HASH_CREATE ([] call EFUNC(common,hashCreate)) +#define HASH_SET(hash, key, val) ([hash, key, val, __FILE__, __LINE__] call EFUNC(common,hashSet)) +#define HASH_GET(hash, key) ([hash, key, __FILE__, __LINE__] call EFUNC(common,hashGet)) +#define HASH_REM(hash, key) ([hash, key, __FILE__, __LINE__] call EFUNC(common,hashRem)) +#define HASH_HASKEY(hash, key) ([hash, key, __FILE__, __LINE__] call EFUNC(common,hashHasKey)) + +#define HASHLIST_CREATELIST(keys) ([keys] call EFUNC(common,hashListCreateList)) +#define HASHLIST_CREATEHASH(hashList) ([hashList] call EFUNC(common,hashListCreateHash)) +#define HASHLIST_SELECT(hashList, index) ([hashList, index, __FILE__, __LINE__] call EFUNC(common,hashListSelect)) +#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)) + +#define ACE_isHC (!hasInterface && !isDedicated) + +#define IDC_STAMINA_BAR 193 + +//By default CBA's TRACE/LOG/WARNING spawn a buffer, which can cause messages to be logged out of order: +#ifdef CBA_DEBUG_SYNCHRONOUS + #define CBA_fnc_log { params ["_file","_lineNum","_message"]; diag_log [diag_frameNo, diag_tickTime, time, _file + ":"+str(_lineNum + 1), _message]; } +#endif + +#define ACE_LOG(module,level,message) diag_log text ACE_LOGFORMAT(module,level,message) +#define ACE_LOGFORMAT(module,level,message) FORMAT_2(QUOTE([ACE] (module) %1: %2),level,message) + +#define ACE_LOGERROR(message) ACE_LOG(COMPONENT,"ERROR",message) +#define ACE_LOGERROR_1(message,arg1) ACE_LOGERROR(FORMAT_1(message,arg1)) +#define ACE_LOGERROR_2(message,arg1,arg2) ACE_LOGERROR(FORMAT_2(message,arg1,arg2)) +#define ACE_LOGERROR_3(message,arg1,arg2,arg3) ACE_LOGERROR(FORMAT_3(message,arg1,arg2,arg3)) +#define ACE_LOGERROR_4(message,arg1,arg2,arg3,arg4) ACE_LOGERROR(FORMAT_4(message,arg1,arg2,arg3,arg4)) +#define ACE_LOGERROR_5(message,arg1,arg2,arg3,arg4,arg5) ACE_LOGERROR(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) +#define ACE_LOGERROR_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_LOGERROR(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) +#define ACE_LOGERROR_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_LOGERROR(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) +#define ACE_LOGERROR_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_LOGERROR(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) + +#define ACE_ERRORFORMAT(message) ACE_LOGFORMAT(COMPONENT,"ERROR",message) +#define ACE_ERRORFORMAT_1(message,arg1) ACE_ERRORFORMAT(FORMAT_1(message,arg1)) +#define ACE_ERRORFORMAT_2(message,arg1,arg2) ACE_ERRORFORMAT(FORMAT_2(message,arg1,arg2)) +#define ACE_ERRORFORMAT_3(message,arg1,arg2,arg3) ACE_ERRORFORMAT(FORMAT_3(message,arg1,arg2,arg3)) +#define ACE_ERRORFORMAT_4(message,arg1,arg2,arg3,arg4) ACE_ERRORFORMAT(FORMAT_4(message,arg1,arg2,arg3,arg4)) +#define ACE_ERRORFORMAT_5(message,arg1,arg2,arg3,arg4,arg5) ACE_ERRORFORMAT(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) +#define ACE_ERRORFORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_ERRORFORMAT(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) +#define ACE_ERRORFORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_ERRORFORMAT(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) +#define ACE_ERRORFORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_ERRORFORMAT(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) + +#define ACE_LOGWARNING(message) ACE_LOG(COMPONENT,"WARNING",message) +#define ACE_LOGWARNING_1(message,arg1) ACE_LOGWARNING(FORMAT_1(message,arg1)) +#define ACE_LOGWARNING_2(message,arg1,arg2) ACE_LOGWARNING(FORMAT_2(message,arg1,arg2)) +#define ACE_LOGWARNING_3(message,arg1,arg2,arg3) ACE_LOGWARNING(FORMAT_3(message,arg1,arg2,arg3)) +#define ACE_LOGWARNING_4(message,arg1,arg2,arg3,arg4) ACE_LOGWARNING(FORMAT_4(message,arg1,arg2,arg3,arg4)) +#define ACE_LOGWARNING_5(message,arg1,arg2,arg3,arg4,arg5) ACE_LOGWARNING(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) +#define ACE_LOGWARNING_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_LOGWARNING(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) +#define ACE_LOGWARNING_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_LOGWARNING(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) +#define ACE_LOGWARNING_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_LOGWARNING(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) + +#define ACE_WARNINGFORMAT(message) ACE_LOGFORMAT(COMPONENT,"WARNING",message) +#define ACE_WARNINGFORMAT_1(message,arg1) ACE_WARNINGFORMAT(FORMAT_1(message,arg1)) +#define ACE_WARNINGFORMAT_2(message,arg1,arg2) ACE_WARNINGFORMAT(FORMAT_2(message,arg1,arg2)) +#define ACE_WARNINGFORMAT_3(message,arg1,arg2,arg3) ACE_WARNINGFORMAT(FORMAT_3(message,arg1,arg2,arg3)) +#define ACE_WARNINGFORMAT_4(message,arg1,arg2,arg3,arg4) ACE_WARNINGFORMAT(FORMAT_4(message,arg1,arg2,arg3,arg4)) +#define ACE_WARNINGFORMAT_5(message,arg1,arg2,arg3,arg4,arg5) ACE_WARNINGFORMAT(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) +#define ACE_WARNINGFORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_WARNINGFORMAT(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) +#define ACE_WARNINGFORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_WARNINGFORMAT(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) +#define ACE_WARNINGFORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_WARNINGFORMAT(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) + +#define ACE_LOGINFO(message) ACE_LOG(COMPONENT,"INFO",message) +#define ACE_LOGINFO_1(message,arg1) ACE_LOGINFO(FORMAT_1(message,arg1)) +#define ACE_LOGINFO_2(message,arg1,arg2) ACE_LOGINFO(FORMAT_2(message,arg1,arg2)) +#define ACE_LOGINFO_3(message,arg1,arg2,arg3) ACE_LOGINFO(FORMAT_3(message,arg1,arg2,arg3)) +#define ACE_LOGINFO_4(message,arg1,arg2,arg3,arg4) ACE_LOGINFO(FORMAT_4(message,arg1,arg2,arg3,arg4)) +#define ACE_LOGINFO_5(message,arg1,arg2,arg3,arg4,arg5) ACE_LOGINFO(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) +#define ACE_LOGINFO_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_LOGINFO(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) +#define ACE_LOGINFO_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_LOGINFO(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) +#define ACE_LOGINFO_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_LOGINFO(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) + +#define ACE_INFOFORMAT(message) ACE_LOGFORMAT(COMPONENT,"INFO",message) +#define ACE_INFOFORMAT_1(message,arg1) ACE_INFOFORMAT(FORMAT_1(message,arg1)) +#define ACE_INFOFORMAT_2(message,arg1,arg2) ACE_INFOFORMAT(FORMAT_2(message,arg1,arg2)) +#define ACE_INFOFORMAT_3(message,arg1,arg2,arg3) ACE_INFOFORMAT(FORMAT_3(message,arg1,arg2,arg3)) +#define ACE_INFOFORMAT_4(message,arg1,arg2,arg3,arg4) ACE_INFOFORMAT(FORMAT_4(message,arg1,arg2,arg3,arg4)) +#define ACE_INFOFORMAT_5(message,arg1,arg2,arg3,arg4,arg5) ACE_INFOFORMAT(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) +#define ACE_INFOFORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_INFOFORMAT(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) +#define ACE_INFOFORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_INFOFORMAT(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) +#define ACE_INFOFORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_INFOFORMAT(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) + +#define ACE_LOGDEBUG(message) ACE_LOG(COMPONENT,"DEBUG",message) +#define ACE_LOGDEBUG_1(message,arg1) ACE_LOGDEBUG(FORMAT_1(message,arg1)) +#define ACE_LOGDEBUG_2(message,arg1,arg2) ACE_LOGDEBUG(FORMAT_2(message,arg1,arg2)) +#define ACE_LOGDEBUG_3(message,arg1,arg2,arg3) ACE_LOGDEBUG(FORMAT_3(message,arg1,arg2,arg3)) +#define ACE_LOGDEBUG_4(message,arg1,arg2,arg3,arg4) ACE_LOGDEBUG(FORMAT_4(message,arg1,arg2,arg3,arg4)) +#define ACE_LOGDEBUG_5(message,arg1,arg2,arg3,arg4,arg5) ACE_LOGDEBUG(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) +#define ACE_LOGDEBUG_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_LOGDEBUG(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) +#define ACE_LOGDEBUG_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_LOGDEBUG(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) +#define ACE_LOGDEBUG_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_LOGDEBUG(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) + +#define ACE_DEBUGFORMAT(message) ACE_LOGFORMAT(COMPONENT,"DEBUG",message) +#define ACE_DEBUGFORMAT_1(message,arg1) ACE_DEBUGFORMAT(FORMAT_1(message,arg1)) +#define ACE_DEBUGFORMAT_2(message,arg1,arg2) ACE_DEBUGFORMAT(FORMAT_2(message,arg1,arg2)) +#define ACE_DEBUGFORMAT_3(message,arg1,arg2,arg3) ACE_DEBUGFORMAT(FORMAT_3(message,arg1,arg2,arg3)) +#define ACE_DEBUGFORMAT_4(message,arg1,arg2,arg3,arg4) ACE_DEBUGFORMAT(FORMAT_4(message,arg1,arg2,arg3,arg4)) +#define ACE_DEBUGFORMAT_5(message,arg1,arg2,arg3,arg4,arg5) ACE_DEBUGFORMAT(FORMAT_5(message,arg1,arg2,arg3,arg4,arg5)) +#define ACE_DEBUGFORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6) ACE_DEBUGFORMAT(FORMAT_6(message,arg1,arg2,arg3,arg4,arg5,arg6)) +#define ACE_DEBUGFORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7) ACE_DEBUGFORMAT(FORMAT_7(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7)) +#define ACE_DEBUGFORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ACE_DEBUGFORMAT(FORMAT_8(message,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)) + +#define ACE_DEPRECATED(arg1,arg2,arg3) ACE_LOGWARNING_3("%1 is deprecated. Support will be dropped in version %2. Replaced by: %3",arg1,arg2,arg3) + +#define PFORMAT_10(MESSAGE,A,B,C,D,E,F,G,H,I,J) \ + format ['%1: A=%2, B=%3, C=%4, D=%5, E=%6, F=%7, G=%8, H=%9, I=%10 J=%11', MESSAGE, RETNIL(A), RETNIL(B), RETNIL(C), RETNIL(D), RETNIL(E), RETNIL(F), RETNIL(G), RETNIL(H), RETNIL(I), RETNIL(J)] +#ifdef DEBUG_MODE_FULL +#define TRACE_10(MESSAGE,A,B,C,D,E,F,G,H,I,J) \ + [THIS_FILE_, __LINE__, PFORMAT_10(MESSAGE,A,B,C,D,E,F,G,H,I,J)] call CBA_fnc_log +#else + #define TRACE_10(MESSAGE,A,B,C,D,E,F,G,H,I,J) /* disabled */ +#endif + +#include "script_debug.hpp" diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index 1f86448c94..1d9a8f2b6b 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -1,16 +1,16 @@ -// COMPONENT should be defined in the script_component.hpp and included BEFORE this hpp - -#define MAINPREFIX z -#define PREFIX ace - -#define MAJOR 3 -#define MINOR 5 -#define PATCHLVL 1 -#define BUILD 0 - -#define VERSION MAJOR.MINOR.PATCHLVL.BUILD -#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD - -// MINIMAL required version for the Mod. Components can specify others.. -#define REQUIRED_VERSION 1.56 -#define REQUIRED_CBA_VERSION {2,3,1} +// COMPONENT should be defined in the script_component.hpp and included BEFORE this hpp + +#define MAINPREFIX z +#define PREFIX ace + +#define MAJOR 3 +#define MINOR 5 +#define PATCHLVL 1 +#define BUILD 0 + +#define VERSION MAJOR.MINOR.PATCHLVL.BUILD +#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD + +// MINIMAL required version for the Mod. Components can specify others.. +#define REQUIRED_VERSION 1.56 +#define REQUIRED_CBA_VERSION {2,3,1} diff --git a/addons/medical/functions/fnc_handleCreateLitter.sqf b/addons/medical/functions/fnc_handleCreateLitter.sqf index 971342affb..3ea891ba53 100644 --- a/addons/medical/functions/fnc_handleCreateLitter.sqf +++ b/addons/medical/functions/fnc_handleCreateLitter.sqf @@ -1,50 +1,50 @@ -/* - * Author: Glowbal - * handle Litter Create - * - * Arguments: - * 0: Litter Class - * 1: Position - * 2: Unit - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -if(!hasInterface) exitWith { false }; - -params ["_litterClass", "_position", "_direction"]; -private["_litterObject", "_maxLitterCount"]; -//IGNORE_PRIVATE_WARNING(_values); - -if (isNil QGVAR(allCreatedLitter)) then { - GVAR(allCreatedLitter) = []; - GVAR(litterPFHRunning) = false; -}; - -_litterObject = _litterClass createVehicleLocal _position; -_litterObject setDir _direction; -_litterObject setPosATL _position; -// Move the litter next frame to get rid of HORRIBLE spacing, fixes #1112 -[{ params ["_object", "_pos"]; _object setPosATL _pos; }, [_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. - private["_oldLitter"]; - _oldLitter = GVAR(allCreatedLitter) deleteAt 0; - { - deleteVehicle _x; - } forEach (_oldLitter select 1); -}; - -GVAR(allCreatedLitter) pushBack [ACE_time, [_litterObject]]; - -if(!GVAR(litterPFHRunning) && {GVAR(litterCleanUpDelay) > 0}) then { - // Start the litter cleanup loop - GVAR(litterPFHRunning) = true; - call FUNC(litterCleanupLoop); -}; +/* + * Author: Glowbal + * handle Litter Create + * + * Arguments: + * 0: Litter Class + * 1: Position + * 2: Unit + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +if(!hasInterface) exitWith { false }; + +params ["_litterClass", "_position", "_direction"]; +private["_litterObject", "_maxLitterCount"]; +//IGNORE_PRIVATE_WARNING(_values); + +if (isNil QGVAR(allCreatedLitter)) then { + GVAR(allCreatedLitter) = []; + GVAR(litterPFHRunning) = false; +}; + +_litterObject = _litterClass createVehicleLocal _position; +_litterObject setDir _direction; +_litterObject setPosATL _position; +// Move the litter next frame to get rid of HORRIBLE spacing, fixes #1112 +[{ params ["_object", "_pos"]; _object setPosATL _pos; }, [_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. + private["_oldLitter"]; + _oldLitter = GVAR(allCreatedLitter) deleteAt 0; + { + deleteVehicle _x; + } forEach (_oldLitter select 1); +}; + +GVAR(allCreatedLitter) pushBack [ACE_time, [_litterObject]]; + +if(!GVAR(litterPFHRunning) && {GVAR(litterCleanUpDelay) > 0}) then { + // Start the litter cleanup loop + GVAR(litterPFHRunning) = true; + call FUNC(litterCleanupLoop); +}; diff --git a/addons/missileguidance/ACE_GuidanceConfig.hpp b/addons/missileguidance/ACE_GuidanceConfig.hpp index 96e417a7e8..f202e7d161 100644 --- a/addons/missileguidance/ACE_GuidanceConfig.hpp +++ b/addons/missileguidance/ACE_GuidanceConfig.hpp @@ -1,61 +1,61 @@ -class GVAR(AttackProfiles) { - class LIN { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(attackProfile_LIN); - }; - class DIR { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(attackProfile_DIR); - }; - class MID { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(attackProfile_MID); - }; - class HI { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(attackProfile_HI); - }; - class JAV_DIR { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(attackProfile_JAV_DIR); - }; - class JAV_TOP { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(attackProfile_JAV_TOP); - }; -}; - -class GVAR(SeekerTypes) { - class SALH { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(seekerType_SALH); - }; - class Optic { - name = ""; - visualName = ""; - description = ""; - - functionName = QFUNC(seekerType_Optic); - }; -}; +class GVAR(AttackProfiles) { + class LIN { + name = ""; + visualName = ""; + description = ""; + + functionName = QFUNC(attackProfile_LIN); + }; + class DIR { + name = ""; + visualName = ""; + description = ""; + + functionName = QFUNC(attackProfile_DIR); + }; + class MID { + name = ""; + visualName = ""; + description = ""; + + functionName = QFUNC(attackProfile_MID); + }; + class HI { + name = ""; + visualName = ""; + description = ""; + + functionName = QFUNC(attackProfile_HI); + }; + class JAV_DIR { + name = ""; + visualName = ""; + description = ""; + + functionName = QFUNC(attackProfile_JAV_DIR); + }; + class JAV_TOP { + name = ""; + visualName = ""; + description = ""; + + functionName = QFUNC(attackProfile_JAV_TOP); + }; +}; + +class GVAR(SeekerTypes) { + class SALH { + name = ""; + visualName = ""; + description = ""; + + functionName = QFUNC(seekerType_SALH); + }; + class Optic { + name = ""; + visualName = ""; + description = ""; + + functionName = QFUNC(seekerType_Optic); + }; +}; diff --git a/addons/missileguidance/ACE_Settings.hpp b/addons/missileguidance/ACE_Settings.hpp index 2ec3326a98..e73d533c08 100644 --- a/addons/missileguidance/ACE_Settings.hpp +++ b/addons/missileguidance/ACE_Settings.hpp @@ -1,10 +1,10 @@ -class ACE_Settings { - class GVAR(enabled) { - value = 2; - typeName = "SCALAR"; - isClientSettable = 1; - displayName = CSTRING(Title); - description = CSTRING(Desc); - values[] = {CSTRING(Off), CSTRING(PlayerOnly), CSTRING(PlayerAndAi)}; - }; +class ACE_Settings { + class GVAR(enabled) { + value = 2; + typeName = "SCALAR"; + isClientSettable = 1; + displayName = CSTRING(Title); + description = CSTRING(Desc); + values[] = {CSTRING(Off), CSTRING(PlayerOnly), CSTRING(PlayerAndAi)}; + }; }; \ No newline at end of file diff --git a/addons/missileguidance/CfgAmmo.hpp b/addons/missileguidance/CfgAmmo.hpp index 92a4d043d8..ad3b854334 100644 --- a/addons/missileguidance/CfgAmmo.hpp +++ b/addons/missileguidance/CfgAmmo.hpp @@ -1,156 +1,156 @@ -enum { - ACE_LOBL = 1, - ACE_LOAL = 2 -}; - -class CfgAmmo { - class MissileBase; - - class M_PG_AT: MissileBase { - model = "\A3\Weapons_F\Ammo\Rocket_01_fly_F"; - proxyShape = "\A3\Weapons_F\Ammo\Rocket_01_F"; - - irLock = 0; - laserLock = 1; - airLock = 0; - weaponLockSystem = "4 + 16"; - - maxSpeed = 720; - maxControlRange = 5000; - maneuvrability = 8; - timeToLive = 60; - simulationStep = 0.01; - airFriction = 0.1; - sideAirFriction = 0.16; - initTime = 0.002; - thrustTime = 1.07; - thrust = 530; - fuseDistance = 2; - - effectsMissileInit = "MissileDAR1"; - effectsMissile = "missile2"; - whistleDist = 4; - muzzleEffect = ""; - - // Turn off arma crosshair-guidance - manualControl = 0; - - // ACE uses these values - trackOversteer = 1; - trackLead = 0; - }; - - class ACE_Hydra70_DAGR: M_PG_AT { - displayName = CSTRING(Hydra70_DAGR); - displayNameShort = CSTRING(Hydra70_DAGR_Short); - - description = CSTRING(Hydra70_DAGR_Desc); - descriptionShort = CSTRING(Hydra70_DAGR_Desc); - - EGVAR(rearm,caliber) = 70; - - class ADDON { - enabled = 1; - - minDeflection = 0.00025; // Minium flap deflection for guidance - maxDeflection = 0.001; // Maximum flap deflection for guidance - incDeflection = 0.0005; // The incrmeent in which deflection adjusts. - - canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode - - // Guidance type for munitions - defaultSeekerType = "SALH"; - seekerTypes[] = { "SALH", "LIDAR", "SARH", "Optic", "Thermal", "GPS", "SACLOS", "MCLOS" }; - - defaultSeekerLockMode = "LOAL"; - seekerLockModes[] = { "LOAL", "LOBL" }; - - seekerAngle = 90; // Angle in front of the missile which can be searched - seekerAccuracy = 1; // seeker accuracy multiplier - - seekerMinRange = 1; - seekerMaxRange = 2500; // Range from the missile which the seeker can visually search - - // Attack profile type selection - defaultAttackProfile = "LIN"; - attackProfiles[] = { "LIN", "DIR", "MID", "HI" }; - }; - }; - - class ACE_Hellfire_AGM114K: ACE_Hydra70_DAGR { - displayName = CSTRING(Hellfire_AGM114K); - displayNameShort = CSTRING(Hellfire_AGM114K_Short); - - description = CSTRING(Hellfire_AGM114K_desc); - descriptionShort = CSTRING(Hellfire_AGM114K_desc); - - // @TODO: placeholder model to at least make it look different - model = "\A3\Weapons_F\Ammo\Missile_AT_03_fly_F"; - proxyShape = "\A3\Weapons_F\Ammo\Missile_AT_03_F"; - - hit = 1400; - indirectHit = 71; - indirectHitRange = 4.5; - effectsMissile = "missile2"; - - //Explicity add guidance config - class ADDON: ADDON {}; - }; - - // Titan - class M_Titan_AT: MissileBase {}; - - class ACE_Javelin_FGM148: M_Titan_AT { - irLock = 0; - laserLock = 0; - airLock = 0; - - // Turn off arma crosshair-guidance - manualControl = 0; - - hit = 1400; // default: 800 - indirectHit = 20; - indirectHitRange = 2; - // ACE uses these values - //trackOversteer = 1; - //trackLead = 0; - - initTime = 2; - - // Begin ACE guidance Configs - class ADDON { - enabled = 1; - - minDeflection = 0.00005; // Minium flap deflection for guidance - maxDeflection = 0.025; // Maximum flap deflection for guidance - incDeflection = 0.00005; // The incrmeent in which deflection adjusts. - - canVanillaLock = 0; - - // Guidance type for munitions - defaultSeekerType = "Optic"; - seekerTypes[] = { "Optic" }; - - defaultSeekerLockMode = "LOBL"; - seekerLockModes[] = { "LOBL" }; - - seekerAngle = 180; // Angle in front of the missile which can be searched - seekerAccuracy = 1; // seeker accuracy multiplier - - seekerMinRange = 0; - seekerMaxRange = 2500; // Range from the missile which the seeker can visually search - - // Attack profile type selection - defaultAttackProfile = "JAV_TOP"; - attackProfiles[] = { "JAV_TOP", "JAV_DIR" }; - }; - }; - class ACE_Javelin_FGM148_static: ACE_Javelin_FGM148 { - //Take config changes from (M_Titan_AT_static: M_Titan_AT) - initTime = 0.25; //"How long (in seconds) the projectile waits before starting it's engine.", - but doesn't seem to do anything - effectsMissileInit = "RocketBackEffectsStaticRPG"; - - //Explicity add guidance config - class ADDON: ADDON {}; - }; -}; +enum { + ACE_LOBL = 1, + ACE_LOAL = 2 +}; + +class CfgAmmo { + class MissileBase; + + class M_PG_AT: MissileBase { + model = "\A3\Weapons_F\Ammo\Rocket_01_fly_F"; + proxyShape = "\A3\Weapons_F\Ammo\Rocket_01_F"; + + irLock = 0; + laserLock = 1; + airLock = 0; + weaponLockSystem = "4 + 16"; + + maxSpeed = 720; + maxControlRange = 5000; + maneuvrability = 8; + timeToLive = 60; + simulationStep = 0.01; + airFriction = 0.1; + sideAirFriction = 0.16; + initTime = 0.002; + thrustTime = 1.07; + thrust = 530; + fuseDistance = 2; + + effectsMissileInit = "MissileDAR1"; + effectsMissile = "missile2"; + whistleDist = 4; + muzzleEffect = ""; + + // Turn off arma crosshair-guidance + manualControl = 0; + + // ACE uses these values + trackOversteer = 1; + trackLead = 0; + }; + + class ACE_Hydra70_DAGR: M_PG_AT { + displayName = CSTRING(Hydra70_DAGR); + displayNameShort = CSTRING(Hydra70_DAGR_Short); + + description = CSTRING(Hydra70_DAGR_Desc); + descriptionShort = CSTRING(Hydra70_DAGR_Desc); + + EGVAR(rearm,caliber) = 70; + + class ADDON { + enabled = 1; + + minDeflection = 0.00025; // Minium flap deflection for guidance + maxDeflection = 0.001; // Maximum flap deflection for guidance + incDeflection = 0.0005; // The incrmeent in which deflection adjusts. + + canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode + + // Guidance type for munitions + defaultSeekerType = "SALH"; + seekerTypes[] = { "SALH", "LIDAR", "SARH", "Optic", "Thermal", "GPS", "SACLOS", "MCLOS" }; + + defaultSeekerLockMode = "LOAL"; + seekerLockModes[] = { "LOAL", "LOBL" }; + + seekerAngle = 90; // Angle in front of the missile which can be searched + seekerAccuracy = 1; // seeker accuracy multiplier + + seekerMinRange = 1; + seekerMaxRange = 2500; // Range from the missile which the seeker can visually search + + // Attack profile type selection + defaultAttackProfile = "LIN"; + attackProfiles[] = { "LIN", "DIR", "MID", "HI" }; + }; + }; + + class ACE_Hellfire_AGM114K: ACE_Hydra70_DAGR { + displayName = CSTRING(Hellfire_AGM114K); + displayNameShort = CSTRING(Hellfire_AGM114K_Short); + + description = CSTRING(Hellfire_AGM114K_desc); + descriptionShort = CSTRING(Hellfire_AGM114K_desc); + + // @TODO: placeholder model to at least make it look different + model = "\A3\Weapons_F\Ammo\Missile_AT_03_fly_F"; + proxyShape = "\A3\Weapons_F\Ammo\Missile_AT_03_F"; + + hit = 1400; + indirectHit = 71; + indirectHitRange = 4.5; + effectsMissile = "missile2"; + + //Explicity add guidance config + class ADDON: ADDON {}; + }; + + // Titan + class M_Titan_AT: MissileBase {}; + + class ACE_Javelin_FGM148: M_Titan_AT { + irLock = 0; + laserLock = 0; + airLock = 0; + + // Turn off arma crosshair-guidance + manualControl = 0; + + hit = 1400; // default: 800 + indirectHit = 20; + indirectHitRange = 2; + // ACE uses these values + //trackOversteer = 1; + //trackLead = 0; + + initTime = 2; + + // Begin ACE guidance Configs + class ADDON { + enabled = 1; + + minDeflection = 0.00005; // Minium flap deflection for guidance + maxDeflection = 0.025; // Maximum flap deflection for guidance + incDeflection = 0.00005; // The incrmeent in which deflection adjusts. + + canVanillaLock = 0; + + // Guidance type for munitions + defaultSeekerType = "Optic"; + seekerTypes[] = { "Optic" }; + + defaultSeekerLockMode = "LOBL"; + seekerLockModes[] = { "LOBL" }; + + seekerAngle = 180; // Angle in front of the missile which can be searched + seekerAccuracy = 1; // seeker accuracy multiplier + + seekerMinRange = 0; + seekerMaxRange = 2500; // Range from the missile which the seeker can visually search + + // Attack profile type selection + defaultAttackProfile = "JAV_TOP"; + attackProfiles[] = { "JAV_TOP", "JAV_DIR" }; + }; + }; + class ACE_Javelin_FGM148_static: ACE_Javelin_FGM148 { + //Take config changes from (M_Titan_AT_static: M_Titan_AT) + initTime = 0.25; //"How long (in seconds) the projectile waits before starting it's engine.", - but doesn't seem to do anything + effectsMissileInit = "RocketBackEffectsStaticRPG"; + + //Explicity add guidance config + class ADDON: ADDON {}; + }; +}; diff --git a/addons/missileguidance/CfgEventhandlers.hpp b/addons/missileguidance/CfgEventhandlers.hpp index 5ec1d7d652..7fba1f43c4 100644 --- a/addons/missileguidance/CfgEventhandlers.hpp +++ b/addons/missileguidance/CfgEventhandlers.hpp @@ -1,30 +1,30 @@ - -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_pre_init)); - }; -}; - -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_post_init)); - }; -}; - -class Extended_FiredBIS_EventHandlers { - class All { - ADDON = QUOTE(_this call FUNC(onFired)); - }; -}; - -class Extended_IncomingMissile_EventHandlers { - class All { - ADDON = QUOTE(_this call FUNC(onIncomingMissile)); - }; -}; + +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_pre_init)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_post_init)); + }; +}; + +class Extended_FiredBIS_EventHandlers { + class All { + ADDON = QUOTE(_this call FUNC(onFired)); + }; +}; + +class Extended_IncomingMissile_EventHandlers { + class All { + ADDON = QUOTE(_this call FUNC(onIncomingMissile)); + }; +}; diff --git a/addons/missileguidance/CfgMagazines.hpp b/addons/missileguidance/CfgMagazines.hpp index a7e729cf32..e4a84862ae 100644 --- a/addons/missileguidance/CfgMagazines.hpp +++ b/addons/missileguidance/CfgMagazines.hpp @@ -1,53 +1,53 @@ -class CfgMagazines { - class 12Rnd_PG_missiles; - - class 6Rnd_ACE_Hydra70_DAGR : 12Rnd_PG_missiles { - ammo = "ACE_Hydra70_DAGR"; - count = 12; - displayName = "6 Round DAGR"; - displayNameShort = "6 Round DAGR"; - descriptionShort = "6 Round DAGR"; - weight = 36; - - }; - class 12Rnd_ACE_Hydra70_DAGR : 6Rnd_ACE_Hydra70_DAGR { - count = 12; - displayName = "16 Round DAGR"; - displayNameShort = "16 Round DAGR"; - descriptionShort = "16 Round DAGR"; - weight = 72; - }; - class 24Rnd_ACE_Hydra70_DAGR : 6Rnd_ACE_Hydra70_DAGR { - count = 24; - displayName = "24 Round DAGR"; - displayNameShort = "24 Round DAGR"; - descriptionShort = "24 Round DAGR"; - weight = 72; - }; - - // Hellfires - class 6Rnd_ACE_Hellfire_AGM114K : 12Rnd_PG_missiles { - count = 12; - ammo = "ACE_Hellfire_AGM114K"; - displayName = "6Rnd_ACE_Hellfire_AGM114K"; - displayNameShort = "6Rnd_ACE_Hellfire_AGM114K"; - descriptionShort = "6Rnd_ACE_Hellfire_AGM114K"; - weight = 36; - - }; - class 12Rnd_ACE_Hellfire_AGM114K : 6Rnd_ACE_Hydra70_DAGR { - count = 12; - displayName = "12Rnd_ACE_Hellfire_AGM114K"; - displayNameShort = "12Rnd_ACE_Hellfire_AGM114K"; - descriptionShort = "12Rnd_ACE_Hellfire_AGM114K"; - weight = 72; - }; - class 24Rnd_ACE_Hellfire_AGM114K : 6Rnd_ACE_Hydra70_DAGR { - count = 24; - displayName = "24Rnd_ACE_Hellfire_AGM114K"; - displayNameShort = "24Rnd_ACE_Hellfire_AGM114K"; - descriptionShort = "24Rnd_ACE_Hellfire_AGM114K"; - weight = 72; - }; - -}; +class CfgMagazines { + class 12Rnd_PG_missiles; + + class 6Rnd_ACE_Hydra70_DAGR : 12Rnd_PG_missiles { + ammo = "ACE_Hydra70_DAGR"; + count = 12; + displayName = "6 Round DAGR"; + displayNameShort = "6 Round DAGR"; + descriptionShort = "6 Round DAGR"; + weight = 36; + + }; + class 12Rnd_ACE_Hydra70_DAGR : 6Rnd_ACE_Hydra70_DAGR { + count = 12; + displayName = "16 Round DAGR"; + displayNameShort = "16 Round DAGR"; + descriptionShort = "16 Round DAGR"; + weight = 72; + }; + class 24Rnd_ACE_Hydra70_DAGR : 6Rnd_ACE_Hydra70_DAGR { + count = 24; + displayName = "24 Round DAGR"; + displayNameShort = "24 Round DAGR"; + descriptionShort = "24 Round DAGR"; + weight = 72; + }; + + // Hellfires + class 6Rnd_ACE_Hellfire_AGM114K : 12Rnd_PG_missiles { + count = 12; + ammo = "ACE_Hellfire_AGM114K"; + displayName = "6Rnd_ACE_Hellfire_AGM114K"; + displayNameShort = "6Rnd_ACE_Hellfire_AGM114K"; + descriptionShort = "6Rnd_ACE_Hellfire_AGM114K"; + weight = 36; + + }; + class 12Rnd_ACE_Hellfire_AGM114K : 6Rnd_ACE_Hydra70_DAGR { + count = 12; + displayName = "12Rnd_ACE_Hellfire_AGM114K"; + displayNameShort = "12Rnd_ACE_Hellfire_AGM114K"; + descriptionShort = "12Rnd_ACE_Hellfire_AGM114K"; + weight = 72; + }; + class 24Rnd_ACE_Hellfire_AGM114K : 6Rnd_ACE_Hydra70_DAGR { + count = 24; + displayName = "24Rnd_ACE_Hellfire_AGM114K"; + displayNameShort = "24Rnd_ACE_Hellfire_AGM114K"; + descriptionShort = "24Rnd_ACE_Hellfire_AGM114K"; + weight = 72; + }; + +}; diff --git a/addons/missileguidance/CfgVehicles.hpp b/addons/missileguidance/CfgVehicles.hpp index 16b4b87767..be5c31a3f6 100644 --- a/addons/missileguidance/CfgVehicles.hpp +++ b/addons/missileguidance/CfgVehicles.hpp @@ -1,36 +1,36 @@ -class CfgVehicles { - - class AllVehicles; - class Air: AllVehicles { - class Turrets; - }; - - class Helicopter: Air { - class Turrets { - class MainTurret; - }; - }; - class Helicopter_Base_F: Helicopter {}; - class Heli_Attack_01_base_F: Helicopter_Base_F {}; - class B_Heli_Attack_01_F : Heli_Attack_01_base_F { - class Turrets: Turrets { - class MainTurret; - }; - }; - - class ACE_Comanche_Test : B_Heli_Attack_01_F { - scope = 1; - scopeCurator = 0; - displayName = "ACE_Comanche_Test"; - author = "ACE Team"; - class Library { - libTextDesc = "ACE_Comanche_Test"; - }; - class Turrets: Turrets { - class MainTurret: MainTurret { - magazines[] = {"ACE_500Rnd_20mm_shells_Comanche", "24Rnd_ACE_Hellfire_AGM114K"}; - }; - }; - }; - -}; +class CfgVehicles { + + class AllVehicles; + class Air: AllVehicles { + class Turrets; + }; + + class Helicopter: Air { + class Turrets { + class MainTurret; + }; + }; + class Helicopter_Base_F: Helicopter {}; + class Heli_Attack_01_base_F: Helicopter_Base_F {}; + class B_Heli_Attack_01_F : Heli_Attack_01_base_F { + class Turrets: Turrets { + class MainTurret; + }; + }; + + class ACE_Comanche_Test : B_Heli_Attack_01_F { + scope = 1; + scopeCurator = 0; + displayName = "ACE_Comanche_Test"; + author = "ACE Team"; + class Library { + libTextDesc = "ACE_Comanche_Test"; + }; + class Turrets: Turrets { + class MainTurret: MainTurret { + magazines[] = {"ACE_500Rnd_20mm_shells_Comanche", "24Rnd_ACE_Hellfire_AGM114K"}; + }; + }; + }; + +}; diff --git a/addons/missileguidance/CfgWeapons.hpp b/addons/missileguidance/CfgWeapons.hpp index 178a55daf7..f57e3ab0df 100644 --- a/addons/missileguidance/CfgWeapons.hpp +++ b/addons/missileguidance/CfgWeapons.hpp @@ -1,12 +1,12 @@ -class Mode_SemiAuto; -class CfgWeapons { - class CannonCore; - class LauncherCore; - - class RocketPods: LauncherCore { - // canLock = 1; - }; - class missiles_DAGR : RocketPods { - canLock = 2; - }; -}; +class Mode_SemiAuto; +class CfgWeapons { + class CannonCore; + class LauncherCore; + + class RocketPods: LauncherCore { + // canLock = 1; + }; + class missiles_DAGR : RocketPods { + canLock = 2; + }; +}; diff --git a/addons/missileguidance/XEH_post_init.sqf b/addons/missileguidance/XEH_post_init.sqf index deaeef669d..d6d82e875d 100644 --- a/addons/missileguidance/XEH_post_init.sqf +++ b/addons/missileguidance/XEH_post_init.sqf @@ -1,3 +1,3 @@ -#include "script_component.hpp" - -[QGVAR(handoff), {_this call FUNC(handleHandoff)}] call EFUNC(common,addEventHandler); +#include "script_component.hpp" + +[QGVAR(handoff), {_this call FUNC(handleHandoff)}] call EFUNC(common,addEventHandler); diff --git a/addons/missileguidance/XEH_pre_init.sqf b/addons/missileguidance/XEH_pre_init.sqf index c3d42816c1..a7feade1c3 100644 --- a/addons/missileguidance/XEH_pre_init.sqf +++ b/addons/missileguidance/XEH_pre_init.sqf @@ -1,7 +1,7 @@ -#include "script_component.hpp" - -ADDON = false; - -#include "XEH_PREP.hpp" - -ADDON = true; +#include "script_component.hpp" + +ADDON = false; + +#include "XEH_PREP.hpp" + +ADDON = true; diff --git a/addons/missileguidance/config.cpp b/addons/missileguidance/config.cpp index 591a4f1c5e..526d9ba757 100644 --- a/addons/missileguidance/config.cpp +++ b/addons/missileguidance/config.cpp @@ -1,20 +1,20 @@ -#include "script_component.hpp" - -class CfgPatches { - class ADDON { - units[] = {"ACE_Comanche_Test"}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_laser"}; - VERSION_CONFIG; - }; -}; - -#include "ACE_GuidanceConfig.hpp" -#include "ACE_Settings.hpp" - -#include "CfgEventhandlers.hpp" -#include "CfgAmmo.hpp" -#include "CfgMagazines.hpp" -#include "CfgWeapons.hpp" -#include "CfgVehicles.hpp" +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {"ACE_Comanche_Test"}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_laser"}; + VERSION_CONFIG; + }; +}; + +#include "ACE_GuidanceConfig.hpp" +#include "ACE_Settings.hpp" + +#include "CfgEventhandlers.hpp" +#include "CfgAmmo.hpp" +#include "CfgMagazines.hpp" +#include "CfgWeapons.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/missileguidance/functions/fnc_attackProfile_AIR.sqf b/addons/missileguidance/functions/fnc_attackProfile_AIR.sqf index 498b754287..9909124e2f 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_AIR.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_AIR.sqf @@ -1,4 +1,4 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + _this call FUNC(attackProfile_LIN); \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_attackProfile_DIR.sqf b/addons/missileguidance/functions/fnc_attackProfile_DIR.sqf index 498b754287..9909124e2f 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_DIR.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_DIR.sqf @@ -1,4 +1,4 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + _this call FUNC(attackProfile_LIN); \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_attackProfile_HI.sqf b/addons/missileguidance/functions/fnc_attackProfile_HI.sqf index 498b754287..9909124e2f 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_HI.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_HI.sqf @@ -1,4 +1,4 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + _this call FUNC(attackProfile_LIN); \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_attackProfile_JAV_DIR.sqf b/addons/missileguidance/functions/fnc_attackProfile_JAV_DIR.sqf index d84b3b126b..d3f095ee95 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_JAV_DIR.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_JAV_DIR.sqf @@ -1,66 +1,66 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -#define STAGE_LAUNCH 1 -#define STAGE_CLIMB 2 -#define STAGE_COAST 3 -#define STAGE_TERMINAL 4 - -EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -private["_targetPos", "_projectilePos", "_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams"]; -private["_distanceToTarget", "_distanceToShooter", "_addHeight", "_returnTargetPos", "_state"]; -private["_cruisAlt", "_distanceShooterToTarget", "_shooterPos"]; -_seekerTargetPos = _this select 0; -_launchParams = _this select 1; - -_target = _launchParams select 0; -_targetLaunchParams = _launchParams select 1; - -_state = _this select 2; -if( (count _state) < 1) then { - _state set[0, STAGE_LAUNCH]; -}; - -_shooterPos = getPosASL _shooter; -_projectilePos = getPosASL _projectile; - -_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos; -_distanceToShooter = _projectilePos vectorDistance _shooterPos; -_distanceShooterToTarget = _shooterPos vectorDistance _seekerTargetPos; - -TRACE_2("", _distanceToTarget, _distanceToShooter); - -// Add height depending on distance for compensate -_returnTargetPos = _seekerTargetPos; - -switch( (_state select 0) ) do { - case STAGE_LAUNCH: { - TRACE_1("STAGE_LAUNCH",""); - if(_distanceToShooter < 10) then { - _returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*2]; - } else { - _state set[0, STAGE_CLIMB]; - }; - }; - case STAGE_CLIMB: { - TRACE_1("STAGE_CLIMB",""); - _cruisAlt = 60 * (_distanceShooterToTarget/2000); - - if( ((ASLToATL _projectilePos) select 2) - ((ASLToATL _seekerTargetPos) select 2) >= _cruisAlt) then { - _state set[0, STAGE_TERMINAL]; - } else { - _returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*1.5]; - }; - }; - case STAGE_TERMINAL: { - TRACE_1("STAGE_TERMINAL",""); - _returnTargetPos = _seekerTargetPos; - }; -}; - -#ifdef DEBUG_MODE_FULL -drawLine3D [(ASLtoATL _returnTargetPos), (ASLtoATL _seekerTargetPos), [0,1,0,1]]; -#endif - -TRACE_1("Adjusted target position", _returnTargetPos); +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +#define STAGE_LAUNCH 1 +#define STAGE_CLIMB 2 +#define STAGE_COAST 3 +#define STAGE_TERMINAL 4 + +EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +private["_targetPos", "_projectilePos", "_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams"]; +private["_distanceToTarget", "_distanceToShooter", "_addHeight", "_returnTargetPos", "_state"]; +private["_cruisAlt", "_distanceShooterToTarget", "_shooterPos"]; +_seekerTargetPos = _this select 0; +_launchParams = _this select 1; + +_target = _launchParams select 0; +_targetLaunchParams = _launchParams select 1; + +_state = _this select 2; +if( (count _state) < 1) then { + _state set[0, STAGE_LAUNCH]; +}; + +_shooterPos = getPosASL _shooter; +_projectilePos = getPosASL _projectile; + +_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos; +_distanceToShooter = _projectilePos vectorDistance _shooterPos; +_distanceShooterToTarget = _shooterPos vectorDistance _seekerTargetPos; + +TRACE_2("", _distanceToTarget, _distanceToShooter); + +// Add height depending on distance for compensate +_returnTargetPos = _seekerTargetPos; + +switch( (_state select 0) ) do { + case STAGE_LAUNCH: { + TRACE_1("STAGE_LAUNCH",""); + if(_distanceToShooter < 10) then { + _returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*2]; + } else { + _state set[0, STAGE_CLIMB]; + }; + }; + case STAGE_CLIMB: { + TRACE_1("STAGE_CLIMB",""); + _cruisAlt = 60 * (_distanceShooterToTarget/2000); + + if( ((ASLToATL _projectilePos) select 2) - ((ASLToATL _seekerTargetPos) select 2) >= _cruisAlt) then { + _state set[0, STAGE_TERMINAL]; + } else { + _returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*1.5]; + }; + }; + case STAGE_TERMINAL: { + TRACE_1("STAGE_TERMINAL",""); + _returnTargetPos = _seekerTargetPos; + }; +}; + +#ifdef DEBUG_MODE_FULL +drawLine3D [(ASLtoATL _returnTargetPos), (ASLtoATL _seekerTargetPos), [0,1,0,1]]; +#endif + +TRACE_1("Adjusted target position", _returnTargetPos); _returnTargetPos; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_attackProfile_JAV_TOP.sqf b/addons/missileguidance/functions/fnc_attackProfile_JAV_TOP.sqf index 393abebc19..f26bcc58b0 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_JAV_TOP.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_JAV_TOP.sqf @@ -1,84 +1,84 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -#define STAGE_LAUNCH 1 -#define STAGE_CLIMB 2 -#define STAGE_COAST 3 -#define STAGE_TERMINAL 4 - -EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -private["_targetPos", "_projectilePos", "_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams"]; -private["_distanceToTarget", "_distanceToShooter", "_addHeight", "_returnTargetPos", "_state"]; -private["_cruisAlt", "_distanceShooterToTarget", "_shooterPos"]; - -_seekerTargetPos = _this select 0; -_launchParams = _this select 1; - -_target = _launchParams select 0; -_targetLaunchParams = _launchParams select 1; - -_state = _this select 2; -if( (count _state) < 1) then { - _state set[0, STAGE_LAUNCH]; -}; - -_shooterPos = getPosASL _shooter; -_projectilePos = getPosASL _projectile; - -_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos; -_distanceToShooter = _projectilePos vectorDistance _shooterPos; -_distanceShooterToTarget = _shooterPos vectorDistance _seekerTargetPos; - -TRACE_2("", _distanceToTarget, _distanceToShooter); - -// Add height depending on distance for compensate -_returnTargetPos = _seekerTargetPos; - -switch( (_state select 0) ) do { - case STAGE_LAUNCH: { - TRACE_1("STAGE_LAUNCH",""); - if(_distanceToShooter < 10) then { - _returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*2]; - } else { - _state set[0, STAGE_CLIMB]; - }; - }; - case STAGE_CLIMB: { - TRACE_1("STAGE_CLIMB",""); - _cruisAlt = 140; - if(_distanceShooterToTarget < 1250) then { - _cruisAlt = 140 * (_distanceShooterToTarget/1250); - TRACE_1("_cruisAlt", _cruisAlt); - }; - if( ((ASLToATL _projectilePos) select 2) - ((ASLToATL _seekerTargetPos) select 2) >= _cruisAlt) then { - if(_cruisAlt < 140) then { - _state set[0, STAGE_TERMINAL]; - } else { - _state set[0, STAGE_COAST]; - }; - } else { - _returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*1.5]; - }; - }; - case STAGE_COAST: { - TRACE_1("STAGE_COAST",""); - TRACE_1("", ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ); - if(_distanceToTarget < ( ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ) * 1.5) then { - _state set[0, STAGE_TERMINAL]; - } else { - _returnTargetPos = _seekerTargetPos vectorAdd [0,0,(_projectilePos select 2)]; - }; - }; - case STAGE_TERMINAL: { - TRACE_1("STAGE_TERMINAL",""); - //_returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget * 0.02]; - _returnTargetPos = _seekerTargetPos; - }; -}; - -#ifdef DEBUG_MODE_FULL -drawLine3D [(ASLtoATL _returnTargetPos), (ASLtoATL _seekerTargetPos), [0,1,0,1]]; -#endif - -TRACE_1("Adjusted target position", _returnTargetPos); +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +#define STAGE_LAUNCH 1 +#define STAGE_CLIMB 2 +#define STAGE_COAST 3 +#define STAGE_TERMINAL 4 + +EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +private["_targetPos", "_projectilePos", "_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams"]; +private["_distanceToTarget", "_distanceToShooter", "_addHeight", "_returnTargetPos", "_state"]; +private["_cruisAlt", "_distanceShooterToTarget", "_shooterPos"]; + +_seekerTargetPos = _this select 0; +_launchParams = _this select 1; + +_target = _launchParams select 0; +_targetLaunchParams = _launchParams select 1; + +_state = _this select 2; +if( (count _state) < 1) then { + _state set[0, STAGE_LAUNCH]; +}; + +_shooterPos = getPosASL _shooter; +_projectilePos = getPosASL _projectile; + +_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos; +_distanceToShooter = _projectilePos vectorDistance _shooterPos; +_distanceShooterToTarget = _shooterPos vectorDistance _seekerTargetPos; + +TRACE_2("", _distanceToTarget, _distanceToShooter); + +// Add height depending on distance for compensate +_returnTargetPos = _seekerTargetPos; + +switch( (_state select 0) ) do { + case STAGE_LAUNCH: { + TRACE_1("STAGE_LAUNCH",""); + if(_distanceToShooter < 10) then { + _returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*2]; + } else { + _state set[0, STAGE_CLIMB]; + }; + }; + case STAGE_CLIMB: { + TRACE_1("STAGE_CLIMB",""); + _cruisAlt = 140; + if(_distanceShooterToTarget < 1250) then { + _cruisAlt = 140 * (_distanceShooterToTarget/1250); + TRACE_1("_cruisAlt", _cruisAlt); + }; + if( ((ASLToATL _projectilePos) select 2) - ((ASLToATL _seekerTargetPos) select 2) >= _cruisAlt) then { + if(_cruisAlt < 140) then { + _state set[0, STAGE_TERMINAL]; + } else { + _state set[0, STAGE_COAST]; + }; + } else { + _returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget*1.5]; + }; + }; + case STAGE_COAST: { + TRACE_1("STAGE_COAST",""); + TRACE_1("", ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ); + if(_distanceToTarget < ( ((ASLToATL _projectilePos) select 2) - (( ASLToATL _seekerTargetPos) select 2) ) * 1.5) then { + _state set[0, STAGE_TERMINAL]; + } else { + _returnTargetPos = _seekerTargetPos vectorAdd [0,0,(_projectilePos select 2)]; + }; + }; + case STAGE_TERMINAL: { + TRACE_1("STAGE_TERMINAL",""); + //_returnTargetPos = _seekerTargetPos vectorAdd [0,0,_distanceToTarget * 0.02]; + _returnTargetPos = _seekerTargetPos; + }; +}; + +#ifdef DEBUG_MODE_FULL +drawLine3D [(ASLtoATL _returnTargetPos), (ASLtoATL _seekerTargetPos), [0,1,0,1]]; +#endif + +TRACE_1("Adjusted target position", _returnTargetPos); _returnTargetPos; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_attackProfile_LIN.sqf b/addons/missileguidance/functions/fnc_attackProfile_LIN.sqf index 8c67e68402..4369f37ef4 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_LIN.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_LIN.sqf @@ -1,50 +1,50 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -private["_targetPos", "_projectilePos", "_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams"]; -private["_distanceToTarget", "_distanceToShooter", "_addHeight", "_returnTargetPos", "_shooterPos"]; -_seekerTargetPos = _this select 0; -_launchParams = _this select 1; - -_target = _launchParams select 0; -_targetLaunchParams = _launchParams select 1; - -_shooterPos = getPosASL _shooter; -_projectilePos = getPosASL _projectile; - -_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos; -_distanceToShooter = _projectilePos vectorDistance _shooterPos; - -TRACE_3("", _distanceToTarget, _distanceToShooter, _seekerTargetPos); - -// Add height depending on distance for compensate -_addHeight = [0,0,0]; - -// Always climb an arc on initial launch if we are close to the round -if( ((ASLtoATL _projectilePos) select 2) < 5 && _distanceToShooter < 15) then { - _addHeight = _addHeight vectorAdd [0,0,_distanceToTarget]; -} else { - // If we are below the target, increase the climbing arc - if((_projectilePos select 2) < (_seekerTargetPos select 2) && _distanceToTarget > 100) then { - _addHeight = _addHeight vectorAdd [0,0, ((_seekerTargetPos select 2) - (_projectilePos select 2))]; - }; -}; - -// Handle arcing terminal low for high decent -if( (_projectilePos select 2) > (_seekerTargetPos select 2) && _distanceToTarget < 100) then { - _addHeight = _addHeight vectorDiff [0,0, ((_projectilePos select 2) - (_seekerTargetPos select 2)) * 0.5]; -} else { - if((_projectilePos select 2) > (_seekerTargetPos select 2) && _distanceToTarget > 100) then { - _addHeight = _addHeight vectorAdd [0,0, _distanceToTarget*0.02]; - }; -}; - -_returnTargetPos = _seekerTargetPos vectorAdd _addHeight; - -#ifdef DEBUG_MODE_FULL -drawLine3D [(ASLtoATL _returnTargetPos) vectorAdd _addHeight, ASLtoATL _returnTargetPos, [0,1,0,1]]; -#endif - -TRACE_1("Adjusted target position", _returnTargetPos); +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +private["_targetPos", "_projectilePos", "_target", "_seekerTargetPos", "_launchParams", "_targetLaunchParams"]; +private["_distanceToTarget", "_distanceToShooter", "_addHeight", "_returnTargetPos", "_shooterPos"]; +_seekerTargetPos = _this select 0; +_launchParams = _this select 1; + +_target = _launchParams select 0; +_targetLaunchParams = _launchParams select 1; + +_shooterPos = getPosASL _shooter; +_projectilePos = getPosASL _projectile; + +_distanceToTarget = _projectilePos vectorDistance _seekerTargetPos; +_distanceToShooter = _projectilePos vectorDistance _shooterPos; + +TRACE_3("", _distanceToTarget, _distanceToShooter, _seekerTargetPos); + +// Add height depending on distance for compensate +_addHeight = [0,0,0]; + +// Always climb an arc on initial launch if we are close to the round +if( ((ASLtoATL _projectilePos) select 2) < 5 && _distanceToShooter < 15) then { + _addHeight = _addHeight vectorAdd [0,0,_distanceToTarget]; +} else { + // If we are below the target, increase the climbing arc + if((_projectilePos select 2) < (_seekerTargetPos select 2) && _distanceToTarget > 100) then { + _addHeight = _addHeight vectorAdd [0,0, ((_seekerTargetPos select 2) - (_projectilePos select 2))]; + }; +}; + +// Handle arcing terminal low for high decent +if( (_projectilePos select 2) > (_seekerTargetPos select 2) && _distanceToTarget < 100) then { + _addHeight = _addHeight vectorDiff [0,0, ((_projectilePos select 2) - (_seekerTargetPos select 2)) * 0.5]; +} else { + if((_projectilePos select 2) > (_seekerTargetPos select 2) && _distanceToTarget > 100) then { + _addHeight = _addHeight vectorAdd [0,0, _distanceToTarget*0.02]; + }; +}; + +_returnTargetPos = _seekerTargetPos vectorAdd _addHeight; + +#ifdef DEBUG_MODE_FULL +drawLine3D [(ASLtoATL _returnTargetPos) vectorAdd _addHeight, ASLtoATL _returnTargetPos, [0,1,0,1]]; +#endif + +TRACE_1("Adjusted target position", _returnTargetPos); _returnTargetPos; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_attackProfile_MID.sqf b/addons/missileguidance/functions/fnc_attackProfile_MID.sqf index 498b754287..9909124e2f 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_MID.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_MID.sqf @@ -1,4 +1,4 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + _this call FUNC(attackProfile_LIN); \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_changeMissileDirection.sqf b/addons/missileguidance/functions/fnc_changeMissileDirection.sqf index fda7ba9d07..f5fdee95a0 100644 --- a/addons/missileguidance/functions/fnc_changeMissileDirection.sqf +++ b/addons/missileguidance/functions/fnc_changeMissileDirection.sqf @@ -1,11 +1,11 @@ -#include "script_component.hpp" -private ["_projectile", "_v", "_l", "_r"]; - -_projectile = _this select 0; -_v = _this select 1; - -_l = sqrt ((_v select 0) ^ 2 + (_v select 1) ^ 2); -_r = -(_v select 2) / _l; - -_projectile setVectorDirAndUp [ _v, [(_v select 0) * _r,(_v select 1) * _r, _l] ]; +#include "script_component.hpp" +private ["_projectile", "_v", "_l", "_r"]; + +_projectile = _this select 0; +_v = _this select 1; + +_l = sqrt ((_v select 0) ^ 2 + (_v select 1) ^ 2); +_r = -(_v select 2) / _l; + +_projectile setVectorDirAndUp [ _v, [(_v select 0) * _r,(_v select 1) * _r, _l] ]; _projectile setVelocity (_v vectorMultiply (vectorMagnitude (velocity _projectile))); \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_checkLos.sqf b/addons/missileguidance/functions/fnc_checkLos.sqf index f21a841367..764769b2f2 100644 --- a/addons/missileguidance/functions/fnc_checkLos.sqf +++ b/addons/missileguidance/functions/fnc_checkLos.sqf @@ -1,29 +1,29 @@ -/* - * Author: jaynus - * Returns whether the seeker object can see the target position with lineIntersect - * - * Argument: - * 0: Seeker [Object] - * 1: Target [Object] - * - * Return value: - * Boolean - */ -#include "script_component.hpp" -private["_seeker", "_seekerPos", "_target", "_targetPos", "_return", "_vectorTo", "_searchPos"]; -_seeker = _this select 0; -_target = _this select 1; - -_targetPos = getPosASL _target; -_seekerPos = getPosASL _seeker; -_return = true; - -if(!(terrainIntersectASL [ _seekerPos, _targetPos])) then { - if(lineIntersects [_seekerPos, _targetPos, _seeker, _target]) then { - _return = false; - }; -} else { - _return = false; -}; - +/* + * Author: jaynus + * Returns whether the seeker object can see the target position with lineIntersect + * + * Argument: + * 0: Seeker [Object] + * 1: Target [Object] + * + * Return value: + * Boolean + */ +#include "script_component.hpp" +private["_seeker", "_seekerPos", "_target", "_targetPos", "_return", "_vectorTo", "_searchPos"]; +_seeker = _this select 0; +_target = _this select 1; + +_targetPos = getPosASL _target; +_seekerPos = getPosASL _seeker; +_return = true; + +if(!(terrainIntersectASL [ _seekerPos, _targetPos])) then { + if(lineIntersects [_seekerPos, _targetPos, _seeker, _target]) then { + _return = false; + }; +} else { + _return = false; +}; + _return; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf b/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf index e8bc1a16f5..ff87b00e42 100644 --- a/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf +++ b/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf @@ -1,31 +1,31 @@ -/* - * Author: jaynus - * Returns whether the target position is within the maximum angle FOV of the provided seeker - * objects current direction. - * - * Argument: - * 0: Seeker [Object] - * 1: Target [Position] - * 2: Max Angle [Degrees] - * - * Return value: - * Boolean - */ - -#include "script_component.hpp" -private["_seeker", "_targetPos", "_seekerMaxAngle", "_sensorPos", "_testPointVector", "_testDotProduct"]; - -_seeker = _this select 0; -_targetPos = _this select 1; -_seekerMaxAngle = _this select 2; - -_sensorPos = getPosASL _seeker; - -_testPointVector = vectorNormalized (_targetPos vectorDiff _sensorPos); -_testDotProduct = (vectorNormalized (velocity _seeker)) vectorDotProduct _testPointVector; - -if(_testDotProduct < (cos _seekerMaxAngle)) exitWith { - false -}; - +/* + * Author: jaynus + * Returns whether the target position is within the maximum angle FOV of the provided seeker + * objects current direction. + * + * Argument: + * 0: Seeker [Object] + * 1: Target [Position] + * 2: Max Angle [Degrees] + * + * Return value: + * Boolean + */ + +#include "script_component.hpp" +private["_seeker", "_targetPos", "_seekerMaxAngle", "_sensorPos", "_testPointVector", "_testDotProduct"]; + +_seeker = _this select 0; +_targetPos = _this select 1; +_seekerMaxAngle = _this select 2; + +_sensorPos = getPosASL _seeker; + +_testPointVector = vectorNormalized (_targetPos vectorDiff _sensorPos); +_testDotProduct = (vectorNormalized (velocity _seeker)) vectorDotProduct _testPointVector; + +if(_testDotProduct < (cos _seekerMaxAngle)) exitWith { + false +}; + true \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_doAttackProfile.sqf b/addons/missileguidance/functions/fnc_doAttackProfile.sqf index 171e169651..436cf275fe 100644 --- a/addons/missileguidance/functions/fnc_doAttackProfile.sqf +++ b/addons/missileguidance/functions/fnc_doAttackProfile.sqf @@ -1,29 +1,29 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -private["_testName", "_attackProfilePos", "_attackProfile", "_attackProfileName", "_attackProfilesCfg", "_i", "_launchParams", "_testame", "_testProfile"]; -_launchParams = ((_this select 1) select 1); -_attackProfileName = _launchParams select 3; - -TRACE_1("Attacking profile", _attackProfileName); - -_attackProfilesCfg = ( configFile >> QGVAR(AttackProfiles) ); - -_attackProfile = nil; -for [{_i=0}, {_i< (count _attackProfilesCfg) }, {_i=_i+1}] do { - _testProfile = _attackProfilesCfg select _i; - _testName = configName _testProfile; - TRACE_3("", _testName, _testProfile, _attackProfilesCfg); - - if( _testName == _attackProfileName) exitWith { - _attackProfile = _attackProfilesCfg select _i; - }; -}; - -_attackProfilePos = [0,0,0]; -if(!isNil "_attackProfile") then { - _attackProfilePos = _this call (missionNamespace getVariable (getText (_attackProfile >> "functionName"))); -}; - -_attackProfilePos; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +private["_testName", "_attackProfilePos", "_attackProfile", "_attackProfileName", "_attackProfilesCfg", "_i", "_launchParams", "_testame", "_testProfile"]; +_launchParams = ((_this select 1) select 1); +_attackProfileName = _launchParams select 3; + +TRACE_1("Attacking profile", _attackProfileName); + +_attackProfilesCfg = ( configFile >> QGVAR(AttackProfiles) ); + +_attackProfile = nil; +for [{_i=0}, {_i< (count _attackProfilesCfg) }, {_i=_i+1}] do { + _testProfile = _attackProfilesCfg select _i; + _testName = configName _testProfile; + TRACE_3("", _testName, _testProfile, _attackProfilesCfg); + + if( _testName == _attackProfileName) exitWith { + _attackProfile = _attackProfilesCfg select _i; + }; +}; + +_attackProfilePos = [0,0,0]; +if(!isNil "_attackProfile") then { + _attackProfilePos = _this call (missionNamespace getVariable (getText (_attackProfile >> "functionName"))); +}; + +_attackProfilePos; diff --git a/addons/missileguidance/functions/fnc_doHandoff.sqf b/addons/missileguidance/functions/fnc_doHandoff.sqf index d99998c8c4..efed4e9340 100644 --- a/addons/missileguidance/functions/fnc_doHandoff.sqf +++ b/addons/missileguidance/functions/fnc_doHandoff.sqf @@ -1,4 +1,4 @@ -#include "script_component.hpp" -PARAMS_2(_target,_args); - +#include "script_component.hpp" +PARAMS_2(_target,_args); + [QGVAR(handoff), [_target, _args]] call EFUNC(common,globalEvent); \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_doSeekerSearch.sqf b/addons/missileguidance/functions/fnc_doSeekerSearch.sqf index bd300effe8..fe73cd5118 100644 --- a/addons/missileguidance/functions/fnc_doSeekerSearch.sqf +++ b/addons/missileguidance/functions/fnc_doSeekerSearch.sqf @@ -1,30 +1,30 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -private["_seekerProfilePos", "_i", "_launchParams", "_seekerType", "_seekerTypeName", "_seekerTypesCfg", "_testName", "_testProfile"]; - -_launchParams = ((_this select 1) select 1); -_seekerTypeName = _launchParams select 2; - -TRACE_1("Seeker type", _seekerTypeName); - -_seekerTypesCfg = ( configFile >> QGVAR(SeekerTypes) ); - -_seekerType = nil; -for [{_i=0}, {_i< (count _seekerTypesCfg) }, {_i=_i+1}] do { - _testProfile = _seekerTypesCfg select _i; - _testName = configName _testProfile; - TRACE_3("", _testName, _testProfile, _seekerTypesCfg); - - if( _testName == _seekerTypeName) exitWith { - _seekerType = _seekerTypesCfg select _i; - }; -}; - -_seekerProfilePos = [0,0,0]; -if(!isNil "_seekerType") then { - _seekerProfilePos = _this call (missionNamespace getVariable (getText (_seekerType >> "functionName"))); -}; - -_seekerProfilePos; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +private["_seekerProfilePos", "_i", "_launchParams", "_seekerType", "_seekerTypeName", "_seekerTypesCfg", "_testName", "_testProfile"]; + +_launchParams = ((_this select 1) select 1); +_seekerTypeName = _launchParams select 2; + +TRACE_1("Seeker type", _seekerTypeName); + +_seekerTypesCfg = ( configFile >> QGVAR(SeekerTypes) ); + +_seekerType = nil; +for [{_i=0}, {_i< (count _seekerTypesCfg) }, {_i=_i+1}] do { + _testProfile = _seekerTypesCfg select _i; + _testName = configName _testProfile; + TRACE_3("", _testName, _testProfile, _seekerTypesCfg); + + if( _testName == _seekerTypeName) exitWith { + _seekerType = _seekerTypesCfg select _i; + }; +}; + +_seekerProfilePos = [0,0,0]; +if(!isNil "_seekerType") then { + _seekerProfilePos = _this call (missionNamespace getVariable (getText (_seekerType >> "functionName"))); +}; + +_seekerProfilePos; diff --git a/addons/missileguidance/functions/fnc_guidancePFH.sqf b/addons/missileguidance/functions/fnc_guidancePFH.sqf index 122d690bae..43e9ad2925 100644 --- a/addons/missileguidance/functions/fnc_guidancePFH.sqf +++ b/addons/missileguidance/functions/fnc_guidancePFH.sqf @@ -1,106 +1,106 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -#define TIMESTEP_FACTOR 0.01 - -private["_launchParams", "_targetLaunchParams", "_flightParams", "_seekerParams", "_stateParams"]; -private["_lastRunTime", "_runtimeDelta", "_adjustTime", "_args", "_seekerTargetPos", "_projectilePos"]; -private["_profileAdjustedTargetPos", "_incDeflection", "_minDeflection", "_maxDeflection"]; -private["_targetVector", "_adjustVector", "_finalAdjustVector", "_changeVector", "_pitch", "_yaw", "_roll"]; -private["_PS", "_distanceToTarget", "_targetRelativeVector", "_vectorTo"]; - -_args = _this select 0; -EXPLODE_7_PVT((_args select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - -if(!alive _projectile || isNull _projectile || isNull _shooter) exitWith { - [(_this select 1)] call CBA_fnc_removePerFrameHandler; -}; - -_launchParams = _args select 1; -_targetLaunchParams = _launchParams select 1; -_flightParams = _args select 2; -_seekerParams = _args select 3; - -_stateParams = _args select 4; - -_lastRunTime = _stateParams select 0; -_runtimeDelta = ACE_diagTime - _lastRunTime; -_adjustTime = 1; - -if(accTime > 0) then { - _adjustTime = 1/accTime; - _adjustTime = _adjustTime * (_runtimeDelta / TIMESTEP_FACTOR); - TRACE_4("Adjust timing", 1/accTime, _adjustTime, _runtimeDelta, (_runtimeDelta / TIMESTEP_FACTOR) ); -} else { - _adjustTime = 0; -}; - -_minDeflection = ((_flightParams select 0) - ((_flightParams select 0) * _adjustTime)) max 0; -_maxDeflection = (_flightParams select 1) * _adjustTime; -_incDeflection = _flightParams select 2; - -_projectilePos = getPosASL _projectile; - -// @TODO: placeholder for "last seek target position" -// Last target pos should be optional based on the seeker unit -_seekerTargetPos = [ [0,0,0], _args, (_stateParams select 1)] call FUNC(doSeekerSearch); -if(isNil "_seekerTargetPos") then { - _seekerTargetPos = _seekerTargetPos vectorAdd ((velocity _projectile) vectorMultiply 5); -} else { - if( (vectorMagnitude _seekerTargetPos) == 0) then { - _seekerTargetPos = _seekerTargetPos vectorAdd ((velocity _projectile) vectorMultiply 5); - }; -}; - -_profileAdjustedTargetPos = [_seekerTargetPos,_args, (_stateParams select 2)] call FUNC(doAttackProfile); -_targetVector = _projectilePos vectorFromTo _profileAdjustedTargetPos; -_adjustVector = _targetVector vectorDiff (vectorDir _projectile); - -_yaw = 0; -_pitch = 0; -_roll = 0; -if((_adjustVector select 0) < 0) then { - _yaw = - ( (_minDeflection max (abs(_adjustVector select 0) min _maxDeflection) ) ); -} else { - if((_adjustVector select 0) > 0) then { - _yaw = ( (_minDeflection max ((_adjustVector select 0) min _maxDeflection) ) ); - }; -}; -if((_adjustVector select 1) < 0) then { - _roll = - ( (_minDeflection max (abs(_adjustVector select 1) min _maxDeflection) ) ); -} else { - if((_adjustVector select 1) > 0) then { - _roll = ( (_minDeflection max ((_adjustVector select 1) min _maxDeflection) ) ); - }; -}; -if((_adjustVector select 2) < 0) then { - _pitch = - ( (_minDeflection max (abs(_adjustVector select 2) min _maxDeflection) ) ); -} else { - if((_adjustVector select 2) > 0) then { - _pitch = ( (_minDeflection max ((_adjustVector select 2) min _maxDeflection) ) ); - }; -}; -_finalAdjustVector = [_yaw, _roll, _pitch]; -TRACE_2("", _pitch, _yaw); -TRACE_4("", _targetVector, _targetRelativeVector, _adjustVector, _finalAdjustVector); - -if(accTime > 0) then { - _changeVector = (vectorDir _projectile) vectorAdd _finalAdjustVector; - [_projectile, _changeVector] call FUNC(changeMissileDirection); -}; - -#ifdef DEBUG_MODE_FULL -drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _projectilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; -drawLine3D [ASLtoATL _projectilePos, ASLtoATL _profileAdjustedTargetPos, [1,0,0,1]]; - -_ps = "#particlesource" createVehicleLocal (ASLtoATL _projectilePos); -_PS setParticleParams [["\A3\Data_f\cl_basic", 8, 3, 1], "", "Billboard", 1, 3.0141, [0, 0, 2], [0, 0, 0], 1, 1.275, 1, 0, [1, 1], [[1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1]], [1], 1, 0, "", "", nil]; -_PS setDropInterval 3.0; - -hintSilent format["d: %1", _distanceToTarget]; -#endif - -_stateParams set[0, ACE_diagTime]; - -_args set[4, _stateParams]; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +#define TIMESTEP_FACTOR 0.01 + +private["_launchParams", "_targetLaunchParams", "_flightParams", "_seekerParams", "_stateParams"]; +private["_lastRunTime", "_runtimeDelta", "_adjustTime", "_args", "_seekerTargetPos", "_projectilePos"]; +private["_profileAdjustedTargetPos", "_incDeflection", "_minDeflection", "_maxDeflection"]; +private["_targetVector", "_adjustVector", "_finalAdjustVector", "_changeVector", "_pitch", "_yaw", "_roll"]; +private["_PS", "_distanceToTarget", "_targetRelativeVector", "_vectorTo"]; + +_args = _this select 0; +EXPLODE_7_PVT((_args select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + +if(!alive _projectile || isNull _projectile || isNull _shooter) exitWith { + [(_this select 1)] call CBA_fnc_removePerFrameHandler; +}; + +_launchParams = _args select 1; +_targetLaunchParams = _launchParams select 1; +_flightParams = _args select 2; +_seekerParams = _args select 3; + +_stateParams = _args select 4; + +_lastRunTime = _stateParams select 0; +_runtimeDelta = ACE_diagTime - _lastRunTime; +_adjustTime = 1; + +if(accTime > 0) then { + _adjustTime = 1/accTime; + _adjustTime = _adjustTime * (_runtimeDelta / TIMESTEP_FACTOR); + TRACE_4("Adjust timing", 1/accTime, _adjustTime, _runtimeDelta, (_runtimeDelta / TIMESTEP_FACTOR) ); +} else { + _adjustTime = 0; +}; + +_minDeflection = ((_flightParams select 0) - ((_flightParams select 0) * _adjustTime)) max 0; +_maxDeflection = (_flightParams select 1) * _adjustTime; +_incDeflection = _flightParams select 2; + +_projectilePos = getPosASL _projectile; + +// @TODO: placeholder for "last seek target position" +// Last target pos should be optional based on the seeker unit +_seekerTargetPos = [ [0,0,0], _args, (_stateParams select 1)] call FUNC(doSeekerSearch); +if(isNil "_seekerTargetPos") then { + _seekerTargetPos = _seekerTargetPos vectorAdd ((velocity _projectile) vectorMultiply 5); +} else { + if( (vectorMagnitude _seekerTargetPos) == 0) then { + _seekerTargetPos = _seekerTargetPos vectorAdd ((velocity _projectile) vectorMultiply 5); + }; +}; + +_profileAdjustedTargetPos = [_seekerTargetPos,_args, (_stateParams select 2)] call FUNC(doAttackProfile); +_targetVector = _projectilePos vectorFromTo _profileAdjustedTargetPos; +_adjustVector = _targetVector vectorDiff (vectorDir _projectile); + +_yaw = 0; +_pitch = 0; +_roll = 0; +if((_adjustVector select 0) < 0) then { + _yaw = - ( (_minDeflection max (abs(_adjustVector select 0) min _maxDeflection) ) ); +} else { + if((_adjustVector select 0) > 0) then { + _yaw = ( (_minDeflection max ((_adjustVector select 0) min _maxDeflection) ) ); + }; +}; +if((_adjustVector select 1) < 0) then { + _roll = - ( (_minDeflection max (abs(_adjustVector select 1) min _maxDeflection) ) ); +} else { + if((_adjustVector select 1) > 0) then { + _roll = ( (_minDeflection max ((_adjustVector select 1) min _maxDeflection) ) ); + }; +}; +if((_adjustVector select 2) < 0) then { + _pitch = - ( (_minDeflection max (abs(_adjustVector select 2) min _maxDeflection) ) ); +} else { + if((_adjustVector select 2) > 0) then { + _pitch = ( (_minDeflection max ((_adjustVector select 2) min _maxDeflection) ) ); + }; +}; +_finalAdjustVector = [_yaw, _roll, _pitch]; +TRACE_2("", _pitch, _yaw); +TRACE_4("", _targetVector, _targetRelativeVector, _adjustVector, _finalAdjustVector); + +if(accTime > 0) then { + _changeVector = (vectorDir _projectile) vectorAdd _finalAdjustVector; + [_projectile, _changeVector] call FUNC(changeMissileDirection); +}; + +#ifdef DEBUG_MODE_FULL +drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,1,1], ASLtoATL _projectilePos, 0.75, 0.75, 0, str _vectorTo, 1, 0.025, "TahomaB"]; +drawLine3D [ASLtoATL _projectilePos, ASLtoATL _profileAdjustedTargetPos, [1,0,0,1]]; + +_ps = "#particlesource" createVehicleLocal (ASLtoATL _projectilePos); +_PS setParticleParams [["\A3\Data_f\cl_basic", 8, 3, 1], "", "Billboard", 1, 3.0141, [0, 0, 2], [0, 0, 0], 1, 1.275, 1, 0, [1, 1], [[1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1]], [1], 1, 0, "", "", nil]; +_PS setDropInterval 3.0; + +hintSilent format["d: %1", _distanceToTarget]; +#endif + +_stateParams set[0, ACE_diagTime]; + +_args set[4, _stateParams]; _this set[0, _args]; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_handleHandoff.sqf b/addons/missileguidance/functions/fnc_handleHandoff.sqf index 7145bc0038..af23ed84d8 100644 --- a/addons/missileguidance/functions/fnc_handleHandoff.sqf +++ b/addons/missileguidance/functions/fnc_handleHandoff.sqf @@ -1,6 +1,6 @@ -#include "script_component.hpp" -PARAMS_2(_target,_args); - -if(isNil "_target" || {isNull _target} || {!local _target} ) exitWith { false }; - +#include "script_component.hpp" +PARAMS_2(_target,_args); + +if(isNil "_target" || {isNull _target} || {!local _target} ) exitWith { false }; + [FUNC(guidancePFH), 0, _args] call CBA_fnc_addPerFrameHandler; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_onFired.sqf b/addons/missileguidance/functions/fnc_onFired.sqf index 26f8d14c6e..068fab152b 100644 --- a/addons/missileguidance/functions/fnc_onFired.sqf +++ b/addons/missileguidance/functions/fnc_onFired.sqf @@ -1,118 +1,118 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - -// Bail if guidance is disabled -// Bail on locality of the projectile, it should be local to us -if(GVAR(enabled) < 1 || {!local _projectile} ) exitWith { false }; - -//Bail if shooter isn't player AND system not enabled for AI: -if( !isPlayer _shooter && { GVAR(enabled) < 2 } ) exitWith { false }; - -// Bail on not missile -if(! (_ammo isKindOf "MissileBase") ) exitWith { false }; - -private["_config", "_configs", "_enabled", "_target", "_seekerType", "_attackProfile"]; -private["_args", "_canUseLock", "_guidingUnit", "_launchPos", "_lockMode", "_targetPos", "_vanillaTarget"]; - -//Verify ammo has explicity added guidance config (ignore inheritances) -_configs = configProperties [(configFile >> "CfgAmmo" >> _ammo), QUOTE(configName _x == QUOTE(QUOTE(ADDON))), false]; -if( (count _configs) < 1) exitWith {}; - -_config = (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON)); -_enabled = getNumber ( _config >> "enabled"); - -// Bail if guidance is not enabled -if(isNil "_enabled" || {_enabled != 1}) exitWith { false }; - -_target = (vehicle _shooter) getVariable [QGVAR(target), nil]; -_targetPos = (vehicle _shooter) getVariable [QGVAR(targetPosition), nil]; -_seekerType = (vehicle _shooter) getVariable [QGVAR(seekerType), nil]; -_attackProfile = (vehicle _shooter) getVariable [QGVAR(attackProfile), nil]; -_lockMode = (vehicle _shooter) getVariable [QGVAR(lockMode), nil]; - -// @TODO: make this vehicle shooter, but we need to differentiate where its set in ace_laser -_laserCode = _shooter getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE]; -_laserInfo = [_laserCode, ACE_DEFAULT_LASER_WAVELENGTH, ACE_DEFAULT_LASER_WAVELENGTH]; - -_launchPos = getPosASL (vehicle _shooter); - -TRACE_3("Begin guidance", _target, _seekerType, _attackProfile); - -if (isNil "_seekerType" || {!(_seekerType in (getArray (_config >> "seekerTypes")))}) then { - _seekerType = getText (_config >> "defaultSeekerType"); -}; -if (isNil "_attackProfile" || {!(_attackProfile in (getArray (_config >> "attackProfiles")))}) then { - _attackProfile = getText (_config >> "defaultAttackProfile"); -}; -if (isNil "_lockMode" || {!(_lockMode in (getArray (_config >> "seekerLockModes")))}) then { - _lockMode = getText (_config >> "defaultSeekerLockMode"); -}; - -// If we didn't get a target, try to fall back on tab locking -if(isNil "_target") then { - if(!isPlayer _shooter) then { - // This was an AI shot, lets still guide it on the AI target - _target = _shooter getVariable[QGVAR(vanilla_target), nil]; - TRACE_1("Detected AI Shooter!", _target); - } else { - _canUseLock = getNumber (_config >> "canVanillaLock"); - // @TODO: Get vanilla target - if(_canUseLock > 0 || difficulty < 1) then { - _vanillaTarget = cursorTarget; - - TRACE_1("Using Vanilla Locking", _vanillaTarget); - if(!isNil "_vanillaTarget") then { - _target = _vanillaTarget; - }; - }; - }; -}; - -TRACE_4("Beginning ACE guidance system",_target,_ammo,_seekerType,_attackProfile); -_args = [_this, - [_shooter, - [_target, _targetPos, _launchPos], - _seekerType, - _attackProfile, - _lockMode, - _laserInfo - ], - [ - getNumber ( _config >> "minDeflection" ), - getNumber ( _config >> "maxDeflection" ), - getNumber ( _config >> "incDeflection" ) - ], - [ - getNumber ( _config >> "seekerAngle" ), - getNumber ( _config >> "seekerAccuracy" ), - getNumber ( _config >> "seekerMaxRange" ) - ], - [ ACE_diagTime, [], [] ] - ]; - -// Hand off to the guiding unit. We just use local player so local PFH fires for now -// Laser code needs to give us a shooter for LOBL, or the seeker unit needs to be able to shift locality -// Based on its homing laser -// Lasers need to be handled in a special LOAL/LOBL case - -//if(isPlayer _shooter) then { -// _guidingUnit = ACE_player; -// -// if(local _guidingUnit) then { -// [FUNC(guidancePFH), 0, _args ] call CBA_fnc_addPerFrameHandler; -// } else { -// [QGVAR(handoff), [_guidingUnit, _args] ] call FUNC(doHandoff); -// }; -//} else { - [FUNC(guidancePFH), 0, _args ] call CBA_fnc_addPerFrameHandler; -//}; - - -/* Clears locking settings -(vehicle _shooter) setVariable [QGVAR(target), nil]; -(vehicle _shooter) setVariable [QGVAR(seekerType), nil]; -(vehicle _shooter) setVariable [QGVAR(attackProfile), nil]; -(vehicle _shooter) setVariable [QGVAR(lockMode), nil]; -*/ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + +// Bail if guidance is disabled +// Bail on locality of the projectile, it should be local to us +if(GVAR(enabled) < 1 || {!local _projectile} ) exitWith { false }; + +//Bail if shooter isn't player AND system not enabled for AI: +if( !isPlayer _shooter && { GVAR(enabled) < 2 } ) exitWith { false }; + +// Bail on not missile +if(! (_ammo isKindOf "MissileBase") ) exitWith { false }; + +private["_config", "_configs", "_enabled", "_target", "_seekerType", "_attackProfile"]; +private["_args", "_canUseLock", "_guidingUnit", "_launchPos", "_lockMode", "_targetPos", "_vanillaTarget"]; + +//Verify ammo has explicity added guidance config (ignore inheritances) +_configs = configProperties [(configFile >> "CfgAmmo" >> _ammo), QUOTE(configName _x == QUOTE(QUOTE(ADDON))), false]; +if( (count _configs) < 1) exitWith {}; + +_config = (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON)); +_enabled = getNumber ( _config >> "enabled"); + +// Bail if guidance is not enabled +if(isNil "_enabled" || {_enabled != 1}) exitWith { false }; + +_target = (vehicle _shooter) getVariable [QGVAR(target), nil]; +_targetPos = (vehicle _shooter) getVariable [QGVAR(targetPosition), nil]; +_seekerType = (vehicle _shooter) getVariable [QGVAR(seekerType), nil]; +_attackProfile = (vehicle _shooter) getVariable [QGVAR(attackProfile), nil]; +_lockMode = (vehicle _shooter) getVariable [QGVAR(lockMode), nil]; + +// @TODO: make this vehicle shooter, but we need to differentiate where its set in ace_laser +_laserCode = _shooter getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE]; +_laserInfo = [_laserCode, ACE_DEFAULT_LASER_WAVELENGTH, ACE_DEFAULT_LASER_WAVELENGTH]; + +_launchPos = getPosASL (vehicle _shooter); + +TRACE_3("Begin guidance", _target, _seekerType, _attackProfile); + +if (isNil "_seekerType" || {!(_seekerType in (getArray (_config >> "seekerTypes")))}) then { + _seekerType = getText (_config >> "defaultSeekerType"); +}; +if (isNil "_attackProfile" || {!(_attackProfile in (getArray (_config >> "attackProfiles")))}) then { + _attackProfile = getText (_config >> "defaultAttackProfile"); +}; +if (isNil "_lockMode" || {!(_lockMode in (getArray (_config >> "seekerLockModes")))}) then { + _lockMode = getText (_config >> "defaultSeekerLockMode"); +}; + +// If we didn't get a target, try to fall back on tab locking +if(isNil "_target") then { + if(!isPlayer _shooter) then { + // This was an AI shot, lets still guide it on the AI target + _target = _shooter getVariable[QGVAR(vanilla_target), nil]; + TRACE_1("Detected AI Shooter!", _target); + } else { + _canUseLock = getNumber (_config >> "canVanillaLock"); + // @TODO: Get vanilla target + if(_canUseLock > 0 || difficulty < 1) then { + _vanillaTarget = cursorTarget; + + TRACE_1("Using Vanilla Locking", _vanillaTarget); + if(!isNil "_vanillaTarget") then { + _target = _vanillaTarget; + }; + }; + }; +}; + +TRACE_4("Beginning ACE guidance system",_target,_ammo,_seekerType,_attackProfile); +_args = [_this, + [_shooter, + [_target, _targetPos, _launchPos], + _seekerType, + _attackProfile, + _lockMode, + _laserInfo + ], + [ + getNumber ( _config >> "minDeflection" ), + getNumber ( _config >> "maxDeflection" ), + getNumber ( _config >> "incDeflection" ) + ], + [ + getNumber ( _config >> "seekerAngle" ), + getNumber ( _config >> "seekerAccuracy" ), + getNumber ( _config >> "seekerMaxRange" ) + ], + [ ACE_diagTime, [], [] ] + ]; + +// Hand off to the guiding unit. We just use local player so local PFH fires for now +// Laser code needs to give us a shooter for LOBL, or the seeker unit needs to be able to shift locality +// Based on its homing laser +// Lasers need to be handled in a special LOAL/LOBL case + +//if(isPlayer _shooter) then { +// _guidingUnit = ACE_player; +// +// if(local _guidingUnit) then { +// [FUNC(guidancePFH), 0, _args ] call CBA_fnc_addPerFrameHandler; +// } else { +// [QGVAR(handoff), [_guidingUnit, _args] ] call FUNC(doHandoff); +// }; +//} else { + [FUNC(guidancePFH), 0, _args ] call CBA_fnc_addPerFrameHandler; +//}; + + +/* Clears locking settings +(vehicle _shooter) setVariable [QGVAR(target), nil]; +(vehicle _shooter) setVariable [QGVAR(seekerType), nil]; +(vehicle _shooter) setVariable [QGVAR(attackProfile), nil]; +(vehicle _shooter) setVariable [QGVAR(lockMode), nil]; +*/ diff --git a/addons/missileguidance/functions/fnc_onIncomingMissile.sqf b/addons/missileguidance/functions/fnc_onIncomingMissile.sqf index 33ebeb34e2..14902c32a5 100644 --- a/addons/missileguidance/functions/fnc_onIncomingMissile.sqf +++ b/addons/missileguidance/functions/fnc_onIncomingMissile.sqf @@ -1,8 +1,8 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" -PARAMS_3(_target,_ammo,_shooter); - -if(GVAR(enabled) < 1) exitWith {}; // bail if enabled -if !(local (gunner _shooter) || {local _shooter}) exitWith {}; // bail if not shooter - +//#define DEBUG_MODE_FULL +#include "script_component.hpp" +PARAMS_3(_target,_ammo,_shooter); + +if(GVAR(enabled) < 1) exitWith {}; // bail if enabled +if !(local (gunner _shooter) || {local _shooter}) exitWith {}; // bail if not shooter + _shooter setVariable [QGVAR(vanilla_target),_target, false]; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_rotateVectLine.sqf b/addons/missileguidance/functions/fnc_rotateVectLine.sqf index b9904f0e5a..b42c8d103d 100644 --- a/addons/missileguidance/functions/fnc_rotateVectLine.sqf +++ b/addons/missileguidance/functions/fnc_rotateVectLine.sqf @@ -1,39 +1,39 @@ -#include "script_component.hpp" -private["_d", "_map", "_p", "_theta", "_u"]; - -_map = _this select 0; -_theta = _this select 1; - -_p = _map select 0; -_p1 = _map select 1; -_p2 = _map select 2; - -_q1 = +(_map select 3); -_q2 = +(_map select 4); -_u = _map select 5; -_d = _map select 6; - -/* Step 4 */ -_q2 set[0, (_q1 select 0) * cos(_theta) - (_q1 select 1) * sin(_theta)]; -_q2 set[1, (_q1 select 0) * sin(_theta) + (_q1 select 1) * cos(_theta)]; -_q2 set[2, (_q1 select 2)]; - -/* Inverse of step 3 */ -_q1 set[0, (_q2 select 0) * _d + (_q2 select 2) * (_u select 0)]; -_q1 set[1, (_q2 select 1)]; -_q1 set[2, - (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; - -/* Inverse of step 2 */ -if (_d != 0) then { - _q2 set[0, (_q1 select 0)]; - _q2 set[1, (_q1 select 1) * (_u select 2) / _d + (_q1 select 2) * (_u select 1) / _d]; - _q2 set[2, - (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; -} else { - _q2 = _q1; -}; - -/* Inverse of step 1 */ -_q1 set[0, (_q2 select 0) + (_p1 select 0)]; -_q1 set[1, (_q2 select 1) + (_p1 select 1)]; -_q1 set[2, (_q2 select 2) + (_p1 select 2)]; +#include "script_component.hpp" +private["_d", "_map", "_p", "_theta", "_u"]; + +_map = _this select 0; +_theta = _this select 1; + +_p = _map select 0; +_p1 = _map select 1; +_p2 = _map select 2; + +_q1 = +(_map select 3); +_q2 = +(_map select 4); +_u = _map select 5; +_d = _map select 6; + +/* Step 4 */ +_q2 set[0, (_q1 select 0) * cos(_theta) - (_q1 select 1) * sin(_theta)]; +_q2 set[1, (_q1 select 0) * sin(_theta) + (_q1 select 1) * cos(_theta)]; +_q2 set[2, (_q1 select 2)]; + +/* Inverse of step 3 */ +_q1 set[0, (_q2 select 0) * _d + (_q2 select 2) * (_u select 0)]; +_q1 set[1, (_q2 select 1)]; +_q1 set[2, - (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; + +/* Inverse of step 2 */ +if (_d != 0) then { + _q2 set[0, (_q1 select 0)]; + _q2 set[1, (_q1 select 1) * (_u select 2) / _d + (_q1 select 2) * (_u select 1) / _d]; + _q2 set[2, - (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; +} else { + _q2 = _q1; +}; + +/* Inverse of step 1 */ +_q1 set[0, (_q2 select 0) + (_p1 select 0)]; +_q1 set[1, (_q2 select 1) + (_p1 select 1)]; +_q1 set[2, (_q2 select 2) + (_p1 select 2)]; _q1; \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_rotateVectLineGetMap.sqf b/addons/missileguidance/functions/fnc_rotateVectLineGetMap.sqf index fdbd6533ef..258cc93ae2 100644 --- a/addons/missileguidance/functions/fnc_rotateVectLineGetMap.sqf +++ b/addons/missileguidance/functions/fnc_rotateVectLineGetMap.sqf @@ -1,37 +1,37 @@ -#include "script_component.hpp" - -private ["_p", "_theta", "_p1", "_p2", "_q1", "_q2", "_u", "_d"]; -_p = _this select 0; -_p1 = _this select 1; -_p2 = _this select 2; - -_q1 = []; -_q2 = []; -_u = []; - -/* Step 1 */ -_q1 set[0, (_p select 0) - (_p1 select 0)]; -_q1 set[1, (_p select 1) - (_p1 select 1)]; -_q1 set[2, (_p select 2) - (_p1 select 2)]; - -_u set[0, (_p2 select 0) - (_p1 select 0)]; -_u set[1, (_p2 select 1) - (_p1 select 1)]; -_u set[2, (_p2 select 2) - (_p1 select 2)]; -_u = _u call BIS_fnc_unitVector; -_d = sqrt((_u select 1)*(_u select 1) + (_u select 2)*(_u select 2)); - -/* Step 2 */ -if (_d != 0) then { - _q2 set[0, (_q1 select 0)]; - _q2 set[1, (_q1 select 1) * (_u select 2) / _d - (_q1 select 2) * (_u select 1) / _d]; - _q2 set[2, (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; -} else { - _q2 = _q1; -}; - -/* Step 3 */ -_q1 set[0, (_q2 select 0) * _d - (_q2 select 2) * (_u select 0)]; -_q1 set[1, (_q2 select 1)]; -_q1 set[2, (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; - +#include "script_component.hpp" + +private ["_p", "_theta", "_p1", "_p2", "_q1", "_q2", "_u", "_d"]; +_p = _this select 0; +_p1 = _this select 1; +_p2 = _this select 2; + +_q1 = []; +_q2 = []; +_u = []; + +/* Step 1 */ +_q1 set[0, (_p select 0) - (_p1 select 0)]; +_q1 set[1, (_p select 1) - (_p1 select 1)]; +_q1 set[2, (_p select 2) - (_p1 select 2)]; + +_u set[0, (_p2 select 0) - (_p1 select 0)]; +_u set[1, (_p2 select 1) - (_p1 select 1)]; +_u set[2, (_p2 select 2) - (_p1 select 2)]; +_u = _u call BIS_fnc_unitVector; +_d = sqrt((_u select 1)*(_u select 1) + (_u select 2)*(_u select 2)); + +/* Step 2 */ +if (_d != 0) then { + _q2 set[0, (_q1 select 0)]; + _q2 set[1, (_q1 select 1) * (_u select 2) / _d - (_q1 select 2) * (_u select 1) / _d]; + _q2 set[2, (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; +} else { + _q2 = _q1; +}; + +/* Step 3 */ +_q1 set[0, (_q2 select 0) * _d - (_q2 select 2) * (_u select 0)]; +_q1 set[1, (_q2 select 1)]; +_q1 set[2, (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; + [_p, _p1, _p2, _q1, _q2, _u, _d] \ No newline at end of file diff --git a/addons/missileguidance/functions/fnc_seekerType_Optic.sqf b/addons/missileguidance/functions/fnc_seekerType_Optic.sqf index 0d80a2309e..8c9062fd49 100644 --- a/addons/missileguidance/functions/fnc_seekerType_Optic.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_Optic.sqf @@ -1,51 +1,51 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -private["_targets", "_foundTargetPos", "_launchParams", "_seekerParams", "_targetLaunchParams"]; -private["_angleFov", "_angleOkay", "_losOkay", "_seekerTargetPos", "_sensorPos", "_target"]; - -_seekerTargetPos = _this select 0; - -_launchParams = _this select 1; -_target = (((_launchParams select 1) select 1) select 0); -_seekerParams = _launchParams select 3; - -TRACE_1("", _this); -TRACE_1("", _launchParams); - -// TODO:: Make sure the missile maintains LOS -_foundTargetPos = [0,0,0]; -if(!isNil "_target") then { - _foundTargetPos = aimPos _target ; - //_foundTargetPos = (_target modelToWorldVisual (getCenterOfMass _target)); -}; - -// @TODO: This is seeker LOS and angle checks for LOAL only; LOBL does not need visual -_angleFov = _seekerParams select 0; -_angleOkay = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle); - -_losOkay = false; -if(_angleOkay) then { - _losOkay = [_projectile, _target] call FUNC(checkSeekerLos); //Note: Func does not exist? probably FUNC(checkLos)?? -}; -TRACE_2("", _angleOkay, _losOkay); - -// If we got here, it was an invalid target, just return a spot 5m in front of the missile -if(!_angleOkay || !_losOkay) then { - _foundTargetPos = _sensorPos vectorAdd ((velocity _projectile) vectorMultiply 5); -} else { - TRACE_2("", _target, _foundTargetPos); - private["_projectileSpeed", "_distanceToTarget", "_eta", "_adjustVelocity"]; - // @TODO: Configurable lead for seekers - _projectileSpeed = (vectorMagnitude velocity _projectile); - _distanceToTarget = (getPosASL _projectile) vectorDistance _foundTargetPos; - - _eta = _distanceToTarget / _projectileSpeed; - - _adjustVelocity = (velocity _target) vectorMultiply _eta; - _foundTargetPos = _foundTargetPos vectorAdd _adjustVelocity; -}; - - -_foundTargetPos; +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +private["_targets", "_foundTargetPos", "_launchParams", "_seekerParams", "_targetLaunchParams"]; +private["_angleFov", "_angleOkay", "_losOkay", "_seekerTargetPos", "_sensorPos", "_target"]; + +_seekerTargetPos = _this select 0; + +_launchParams = _this select 1; +_target = (((_launchParams select 1) select 1) select 0); +_seekerParams = _launchParams select 3; + +TRACE_1("", _this); +TRACE_1("", _launchParams); + +// TODO:: Make sure the missile maintains LOS +_foundTargetPos = [0,0,0]; +if(!isNil "_target") then { + _foundTargetPos = aimPos _target ; + //_foundTargetPos = (_target modelToWorldVisual (getCenterOfMass _target)); +}; + +// @TODO: This is seeker LOS and angle checks for LOAL only; LOBL does not need visual +_angleFov = _seekerParams select 0; +_angleOkay = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle); + +_losOkay = false; +if(_angleOkay) then { + _losOkay = [_projectile, _target] call FUNC(checkSeekerLos); //Note: Func does not exist? probably FUNC(checkLos)?? +}; +TRACE_2("", _angleOkay, _losOkay); + +// If we got here, it was an invalid target, just return a spot 5m in front of the missile +if(!_angleOkay || !_losOkay) then { + _foundTargetPos = _sensorPos vectorAdd ((velocity _projectile) vectorMultiply 5); +} else { + TRACE_2("", _target, _foundTargetPos); + private["_projectileSpeed", "_distanceToTarget", "_eta", "_adjustVelocity"]; + // @TODO: Configurable lead for seekers + _projectileSpeed = (vectorMagnitude velocity _projectile); + _distanceToTarget = (getPosASL _projectile) vectorDistance _foundTargetPos; + + _eta = _distanceToTarget / _projectileSpeed; + + _adjustVelocity = (velocity _target) vectorMultiply _eta; + _foundTargetPos = _foundTargetPos vectorAdd _adjustVelocity; +}; + + +_foundTargetPos; diff --git a/addons/missileguidance/functions/fnc_seekerType_SALH.sqf b/addons/missileguidance/functions/fnc_seekerType_SALH.sqf index 6297d21dfa..415e516617 100644 --- a/addons/missileguidance/functions/fnc_seekerType_SALH.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_SALH.sqf @@ -1,32 +1,32 @@ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -private["_angleFov", "_canSeeTarget", "_foundTargetPos", "_laserResult", "_launchParams", "_seekerParams", "_laserCode", "_laserParams", "_seekerTargetPos", "_sensorPos", "_target"]; -_seekerTargetPos = _this select 0; -_launchParams = _this select 1; -_seekerParams = _launchParams select 3; -_angleFov = _seekerParams select 0; - -_laserParams = (_launchParams select 1) select 5; -TRACE_2("", _launchParams, _laserParams); -if(!isNil "_target") then { - // Handle AI or moving vanilla lasers - _foundTargetPos = getPosASL _target; -} else { - _laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [(_laserParams select 1),(_laserParams select 2)], (_laserParams select 0)] call EFUNC(laser,seekerFindLaserSpot); - _foundTargetPos = _laserResult select 0; - TRACE_1("Search", _laserResult); -}; - -if(!isNil "_foundTargetPos") then { - //_canSeeTarget = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle); - - // If we got here, it was an invalid target, just return a spot 5m in front of the missile - if(!_canSeeTarget) then { - _foundTargetPos = _sensorPos vectorAdd ((velocity _projectile) vectorMultiply 5); - }; - -}; - +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +private["_angleFov", "_canSeeTarget", "_foundTargetPos", "_laserResult", "_launchParams", "_seekerParams", "_laserCode", "_laserParams", "_seekerTargetPos", "_sensorPos", "_target"]; +_seekerTargetPos = _this select 0; +_launchParams = _this select 1; +_seekerParams = _launchParams select 3; +_angleFov = _seekerParams select 0; + +_laserParams = (_launchParams select 1) select 5; +TRACE_2("", _launchParams, _laserParams); +if(!isNil "_target") then { + // Handle AI or moving vanilla lasers + _foundTargetPos = getPosASL _target; +} else { + _laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [(_laserParams select 1),(_laserParams select 2)], (_laserParams select 0)] call EFUNC(laser,seekerFindLaserSpot); + _foundTargetPos = _laserResult select 0; + TRACE_1("Search", _laserResult); +}; + +if(!isNil "_foundTargetPos") then { + //_canSeeTarget = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle); + + // If we got here, it was an invalid target, just return a spot 5m in front of the missile + if(!_canSeeTarget) then { + _foundTargetPos = _sensorPos vectorAdd ((velocity _projectile) vectorMultiply 5); + }; + +}; + _foundTargetPos; \ No newline at end of file diff --git a/addons/missileguidance/script_component.hpp b/addons/missileguidance/script_component.hpp index 25e98bea60..b7a1eafbbc 100644 --- a/addons/missileguidance/script_component.hpp +++ b/addons/missileguidance/script_component.hpp @@ -1,19 +1,19 @@ -#define COMPONENT missileguidance -#include "\z\ace\addons\main\script_mod.hpp" - -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS -// #define ENABLE_PERFORMANCE_COUNTERS - -#ifdef DEBUG_ENABLED_MISSILEGUIDANCE - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_MISSILEGUIDANCE - #define DEBUG_SETTINGS DEBUG_SETTINGS_MISSILEGUIDANCE -#endif - -#include "\z\ace\addons\main\script_macros.hpp" - +#define COMPONENT missileguidance +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_MISSILEGUIDANCE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_MISSILEGUIDANCE + #define DEBUG_SETTINGS DEBUG_SETTINGS_MISSILEGUIDANCE +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + #define FIREMODE_DIRECT_LOAL 1 \ No newline at end of file diff --git a/addons/vehiclelock/UI/Icon_Module_VehicleKey_ca.paa b/addons/vehiclelock/ui/Icon_Module_VehicleKey_ca.paa similarity index 100% rename from addons/vehiclelock/UI/Icon_Module_VehicleKey_ca.paa rename to addons/vehiclelock/ui/Icon_Module_VehicleKey_ca.paa diff --git a/addons/vehiclelock/UI/Icon_Module_VehicleLock_ca.paa b/addons/vehiclelock/ui/Icon_Module_VehicleLock_ca.paa similarity index 100% rename from addons/vehiclelock/UI/Icon_Module_VehicleLock_ca.paa rename to addons/vehiclelock/ui/Icon_Module_VehicleLock_ca.paa diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index db4c94242b..a0959dad5c 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -1,142 +1,142 @@ -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) - - -if(CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_CXX_FLAGS "-std=c++11 -pedantic -pedantic-errors -march=i686 -m32 -O2 -s -fPIC -fpermissive") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++") -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() - - -string(TIMESTAMP ACE_BUILDSTAMP "%Y-%m-%dT%H:%M:%SZ") -set(ACE_VERSION_MAJOR 3) -set(ACE_VERSION_MINOR 5) -set(ACE_VERSION_REVISION 0) -EXECUTE_PROCESS(COMMAND git rev-parse --verify HEAD - OUTPUT_VARIABLE T_ACE_VERSION_BUILD - OUTPUT_STRIP_TRAILING_WHITESPACE -) -string(SUBSTRING ${T_ACE_VERSION_BUILD} 0 7 ACE_VERSION_BUILD ) - -message("Building for: " ${ACE_VERSION_MAJOR}.${ACE_VERSION_MINOR}.${ACE_VERSION_REVISION}-${ACE_VERSION_BUILD}) - -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/common/ace_version.hpp.in" - "${CMAKE_CURRENT_BINARY_DIR}/common/ace_version.hpp" - @ONLY) - -if(MSVC) - configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/common/ace_version_win32.rc.in" - "${CMAKE_CURRENT_BINARY_DIR}/common/ace_version_win32.rc" - @ONLY) - set(GLOBAL_RC ${CMAKE_CURRENT_BINARY_DIR}/common/ace_version_win32.rc) -endif() - -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) -add_subdirectory(medical) -add_subdirectory(parse_imagepath) - -# 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() - - - +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) + + +if(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS "-std=c++11 -pedantic -pedantic-errors -march=i686 -m32 -O2 -s -fPIC -fpermissive") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++") +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() + + +string(TIMESTAMP ACE_BUILDSTAMP "%Y-%m-%dT%H:%M:%SZ") +set(ACE_VERSION_MAJOR 3) +set(ACE_VERSION_MINOR 5) +set(ACE_VERSION_REVISION 0) +EXECUTE_PROCESS(COMMAND git rev-parse --verify HEAD + OUTPUT_VARIABLE T_ACE_VERSION_BUILD + OUTPUT_STRIP_TRAILING_WHITESPACE +) +string(SUBSTRING ${T_ACE_VERSION_BUILD} 0 7 ACE_VERSION_BUILD ) + +message("Building for: " ${ACE_VERSION_MAJOR}.${ACE_VERSION_MINOR}.${ACE_VERSION_REVISION}-${ACE_VERSION_BUILD}) + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/common/ace_version.hpp.in" + "${CMAKE_CURRENT_BINARY_DIR}/common/ace_version.hpp" + @ONLY) + +if(MSVC) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/common/ace_version_win32.rc.in" + "${CMAKE_CURRENT_BINARY_DIR}/common/ace_version_win32.rc" + @ONLY) + set(GLOBAL_RC ${CMAKE_CURRENT_BINARY_DIR}/common/ace_version_win32.rc) +endif() + +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) +add_subdirectory(medical) +add_subdirectory(parse_imagepath) + +# 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/CMakeLists.txt b/extensions/advanced_ballistics/CMakeLists.txt index 51e709f6d2..55d84810d1 100644 --- a/extensions/advanced_ballistics/CMakeLists.txt +++ b/extensions/advanced_ballistics/CMakeLists.txt @@ -1,12 +1,12 @@ -set(ACE_EXTENSION_NAME "ace_advanced_ballistics") - -file(GLOB SOURCES *.h *.hpp *.c *.cpp) -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) - set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1) +set(ACE_EXTENSION_NAME "ace_advanced_ballistics") + +file(GLOB SOURCES *.h *.hpp *.c *.cpp) +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) + set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1) endif() \ No newline at end of file diff --git a/extensions/build/.gitignore b/extensions/build/.gitignore index 44c5ea8fa7..86d0cb2726 100644 --- a/extensions/build/.gitignore +++ b/extensions/build/.gitignore @@ -1,4 +1,4 @@ -# Ignore everything in this directory -* -# Except this file +# Ignore everything in this directory +* +# Except this file !.gitignore \ No newline at end of file diff --git a/extensions/clipboard/ace_clipboard.cpp b/extensions/clipboard/ace_clipboard.cpp index cdd5f7c423..7b019d5ba7 100644 --- a/extensions/clipboard/ace_clipboard.cpp +++ b/extensions/clipboard/ace_clipboard.cpp @@ -1,90 +1,90 @@ -/* - * ace_clipboard.cpp - * - * Takes a string and copies it to the clipboard; bypasses arma 8k clippy limit. - * - * Takes: - * Localized string as string - * - * Returns: - * None - */ -#include "shared.hpp" -#include -#include - -extern "C" { - EXPORT void __stdcall RVExtension(char *output, int outputSize, const char *function); -} - -std::string gClipboardData; - -void __stdcall RVExtension(char *output, int outputSize, const char *function) { - std::string cur_input(function); - std::string result; - - ZERO_OUTPUT(); - - if (cur_input.length() < 1) { - EXTENSION_RETURN(); - } - - if (!strcmp(function, "version")) { - strncpy(output, ACE_FULL_VERSION_STR, outputSize); - EXTENSION_RETURN(); - } - -#ifdef _WIN32 - - if (!strcmp(function, "--COMPLETE--")) { - HGLOBAL hClipboardData = GlobalAlloc(GMEM_FIXED, gClipboardData.length() + 1); - if (!hClipboardData) { - result = "GlobalAlloc() failed, GetLastError=" + GetLastError(); - gClipboardData = ""; - EXTENSION_RETURN(); - } - - char *pClipboardData = (char *)GlobalLock(hClipboardData); - if (!pClipboardData) { - result = "GlobalLock() failed, GetLastError=" + GetLastError(); - gClipboardData = ""; - EXTENSION_RETURN(); - } - memcpy(pClipboardData, gClipboardData.c_str(), gClipboardData.length()); - pClipboardData[gClipboardData.length() + 1] = 0x00; - - GlobalUnlock(hClipboardData); - - if (!OpenClipboard(NULL)) { - result = "OpenClipboard() failed, GetLastError=" + GetLastError(); - } - else { - if (!EmptyClipboard()) { - result = "OpenClipboard() failed, GetLastError=" + GetLastError(); - } - else { - if (!SetClipboardData(CF_TEXT, hClipboardData)) { - result = "SetClipboardData() failed, GetLastError=" + GetLastError(); - } - else { - if (!CloseClipboard()) { - result = "CloseClipboard() failed, GetLastError=" + GetLastError(); - } - } - } - } - - gClipboardData = ""; - } else { - gClipboardData = gClipboardData + cur_input; - } - - end: - if(result.length() > 1) - memcpy(output, result.c_str(), result.length()+1); - - #endif - - EXTENSION_RETURN(); -} - +/* + * ace_clipboard.cpp + * + * Takes a string and copies it to the clipboard; bypasses arma 8k clippy limit. + * + * Takes: + * Localized string as string + * + * Returns: + * None + */ +#include "shared.hpp" +#include +#include + +extern "C" { + EXPORT void __stdcall RVExtension(char *output, int outputSize, const char *function); +} + +std::string gClipboardData; + +void __stdcall RVExtension(char *output, int outputSize, const char *function) { + std::string cur_input(function); + std::string result; + + ZERO_OUTPUT(); + + if (cur_input.length() < 1) { + EXTENSION_RETURN(); + } + + if (!strcmp(function, "version")) { + strncpy(output, ACE_FULL_VERSION_STR, outputSize); + EXTENSION_RETURN(); + } + +#ifdef _WIN32 + + if (!strcmp(function, "--COMPLETE--")) { + HGLOBAL hClipboardData = GlobalAlloc(GMEM_FIXED, gClipboardData.length() + 1); + if (!hClipboardData) { + result = "GlobalAlloc() failed, GetLastError=" + GetLastError(); + gClipboardData = ""; + EXTENSION_RETURN(); + } + + char *pClipboardData = (char *)GlobalLock(hClipboardData); + if (!pClipboardData) { + result = "GlobalLock() failed, GetLastError=" + GetLastError(); + gClipboardData = ""; + EXTENSION_RETURN(); + } + memcpy(pClipboardData, gClipboardData.c_str(), gClipboardData.length()); + pClipboardData[gClipboardData.length() + 1] = 0x00; + + GlobalUnlock(hClipboardData); + + if (!OpenClipboard(NULL)) { + result = "OpenClipboard() failed, GetLastError=" + GetLastError(); + } + else { + if (!EmptyClipboard()) { + result = "OpenClipboard() failed, GetLastError=" + GetLastError(); + } + else { + if (!SetClipboardData(CF_TEXT, hClipboardData)) { + result = "SetClipboardData() failed, GetLastError=" + GetLastError(); + } + else { + if (!CloseClipboard()) { + result = "CloseClipboard() failed, GetLastError=" + GetLastError(); + } + } + } + } + + gClipboardData = ""; + } else { + gClipboardData = gClipboardData + cur_input; + } + + end: + if(result.length() > 1) + memcpy(output, result.c_str(), result.length()+1); + + #endif + + EXTENSION_RETURN(); +} + diff --git a/extensions/cmake/FindDirectX.cmake b/extensions/cmake/FindDirectX.cmake index 69bf1d62e8..b413b0b294 100644 --- a/extensions/cmake/FindDirectX.cmake +++ b/extensions/cmake/FindDirectX.cmake @@ -1,215 +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." - ) - +# - 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 index 620023ceb1..b9291e3dc4 100644 --- a/extensions/common/CMakeLists.txt +++ b/extensions/common/CMakeLists.txt @@ -1,18 +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}) +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/ace_common.cpp b/extensions/common/ace_common.cpp index 6ccd690c3a..2f887450f2 100644 --- a/extensions/common/ace_common.cpp +++ b/extensions/common/ace_common.cpp @@ -1,4 +1,4 @@ - -int test(int var) { - return var; + +int test(int var) { + return var; } \ No newline at end of file diff --git a/extensions/common/ace_common.h b/extensions/common/ace_common.h index 93f7b9af8a..8da16d779a 100644 --- a/extensions/common/ace_common.h +++ b/extensions/common/ace_common.h @@ -1,4 +1,4 @@ -#pragma once - -#include "targetver.h" -#include "ace_version.hpp" +#pragma once + +#include "targetver.h" +#include "ace_version.hpp" diff --git a/extensions/common/ace_version.hpp.in b/extensions/common/ace_version.hpp.in index 853648497d..48ff6e75c1 100644 --- a/extensions/common/ace_version.hpp.in +++ b/extensions/common/ace_version.hpp.in @@ -1,4 +1,4 @@ -#pragma once - -#define ACE_VERSION_STR "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@" +#pragma once + +#define ACE_VERSION_STR "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@" #define ACE_FULL_VERSION_STR "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@-@ACE_VERSION_BUILD@" \ No newline at end of file diff --git a/extensions/common/ace_version_win32.rc.in b/extensions/common/ace_version_win32.rc.in index 112f404649..5bba006f9a 100644 --- a/extensions/common/ace_version_win32.rc.in +++ b/extensions/common/ace_version_win32.rc.in @@ -1,47 +1,47 @@ -#ifdef _WIN32 - - #include - - #ifndef DEBUG - #define VER_DEBUG 0 - #else - #define VER_DEBUG VS_FF_DEBUG - #endif - - VS_VERSION_INFO VERSIONINFO - FILEVERSION @ACE_VERSION_MAJOR@, @ACE_VERSION_MINOR@, @ACE_VERSION_REVISION@ - PRODUCTVERSION @ACE_VERSION_MAJOR@, @ACE_VERSION_MINOR@, @ACE_VERSION_REVISION@ - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS (VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE|VER_DEBUG) - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN - BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - BEGIN - VALUE "CompanyName", "ACE3 Team" - VALUE "FileDescription", "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@-@ACE_VERSION_BUILD@" - VALUE "FileVersion", "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@-@ACE_VERSION_BUILD@" - VALUE "ProductName", "ACE3" - VALUE "ProductVersion", "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@-@ACE_VERSION_BUILD@" - VALUE "Build Date", "@ACE_BUILDSTAMP@" - END - END - - BLOCK "VarFileInfo" - BEGIN - /* The following line should only be modified for localized versions. */ - /* It consists of any number of WORD,WORD pairs, with each pair */ - /* describing a language,codepage combination supported by the file. */ - /* */ - /* For example, a file might have values "0x409,1252" indicating that it */ - /* supports English language (0x409) in the Windows ANSI codepage (1252). */ - - VALUE "Translation", 0x409, 1252 - - END - END - +#ifdef _WIN32 + + #include + + #ifndef DEBUG + #define VER_DEBUG 0 + #else + #define VER_DEBUG VS_FF_DEBUG + #endif + + VS_VERSION_INFO VERSIONINFO + FILEVERSION @ACE_VERSION_MAJOR@, @ACE_VERSION_MINOR@, @ACE_VERSION_REVISION@ + PRODUCTVERSION @ACE_VERSION_MAJOR@, @ACE_VERSION_MINOR@, @ACE_VERSION_REVISION@ + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS (VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE|VER_DEBUG) + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_UNKNOWN + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "ACE3 Team" + VALUE "FileDescription", "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@-@ACE_VERSION_BUILD@" + VALUE "FileVersion", "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@-@ACE_VERSION_BUILD@" + VALUE "ProductName", "ACE3" + VALUE "ProductVersion", "@ACE_VERSION_MAJOR@.@ACE_VERSION_MINOR@.@ACE_VERSION_REVISION@-@ACE_VERSION_BUILD@" + VALUE "Build Date", "@ACE_BUILDSTAMP@" + END + END + + BLOCK "VarFileInfo" + BEGIN + /* The following line should only be modified for localized versions. */ + /* It consists of any number of WORD,WORD pairs, with each pair */ + /* describing a language,codepage combination supported by the file. */ + /* */ + /* For example, a file might have values "0x409,1252" indicating that it */ + /* supports English language (0x409) in the Windows ANSI codepage (1252). */ + + VALUE "Translation", 0x409, 1252 + + END + END + #endif \ No newline at end of file diff --git a/extensions/common/arguments.hpp b/extensions/common/arguments.hpp index 70e942a241..7869cc2998 100644 --- a/extensions/common/arguments.hpp +++ b/extensions/common/arguments.hpp @@ -1,90 +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; - }; +#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 index bfc7a0e013..3b175fd7e4 100644 --- a/extensions/common/directx/d3d_display.cpp +++ b/extensions/common/directx/d3d_display.cpp @@ -1,439 +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); - } - } - }; - - -}; - +#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 index b10e8ef070..c17eedf8cc 100644 --- a/extensions/common/directx/d3d_display.hpp +++ b/extensions/common/directx/d3d_display.hpp @@ -1,130 +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; - }; - }; -}; - +#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 index 0a37824b83..5292336b85 100644 --- a/extensions/common/dispatch.hpp +++ b/extensions/common/dispatch.hpp @@ -1,153 +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 { }; +#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 index 3a5455c4d0..962c61be84 100644 --- a/extensions/common/easyloggingc++.hpp +++ b/extensions/common/easyloggingc++.hpp @@ -1,6718 +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) +// +// 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 index fe28b5d975..aaeae6269e 100644 --- a/extensions/common/glm/CMakeLists.txt +++ b/extensions/common/glm/CMakeLists.txt @@ -1,43 +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) +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 index 57beb106a9..9ee5425643 100644 --- a/extensions/common/glm/common.hpp +++ b/extensions/common/glm/common.hpp @@ -1,35 +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" +/////////////////////////////////////////////////////////////////////////////////// +/// 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 index ce2a35d9c1..1e6089d231 100644 --- a/extensions/common/glm/detail/_features.hpp +++ b/extensions/common/glm/detail/_features.hpp @@ -1,428 +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)) +/////////////////////////////////////////////////////////////////////////////////// +/// 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 index 9728cafb73..ba7a34f0ec 100644 --- a/extensions/common/glm/detail/_fixes.hpp +++ b/extensions/common/glm/detail/_fixes.hpp @@ -1,59 +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 - +/////////////////////////////////////////////////////////////////////////////////// +/// 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 index 296709d4b9..a51ac5ca33 100644 --- a/extensions/common/glm/detail/_noise.hpp +++ b/extensions/common/glm/detail/_noise.hpp @@ -1,136 +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 - +/////////////////////////////////////////////////////////////////////////////////// +/// 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 index 04ea55bcf2..43ca2c6154 100644 --- a/extensions/common/glm/detail/_swizzle.hpp +++ b/extensions/common/glm/detail/_swizzle.hpp @@ -1,833 +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; }; +/////////////////////////////////////////////////////////////////////////////////// +/// 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 index 4dbb783c5b..5601d910fe 100644 --- a/extensions/common/glm/detail/_swizzle_func.hpp +++ b/extensions/common/glm/detail/_swizzle_func.hpp @@ -1,725 +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) +/////////////////////////////////////////////////////////////////////////////////// +/// 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 index 1deff1e080..3a8a466689 100644 --- a/extensions/common/glm/detail/_vectorize.hpp +++ b/extensions/common/glm/detail/_vectorize.hpp @@ -1,160 +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 +/////////////////////////////////////////////////////////////////////////////////// +/// 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 index 88d8f3b807..a64ce33075 100644 --- a/extensions/common/glm/detail/dummy.cpp +++ b/extensions/common/glm/detail/dummy.cpp @@ -1,232 +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; -} +/////////////////////////////////////////////////////////////////////////////////// +/// 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 index da28007b05..a9d01bd042 100644 --- a/extensions/common/glm/detail/func_common.hpp +++ b/extensions/common/glm/detail/func_common.hpp @@ -1,456 +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