Got rid of the newline braces

This commit is contained in:
ulteq 2015-05-03 11:51:30 +02:00
parent e5a81bfe37
commit d07cb0e6ed

View File

@ -97,8 +97,7 @@ double calculateAirDensity(double temperature, double pressure, double relativeH
double partialPressure = pressure - vaporPressure;
return (partialPressure * 0.028964 + vaporPressure * 0.018016) / (8.314 * (273.15 + temperature));
}
else {
} else {
return pressure / (287.058 * (273.15 + temperature));
}
}
@ -108,14 +107,12 @@ double calculateAtmosphericCorrection(double ballisticCoefficient, double temper
if (!strcmp(atmosphereModel, "ICAO")) {
return (1.22498 / airDensity) * ballisticCoefficient;
}
else {
} else {
return (1.20885 / airDensity) * ballisticCoefficient;
}
}
double calculateRetard(int DragFunction, double DragCoefficient, double Velocity) {
double vel = Velocity * 3.2808399;
double val = -1;
double A = -1;
@ -123,7 +120,7 @@ double calculateRetard(int DragFunction, double DragCoefficient, double Velocity
switch (DragFunction) {
case 1:
if (vel> 4230) { A = 1.477404177730177e-04; M = 1.9565; }
if (vel> 4230) { A = 1.477404177730177e-04; M = 1.9565; }
else if (vel> 3680) { A = 1.920339268755614e-04; M = 1.925; }
else if (vel> 3450) { A = 2.894751026819746e-04; M = 1.875; }
else if (vel> 3295) { A = 4.349905111115636e-04; M = 1.825; }
@ -167,7 +164,7 @@ double calculateRetard(int DragFunction, double DragCoefficient, double Velocity
break;
case 2:
if (vel> 1674) { A = .0079470052136733; M = 1.36999902851493; }
if (vel> 1674) { A = .0079470052136733; M = 1.36999902851493; }
else if (vel> 1172) { A = 1.00419763721974e-03; M = 1.65392237010294; }
else if (vel> 1060) { A = 7.15571228255369e-23; M = 7.91913562392361; }
else if (vel> 949) { A = 1.39589807205091e-10; M = 3.81439537623717; }
@ -177,7 +174,7 @@ double calculateRetard(int DragFunction, double DragCoefficient, double Velocity
break;
case 5:
if (vel> 1730) { A = 7.24854775171929e-03; M = 1.41538574492812; }
if (vel> 1730) { A = 7.24854775171929e-03; M = 1.41538574492812; }
else if (vel> 1228) { A = 3.50563361516117e-05; M = 2.13077307854948; }
else if (vel> 1116) { A = 1.84029481181151e-13; M = 4.81927320350395; }
else if (vel> 1004) { A = 1.34713064017409e-22; M = 7.8100555281422; }
@ -187,7 +184,7 @@ double calculateRetard(int DragFunction, double DragCoefficient, double Velocity
break;
case 6:
if (vel> 3236) { A = 0.0455384883480781; M = 1.15997674041274; }
if (vel> 3236) { A = 0.0455384883480781; M = 1.15997674041274; }
else if (vel> 2065) { A = 7.167261849653769e-02; M = 1.10704436538885; }
else if (vel> 1311) { A = 1.66676386084348e-03; M = 1.60085100195952; }
else if (vel> 1144) { A = 1.01482730119215e-07; M = 2.9569674731838; }
@ -197,7 +194,7 @@ double calculateRetard(int DragFunction, double DragCoefficient, double Velocity
break;
case 7:
if (vel> 4200) { A = 1.29081656775919e-09; M = 3.24121295355962; }
if (vel> 4200) { A = 1.29081656775919e-09; M = 3.24121295355962; }
else if (vel> 3000) { A = 0.0171422231434847; M = 1.27907168025204; }
else if (vel> 1470) { A = 2.33355948302505e-03; M = 1.52693913274526; }
else if (vel> 1260) { A = 7.97592111627665e-04; M = 1.67688974440324; }
@ -209,7 +206,7 @@ double calculateRetard(int DragFunction, double DragCoefficient, double Velocity
break;
case 8:
if (vel> 3571) { A = .0112263766252305; M = 1.33207346655961; }
if (vel> 3571) { A = .0112263766252305; M = 1.33207346655961; }
else if (vel> 1841) { A = .0167252613732636; M = 1.28662041261785; }
else if (vel> 1120) { A = 2.20172456619625e-03; M = 1.55636358091189; }
else if (vel> 1088) { A = 2.0538037167098e-16; M = 5.80410776994789; }
@ -227,7 +224,7 @@ double calculateRetard(int DragFunction, double DragCoefficient, double Velocity
val = val / 3.2808399;
return val;
}
return 0.0;
}
@ -238,8 +235,7 @@ extern "C"
void __stdcall RVExtension(char *output, int outputSize, const char *function)
{
if (!strcmp(function, "version"))
{
if (!strcmp(function, "version")) {
int n = sprintf_s(output, outputSize, "%s", ACE_FULL_VERSION_STR);
return;
}
@ -262,8 +258,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
retard = calculateRetard(dragModel, ballisticCoefficient, velocity);
int n = sprintf_s(output, outputSize, "%f", retard);
return;
}
else if (!strcmp(mode, "atmosphericCorrection")) {
} else if (!strcmp(mode, "atmosphericCorrection")) {
double ballisticCoefficient = 1.0;
double temperature = 15.0;
double pressure = 1013.25;
@ -279,8 +274,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
ballisticCoefficient = calculateAtmosphericCorrection(ballisticCoefficient, temperature, pressure, humidity, atmosphereModel);
int n = sprintf_s(output, outputSize, "%f", ballisticCoefficient);
return;
}
else if (!strcmp(mode, "new")) {
} else if (!strcmp(mode, "new")) {
unsigned int index = 0;
double airFriction = 0.0;
char* ballisticCoefficientArray;
@ -311,8 +305,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
ballisticCoefficientArray++;
ballisticCoefficientArray[strlen(ballisticCoefficientArray) - 1] = 0;
ballisticCoefficient = strtok_s(ballisticCoefficientArray, ",", &token);
while (ballisticCoefficient != NULL)
{
while (ballisticCoefficient != NULL) {
ballisticCoefficients.push_back(strtod(ballisticCoefficient, NULL));
ballisticCoefficient = strtok_s(NULL, ",", &token);
}
@ -320,8 +313,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
velocityBoundaryArray++;
velocityBoundaryArray[strlen(velocityBoundaryArray) - 1] = 0;
velocityBoundary = strtok_s(velocityBoundaryArray, ",", &token);
while (velocityBoundary != NULL)
{
while (velocityBoundary != NULL) {
velocityBoundaries.push_back(strtod(velocityBoundary, NULL));
velocityBoundary = strtok_s(NULL, ",", &token);
}
@ -335,8 +327,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
originArray++;
originArray[strlen(originArray) - 1] = 0;
originEntry = strtok_s(originArray, ",", &token);
while (originEntry != NULL)
{
while (originEntry != NULL) {
origin.push_back(strtod(originEntry, NULL));
originEntry = strtok_s(NULL, ",", &token);
}
@ -378,8 +369,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
int n = sprintf_s(output, outputSize, "%s", "");
return;
}
else if (!strcmp(mode, "simulate")) {
} else if (!strcmp(mode, "simulate")) {
// simulate:0:[-0.109985,542.529,-3.98301]:[3751.57,5332.23,214.252]:[0.598153,2.38829,0]:28.6:0:0.481542:0:215.16
unsigned int index = 0;
char* velocityArray;
@ -459,12 +449,11 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
bulletDatabase[index].speed += bulletSpeed;
bulletDatabase[index].frames += 1;
bulletSpeedAvg = (bulletDatabase[index].speed / bulletDatabase[index].frames);
windSpeed = sqrt(pow(wind[0], 2) + pow(wind[1], 2) + pow(wind[2], 2));
if (windSpeed > 0.1)
{
if (windSpeed > 0.1) {
double windSourceTerrain[3];
windSourceTerrain[0] = position[0] - wind[0] / windSpeed * 100;
windSourceTerrain[1] = position[1] - wind[1] / windSpeed * 100;
windSourceTerrain[2] = position[2] - wind[2] / windSpeed * 100;
@ -483,8 +472,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
}
}
if (windSpeed > 0.1)
{
if (windSpeed > 0.1) {
double windSourceObstacles[3];
windSourceObstacles[0] = position[0] - wind[0] / windSpeed * 25;
@ -497,8 +485,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
}
}
if (windAttenuation < 1)
{
if (windAttenuation < 1) {
wind[0] *= windAttenuation;
wind[1] *= windAttenuation;
wind[2] *= windAttenuation;
@ -511,7 +498,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
trueSpeed = sqrt(pow(trueVelocity[0], 2) + pow(trueVelocity[1], 2) + pow(trueVelocity[2], 2));
temperature = bulletDatabase[index].temperature - 0.0065 * position[2];
if (bulletDatabase[index].ballisticCoefficients.size() == bulletDatabase[index].velocityBoundaries.size() + 1) {
double pressure = 1013.25 * exp(-(bulletDatabase[index].altitude + position[2]) / 7990) - 10 * bulletDatabase[index].overcast;
@ -526,10 +513,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
velocityOffset[2] -= accelRef[2];
ballisticCoefficient = bulletDatabase[index].ballisticCoefficients[0];
for (int i = (int)bulletDatabase[index].velocityBoundaries.size() - 1; i >= 0; i = i - 1)
{
if (bulletSpeed < bulletDatabase[index].velocityBoundaries[i])
{
for (int i = (int)bulletDatabase[index].velocityBoundaries.size() - 1; i >= 0; i = i - 1) {
if (bulletSpeed < bulletDatabase[index].velocityBoundaries[i]) {
ballisticCoefficient = bulletDatabase[index].ballisticCoefficients[i + 1];
break;
}
@ -544,14 +529,13 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
velocityOffset[0] -= accel[0];
velocityOffset[1] -= accel[1];
velocityOffset[2] -= accel[2];
}
else {
} else {
double pressureDeviation = 1013.25 * exp(-(bulletDatabase[index].altitude + position[2]) / 7990) - 1013.25 - 10 * bulletDatabase[index].overcast;
double airFriction = bulletDatabase[index].airFriction + ((temperature - 15) * 0.0000015 + bulletDatabase[index].humidity * 0.0000040 + pressureDeviation * -0.0000009);
if (airFriction != bulletDatabase[index].airFriction || windSpeed > 0) {
dragRef = deltaT * bulletDatabase[index].airFriction * bulletSpeed * bulletSpeed;
accelRef[0] = (velocity[0] / bulletSpeed) * dragRef;
accelRef[1] = (velocity[1] / bulletSpeed) * dragRef;
accelRef[2] = (velocity[2] / bulletSpeed) * dragRef;
@ -594,7 +578,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
if (bulletSpeed < 345 && bulletSpeedAvg > 340 && bulletSpeed > 335) {
std::uniform_real_distribution<double> distribution(0.0, 1.0);
double coef = 1.0f - bulletDatabase[index].transonicStabilityCoef;
velocityOffset[0] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef;
velocityOffset[1] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef;
velocityOffset[2] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef;
@ -602,8 +586,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
int n = sprintf_s(output, outputSize, "_bullet setVelocity (_bulletVelocity vectorAdd [%f, %f, %f]); _bullet setPosASL (_bulletPosition vectorAdd [%f, %f, %f]);", velocityOffset[0], velocityOffset[1], velocityOffset[2], positionOffset[0], positionOffset[1], positionOffset[2]);
return;
}
else if (!strcmp(mode, "set")) {
} else if (!strcmp(mode, "set")) {
int height = 0;
int numObjects = 0;
int surfaceIsWater = 0;
@ -618,8 +601,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
int n = sprintf_s(output, outputSize, "%s", "");
return;
}
else if (!strcmp(mode, "init")) {
} else if (!strcmp(mode, "init")) {
int mapSize = 0;
int mapGrids = 0;
int gridCells = 0;