Merge branch 'master' into medicalExtension

This commit is contained in:
Glowbal 2015-05-14 16:43:12 +02:00
commit 4dbacbead8
16 changed files with 95 additions and 33 deletions

View File

@ -76,7 +76,7 @@ if (GVAR(barrelLengthInfluenceEnabled)) then {
};
if (GVAR(ammoTemperatureEnabled)) then {
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL _unit) select 2);
_temperature = ((getPosASL _unit) select 2) call EFUNC(weather,calculateTemperatureAtHeight);
_muzzleVelocityShift = [_AmmoCacheEntry select 9, _temperature] call FUNC(calculateAmmoTemperatureVelocityShift);
if (_muzzleVelocityShift != 0) then {
_bulletVelocity = _bulletVelocity vectorAdd ((vectorNormalized _bulletVelocity) vectorMultiply (_muzzleVelocityShift));
@ -105,7 +105,7 @@ _barrelTwist = _WeaponCacheEntry select 0;
_stabilityFactor = 1.5;
if (_caliber > 0 && _bulletLength > 0 && _bulletMass > 0 && _barrelTwist > 0) then {
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL _unit) select 2);
_temperature = ((getPosASL _unit) select 2) call EFUNC(weather,calculateTemperatureAtHeight);
_barometricPressure = ((getPosASL _bullet) select 2) call EFUNC(weather,calculateBarometricPressure);
_stabilityFactor = [_caliber, _bulletLength, _bulletMass, _barrelTwist, _muzzleVelocity, _temperature, _barometricPressure] call FUNC(calculateStabilityFactor);
};

View File

@ -21,6 +21,5 @@
#define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058
#define STD_AIR_DENSITY_ICAO 1.22498
#define STD_AIR_DENSITY_ASM 1.20885
#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h))
#define EXTENSION_REQUIRED_VERSION "1.0"

View File

@ -22,4 +22,6 @@ GVAR(MeasuredWindSpeed) = 0;
GVAR(ImpellerState) = 0;
GVAR(Kestrel4500) = false;
GVAR(Overlay) = false;
GVAR(Overlay) = false;
[] call FUNC(restoreUserData);

View File

@ -9,10 +9,11 @@ PREP(createKestrelDialog);
PREP(displayKestrel);
PREP(generateOutputData);
PREP(measureWindSpeed);
PREP(onCloseDialog);
PREP(onCloseDisplay);
PREP(restoreUserData);
PREP(storeUserData);
PREP(updateDisplay);
PREP(updateImpellerState);
PREP(onCloseDialog);
PREP(onCloseDisplay);
ADDON = true;

View File

@ -51,3 +51,4 @@ switch (_this) do {
};
[] call FUNC(updateDisplay);
[] call FUNC(storeUserData);

View File

