diff --git a/code/nel/src/3d/water_pool_manager.cpp b/code/nel/src/3d/water_pool_manager.cpp index b38068852..c377ff1f3 100644 --- a/code/nel/src/3d/water_pool_manager.cpp +++ b/code/nel/src/3d/water_pool_manager.cpp @@ -44,19 +44,19 @@ NLMISC_COMMAND(setWaterPool, "Setup a pool of water in the water pool manager", } if (numArgs == 3) { - whmb.FilterWeight = ::atof(args[2].c_str()); + NLMISC::fromString(args[2], whmb.FilterWeight); } if (numArgs == 4) { - whmb.UnitSize = ::atof(args[3].c_str()); + NLMISC::fromString(args[3], whmb.UnitSize); } if (numArgs == 5) { - whmb.WaveIntensity = ::atof(args[4].c_str()); + NLMISC::fromString(args[4], whmb.WaveIntensity); } if (numArgs == 4) { - whmb.WavePeriod = ::atof(args[5].c_str()); + NLMISC::fromString(args[5], whmb.WavePeriod); } // create the water pool GetWaterPoolManager().createWaterPool(whmb); diff --git a/code/nel/src/misc/sstring.cpp b/code/nel/src/misc/sstring.cpp index fe9332328..833553f21 100644 --- a/code/nel/src/misc/sstring.cpp +++ b/code/nel/src/misc/sstring.cpp @@ -1731,7 +1731,9 @@ namespace NLMISC double CSString::atof() const { - return ::atof(c_str()); + double val; + NLMISC::fromString(*this, val); + return val; } bool CSString::readFromFile(const CSString& fileName) diff --git a/code/nel/src/sound/sound_animation.cpp b/code/nel/src/sound/sound_animation.cpp index 5a6f1c256..1d1f9093a 100644 --- a/code/nel/src/sound/sound_animation.cpp +++ b/code/nel/src/sound/sound_animation.cpp @@ -176,7 +176,10 @@ void CSoundAnimation::load() throw NLMISC::Exception("Invalid sound animation marker"); } - marker->setTime((float) atof(time)); + float val; + NLMISC::fromString(time, val); + + marker->setTime(val); xmlFree ((void*)time); diff --git a/code/nelns/login_service/connection_client.cpp b/code/nelns/login_service/connection_client.cpp index 8ff713ec2..ebdef1b9a 100644 --- a/code/nelns/login_service/connection_client.cpp +++ b/code/nelns/login_service/connection_client.cpp @@ -126,7 +126,7 @@ retry: // now the user is on the database - uid = atoi(row[0]); + NLMISC::fromString(row[0], uid); if(cpassword != row[2]) { diff --git a/code/nelns/login_system/nel_launcher_windows_ext/Configuration.cpp b/code/nelns/login_system/nel_launcher_windows_ext/Configuration.cpp index f9092e56b..88b0d854a 100644 --- a/code/nelns/login_system/nel_launcher_windows_ext/Configuration.cpp +++ b/code/nelns/login_system/nel_launcher_windows_ext/Configuration.cpp @@ -52,7 +52,7 @@ BOOL CConfiguration::Load() // Reading the configuration file version GetValue(csBuffer, KEY_VERSION, csValue); - m_dVersion = atof(csValue); + NLMISC::fromString(csValue, m_dVersion); nlinfo("Config' version %s", csValue); if(m_dVersion < APP.m_dVersion) diff --git a/code/nelns/login_system/nel_launcher_windows_ext/nel_launcher.cpp b/code/nelns/login_system/nel_launcher_windows_ext/nel_launcher.cpp index 8ace867f7..2e36702d8 100644 --- a/code/nelns/login_system/nel_launcher_windows_ext/nel_launcher.cpp +++ b/code/nelns/login_system/nel_launcher_windows_ext/nel_launcher.cpp @@ -324,7 +324,7 @@ void CNel_launcherApp::LoadVersion() else { nlinfo("Launcher' version %s", csVersion); - m_dVersion = atof(csVersion); + NLMISC::fromString(csVersion, m_dVersion); } } diff --git a/code/ryzom/client/src/3d_notes.cpp b/code/ryzom/client/src/3d_notes.cpp index 7156854e4..618525de4 100644 --- a/code/ryzom/client/src/3d_notes.cpp +++ b/code/ryzom/client/src/3d_notes.cpp @@ -57,9 +57,10 @@ void cbNotesChanged() Notes.Notes.clear(); return; } - pos.x = (float)atof(posstr[0].c_str()); - pos.y = (float)atof(posstr[1].c_str()); - pos.z = (float)atof(posstr[2].c_str()); + + NLMISC::fromString(posstr[0], pos.x); + NLMISC::fromString(posstr[1], pos.y); + NLMISC::fromString(posstr[2], pos.z); string note(var.asString(i+2)); if(note.empty()) diff --git a/code/ryzom/client/src/interfaces_manager/interf_script.cpp b/code/ryzom/client/src/interfaces_manager/interf_script.cpp index f083eda18..734b99098 100644 --- a/code/ryzom/client/src/interfaces_manager/interf_script.cpp +++ b/code/ryzom/client/src/interfaces_manager/interf_script.cpp @@ -37,7 +37,11 @@ float getFloat() char delimiter[] = "[] \t"; char *ptr = strtok(NULL, delimiter); if(ptr != NULL) - return (float) atof(ptr); + { + float val; + NLMISC::fromString(ptr, val); + return val; + } return 0.f; }// getFloat // @@ -94,7 +98,7 @@ std::vector getVectorOfFloat(uint8 nbCol) ptr = strtok(NULL, delimiter); if(ptr != NULL) { - val = (float)atof(ptr); + NLMISC::fromString(ptr, val); if (val != 0.0f) vect.push_back(val); } diff --git a/code/ryzom/client/src/scene_parser.cpp b/code/ryzom/client/src/scene_parser.cpp index 1108f3a19..484c00129 100644 --- a/code/ryzom/client/src/scene_parser.cpp +++ b/code/ryzom/client/src/scene_parser.cpp @@ -123,7 +123,7 @@ void CSceneParser::load(const string &filename) char *ptr = strtok(tmpBuff, delimiter); if(ptr != NULL) - _FrameRate = atof(ptr); + NLMISC::fromString(ptr, _FrameRate); } // Close the speed file. @@ -1693,7 +1693,7 @@ void CSceneParser::loadScene(const string &filename) ptr = strtok(NULL, delimiter); if(ptr != NULL) { - seq.second = atof(ptr); + NLMISC::fromString(ptr, seq.second); _Scene.push_back(seq); } } diff --git a/code/ryzom/common/src/game_share/fame.cpp b/code/ryzom/common/src/game_share/fame.cpp index b453bca4e..ca226ecdc 100644 --- a/code/ryzom/common/src/game_share/fame.cpp +++ b/code/ryzom/common/src/game_share/fame.cpp @@ -479,10 +479,9 @@ void CStaticFames::loadStaticFame( const string& filename ) else NLMISC::fromString(s.substr(sep+1, s.size()-sep-1), factor); // Fames in file are in [-600;600] so don't forget 1000 factor - sint32 fame; float fameFloat; NLMISC::fromString(s.substr(0, sep), fameFloat); - fame = (sint32)(fameFloat * 1000.f); + sint32 fame = (sint32)(fameFloat * 1000.f); _FameTable[iFaction*_FameTableSize + jFaction] = fame; _PropagationFactorTable[iFaction*_FameTableSize + jFaction] = factor; diff --git a/code/ryzom/common/src/game_share/persistent_data_inline.h b/code/ryzom/common/src/game_share/persistent_data_inline.h index 72ef3fc9d..a2d575eef 100644 --- a/code/ryzom/common/src/game_share/persistent_data_inline.h +++ b/code/ryzom/common/src/game_share/persistent_data_inline.h @@ -706,7 +706,12 @@ inline float CPersistentDataRecord::CArg::asFloat() const case UINT64: return (float)(uint64)_Value.i64; case FLOAT32: return (float)_Value.f32; case FLOAT64: return (float)_Value.f64; - case STRING: return (float)atof(_String.c_str()); + case STRING: + { + float val; + NLMISC::fromString(_String, val); + return val; + } case FLAG: return 1.0f; case EXTEND_TYPE: switch(_Value.ExType) @@ -733,7 +738,12 @@ inline double CPersistentDataRecord::CArg::asDouble() const case UINT64: return (double)(uint64)_Value.i64; case FLOAT32: return (double)_Value.f32; case FLOAT64: return (double)_Value.f64; - case STRING: return (double)atof(_String.c_str()); + case STRING: + { + double val; + NLMISC::fromString(_String, val); + return val; + } case FLAG: return 1.0; case EXTEND_TYPE: switch(_Value.ExType) diff --git a/code/ryzom/server/src/admin_modules/aes_client_module.cpp b/code/ryzom/server/src/admin_modules/aes_client_module.cpp index e2b9ca390..9200f2d58 100644 --- a/code/ryzom/server/src/admin_modules/aes_client_module.cpp +++ b/code/ryzom/server/src/admin_modules/aes_client_module.cpp @@ -259,7 +259,7 @@ namespace ADMIN gs.HighRezTimeStamp = timer; IVariable *var = dynamic_cast(ICommand::getCommand(gvi.VarName)); if (var != NULL) - gs.SampleValue = atof(var->toString().c_str()); + NLMISC::fromString(var->toString(), gs.SampleValue); } } } @@ -305,7 +305,11 @@ namespace ADMIN // no sample collected yet, just ask a new one IVariable *var = dynamic_cast(ICommand::getCommand(gvi.VarName)); if (var != NULL) - gd.setValue(atof(var->toString().c_str())); + { + float val; + NLMISC::fromString(var->toString(), val); + gd.setValue(val); + } } else { diff --git a/code/ryzom/server/src/ags_test/commands.cpp b/code/ryzom/server/src/ags_test/commands.cpp index 7b2e6c2a8..4fa955401 100644 --- a/code/ryzom/server/src/ags_test/commands.cpp +++ b/code/ryzom/server/src/ags_test/commands.cpp @@ -586,7 +586,10 @@ NLMISC_COMMAND(actorSetOrientation,"Add one or more static actors"," if (i<(sizeof(angleNames)/sizeof(angleNames[0]))) theta=3.14159265359f*2.0f*(float)i/(float)(sizeof(angleNames)/sizeof(angleNames[0])); else - theta=(float)atof(args[0].c_str())/360.0f*2.0f*3.14159265359f; + { + NLMISC::fromString(args[0], theta); + theta = theta / 360.0f*2.0f*3.14159265359f; + } if (args.size()==1) { @@ -620,11 +623,13 @@ NLMISC_COMMAND(actorSetMagnetRange,"Set the magnet properties for wandering beha if(args.size() <1) return false; COMMAND_MACRO_RECORD_TEST - float range=(float)atof(args[0].c_str()); + float range; + NLMISC::fromString(args[0], range); if (range<=0.0f) return false; unsigned start; - float decay=(float)atof(args[0].c_str()); + float decay; + NLMISC::fromString(args[0], decay); if (decay<0.0f) return false; if (decay==0.0f) { @@ -664,7 +669,8 @@ NLMISC_COMMAND(actorSetAttackDistance,"set actor attack distance"," [< if(args.size() <1) return false; COMMAND_MACRO_RECORD_TEST - float distance=(float)atof(args[0].c_str()); + float distance; + NLMISC::fromString(args[0], distance); // if (distance<=0.0f) return false; if (args.size()<2) @@ -781,11 +787,13 @@ NLMISC_COMMAND(actorSetRespawnDelay,"set actor respawn delay"," [ filters; diff --git a/code/ryzom/server/src/ai_data_service/pacs_scan.cpp b/code/ryzom/server/src/ai_data_service/pacs_scan.cpp index 28e55559c..9b5af1d5b 100644 --- a/code/ryzom/server/src/ai_data_service/pacs_scan.cpp +++ b/code/ryzom/server/src/ai_data_service/pacs_scan.cpp @@ -2465,9 +2465,17 @@ NLMISC_COMMAND(setDefaultStart,"Set the default start point for all continents", CVectorD startPoint; - startPoint.x = atof(args[0].c_str()); - startPoint.y = atof(args[1].c_str()); - startPoint.z = (args.size() < 3 ? 0.0 : atof(args[2].c_str())); + NLMISC::fromString(args[0], startPoint.x); + NLMISC::fromString(args[1], startPoint.y); + + if (args.size() > 2) + { + NLMISC::fromString(args[2], startPoint.z); + } + else + { + startPoint.z = 0.0; + } DefaultStartPoint = startPoint; @@ -2921,13 +2929,15 @@ NLMISC_COMMAND(testPacsMove, "test a pacs move", " " if (args.size() != 5) return false; - CPacsCruncher pc; + CPacsCruncher pc; - string name = args[0]; - double x = atof(args[1].c_str()); - double y = atof(args[2].c_str()); - double dx = atof(args[3].c_str()); - double dy = atof(args[4].c_str()); + string name = args[0]; + + double x, y, dx, dy; + NLMISC::fromString(args[1], x); + NLMISC::fromString(args[2], y); + NLMISC::fromString(args[3], dx); + NLMISC::fromString(args[4], dy); pc.init(name); diff --git a/code/ryzom/server/src/ai_service/commands.cpp b/code/ryzom/server/src/ai_service/commands.cpp index b51c7615b..350afa67d 100644 --- a/code/ryzom/server/src/ai_service/commands.cpp +++ b/code/ryzom/server/src/ai_service/commands.cpp @@ -229,8 +229,9 @@ NLMISC_COMMAND(eventCreateNpcGroup, "create an event npc group", " return true; } - double x = atof(args[3].c_str()); - double y = atof(args[4].c_str()); + double x, y; + NLMISC::fromString(args[3], x); + NLMISC::fromString(args[4], y); double dispersionRadius = 10.; if (args.size()>5) @@ -1970,8 +1971,8 @@ NLMISC_COMMAND(displayVision3x3,"display 3x3 cell vision centred on a given coor } CAICoord x, y; - x=atof(args[1].c_str()); - y=atof(args[2].c_str()); + NLMISC::fromString(args[1], x); + NLMISC::fromString(args[2], y); log.displayNL("3x3 Vision around (%.3f,%.3f)", x.asDouble(), y.asDouble()); uint32 botCount=0; diff --git a/code/ryzom/server/src/ai_service/generic_logic_action.cpp b/code/ryzom/server/src/ai_service/generic_logic_action.cpp index aaa113b30..e2c761619 100644 --- a/code/ryzom/server/src/ai_service/generic_logic_action.cpp +++ b/code/ryzom/server/src/ai_service/generic_logic_action.cpp @@ -1412,8 +1412,7 @@ public: if ((str[0]<='9' && str[0]>='0')||(str[0]=='-')) // its a number { var.Type = constant; - double val = atof(str.c_str()); - var.Value = float(val); + NLMISC::fromString(str, var.Value); return true; } diff --git a/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp b/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp index 85579dcf8..50b039522 100644 --- a/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp @@ -1058,8 +1058,9 @@ NLMISC_COMMAND(getEffects, "get effects of a spire"," " ) return false; else { - float x = (float)atof(args[0].c_str()); - float y = (float)atof(args[1].c_str()); + float x, y; + NLMISC::fromString(args[0], x); + NLMISC::fromString(args[1], y); NLMISC::CVector vec( x, y, 0.0f ); @@ -1101,8 +1102,9 @@ NLMISC_COMMAND(buildSpirePos, "build a spire"," ") return true; } - float x = (float)atof(args[1].c_str()); - float y = (float)atof(args[2].c_str()); + float x, y; + NLMISC::fromString(args[1], x); + NLMISC::fromString(args[2], y); NLMISC::CVector vec( x, y, 0.0f ); @@ -1138,8 +1140,9 @@ NLMISC_COMMAND(destroySpirePos, "destroy a spire"," ") return false; else { - float x = (float)atof(args[0].c_str()); - float y = (float)atof(args[1].c_str()); + float x, y; + NLMISC::fromString(args[0], x); + NLMISC::fromString(args[1], y); NLMISC::CVector vec( x, y, 0.0f ); @@ -1178,8 +1181,9 @@ NLMISC_COMMAND(getEffectsPos, "get effects of a spire"," " ) return true; } - float x = (float)atof(args[1].c_str()); - float y = (float)atof(args[2].c_str()); + float x, y; + NLMISC::fromString(args[1], x); + NLMISC::fromString(args[2], y); NLMISC::CVector vec( x, y, 0.0f ); @@ -1265,8 +1269,9 @@ NLMISC_COMMAND(getRegionOwner, "display the faction which currently owns the reg return false; else { - float x = (float)atof(args[0].c_str()); - float y = (float)atof(args[1].c_str()); + float x, y; + NLMISC::fromString(args[0], x); + NLMISC::fromString(args[1], y); NLMISC::CVector vec( x, y, 0.0f ); @@ -1294,8 +1299,9 @@ NLMISC_COMMAND(getSpireStats, "display the status of spire in region correspondi return false; else { - float x = (float)atof(args[0].c_str()); - float y = (float)atof(args[1].c_str()); + float x, y; + NLMISC::fromString(args[0], x); + NLMISC::fromString(args[1], y); NLMISC::CVector vec( x, y, 0.0f ); diff --git a/code/ryzom/server/src/gpm_service/commands.cpp b/code/ryzom/server/src/gpm_service/commands.cpp index 127074856..8e5c8d1b8 100644 --- a/code/ryzom/server/src/gpm_service/commands.cpp +++ b/code/ryzom/server/src/gpm_service/commands.cpp @@ -179,8 +179,8 @@ NLMISC_COMMAND(getPatatEntryIndex, "Get the patat entry index at a pos", "x, y") CVector pos; - pos.x = (float)atof(args[0].c_str()); - pos.y = (float)atof(args[1].c_str()); + NLMISC::fromString(args[0], pos.x); + NLMISC::fromString(args[1], pos.y); pos.z = 0; nlinfo("entryIndex(%.1f, %.1f) = %d", pos.x, pos.y, CWorldPositionManager::getEntryIndex(pos)); diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.cpp b/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.cpp index 6244c0f4a..674f77cd6 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.cpp @@ -203,7 +203,7 @@ void CTypeUnitDouble::SetLowLimit( const CStringEx _sxll ) void CTypeUnitDouble::SetHighLimit( const CStringEx _sxhl ) { sxhighlimit = _sxhl; - dhighlimit = atof( sxhighlimit.c_str() ); + NLMISC::fromString(sxhighlimit, dhighlimit); } } diff --git a/code/ryzom/tools/leveldesign/prim_export/main.cpp b/code/ryzom/tools/leveldesign/prim_export/main.cpp index 86aeafa62..f9c33d953 100644 --- a/code/ryzom/tools/leveldesign/prim_export/main.cpp +++ b/code/ryzom/tools/leveldesign/prim_export/main.cpp @@ -629,7 +629,7 @@ void addPointPrimitive (CLandscape &landscape, const char *primFilename, uint32 string scaleText; float scale = 1; if (point->getPropertyByName ("scale", scaleText)) - scale = (float) atof (scaleText.c_str ()); + NLMISC::fromString(scaleText, scale); // Get zone coordinates sint x = (sint)floor (position.x / options.CellSize); @@ -654,7 +654,7 @@ void addPointPrimitive (CLandscape &landscape, const char *primFilename, uint32 // Get height if (!snap && point->getPropertyByName ("height", text)) - position.z = (float)atof(text.c_str()); + NLMISC::fromString(text, position.z); // *** Add the instance diff --git a/code/ryzom/tools/make_anim_melee_impact/main.cpp b/code/ryzom/tools/make_anim_melee_impact/main.cpp index 10fdeb0ed..3f67edd5e 100644 --- a/code/ryzom/tools/make_anim_melee_impact/main.cpp +++ b/code/ryzom/tools/make_anim_melee_impact/main.cpp @@ -79,7 +79,7 @@ void CAnimCombatState::build(const string &line) { StateCode= line.substr(4, 2); string time= line.substr(10, 5); - MeanAnimTime= (float)atof(time.c_str()); + NLMISC::fromString(time, MeanAnimTime); }