mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
strcpy instead of sprintf
This commit is contained in:
parent
b6b203b57f
commit
154cf9d032
@ -236,9 +236,9 @@ extern "C"
|
|||||||
void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||||
{
|
{
|
||||||
ZERO_OUTPUT();
|
ZERO_OUTPUT();
|
||||||
|
std::stringstream outputStr;
|
||||||
if (!strcmp(function, "version")) {
|
if (!strcmp(function, "version")) {
|
||||||
int n = sprintf(output, "%s", ACE_FULL_VERSION_STR);
|
strncpy(output, ACE_FULL_VERSION_STR, outputSize);
|
||||||
EXTENSION_RETURN();
|
EXTENSION_RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,11 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
|||||||
velocity = strtod(strtok_s(NULL, ":", &next_token), NULL);
|
velocity = strtod(strtok_s(NULL, ":", &next_token), NULL);
|
||||||
|
|
||||||
retard = calculateRetard(dragModel, ballisticCoefficient, velocity);
|
retard = calculateRetard(dragModel, ballisticCoefficient, velocity);
|
||||||
int n = sprintf(output, "%f", retard);
|
// int n = sprintf(output, "%f", retard);
|
||||||
|
|
||||||
|
outputStr << retard;
|
||||||
|
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||||
|
|
||||||
EXTENSION_RETURN();
|
EXTENSION_RETURN();
|
||||||
} else if (!strcmp(mode, "atmosphericCorrection")) {
|
} else if (!strcmp(mode, "atmosphericCorrection")) {
|
||||||
double ballisticCoefficient = 1.0;
|
double ballisticCoefficient = 1.0;
|
||||||
@ -274,7 +278,9 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
|||||||
atmosphereModel = strtok_s(NULL, ":", &next_token);
|
atmosphereModel = strtok_s(NULL, ":", &next_token);
|
||||||
|
|
||||||
ballisticCoefficient = calculateAtmosphericCorrection(ballisticCoefficient, temperature, pressure, humidity, atmosphereModel);
|
ballisticCoefficient = calculateAtmosphericCorrection(ballisticCoefficient, temperature, pressure, humidity, atmosphereModel);
|
||||||
int n = sprintf(output, "%f", ballisticCoefficient);
|
//int n = sprintf(output, "%f", ballisticCoefficient);
|
||||||
|
outputStr << ballisticCoefficient;
|
||||||
|
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||||
EXTENSION_RETURN();
|
EXTENSION_RETURN();
|
||||||
} else if (!strcmp(mode, "new")) {
|
} else if (!strcmp(mode, "new")) {
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
@ -369,7 +375,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
|||||||
bulletDatabase[index].frames = 0.0;
|
bulletDatabase[index].frames = 0.0;
|
||||||
bulletDatabase[index].randSeed = 0;
|
bulletDatabase[index].randSeed = 0;
|
||||||
|
|
||||||
int n = sprintf(output, "%s", "");
|
strncpy(output, "", outputSize);
|
||||||
EXTENSION_RETURN();
|
EXTENSION_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
|
// 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
|
||||||
@ -587,7 +593,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
|||||||
velocityOffset[2] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef;
|
velocityOffset[2] += (distribution(bulletDatabase[index].randGenerator) * 0.8 - 0.4) * coef;
|
||||||
};
|
};
|
||||||
|
|
||||||
int n = sprintf(output, "_bullet setVelocity (_bulletVelocity vectorAdd [%f, %f, %f]); _bullet setPosASL (_bulletPosition vectorAdd [%f, %f, %f]);", velocityOffset[0], velocityOffset[1], velocityOffset[2], positionOffset[0], positionOffset[1], positionOffset[2]);
|
outputStr << "_bullet setVelocity (_bulletVelocity vectorAdd [" << velocityOffset[0] << "," << velocityOffset[1] << "," << velocityOffset[2] << "]); _bullet setPosASL (_bulletPosition vectorAdd [[" << positionOffset[0] << "," << positionOffset[1] << "," << positionOffset[2] << "]);";
|
||||||
|
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||||
EXTENSION_RETURN();
|
EXTENSION_RETURN();
|
||||||
} else if (!strcmp(mode, "set")) {
|
} else if (!strcmp(mode, "set")) {
|
||||||
int height = 0;
|
int height = 0;
|
||||||
@ -602,7 +609,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
|||||||
map->gridBuildingNums.push_back(numObjects);
|
map->gridBuildingNums.push_back(numObjects);
|
||||||
map->gridSurfaceIsWater.push_back(surfaceIsWater);
|
map->gridSurfaceIsWater.push_back(surfaceIsWater);
|
||||||
|
|
||||||
int n = sprintf(output, "%s", "");
|
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||||
EXTENSION_RETURN();
|
EXTENSION_RETURN();
|
||||||
} else if (!strcmp(mode, "init")) {
|
} else if (!strcmp(mode, "init")) {
|
||||||
int mapSize = 0;
|
int mapSize = 0;
|
||||||
@ -617,7 +624,8 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
|||||||
|
|
||||||
map = &mapDatabase[worldName];
|
map = &mapDatabase[worldName];
|
||||||
if (map->gridHeights.size() == gridCells) {
|
if (map->gridHeights.size() == gridCells) {
|
||||||
int n = sprintf(output, "%s", "Terrain already initialized");
|
outputStr << "Terrain already initialized";
|
||||||
|
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||||
EXTENSION_RETURN();
|
EXTENSION_RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,10 +638,9 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
|||||||
map->gridBuildingNums.reserve(gridCells);
|
map->gridBuildingNums.reserve(gridCells);
|
||||||
map->gridSurfaceIsWater.reserve(gridCells);
|
map->gridSurfaceIsWater.reserve(gridCells);
|
||||||
|
|
||||||
int n = sprintf(output, "%s", "");
|
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||||
EXTENSION_RETURN();
|
EXTENSION_RETURN();
|
||||||
}
|
}
|
||||||
|
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||||
int n = sprintf(output, "%s", "");
|
|
||||||
EXTENSION_RETURN();
|
EXTENSION_RETURN();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user