@ -14,13 +14,14 @@
*/
#include "script_component.hpp"
private ["_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"];
private ["_playerAltitude", "_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"];
_playerAltitude = (getPosASL ACE_player) select 2;
if (isNil QGVAR(MIN) || isNil QGVAR(MAX)) then {
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight);
_humidity = EGVAR(weather,currentHumidity);
_barometricPressure = ((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure);
_altitude = EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2);
_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure);
_altitude = EGVAR(weather,Altitude) + _playerAltitude;
GVAR(MIN) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude];
GVAR(MAX) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude];
};
@ -42,9 +43,9 @@ if (GVAR(MinAvgMaxMode) == 1) then {
// Wind SPD
_windSpeed = call FUNC(measureWindSpeed);
GVAR(MIN) set [1, (GVAR(MIN) select 1) min abs(_windSpeed)];
GVAR(MAX) set [1, abs(_windSpeed) max (GVAR(MAX) select 1)];
GVAR(TOTAL) set [1, (GVAR(TOTAL) select 1) + abs(_windSpeed)];
GVAR(MIN) set [1, (GVAR(MIN) select 1) min _windSpeed];
GVAR(MAX) set [1, _windSpeed max (GVAR(MAX) select 1)];
GVAR(TOTAL) set [1, (GVAR(TOTAL) select 1) + _windSpeed];
// CROSSWIND
_crosswind = 0;
@ -70,7 +71,7 @@ if (GVAR(MinAvgMaxMode) == 1) then {
};
// TEMP
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight);
GVAR(MIN) set [4, (GVAR(MIN) select 4) min _temperature];
GVAR(MAX) set [4, _temperature max (GVAR(MAX) select 4)];
GVAR(TOTAL) set [4, (GVAR(TOTAL) select 4) + _temperature];
@ -82,13 +83,13 @@ GVAR(MAX) set [5, _humidity max (GVAR(MAX) select 5)];
GVAR(TOTAL) set [5, (GVAR(TOTAL) select 5) + _humidity];
// BARO
_barometricPressure = ((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure);
_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure);
GVAR(MIN) set [6, (GVAR(MIN) select 6) min _barometricPressure];
GVAR(MAX) set [6, _barometricPressure max (GVAR(MAX) select 6)];
GVAR(TOTAL) set [6, (GVAR(TOTAL) select 6) + _barometricPressure];
// ALTITUDE
_altitude = EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2);
_altitude = EGVAR(weather,Altitude) + _playerAltitude;
GVAR(MIN) set [7, (GVAR(MIN) select 7) min _altitude];
GVAR(MAX) set [7, _altitude max (GVAR(MAX) select 7)];
GVAR(TOTAL) set [7, (GVAR(TOTAL) select 7) + _altitude];

View File

@ -34,10 +34,11 @@ _textInfoLine2 = "";
_windSpeed = call FUNC(measureWindSpeed);
_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1);
_temperature = GET_TEMPERATURE_AT_HEIGHT((getPosASL ACE_player) select 2);
_humidity = EGVAR(weather,currentHumidity);
_playerDir = getDir ACE_player;
_playerAltitude = (getPosASL ACE_player) select 2;
_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight);
_humidity = EGVAR(weather,currentHumidity);
GVAR(Direction) = 4 * floor(_playerDir / 90);
if (_playerDir % 90 > 10) then { GVAR(Direction) = GVAR(Direction) + 1};
@ -174,7 +175,7 @@ switch (GVAR(Menu)) do {
};
case 6: { // BARO
if (!GVAR(MinAvgMax)) then {
_textCenterBig = Str(round((((getPosASL ACE_player) select 2) call EFUNC(weather,calculateBarometricPressure)) * 10) / 10);
_textCenterBig = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10);
} else {
_textCenterLine1Left = "Min";
_textCenterLine2Left = "Avg";
@ -186,7 +187,7 @@ switch (GVAR(Menu)) do {
};
case 7: { // ALTITUDE
if (!GVAR(MinAvgMax)) then {
_textCenterBig = Str(round(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2)));
_textCenterBig = Str(round(EGVAR(weather,Altitude) + _playerAltitude));
} else {
_textCenterLine1Left = "Min";
_textCenterLine2Left = "Avg";
@ -198,7 +199,7 @@ switch (GVAR(Menu)) do {
};
case 8: { // User Screen 1
_textCenterLine1Left = Str(round(_playerDir));
_textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2)));
_textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + _playerAltitude));
_textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10);
_textCenterLine1Right = GVAR(Directions) select GVAR(Direction);
_textCenterLine2Right = "m";
@ -207,7 +208,7 @@ switch (GVAR(Menu)) do {
case 9: { // User Screen 2
_textCenterLine1Left = Str(round(_temperature * 10) / 10);
_textCenterLine2Left = Str(round(_humidity * 100 * 10) / 10);
_textCenterLine3Left = Str(round((1013.25 * exp(-(EGVAR(weather,Altitude) + ((getPosASL ACE_player) select 2)) / 7990) - 10 * overcast) * 10) / 10);
_textCenterLine3Left = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10);
_textCenterLine1Right = "C";
_textCenterLine2Right = "%";
_textCenterLine3Right = "hPA";

View File

@ -0,0 +1,18 @@
/*
* Author: Ruthberg
* Reads user data from profileNamespace
*
* Arguments:
* Nothing
*
* Return Value:
* Nothing
*
* Example:
* call ace_kestrel4500_fnc_restore_user_data
*
* Public: No
*/
#include "script_component.hpp"
GVAR(Menu) = 0 max (profileNamespace getVariable ["ACE_Kestrel4500_menu", 0]) min ((count GVAR(Menus)) - 1);

View File

@ -0,0 +1,18 @@
/*
* Author: Ruthberg
* Saves user data into profileNamespace
*
* Arguments:
* Nothing
*
* Return Value:
* Nothing
*
* Example:
* call ace_kestrel4500_fnc_store_user_data
*
* Public: No
*/
#include "script_component.hpp"
profileNamespace setVariable ["ACE_Kestrel4500_menu", GVAR(menu)];

View File

@ -10,5 +10,3 @@
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h))

