Skip to content
Permalink
Browse files

fix undef'ed ref; s/atof/strtof

  • Loading branch information...
rtri
rtri committed Aug 18, 2019
1 parent 8194ede commit 5a94148dd7114f23a9d0a8e1f0c6d1dfb73b5fec
Showing with 17 additions and 17 deletions.
  1. +17 −17 rts/Game/UnsyncedGameCommands.cpp
@@ -1518,7 +1518,7 @@ class GammaExponentActionExecutor : public IUnsyncedActionExecutor {
if (args.empty())
return false;

const float rawGammaExp = atof(args.c_str());
const float rawGammaExp = strtof(args.c_str(), nullptr);
const float modGammaExp = Clamp(rawGammaExp, 0.0f, 1.0f);

LOG("gamma-correction exponent set to %f", globalRendering->gammaExponent = modGammaExp);
@@ -2525,9 +2525,7 @@ class MinViewRangeActionExecutor : public IUnsyncedActionExecutor {
if (args.empty())
return false;

globalRendering->minViewRange = std::fabs(atof(args.c_str()));
globalRendering->minViewRange = std::max(globalRendering->minViewRange, CGlobalRendering::MIN_ZNEAR_DIST);
globalRendering->minViewRange = std::min(globalRendering->minViewRange, globalRendering->maxViewRange);
globalRendering->minViewRange = Clamp(strtof(args.c_str(), nullptr), CGlobalRendering::MIN_ZNEAR_DIST, globalRendering->maxViewRange);
return true;
}
};
@@ -2543,9 +2541,7 @@ class MaxViewRangeActionExecutor : public IUnsyncedActionExecutor {
if (args.empty())
return false;

globalRendering->maxViewRange = std::fabs(atof(args.c_str()));
globalRendering->maxViewRange = std::min(globalRendering->maxViewRange, CGlobalRendering::MAX_VIEW_RANGE);
globalRendering->maxViewRange = std::max(globalRendering->maxViewRange, globalRendering->minViewRange);
globalRendering->maxViewRange = Clamp(strtof(args.c_str(), nullptr), globalRendering->minViewRange, CGlobalRendering::MAX_VIEW_RANGE);
return true;
}
};
@@ -2690,20 +2686,24 @@ class LODScaleActionExecutor : public IUnsyncedActionExecutor {

if (args.size() == 2) {
const int objType = Clamp(atoi(args[0].c_str()), int(LUAOBJ_UNIT), int(LUAOBJ_FEATURE));
const float lodScale = atof(args[1].c_str());
const float lodScale = strtof(args[1].c_str(), nullptr);

LuaObjectDrawer::SetLODScale(objType, lodScale);
}
else if (args.size() == 3) {
const int objType = Clamp(atoi(args[1].c_str()), int(LUAOBJ_UNIT), int(LUAOBJ_FEATURE));
const float lodScale = atof(args[2].c_str());

if (args[0] == "shadow") {
LuaObjectDrawer::SetLODScaleShadow(objType, lodScale);
} else if (args[0] == "reflection") {
LuaObjectDrawer::SetLODScaleReflection(objType, lodScale);
} else if (args[0] == "refraction") {
LuaObjectDrawer::SetLODScaleRefraction(objType, lodScale);
const float lodScale = strtof(args[2].c_str(), nullptr);

switch (hashString(args[0].c_str())) {
case hashString("shadow"): {
LuaObjectDrawer::SetLODScaleShadow(objType, lodScale);
} break;
case hashString("reflection"): {
LuaObjectDrawer::SetLODScaleReflection(objType, lodScale);
} break;
case hashString("refraction"): {
LuaObjectDrawer::SetLODScaleRefraction(objType, lodScale);
} break;
}
} else {
LOG_L(L_WARNING, "/%s: wrong syntax", GetCommand().c_str());
@@ -2849,7 +2849,7 @@ class HangActionExecutor : public IUnsyncedActionExecutor {
const std::string& args = action.GetArgs();

const spring_time t0 = spring_now();
const spring_time t1 = t0 + spring_time((args.empty())? 20.0f * 1000.0f: atof(args.c_str()) * 1000.0f);
const spring_time t1 = t0 + spring_time((args.empty())? 20.0f * 1000.0f: strtof(args.c_str(), nullptr) * 1000.0f);

for (spring_time t = t0; t < t1; t = spring_now()) {
// prevent compiler from removing this

0 comments on commit 5a94148

Please sign in to comment.
You can’t perform that action at this time.