View File

@ -42,8 +42,7 @@ if (_bisAirFriction != 0) exitWith {ERROR("Non zero base airFriction");};
//Calculate air density:
_altitude = (getPosASL _vehicle) select 2;
#define GET_TEMPERATURE_AT_HEIGHT(h) (EGVAR(weather,currentTemperature) - 0.0065 * (h))
_temperature = GET_TEMPERATURE_AT_HEIGHT(_altitude);
_temperature = _altitude call EFUNC(weather,calculateTemperatureAtHeight);
_pressure = _altitude call EFUNC(weather,calculateBarometricPressure);
_relativeHumidity = EGVAR(weather,currentHumidity);
_airDensity = [_temperature, _pressure, _relativeHumidity] call EFUNC(weather,calculateAirDensity);

View File

@ -6,6 +6,7 @@ ADDON = false;
PREP(calculateAirDensity);
PREP(calculateBarometricPressure);
PREP(calculateRoughnessLength);
PREP(calculateTemperatureAtHeight);
PREP(calculateWindSpeed);
PREP(displayWindInfo);
PREP(getMapData);

View File

@ -14,7 +14,4 @@
*/
#include "script_component.hpp"
private ["_altitude"];
_altitude = _this;
(1013.25 * exp(-(GVAR(Altitude) + _altitude) / 7990) - 10 * overcast)
(1013.25 * exp(-(GVAR(Altitude) + _this) / 7990) - 10 * overcast)

View File

@ -0,0 +1,17 @@
/*
* Author: Ruthberg
*
* Calculates the temperature based on altitude and weather
*
* Arguments:
* 0: height - meters <NUMBER>
*
* Return Value:
* 0: temperature - degrees celsius <NUMBER>
*
* Return value:
* None
*/
#include "script_component.hpp"
(GVAR(currentTemperature) - 0.0065 * _this)

View File

@ -41,7 +41,12 @@ namespace ace {
if (in.eof()) {
in.clear();
}
_data = std::unique_ptr<uint8_t[]>(new uint8_t[expected_size + (expected_size % 8)]);
#if _MSC_VER == 1800
_data = std::make_shared<uint8_t[]>(expected_size + (expected_size % 8));
#else
_data = std::make_unique<uint8_t[]>(expected_size + (expected_size % 8));
#endif
result = _mikero_lzo1x_decompress_safe(buffer, _data.get(), expected_size);
if (result < 0) {
LOG(ERROR) << "Decompression failed";

View File

@ -12,7 +12,11 @@ namespace ace {
protected:
int _mikero_lzo1x_decompress_safe(const uint8_t*, uint8_t*, uint32_t);
int _decompress_safe(std::istream &, uint32_t);
#if _MSC_VER == 1800
std::shared_ptr<uint8_t[]> _data;
#else
std::unique_ptr<uint8_t[]> _data;
#endif
};
template<typename T>
class compressed_base : public _compressed_base {