From 4a97f339a3d1209697cdab3b77924025e7bc563b Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 13 Nov 2015 16:22:49 +0100 Subject: [PATCH 1/6] Changed: Replaced some NLMISC::strlwr by NLMISC::toLower --HG-- branch : develop --- code/nel/src/gui/ctrl_scroll.cpp | 6 +-- code/nel/src/gui/group_editbox.cpp | 6 +-- code/nel/src/gui/group_html.cpp | 23 +++++------ code/nel/src/gui/interface_anim.cpp | 3 +- code/nel/src/gui/interface_group.cpp | 3 +- code/nel/src/gui/interface_options.cpp | 3 +- code/nel/src/gui/interface_parser.cpp | 20 ++++++--- code/nel/src/gui/view_pointer.cpp | 39 ++++++------------ code/nel/src/gui/view_renderer.cpp | 9 ++-- code/ryzom/client/src/animation_fx.cpp | 3 +- code/ryzom/client/src/auto_anim.cpp | 2 +- code/ryzom/client/src/character_cl.cpp | 4 +- code/ryzom/client/src/client.cpp | 2 +- code/ryzom/client/src/commands.cpp | 2 +- code/ryzom/client/src/continent.cpp | 6 +-- code/ryzom/client/src/continent_manager.cpp | 2 +- code/ryzom/client/src/door_manager.cpp | 10 ++--- .../client/src/entity_animation_manager.cpp | 2 +- code/ryzom/client/src/ground_fx_manager.cpp | 2 +- code/ryzom/client/src/ig_callback.cpp | 2 +- code/ryzom/client/src/init.cpp | 5 +-- .../client/src/interface_v3/dbctrl_sheet.cpp | 41 ++++++++----------- .../client/src/interface_v3/group_compas.cpp | 4 +- .../client/src/interface_v3/guild_manager.cpp | 2 +- .../src/interface_v3/interface_3d_scene.cpp | 17 +++----- .../src/interface_v3/interface_manager.cpp | 4 +- .../src/interface_v3/inventory_manager.cpp | 2 +- .../client/src/interface_v3/music_player.cpp | 2 +- .../client/src/interface_v3/people_list.cpp | 4 +- .../src/interface_v3/sbrick_manager.cpp | 5 +-- .../src/interface_v3/view_bitmap_faber_mp.cpp | 3 +- .../client/src/interface_v3/view_radar.cpp | 6 +-- .../client/src/mesh_camera_col_manager.cpp | 2 +- code/ryzom/client/src/net_manager.cpp | 4 +- code/ryzom/client/src/outpost.cpp | 2 +- code/ryzom/client/src/pacs_client.cpp | 4 +- code/ryzom/client/src/sky.cpp | 2 +- code/ryzom/client/src/streamable_ig.cpp | 14 +++---- .../client/src/string_manager_client.cpp | 12 ++---- code/ryzom/common/src/game_share/fame.cpp | 15 ++----- .../time_weather_season/weather_manager.cpp | 4 +- .../weather_setup_sheet_base.cpp | 6 +-- 42 files changed, 129 insertions(+), 180 deletions(-) diff --git a/code/nel/src/gui/ctrl_scroll.cpp b/code/nel/src/gui/ctrl_scroll.cpp index c29f73fea..da42cd40b 100644 --- a/code/nel/src/gui/ctrl_scroll.cpp +++ b/code/nel/src/gui/ctrl_scroll.cpp @@ -519,17 +519,17 @@ namespace NLGUI // Read Action handlers prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" ); - if (prop) _AHOnScroll = NLMISC::strlwr(prop.str()); + if (prop) _AHOnScroll = NLMISC::toLower(prop.str()); prop = (char*) xmlGetProp( node, (xmlChar*)"params" ); if (prop) _AHOnScrollParams = string((const char*)prop); // prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" ); - if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop.str()); + if (prop) _AHOnScrollEnd = NLMISC::toLower(prop.str()); prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" ); if (prop) _AHOnScrollEndParams = string((const char*)prop); // prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" ); - if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop.str()); + if (prop) _AHOnScrollCancel = NLMISC::toLower(prop.str()); prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" ); if (prop) _AHOnScrollCancelParams = string((const char*)prop); diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index f6d909119..c96c27b46 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -606,11 +606,7 @@ namespace NLGUI } prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); - if (prop) - { - string tmp = (const char *) prop; - _ListMenuRight = strlwr(tmp); - } + if (prop) _ListMenuRight = toLower((const char *) prop); prop = (char*) xmlGetProp( cur, (xmlChar*)"max_historic" ); if (prop) fromString((const char*)prop, _MaxHistoric); diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 4df0b0ee5..9eea81220 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -772,8 +772,7 @@ namespace NLGUI cellParams.NoWrap = true; \ if (present[prefix##_ALIGN] && value[prefix##_ALIGN]) \ { \ - string align = value[prefix##_ALIGN]; \ - align = strlwr(align); \ + string align = toLower(value[prefix##_ALIGN]); \ if (align == "left") \ cellParams.Align = CGroupCell::Left; \ if (align == "center") \ @@ -783,8 +782,7 @@ namespace NLGUI } \ if (present[prefix##_VALIGN] && value[prefix##_VALIGN]) \ { \ - string align = value[prefix##_VALIGN]; \ - align = strlwr(align); \ + string align = toLower(value[prefix##_VALIGN]); \ if (align == "top") \ cellParams.VAlign = CGroupCell::Top; \ if (align == "middle") \ @@ -1182,7 +1180,7 @@ namespace NLGUI if (it != styles.end()) { string image = it->second; - string::size_type texExt = strlwr(image).find("url("); + string::size_type texExt = toLower(image).find("url("); // Url image if (texExt != string::npos) // Remove url() @@ -1321,8 +1319,7 @@ namespace NLGUI if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT]) tooltip = value[MY_HTML_INPUT_ALT]; - string type = value[MY_HTML_INPUT_TYPE]; - type = strlwr (type); + string type = toLower(value[MY_HTML_INPUT_TYPE]); if (type == "image") { // The submit button @@ -1668,7 +1665,7 @@ namespace NLGUI { nlinfo("found background-image %s", it->second.c_str()); string image = (*it).second; - string::size_type texExt = strlwr(image).find("url("); + string::size_type texExt = toLower(image).find("url("); // Url image if (texExt != string::npos) { @@ -3826,7 +3823,7 @@ namespace NLGUI // folder used for images cache static const string cacheDir = "cache"; - string::size_type protocolPos = strlwr(result).find("://"); + string::size_type protocolPos = toLower(result).find("://"); if (protocolPos != string::npos) { @@ -3840,7 +3837,7 @@ namespace NLGUI else { // Url is a file ? - if (strlwr(result).find("file:") == 0) + if (toLower(result).find("file:") == 0) { result = result.substr(5, result.size()-5); } @@ -3857,7 +3854,7 @@ namespace NLGUI { // Normalize the path if (isUrl) - //result = "file:"+strlwr(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/ + //result = "file:"+toLower(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/ result = "file:/"+tmp; else result = tmp; @@ -4114,7 +4111,7 @@ namespace NLGUI void CGroupHTML::doBrowseLocalFile(const std::string &uri) { std::string filename; - if (strlwr(uri).find("file:/") == 0) + if (toLower(uri).find("file:/") == 0) { filename = uri.substr(6, uri.size() - 6); } @@ -4978,7 +4975,7 @@ namespace NLGUI else if (it->first == "text-decoration" || it->first == "text-decoration-line") { - std::string prop(strlwr(it->second)); + std::string prop(toLower(it->second)); style.Underlined = (prop.find("underline") != std::string::npos); style.StrikeThrough = (prop.find("line-through") != std::string::npos); } diff --git a/code/nel/src/gui/interface_anim.cpp b/code/nel/src/gui/interface_anim.cpp index edd96e1cf..4b230bb25 100644 --- a/code/nel/src/gui/interface_anim.cpp +++ b/code/nel/src/gui/interface_anim.cpp @@ -55,8 +55,7 @@ namespace NLGUI if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr); ptr = xmlGetProp (cur, (xmlChar*)"type"); - string sTmp = ptr.str(); - sTmp = strlwr(sTmp); + string sTmp = toLower(ptr.str()); if (sTmp == "linear") _Type = Track_Linear; else if (sTmp == "bezier") diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 46df4c816..f2a695436 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -312,8 +312,7 @@ namespace NLGUI ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeparent" ); if (ptr) { - string idparent = ptr.str(); - idparent = NLMISC::strlwr(idparent); + string idparent = NLMISC::toLower(ptr.str()); if (idparent != "parent") { if (parentGroup) diff --git a/code/nel/src/gui/interface_options.cpp b/code/nel/src/gui/interface_options.cpp index 3de015d65..1daef83cb 100644 --- a/code/nel/src/gui/interface_options.cpp +++ b/code/nel/src/gui/interface_options.cpp @@ -127,8 +127,7 @@ namespace NLGUI // *************************************************************************** const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const { - string sLwrParamName = strlwr (sParamName); - std::map::const_iterator it = _ParamValue.find (sLwrParamName); + std::map::const_iterator it = _ParamValue.find (toLower(sParamName)); if (it != _ParamValue.end()) return it->second; else diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 1dbf62d51..02434e66a 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -1359,6 +1359,9 @@ namespace NLGUI { CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" )); if (!ptr) return false; + + string stmp2 = toLower(string((const char*)ptr)); + CInterfaceElement *pEltFound = NULL; std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 i = 0; i < _MasterGroups.size(); ++i) @@ -1367,8 +1370,8 @@ namespace NLGUI for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j) { CInterfaceGroup *pIG = rMG.Group->getGroups()[j]; - string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size())); - string stmp2 = strlwr(string((const char*)ptr)); + string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size())); + if (stmp == stmp2) { pEltFound = pIG; @@ -1408,6 +1411,9 @@ namespace NLGUI { CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" )); if (!ptr) return false; + + string stmp2 = toLower(string((const char*)ptr)); + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); CInterfaceElement *pEltFound = NULL; for (uint32 i = 0; i < _MasterGroups.size(); ++i) @@ -1416,8 +1422,7 @@ namespace NLGUI for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j) { CInterfaceGroup *pIG = rMG.Group->getGroups()[j]; - string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size())); - string stmp2 = strlwr(string((const char*)ptr)); + string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size())); if (stmp == stmp2) { pEltFound = pIG; @@ -1600,6 +1605,9 @@ namespace NLGUI { CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" )); if (!ptr) return false; + + string stmp2 = toLower(string((const char*)ptr)); + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); CInterfaceElement *pEltFound = NULL; for (uint32 i = 0; i < _MasterGroups.size(); ++i) @@ -1608,8 +1616,8 @@ namespace NLGUI for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j) { CInterfaceGroup *pIG = rMG.Group->getGroups()[j]; - string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size())); - string stmp2 = strlwr(string((const char*)ptr)); + string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size())); + if (stmp == stmp2) { pEltFound = pIG; diff --git a/code/nel/src/gui/view_pointer.cpp b/code/nel/src/gui/view_pointer.cpp index bc69ebdaa..da8d730fc 100644 --- a/code/nel/src/gui/view_pointer.cpp +++ b/code/nel/src/gui/view_pointer.cpp @@ -84,56 +84,43 @@ namespace NLGUI _OffsetY = getY(); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_default"); - if (prop) _TxDefault = (const char *) prop; - _TxDefault = NLMISC::strlwr (_TxDefault); + if (prop) _TxDefault = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_move_window"); - if (prop) _TxMoveWindow = (const char *) prop; - _TxMoveWindow = NLMISC::strlwr (_TxMoveWindow); + if (prop) _TxMoveWindow = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BR_TL"); - if (prop) _TxResizeBRTL = (const char *) prop; - _TxResizeBRTL = NLMISC::strlwr (_TxResizeBRTL); + if (prop) _TxResizeBRTL = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BL_TR"); - if (prop) _TxResizeBLTR = (const char *) prop; - _TxResizeBLTR = NLMISC::strlwr (_TxResizeBLTR); + if (prop) _TxResizeBLTR = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_TB"); - if (prop) _TxResizeTB = (const char *) prop; - _TxResizeTB = NLMISC::strlwr (_TxResizeTB); + if (prop) _TxResizeTB = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_LR"); - if (prop) _TxResizeLR = (const char *) prop; - _TxResizeLR = NLMISC::strlwr (_TxResizeLR); + if (prop) _TxResizeLR = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_rotate"); - if (prop) _TxRotate = (const char *) prop; - _TxRotate = NLMISC::strlwr (_TxRotate); + if (prop) _TxRotate = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_scale"); - if (prop) _TxScale = (const char *) prop; - _TxScale = NLMISC::strlwr (_TxScale); + if (prop) _TxScale = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_colpick"); - if (prop) _TxColPick = (const char *) prop; - _TxColPick = NLMISC::strlwr (_TxColPick); + if (prop) _TxColPick = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan"); - if (prop) _TxPan = (const char *) prop; - _TxPan = NLMISC::strlwr (_TxPan); + if (prop) _TxPan = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan"); - if (prop) _TxCanPan = (const char *) prop; - _TxCanPan = NLMISC::strlwr (_TxCanPan); + if (prop) _TxCanPan = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan_r2"); - if (prop) _TxPanR2 = (const char *) prop; - _TxPanR2 = NLMISC::strlwr (_TxPanR2); + if (prop) _TxPanR2 = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan_r2"); - if (prop) _TxCanPanR2 = (const char *) prop; - _TxCanPanR2 = NLMISC::strlwr (_TxCanPanR2); + if (prop) _TxCanPanR2 = NLMISC::toLower ((const char *) prop); prop = (char*) xmlGetProp (cur, (xmlChar*)"color"); if (prop) _Color = convertColor(prop); diff --git a/code/nel/src/gui/view_renderer.cpp b/code/nel/src/gui/view_renderer.cpp index 6e6675599..0b4d837f3 100644 --- a/code/nel/src/gui/view_renderer.cpp +++ b/code/nel/src/gui/view_renderer.cpp @@ -854,12 +854,11 @@ namespace NLGUI return; } // Look if already existing - string sLwrGTName = strlwr(sGlobalTextureName); + string sLwrGTName = toLower(sGlobalTextureName); TGlobalTextureList::iterator ite = _GlobalTextures.begin(); while (ite != _GlobalTextures.end()) { - std::string sText = strlwr(ite->Name); - if (sText == sLwrGTName) + if (toLower(ite->Name) == sLwrGTName) break; ite++; } @@ -984,11 +983,11 @@ namespace NLGUI */ NL3D::UTexture *CViewRenderer::getGlobalTexture(const std::string &name) { - string sLwrGTName = strlwr(name); + string sLwrGTName = NLMISC::toLower(name); TGlobalTextureList::iterator ite = _GlobalTextures.begin(); while (ite != _GlobalTextures.end()) { - std::string sText = strlwr(ite->Name); + std::string sText = NLMISC::toLower(ite->Name); if (sText == sLwrGTName) break; ite++; diff --git a/code/ryzom/client/src/animation_fx.cpp b/code/ryzom/client/src/animation_fx.cpp index ee4016b67..7be1a79a9 100644 --- a/code/ryzom/client/src/animation_fx.cpp +++ b/code/ryzom/client/src/animation_fx.cpp @@ -61,8 +61,7 @@ void CAnimationFX::buildTrack(NL3D::UAnimationSet *as) nlassert(Sheet != NULL); if (!as) return; if (Sheet->TrajectoryAnim.empty()) return; - std::string animName = Sheet->TrajectoryAnim; - NLMISC::strlwr(animName); + std::string animName = NLMISC::toLower(Sheet->TrajectoryAnim); uint id = as->getAnimationIdByName(animName); NL3D::UAnimation *anim = NULL; if (id != NL3D::UAnimationSet::NotFound) diff --git a/code/ryzom/client/src/auto_anim.cpp b/code/ryzom/client/src/auto_anim.cpp index 5776b285c..5cc21305a 100644 --- a/code/ryzom/client/src/auto_anim.cpp +++ b/code/ryzom/client/src/auto_anim.cpp @@ -81,7 +81,7 @@ void initAutoAnimation() file.getline(line, 512); // Read the animation file - string animName = strlwr (CFile::getFilenameWithoutExtension(line)); + string animName = toLower(CFile::getFilenameWithoutExtension(line)); uint id = AutoAnimSet->addAnimation (line, animName.c_str ()); if (id == UAnimationSet::NotFound) { diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index f4892eb70..029fd9486 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -610,7 +610,7 @@ uint32 CCharacterCL::buildEquipment(const CCharacterSheet::CEquipment &slot, SLO { // IS the item a valid one ? CSheetId itemId; - if(itemId.buildSheetId(NLMISC::strlwr(slot.getItem()))) + if(itemId.buildSheetId(NLMISC::toLower(slot.getItem()))) { // Is it stored in the database ? CEntitySheet *entitySheet = SheetMngr.get(itemId); @@ -1098,7 +1098,7 @@ string CCharacterCL::automatonType() const // virtual //----------------------------------------------- void CCharacterCL::computeAutomaton() { - _CurrentAutomaton = automatonType() + "_" + NLMISC::strlwr(MBEHAV::modeToString(_Mode)) + ".automaton"; + _CurrentAutomaton = automatonType() + "_" + NLMISC::toLower(MBEHAV::modeToString(_Mode)) + ".automaton"; }// computeAutomaton // diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index be7cf1647..a312c3978 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -520,7 +520,7 @@ int main(int argc, char **argv) uint i; for (i=0; i this zone should be a ZC. - string outpostZone = strlwr(CFile::getFilenameWithoutExtension(ZCList[j].Name)); + string outpostZone = toLower(CFile::getFilenameWithoutExtension(ZCList[j].Name)); if(igZone == outpostZone) { nlctassert(RZ_MAX_BUILDING_PER_OUTPOST==4); @@ -788,7 +788,7 @@ void CContinent::reloadFogMap() const R2::CScenarioEntryPoints::CCompleteIsland *completeIsland = R2::CScenarioEntryPoints::getInstance().getCompleteIslandFromCoords(CVector2f((float) UserEntity->pos().x, (float) UserEntity->pos().y)); if (completeIsland) { - std::string islandName = strlwr(completeIsland->Island); + std::string islandName = toLower(completeIsland->Island); std::string::size_type lastPos = islandName.find_last_of("_"); if (lastPos != std::string::npos) { diff --git a/code/ryzom/client/src/continent_manager.cpp b/code/ryzom/client/src/continent_manager.cpp index 87172ce1a..ddc4bff89 100644 --- a/code/ryzom/client/src/continent_manager.cpp +++ b/code/ryzom/client/src/continent_manager.cpp @@ -183,7 +183,7 @@ void CContinentManager::preloadSheets() for (i = 0; i < ws->ContLocs.size(); ++i) { const SContLoc &clTmp = ws->ContLocs[i]; - std::string continentSheetName = NLMISC::strlwr(clTmp.ContinentName); + std::string continentSheetName = NLMISC::toLower(clTmp.ContinentName); if (continentSheetName.find(".continent") == std::string::npos) { continentSheetName += ".continent"; diff --git a/code/ryzom/client/src/door_manager.cpp b/code/ryzom/client/src/door_manager.cpp index 8ac8aeeb5..543d7b415 100644 --- a/code/ryzom/client/src/door_manager.cpp +++ b/code/ryzom/client/src/door_manager.cpp @@ -248,8 +248,7 @@ void CDoorManager::SDoor::checkToClose() std::string CDoorManager::transformName (uint /* index */, const std::string &/* instanceName */, const std::string &shapeName) { if (shapeName.rfind('.') == string::npos) return shapeName; - string sExt = shapeName.substr(shapeName.rfind('.')+1,shapeName.size()); - sExt = strlwr(sExt); + string sExt = toLower(shapeName.substr(shapeName.rfind('.')+1,shapeName.size())); if (sExt != "pacs_prim") return shapeName; return ""; // Do not load a pacs prim as a mesh... } @@ -266,8 +265,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig) string sShapeName = ig->getShapeName(k); if (sShapeName.rfind('.') == string::npos) continue; - string sExt = sShapeName.substr(sShapeName.rfind('.')+1,sShapeName.size()); - sExt = strlwr(sExt); + string sExt = toLower(sShapeName.substr(sShapeName.rfind('.')+1,sShapeName.size())); if (sExt != "pacs_prim") continue; // Check if the pacs_prim is a door detection @@ -349,7 +347,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig) case SDoor::Matis3PartBourgeon: { string sDebug = ig->getShapeName(i); - sDebug = strlwr(sDebug.substr(sDebug.rfind('_')+1,sDebug.size())); + sDebug = toLower(sDebug.substr(sDebug.rfind('_')+1,sDebug.size())); if (sDebug == "gauche") pDoor->Instances[0] = i; else if (sDebug == "droite") @@ -362,7 +360,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig) case SDoor::Zorai2Part: { string sDebug = ig->getShapeName(i); - sDebug = strlwr(sDebug.substr(sDebug.rfind('_')+1,sDebug.size())); + sDebug = toLower(sDebug.substr(sDebug.rfind('_')+1,sDebug.size())); if (sDebug == "gauche") pDoor->Instances[0] = i; else if (sDebug == "droite") diff --git a/code/ryzom/client/src/entity_animation_manager.cpp b/code/ryzom/client/src/entity_animation_manager.cpp index db1eccb01..98a56cc3c 100644 --- a/code/ryzom/client/src/entity_animation_manager.cpp +++ b/code/ryzom/client/src/entity_animation_manager.cpp @@ -205,7 +205,7 @@ void CEntityAnimationManager::load(NLMISC::IProgressCallback &/* progress */, bo for (uint32 i = 0; i < pASLS->AnimSetList.size(); ++i) { CAnimationSet as; - string sTmp = strlwr(pASLS->AnimSetList[i].Name); + string sTmp = toLower(pASLS->AnimSetList[i].Name); sTmp = sTmp.substr(0,sTmp.rfind('.')); pair::iterator, bool> it; it = _AnimSet.insert(pair(sTmp,as)); diff --git a/code/ryzom/client/src/ground_fx_manager.cpp b/code/ryzom/client/src/ground_fx_manager.cpp index f13309183..c0650a38e 100644 --- a/code/ryzom/client/src/ground_fx_manager.cpp +++ b/code/ryzom/client/src/ground_fx_manager.cpp @@ -520,7 +520,7 @@ void CGroundFXManager::update(const NLMISC::CVectorD &camPos) } if (!fxName.empty()) { - stdFXName = NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(fxName)); + stdFXName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fxName)); } // is an fx already attached to the entity ? if (_SortedInstances[k]->HasFX) diff --git a/code/ryzom/client/src/ig_callback.cpp b/code/ryzom/client/src/ig_callback.cpp index 410a690cd..49b790d77 100644 --- a/code/ryzom/client/src/ig_callback.cpp +++ b/code/ryzom/client/src/ig_callback.cpp @@ -197,7 +197,7 @@ void CIGCallback::CIGInstance::instanceGroupAdded() uint numInstances = _IG->getNumInstance(); for(uint k = 0; k < numInstances; ++k) { - TPacsPrimMap::iterator pbIt = PacsPrims.find(NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(_IG->getShapeName(k)))); + TPacsPrimMap::iterator pbIt = PacsPrims.find(NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(_IG->getShapeName(k)))); if (pbIt != PacsPrims.end()) { // compute orientation and position diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 3a51b82a0..6a6120d1c 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -505,8 +505,7 @@ void checkDriverVersion() uint i; for (i=0; i< sizeofarray(driversVersion); i++) { - string lwr = deviceName; - strlwr(lwr); + string lwr = toLower(deviceName); if ((lwr.find (driversTest[i])!=string::npos) && (driversNTest[i]==NULL || lwr.find (driversNTest[i])==string::npos)) { if (driverVersion < driversVersion[i]) @@ -1290,7 +1289,7 @@ void initBotObjectSelection() { // IS the item a valid one ? CSheetId itemId; - if(itemId.buildSheetId(NLMISC::strlwr(strShape))) + if(itemId.buildSheetId(NLMISC::toLower(strShape))) { // Get this item sheet ? CItemSheet *itemSheet= dynamic_cast(SheetMngr.get(itemId)); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 68ceb7bf0..8d913a1a8 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -333,29 +333,29 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr prop = (char*) xmlGetProp( cur, (xmlChar*)"nature" ); if (prop) { - if (NLMISC::strlwr(prop.str()) == "item") + if (NLMISC::toLower(prop.str()) == "item") _Type = CCtrlSheetInfo::SheetType_Item; - else if (NLMISC::strlwr(prop.str()) == "pact") + else if (NLMISC::toLower(prop.str()) == "pact") _Type = CCtrlSheetInfo::SheetType_Pact; - else if (NLMISC::strlwr(prop.str()) == "skill") + else if (NLMISC::toLower(prop.str()) == "skill") _Type = CCtrlSheetInfo::SheetType_Skill; - else if (NLMISC::strlwr(prop.str()) == "auto") + else if (NLMISC::toLower(prop.str()) == "auto") _Type = CCtrlSheetInfo::SheetType_Auto; - else if (NLMISC::strlwr(prop.str()) == "macro") + else if (NLMISC::toLower(prop.str()) == "macro") _Type = CCtrlSheetInfo::SheetType_Macro; - else if (NLMISC::strlwr(prop.str()) == "guild_flag") + else if (NLMISC::toLower(prop.str()) == "guild_flag") _Type = CCtrlSheetInfo::SheetType_GuildFlag; - else if (NLMISC::strlwr(prop.str()) == "mission") + else if (NLMISC::toLower(prop.str()) == "mission") _Type = CCtrlSheetInfo::SheetType_Mission; - else if (NLMISC::strlwr(prop.str()) == "sbrick") + else if (NLMISC::toLower(prop.str()) == "sbrick") _Type = CCtrlSheetInfo::SheetType_SBrick; - else if (NLMISC::strlwr(prop.str()) == "sphraseid") + else if (NLMISC::toLower(prop.str()) == "sphraseid") _Type = CCtrlSheetInfo::SheetType_SPhraseId; - else if (NLMISC::strlwr(prop.str()) == "sphrase") + else if (NLMISC::toLower(prop.str()) == "sphrase") _Type = CCtrlSheetInfo::SheetType_SPhrase; - else if (NLMISC::strlwr(prop.str()) == "elevator_destination") + else if (NLMISC::toLower(prop.str()) == "elevator_destination") _Type = CCtrlSheetInfo::SheetType_ElevatorDestination; - else if (NLMISC::strlwr(prop.str()) == "outpost_building") + else if (NLMISC::toLower(prop.str()) == "outpost_building") _Type = CCtrlSheetInfo::SheetType_OutpostBuilding; } @@ -363,8 +363,7 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_noitem" ); if (prop) { - string TxName = (const char *) prop; - TxName = strlwr (TxName); + string TxName = toLower((const char *) prop); CViewRenderer &rVR = *CViewRenderer::getInstance(); _DispNoSheetBmpId = rVR.getTextureIdFromName (TxName); } @@ -410,27 +409,23 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" ); if (prop) { - string tmp = (const char *) prop; - _ListMenuLeft = strlwr(tmp); + _ListMenuLeft = toLower((const char *) prop); } prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); if (prop) { - string tmp = (const char *) prop; - _ListMenuRight = strlwr(tmp); + _ListMenuRight = toLower((const char *) prop); } prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r_empty_slot" ); if (prop) { - string tmp = (const char *) prop; - _ListMenuRightEmptySlot = strlwr(tmp); + _ListMenuRightEmptySlot = toLower((const char *) prop); } // list menu on both clicks prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" ); if (prop) { - string tmp = (const char *) prop; - setListMenuBoth(strlwr(tmp)); + setListMenuBoth(toLower((const char *) prop)); } // _BrickTypeBitField @@ -1745,7 +1740,7 @@ void CDBCtrlSheet::resetCharBitmaps() void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar, bool topDown) { // Use the optString for the Macro name - _OptString = strlwr(_OptString); + _OptString = toLower(_OptString); CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); diff --git a/code/ryzom/client/src/interface_v3/group_compas.cpp b/code/ryzom/client/src/interface_v3/group_compas.cpp index d4d0631ce..590bf916b 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.cpp +++ b/code/ryzom/client/src/interface_v3/group_compas.cpp @@ -74,7 +74,7 @@ void CCompassTarget::serial(NLMISC::IStream &f) // for the name, try to save a string identifier if possible, because language may be changed between // save & reload f.serial(Name); - std::string language = strlwr(ClientCfg.LanguageCode); + std::string language = toLower(ClientCfg.LanguageCode); f.serial(language); f.serialEnum(_Type); if (_Type == PosTracker) @@ -100,7 +100,7 @@ void CCompassTarget::serial(NLMISC::IStream &f) // reset the compass to north to avoid incoherency if (f.isReading()) { - if (strlwr(ClientCfg.LanguageCode) != language) + if (toLower(ClientCfg.LanguageCode) != language) { *this = CCompassTarget(); } diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 2e0e4e3e7..a22c8dbc5 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -729,7 +729,7 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT { LIFT_ICONS::TLiftIcon li = (LIFT_ICONS::TLiftIcon)(icon & UINT64_CONSTANT(0x7FFFFFFFFFFFFFFF)); - string str = strlwr(LIFT_ICONS::toString(li)); + string str = toLower(LIFT_ICONS::toString(li)); Ctrl->setType(CCtrlSheetInfo::SheetType_Teleport_Location); Ctrl->setSlot("asc_"+str+".tga"); } diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index f17270143..19a6f4229 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -294,7 +294,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) CXMLAutoPtr ptr((const char*)xmlGetProp (cur, (xmlChar*)"name")); string animName; if (ptr) - animName = strlwr (CFile::getFilenameWithoutExtension(ptr.str())); + animName = toLower(CFile::getFilenameWithoutExtension(ptr.str())); if (!animName.empty()) { @@ -1084,11 +1084,9 @@ bool CInterface3DIG::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) ptr = xmlGetProp (cur, (xmlChar*)"rot"); if (ptr) _Rot = convertVector(ptr); - string name; ptr = xmlGetProp (cur, (xmlChar*)"name"); - if (ptr) name = (const char*)ptr; + if (ptr) _Name = toLower((const char*)ptr); - _Name = strlwr(name); _IG = UInstanceGroup::createInstanceGroup(_Name); if (_IG == NULL) return true; // Create anyway @@ -1202,7 +1200,7 @@ std::string CInterface3DIG::getName() const // ---------------------------------------------------------------------------- void CInterface3DIG::setName (const std::string &ht) { - string lwrname = strlwr(ht); + string lwrname = toLower(ht); if (lwrname != _Name) { CInterface3DScene *pI3DS = dynamic_cast(_Parent); @@ -1248,11 +1246,9 @@ bool CInterface3DShape::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) ptr = xmlGetProp (cur, (xmlChar*)"rot"); if (ptr) _Rot = convertVector(ptr); - string name; ptr = xmlGetProp (cur, (xmlChar*)"name"); - if (ptr) name = (const char*)ptr; + if (ptr) _Name = toLower((const char*)ptr); - _Name = strlwr(name); _Instance = parentGroup->getScene()->createInstance(_Name); if (_Instance.empty()) return false; @@ -1529,11 +1525,8 @@ bool CInterface3DFX::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) ptr = xmlGetProp (cur, (xmlChar*)"rot"); if (ptr) _Rot = convertVector(ptr); - string name; ptr = xmlGetProp (cur, (xmlChar*)"name"); - if (ptr) name = (const char*)ptr; - - _Name = strlwr(name); + if (ptr) _Name = toLower((const char*)ptr); return true; } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 0a3fe04a8..e97aa475e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2280,7 +2280,7 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat CRGBA color = CRGBA::White; - map::const_iterator it = ClientCfg.SystemInfoParams.find(strlwr(cat)); + map::const_iterator it = ClientCfg.SystemInfoParams.find(toLower(cat)); if (it != ClientCfg.SystemInfoParams.end()) { mode = it->second.Mode; @@ -2315,7 +2315,7 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat CRGBA CInterfaceManager::getSystemInfoColor(const std::string &cat) { CRGBA col = CRGBA::White; - map::const_iterator it = ClientCfg.SystemInfoParams.find(strlwr(cat)); + map::const_iterator it = ClientCfg.SystemInfoParams.find(toLower(cat)); if (it != ClientCfg.SystemInfoParams.end()) col = it->second.Color; return col; diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index 7a56e470e..f886bc3e9 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -3488,7 +3488,7 @@ CItemImage &CInventoryManager::getServerItem(uint inv, uint index) // *************************************************************************** CInventoryManager::TInvType CInventoryManager::invTypeFromString(const string &str) { - string sTmp = strlwr(str); + string sTmp = toLower(str); if (sTmp == "inv_bag") return InvBag; if (sTmp == "inv_pa0") return InvPA0; if (sTmp == "inv_pa1") return InvPA1; diff --git a/code/ryzom/client/src/interface_v3/music_player.cpp b/code/ryzom/client/src/interface_v3/music_player.cpp index c53dad13c..171fc328e 100644 --- a/code/ryzom/client/src/interface_v3/music_player.cpp +++ b/code/ryzom/client/src/interface_v3/music_player.cpp @@ -243,7 +243,7 @@ public: while (*bufferPtr) { // Concat the directory name with the filename - if (strlwr (CFile::getExtension(bufferPtr)) == "m3u") + if (toLower(CFile::getExtension(bufferPtr)) == "m3u") playlists.push_back (path+bufferPtr); else filenames.push_back (path+bufferPtr); diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index c2167358f..3433d1154 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -155,10 +155,10 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha //================================================================== sint CPeopleList::getIndexFromName(const ucstring &name) const { - string sNameIn = strlwr(name.toString()); + string sNameIn = toLower(name.toString()); for(uint k = 0; k < _Peoples.size(); ++k) { - string sPeopleName = strlwr(_Peoples[k].getName().toString()); + string sPeopleName = toLower(_Peoples[k].getName().toString()); if (sPeopleName == sNameIn) return k; } return -1; diff --git a/code/ryzom/client/src/interface_v3/sbrick_manager.cpp b/code/ryzom/client/src/interface_v3/sbrick_manager.cpp index 036a50052..691f85e7d 100644 --- a/code/ryzom/client/src/interface_v3/sbrick_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sbrick_manager.cpp @@ -404,8 +404,7 @@ void CSBrickManager::compileBrickProperties() string::size_type pos = prop.Text.find(':'); if (pos != string::npos) { - string key = prop.Text.substr(0, pos); - strlwr(key); + string key = toLower(prop.Text.substr(0, pos)); string value = prop.Text.substr(pos + 1); // get key id. if (_BrickPropIdMap.find(key) == _BrickPropIdMap.end()) @@ -506,7 +505,7 @@ void CSBrickManager::compileBrickProperties() // Parse all the brick properties if match the key float value= 0.f; // get the wanted prop id - strlwr(key); + key = toLower(key); uint propId= getBrickPropId(key); // if propid exist if(propId) diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp index d59a89235..212ceebeb 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp @@ -59,8 +59,7 @@ bool CViewBitmapFaberMp::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_noitem" ); if (prop) { - _TextureNoItemName = (const char *) prop; - _TextureNoItemName = strlwr (_TextureNoItemName); + _TextureNoItemName = toLower((const char *) prop); _TextureNoItemId = -2; } diff --git a/code/ryzom/client/src/interface_v3/view_radar.cpp b/code/ryzom/client/src/interface_v3/view_radar.cpp index 5ebb7fd64..073318ec8 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.cpp +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp @@ -95,8 +95,7 @@ bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)spotTextureNames[i] ); if (prop) { - txName = (const char *) prop; - txName = strlwr (txName); + txName = toLower((const char *) prop); } _SpotDescriptions[i].TextureId.setTexture(txName.c_str()); rVR.getTextureSizeFromId (_SpotDescriptions[i].TextureId, _SpotDescriptions[i].TxW, _SpotDescriptions[i].TxH); @@ -105,8 +104,7 @@ bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)spotMiniTextureNames[i] ); if (prop) { - txName = (const char *) prop; - txName = strlwr (txName); + txName = toLower((const char *) prop); } _SpotDescriptions[i].MiniTextureId.setTexture(txName.c_str()); rVR.getTextureSizeFromId (_SpotDescriptions[i].MiniTextureId, _SpotDescriptions[i].MTxW, _SpotDescriptions[i].MTxH); diff --git a/code/ryzom/client/src/mesh_camera_col_manager.cpp b/code/ryzom/client/src/mesh_camera_col_manager.cpp index 00cff5652..7a4452e38 100644 --- a/code/ryzom/client/src/mesh_camera_col_manager.cpp +++ b/code/ryzom/client/src/mesh_camera_col_manager.cpp @@ -108,7 +108,7 @@ void CMeshCameraColManager::instanceGroupAdded(NL3D::UInstanceGroup *ig) bool avoidCollisionInside= ig->dontCastShadowForInterior(i); bool avoidCollisionOutside= ig->dontCastShadowForExterior(i); // very special patch for the matis serre (grrrrrrrrrrrrr) - avoidCollisionOutside= avoidCollisionOutside || strlwr(shapeName)== "ma_serre_interieur.shape"; + avoidCollisionOutside= avoidCollisionOutside || toLower(shapeName)== "ma_serre_interieur.shape"; // then send the result to the collision manager, and keep the mesh col id if succeed uint32 meshId= CollisionManager->addMeshInstanceCollision(colMesh, mat, avoidCollisionInside, avoidCollisionOutside); diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index b238dbd55..ead456a81 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -692,7 +692,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (!stringCategory.empty() && stringCategory != "SYS") { map::const_iterator it; - it = ClientCfg.SystemInfoParams.find(strlwr(stringCategory)); + it = ClientCfg.SystemInfoParams.find(toLower(stringCategory)); if (it != ClientCfg.SystemInfoParams.end()) { col = it->second.Color; @@ -723,7 +723,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if( !stringCategory.empty() ) { map::const_iterator it; - it = ClientCfg.SystemInfoParams.find( strlwr(stringCategory) ); + it = ClientCfg.SystemInfoParams.find( toLower(stringCategory) ); if( it != ClientCfg.SystemInfoParams.end() ) { if( !(*it).second.SysInfoFxName.empty() ) diff --git a/code/ryzom/client/src/outpost.cpp b/code/ryzom/client/src/outpost.cpp index 4968b8968..b345d36cb 100644 --- a/code/ryzom/client/src/outpost.cpp +++ b/code/ryzom/client/src/outpost.cpp @@ -99,7 +99,7 @@ void COutpost::initOutpost () for (i=0; i::const_iterator igIt = IGLoaded.find(strlwr(strPos)); + std::map::const_iterator igIt = IGLoaded.find(toLower(strPos)); if (igIt != IGLoaded.end()) { return igIt->second; @@ -188,7 +188,7 @@ void releaseLandscapeIGCallbacks() void addPacsPrim(const std::string &fileName) { - std::string ppName = NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(fileName)); + std::string ppName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fileName)); if (PacsPrims.find(ppName) != PacsPrims.end()) { nlwarning(("Pacs primitive " + ppName + " already has been inserted").c_str()); diff --git a/code/ryzom/client/src/sky.cpp b/code/ryzom/client/src/sky.cpp index 855ab3387..5d66c2d70 100644 --- a/code/ryzom/client/src/sky.cpp +++ b/code/ryzom/client/src/sky.cpp @@ -281,7 +281,7 @@ CBitmap *buildSharedBitmap(const std::string &filename, { alreadyBuilt = false; if (filename.empty()) return NULL; - std::string lcBMFilename = strlwr(CFile::getFilenameWithoutExtension(filename)); + std::string lcBMFilename = toLower(CFile::getFilenameWithoutExtension(filename)); std::map::iterator it = bitmapByName.find(lcBMFilename); if (it != bitmapByName.end()) { diff --git a/code/ryzom/client/src/streamable_ig.cpp b/code/ryzom/client/src/streamable_ig.cpp index f73df6126..e93b62c4c 100644 --- a/code/ryzom/client/src/streamable_ig.cpp +++ b/code/ryzom/client/src/streamable_ig.cpp @@ -291,10 +291,8 @@ bool CStreamableIG::setIG(uint ig, const std::string &name, const std::string &p } // Load this IG - _IGs[ig].Name = NLMISC::CFile::getFilenameWithoutExtension(name); - _IGs[ig].ParentName = NLMISC::CFile::getFilenameWithoutExtension(parentName); - NLMISC::strlwr(_IGs[ig].Name); - NLMISC::strlwr(_IGs[ig].ParentName); + _IGs[ig].Name = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(name)); + _IGs[ig].ParentName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(parentName)); _IGs[ig].IG = NULL; _IGs[ig].Loading = false; _Linked = false; @@ -308,10 +306,8 @@ void CStreamableIG::addIG(const std::string &name,const std::string &parentName, { H_AUTO_USE(RZ_StremableIG) _IGs.push_back(CIGNode ()); - _IGs.back().Name = NLMISC::CFile::getFilenameWithoutExtension(name); - _IGs.back().ParentName = NLMISC::CFile::getFilenameWithoutExtension(parentName); - NLMISC::strlwr(_IGs.back().Name); - NLMISC::strlwr(_IGs.back().ParentName); + _IGs.back().Name = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(name)); + _IGs.back().ParentName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(parentName)); _IGs.back().IG = NULL; _IGs.back().Loading = false; _IGs.back().Pos = pos; @@ -376,7 +372,7 @@ void CStreamableIG::addLoadedIGToMap() if (_IGs[k].IG && _IGs[k].IG != (NL3D::UInstanceGroup *)-1) // is this a successfully loaded ig ? { // insert the new ig if it hasn't before.. - if( _IGMap->insert(std::make_pair(NLMISC::strlwr(_IGs[k].Name), _IGs[k].IG)).second ) + if( _IGMap->insert(std::make_pair(NLMISC::toLower(_IGs[k].Name), _IGs[k].IG)).second ) // if inserted, must notify IG Added, else already notifiyed by loadAsync() this->notifyIGAdded(_IGs[k].IG); } diff --git a/code/ryzom/client/src/string_manager_client.cpp b/code/ryzom/client/src/string_manager_client.cpp index 71ca87ad8..da2fef260 100644 --- a/code/ryzom/client/src/string_manager_client.cpp +++ b/code/ryzom/client/src/string_manager_client.cpp @@ -1413,8 +1413,7 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo // avoid case problems static std::string lwrLabel; - lwrLabel = label; - strlwr(lwrLabel); + lwrLabel = toLower(label); if (_SpecItem_MemoryCompressed) { @@ -1464,8 +1463,7 @@ const ucchar * CStringManagerClient::getSpecialDesc(const std::string &label) // avoid case problems static std::string lwrLabel; - lwrLabel= label; - strlwr(lwrLabel); + lwrLabel = toLower(label); if (_SpecItem_MemoryCompressed) { @@ -1498,8 +1496,7 @@ const ucchar * CStringManagerClient::getSpecialDesc2(const std::string &label) // avoid case problems static std::string lwrLabel; - lwrLabel= label; - strlwr(lwrLabel); + lwrLabel = toLower(label); if (_SpecItem_MemoryCompressed) { @@ -1703,8 +1700,7 @@ void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring // avoid case problems static std::string lwrLabel; - lwrLabel= label; - strlwr(lwrLabel); + lwrLabel = toLower(label); if (_SpecItem_MemoryCompressed) { diff --git a/code/ryzom/common/src/game_share/fame.cpp b/code/ryzom/common/src/game_share/fame.cpp index ca226ecdc..51f80114e 100644 --- a/code/ryzom/common/src/game_share/fame.cpp +++ b/code/ryzom/common/src/game_share/fame.cpp @@ -359,8 +359,7 @@ void CStaticFames::loadStaticFame( const string& filename ) // 1st, build the index table for (uint i=1; i &sh { if (sheets[k]) { - std::string id = NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(sheetNames[k])); + std::string id = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(sheetNames[k])); CWeatherSetup *ws = newWeatherSetup(); if (ws) { @@ -70,7 +70,7 @@ void CWeatherManager::release() //================================================================================================ const CWeatherSetup *CWeatherManager::getSetup(const char *name) const { - std::string id = NLMISC::strlwr(CFile::getFilenameWithoutExtension(name)); + std::string id = NLMISC::toLower(CFile::getFilenameWithoutExtension(name)); TWeatherSetupMap::const_iterator it = _WeatherSetupMap.find(id); if (it == _WeatherSetupMap.end()) return NULL; return it->second; diff --git a/code/ryzom/common/src/game_share/time_weather_season/weather_setup_sheet_base.cpp b/code/ryzom/common/src/game_share/time_weather_season/weather_setup_sheet_base.cpp index 6d868741d..345b0e4a2 100644 --- a/code/ryzom/common/src/game_share/time_weather_season/weather_setup_sheet_base.cpp +++ b/code/ryzom/common/src/game_share/time_weather_season/weather_setup_sheet_base.cpp @@ -85,7 +85,7 @@ void CWeatherStateSheet::build(const NLGEORGES::UFormElm &item) GetWeatherFormValue(item, fxName, "FXName"); if (!fxName.empty()) { - fxName = NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(fxName)); + fxName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fxName)); if (!fxName.empty()) { FXInfos.resize(1); @@ -192,7 +192,7 @@ void CWeatherSetupSheetBase::build(const NLGEORGES::UFormElm &item) CloudState.build(item); std::string setupName; GetWeatherFormValue(item, setupName, "SetupName"); - SetupName = NLMISC::CStringMapper::map(NLMISC::strlwr(setupName)); + SetupName = NLMISC::CStringMapper::map(NLMISC::toLower(setupName)); } //================================================================================== @@ -203,7 +203,7 @@ void CWeatherSetupSheetBase::serial(class NLMISC::IStream &f) throw(NLMISC::EStr { std::string setupName; f.serial(setupName); - SetupName = NLMISC::CStringMapper::map(NLMISC::strlwr(setupName)); + SetupName = NLMISC::CStringMapper::map(NLMISC::toLower(setupName)); } else { From a8d81c689b9e59c1b6370dc19f3c724f61bdf979 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 13 Nov 2015 18:42:50 +0100 Subject: [PATCH 2/6] Changed: Support for integer types in Lua 5.3, fixes #253 --HG-- branch : develop --- code/nel/include/nel/gui/lua_helper.h | 6 +- code/nel/include/nel/gui/lua_helper_inline.h | 28 ++ code/nel/include/nel/gui/lua_object.h | 4 + code/nel/src/gui/dbgroup_combo_box.cpp | 10 +- code/nel/src/gui/group_container.cpp | 2 +- code/nel/src/gui/group_header.cpp | 4 +- code/nel/src/gui/group_html.cpp | 12 +- code/nel/src/gui/group_list.cpp | 12 +- code/nel/src/gui/group_menu.cpp | 28 +- code/nel/src/gui/group_tab.cpp | 10 +- code/nel/src/gui/group_tree.cpp | 6 +- code/nel/src/gui/interface_group.cpp | 2 +- code/nel/src/gui/lua_helper.cpp | 17 + code/nel/src/gui/lua_ihm.cpp | 28 +- code/nel/src/gui/lua_object.cpp | 6 +- .../src/interface_v3/interface_3d_scene.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 8 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 37 +- code/ryzom/client/src/r2/config_var.h | 4 +- .../client/src/r2/dmc/com_lua_module.cpp | 70 +-- .../client/src/r2/dmc/property_accessor.cpp | 8 + .../client/src/r2/dmc/property_accessor.h | 1 + code/ryzom/client/src/r2/editor.cpp | 60 +-- code/ryzom/client/src/r2/instance.cpp | 4 +- code/ryzom/client/src/r2/prim_render.cpp | 2 +- code/ryzom/client/src/r2/tool_select_move.cpp | 6 +- .../ryzom/client/src/session_browser_impl.cpp | 4 +- code/ryzom/common/src/game_share/object.cpp | 398 ++++++++++++++---- code/ryzom/common/src/game_share/object.h | 54 +++ .../game_share/server_animation_module.cpp | 34 +- .../src/game_share/small_string_manager.cpp | 8 +- 31 files changed, 636 insertions(+), 239 deletions(-) diff --git a/code/nel/include/nel/gui/lua_helper.h b/code/nel/include/nel/gui/lua_helper.h index 69639fc04..cacec7931 100644 --- a/code/nel/include/nel/gui/lua_helper.h +++ b/code/nel/include/nel/gui/lua_helper.h @@ -239,6 +239,7 @@ namespace NLGUI bool isNil(int index = -1); bool isBoolean(int index = -1); bool isNumber(int index = -1); + bool isInteger(int index = -1); bool isString(int index = -1); bool isTable(int index = -1); bool isFunction(int index = -1); @@ -248,6 +249,7 @@ namespace NLGUI // converting then getting a value from the stack bool toBoolean(int index = -1); lua_Number toNumber(int index = -1); + lua_Integer toInteger(int index = -1); const char *toString(int index = -1); void toString(int index, std::string &str); // convert to a std::string, with a NULL check. size_t strlen(int index = -1); @@ -259,11 +261,13 @@ namespace NLGUI * If conversion fails then an exception is thrown (with optional msg) */ bool getTableBooleanValue(const char *name, bool defaultValue= false); - double getTableNumberValue(const char *name, double defaultValue= 0); + double getTableNumberValue(const char *name, double defaultValue= 0.0); + sint64 getTableIntegerValue(const char *name, sint64 defaultValue= 0); const char *getTableStringValue(const char *name, const char *defaultValue= NULL); // pushing value onto the stack void push(bool value); void push(lua_Number value); + void push(lua_Integer value); void push(const char *str); void push(const char *str, int length); void push(const std::string &str); diff --git a/code/nel/include/nel/gui/lua_helper_inline.h b/code/nel/include/nel/gui/lua_helper_inline.h index 01afd142f..eadce7eaa 100644 --- a/code/nel/include/nel/gui/lua_helper_inline.h +++ b/code/nel/include/nel/gui/lua_helper_inline.h @@ -172,6 +172,18 @@ inline bool CLuaState::isNumber(int index) return lua_isnumber(_State, index) != 0; } +//================================================================================ +inline bool CLuaState::isInteger(int index) +{ + //H_AUTO(Lua_CLuaState_isInteger) + checkIndex(index); +#if LUA_VERSION_NUM >= 503 + return lua_isinteger(_State, index) != 0; +#else + return lua_isnumber(_State, index) != 0; +#endif +} + //================================================================================ inline bool CLuaState::isString(int index) { @@ -236,6 +248,14 @@ inline lua_Number CLuaState::toNumber(int index) return lua_tonumber(_State, index); } +//================================================================================ +inline lua_Integer CLuaState::toInteger(int index) +{ + //H_AUTO(Lua_CLuaState_toInteger) + checkIndex(index); + return lua_tointeger(_State, index); +} + //================================================================================ inline const char *CLuaState::toString(int index) { @@ -309,6 +329,14 @@ inline void CLuaState::push(lua_Number value) lua_pushnumber(_State, value); } +//================================================================================ +inline void CLuaState::push(lua_Integer value) +{ + //H_AUTO(Lua_CLuaState_push) + nlverify( lua_checkstack(_State, 1) ); + lua_pushinteger(_State, value); +} + //================================================================================ inline void CLuaState::push(const char *str) { diff --git a/code/nel/include/nel/gui/lua_object.h b/code/nel/include/nel/gui/lua_object.h index 2360f1609..4ea052ef7 100644 --- a/code/nel/include/nel/gui/lua_object.h +++ b/code/nel/include/nel/gui/lua_object.h @@ -80,6 +80,7 @@ namespace NLGUI const char *getTypename() const; bool isNil() const; bool isNumber() const; + bool isInteger() const; bool isBoolean() const; bool isString() const; bool isFunction() const; @@ -94,6 +95,7 @@ namespace NLGUI NLMISC::CRGBA toRGBA() const; // default to black if not a crgba bool toBoolean() const; lua_Number toNumber() const; + lua_Integer toInteger() const; std::string toString() const; lua_CFunction toCFunction() const; void *toUserData() const; @@ -102,6 +104,8 @@ namespace NLGUI operator bool() const; operator float() const; operator double() const; + operator sint32() const; + operator sint64() const; operator std::string() const; /** create a sub table for this object, with a string as a key * This object must be a table or an exception if thrown diff --git a/code/nel/src/gui/dbgroup_combo_box.cpp b/code/nel/src/gui/dbgroup_combo_box.cpp index 39ddd63c1..b594fea9a 100644 --- a/code/nel/src/gui/dbgroup_combo_box.cpp +++ b/code/nel/src/gui/dbgroup_combo_box.cpp @@ -543,7 +543,7 @@ namespace NLGUI CLuaIHM::checkArgTypeUCString(ls, funcName, 2); ucstring text; nlverify(CLuaIHM::pop(ls, text)); - setText((uint) ls.toNumber(1), text); + setText((uint) ls.toInteger(1), text); return 0; } @@ -556,7 +556,7 @@ namespace NLGUI CLuaIHM::checkArgTypeUCString(ls, funcName, 2); ucstring text; nlverify(CLuaIHM::pop(ls, text)); - insertText((uint) ls.toNumber(1), text); + insertText((uint) ls.toInteger(1), text); return 0; } @@ -569,7 +569,7 @@ namespace NLGUI CLuaIHM::checkArgTypeUCString(ls, funcName, 2); ucstring texture; nlverify(CLuaIHM::pop(ls, texture)); - setTexture((uint) ls.toNumber(1), texture); + setTexture((uint) ls.toInteger(1), texture); return 0; } @@ -579,7 +579,7 @@ namespace NLGUI const char *funcName = "setText"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::push(ls, getText((uint) ls.toNumber(1))); + CLuaIHM::push(ls, getText((uint) ls.toInteger(1))); return 1; } @@ -589,7 +589,7 @@ namespace NLGUI const char *funcName = "removeText"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - removeText((uint) ls.toNumber(1)); + removeText((uint) ls.toInteger(1)); return 0; } diff --git a/code/nel/src/gui/group_container.cpp b/code/nel/src/gui/group_container.cpp index 18a65bc5f..5003654f9 100644 --- a/code/nel/src/gui/group_container.cpp +++ b/code/nel/src/gui/group_container.cpp @@ -4820,7 +4820,7 @@ namespace NLGUI const char *funcName = "blink"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - enableBlink((uint) ls.toNumber(1)); + enableBlink((uint) ls.toInteger(1)); return 0; } diff --git a/code/nel/src/gui/group_header.cpp b/code/nel/src/gui/group_header.cpp index 16b52cad6..d166b539b 100644 --- a/code/nel/src/gui/group_header.cpp +++ b/code/nel/src/gui/group_header.cpp @@ -202,7 +202,7 @@ namespace NLGUI const char *funcName = "enlargeColumns"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - enlargeColumns((sint32) ls.toNumber(1)); + enlargeColumns((sint32) ls.toInteger(1)); return 0; } @@ -212,7 +212,7 @@ namespace NLGUI const char *funcName = "resizeColumnsAndContainer"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - resizeColumnsAndContainer((sint32) ls.toNumber(1)); + resizeColumnsAndContainer((sint32) ls.toInteger(1)); return 0; } diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 9eea81220..7d451d561 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -4725,7 +4725,7 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TTABLE); - uint element_number = (uint)ls.toNumber(1); + uint element_number = (uint)ls.toInteger(1); std::vector present; std::vector value; present.resize(30, false); @@ -4738,7 +4738,7 @@ namespace NLGUI ENUM_LUA_TABLE(params, it) { - if (!it.nextKey().isNumber()) + if (!it.nextKey().isInteger()) { nlwarning("%s : bad key encountered with type %s, number expected.", funcName, it.nextKey().getTypename()); continue; @@ -4748,16 +4748,16 @@ namespace NLGUI nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); continue; } - uint idx = (uint)it.nextKey().toNumber(); + uint idx = (uint)it.nextKey().toInteger(); - present.insert(present.begin() + (uint)it.nextKey().toNumber(), true); + present.insert(present.begin() + (uint)it.nextKey().toInteger(), true); string str = it.nextValue().toString(); size_t size = str.size() + 1; char * buffer = new char[ size ]; strncpy(buffer, str.c_str(), size ); - value.insert(value.begin() + (uint)it.nextKey().toNumber(), buffer); + value.insert(value.begin() + (uint)it.nextKey().toInteger(), buffer); } beginElement(element_number, present, value); @@ -4775,7 +4775,7 @@ namespace NLGUI CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - uint element_number = (uint)ls.toNumber(1); + uint element_number = (uint)ls.toInteger(1); endElement(element_number); return 0; diff --git a/code/nel/src/gui/group_list.cpp b/code/nel/src/gui/group_list.cpp index 4936ad3e2..0b4fbf8b8 100644 --- a/code/nel/src/gui/group_list.cpp +++ b/code/nel/src/gui/group_list.cpp @@ -1224,7 +1224,7 @@ namespace NLGUI const char *funcName = "getChild"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - sint index = (sint) ls.toNumber(1); + sint index = (sint) ls.toInteger(1); if(index < 0 || index >= (sint) _Elements.size()) { CLuaIHM::fails(ls, "getChild : trying to access element %d in list '%s', which has %d elements", @@ -1304,10 +1304,10 @@ namespace NLGUI ucstring ucText; ucText.fromUtf8(text); - uint r = (uint) ls.toNumber(2); - uint g = (uint) ls.toNumber(3); - uint b = (uint) ls.toNumber(4); - uint a = (uint) ls.toNumber(5); + uint r = (uint) ls.toInteger(2); + uint g = (uint) ls.toInteger(3); + uint b = (uint) ls.toInteger(4); + uint a = (uint) ls.toInteger(5); addTextChild(ucText, CRGBA(r, g, b, a)); @@ -1344,7 +1344,7 @@ namespace NLGUI } else { - addChildAtIndex(vb, (uint) ls.toNumber(2)); + addChildAtIndex(vb, (uint) ls.toInteger(2)); } return 0; } diff --git a/code/nel/src/gui/group_menu.cpp b/code/nel/src/gui/group_menu.cpp index ddd022310..e41af0ad9 100644 --- a/code/nel/src/gui/group_menu.cpp +++ b/code/nel/src/gui/group_menu.cpp @@ -1712,7 +1712,7 @@ namespace NLGUI const char *funcName = "getSubMenu"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); + CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toInteger(1))); return 1; } @@ -1722,8 +1722,8 @@ namespace NLGUI const char *funcName = "addSubMenu"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - setSubMenu((uint) ls.toNumber(1), new CGroupSubMenu(CViewText::TCtorParam())); - CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); + setSubMenu((uint) ls.toInteger(1), new CGroupSubMenu(CViewText::TCtorParam())); + CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toInteger(1))); return 1; } @@ -1733,7 +1733,7 @@ namespace NLGUI const char *funcName = "getLineId"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - std::string id = getLineId((uint) ls.toNumber(1)); + std::string id = getLineId((uint) ls.toInteger(1)); CLuaIHM::push(ls, id); return 1; } @@ -1754,7 +1754,7 @@ namespace NLGUI const char *funcName = "isSeparator"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - ls.push(isSeparator((uint) ls.toNumber(1))); + ls.push(isSeparator((uint) ls.toInteger(1))); return 1; } @@ -1785,7 +1785,7 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); ucstring arg2; nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); - addLineAtIndex((uint) ls.toNumber(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5)); + addLineAtIndex((uint) ls.toInteger(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5)); return 0; } @@ -1803,7 +1803,7 @@ namespace NLGUI const char *funcName = "addSeparatorAtIndex"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - addSeparatorAtIndex((uint) ls.toNumber(1)); + addSeparatorAtIndex((uint) ls.toInteger(1)); return 0; } @@ -1813,7 +1813,7 @@ namespace NLGUI const char *funcName = "removeLine"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - removeLine((uint) ls.toNumber(1)); + removeLine((uint) ls.toInteger(1)); return 0; } @@ -1833,7 +1833,7 @@ namespace NLGUI { CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); } - setUserGroupRight((uint) ls.toNumber(1), group, true); + setUserGroupRight((uint) ls.toInteger(1), group, true); return 0; } @@ -1853,7 +1853,7 @@ namespace NLGUI { CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); } - setUserGroupLeft((uint) ls.toNumber(1), group, true); + setUserGroupLeft((uint) ls.toInteger(1), group, true); return 0; } @@ -1864,7 +1864,7 @@ namespace NLGUI const char *funcName = "getUserGroupRight"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1))); + CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toInteger(1))); return 1; } @@ -1875,7 +1875,7 @@ namespace NLGUI const char *funcName = "getUserGroupLeft"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toNumber(1)); + CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toInteger(1)); if (pIE) { CLuaIHM::pushUIOnStack(ls, pIE); @@ -1890,7 +1890,7 @@ namespace NLGUI const char *funcName = "setMaxVisibleLine"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - setMaxVisibleLine((uint) ls.toNumber(1)); + setMaxVisibleLine((uint) ls.toInteger(1)); return 0; } @@ -2566,7 +2566,7 @@ namespace NLGUI const char *funcName = "setMinW"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - setMinW((sint32) ls.toNumber(1)); + setMinW((sint32) ls.toInteger(1)); return 0; } } diff --git a/code/nel/src/gui/group_tab.cpp b/code/nel/src/gui/group_tab.cpp index 1a8c6b726..ca876c25e 100644 --- a/code/nel/src/gui/group_tab.cpp +++ b/code/nel/src/gui/group_tab.cpp @@ -316,7 +316,7 @@ namespace NLGUI if (tabB) { // don't use addTab to avoid selection of new tab - addTab(tabB, (sint) ls.toNumber(2)); + addTab(tabB, (sint) ls.toInteger(2)); } return 0; } @@ -395,7 +395,7 @@ namespace NLGUI const char *funcName = "removeTab"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - removeTab((uint) ls.toNumber(1)); + removeTab((uint) ls.toInteger(1)); return 0; } @@ -441,7 +441,7 @@ namespace NLGUI const char *funcName = "getTabButton"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CCtrlTabButton* tab = getTabButton((uint) ls.toNumber(1)); + CCtrlTabButton* tab = getTabButton((uint) ls.toInteger(1)); if(tab != NULL) { CLuaIHM::pushUIOnStack(ls, tab); @@ -562,7 +562,7 @@ namespace NLGUI const char *funcName = "showTabButton"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - sint showTab = (sint)ls.toNumber(1); + sint showTab = (sint)ls.toInteger(1); if(showTab>=0 && showTab<(sint)_Buttons.size()) { @@ -770,7 +770,7 @@ namespace NLGUI const char *funcName = "getGroup"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CInterfaceGroup* group = getGroup((uint) ls.toNumber(1)); + CInterfaceGroup* group = getGroup((uint) ls.toInteger(1)); if(group != NULL) { CLuaIHM::pushUIOnStack(ls, group); diff --git a/code/nel/src/gui/group_tree.cpp b/code/nel/src/gui/group_tree.cpp index 82a2f5eb0..b0b936215 100644 --- a/code/nel/src/gui/group_tree.cpp +++ b/code/nel/src/gui/group_tree.cpp @@ -1815,7 +1815,7 @@ namespace NLGUI const char *funcName = "CGroupTree::SNode::luaAddChildAtIndex"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - addChildAtIndex(luaGetNodeOnStack(ls, funcName), (sint) ls.toNumber(2)); + addChildAtIndex(luaGetNodeOnStack(ls, funcName), (sint) ls.toInteger(2)); return 0; } @@ -1847,7 +1847,7 @@ namespace NLGUI CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); // - sint index = (sint) ls.toNumber(1); + sint index = (sint) ls.toInteger(1); if (index < 0 || index >= (sint) Children.size()) { std::string range = Children.empty() ? "" : toString("[0, %d]", Children.size() - 1); @@ -1890,7 +1890,7 @@ namespace NLGUI { CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 2, LUA_TBOOLEAN); - selectLine((uint) ls.toNumber(1), ls.toBoolean(2)); + selectLine((uint) ls.toInteger(1), ls.toBoolean(2)); return 0; } diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index f2a695436..1fc404fec 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -1183,7 +1183,7 @@ namespace NLGUI const char *funcName = "CInterfaceGroup::getGroup"; CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getGroup", 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - uint index = (uint) ls.toNumber(1); + uint index = (uint) ls.toInteger(1); if (index >= _ChildrenGroups.size()) { CLuaIHM::fails(ls, "getGroup : try to index group %s, but there are only %d son groups", ls.toString(1), (int) _ChildrenGroups.size()); diff --git a/code/nel/src/gui/lua_helper.cpp b/code/nel/src/gui/lua_helper.cpp index fb9466b36..0e2b9ba71 100644 --- a/code/nel/src/gui/lua_helper.cpp +++ b/code/nel/src/gui/lua_helper.cpp @@ -623,6 +623,23 @@ namespace NLGUI return result; } + // *************************************************************************** + sint64 CLuaState::getTableIntegerValue(const char *name, sint64 defaultValue) + { + //H_AUTO(Lua_CLuaState_getTableIntegerValue) + nlassert(name); + push(name); + getTable(-2); + if (isNil()) + { + pop(); + return defaultValue; + } + sint64 result = toInteger(-1); + pop(); + return result; + } + // *************************************************************************** const char *CLuaState::getTableStringValue(const char *name, const char *defaultValue) { diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index 0a7bacf9b..9c2dfc1ac 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -231,20 +231,24 @@ namespace NLGUI } +#if LUA_VERSION_NUM < 503 +#define lua_isinteger(a, b) lua_isnumber(a, b) +#endif + // *************************************************************************** #define LUA_REGISTER_BASIC(_type_) \ - luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \ - _type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ + luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \ + _type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ { \ - return (_type_)lua_tonumber(L, index); \ + return (_type_)lua_tointeger(L, index); \ } \ - int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ + int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ { \ - if (lua_isnumber(L, index)) return 0; else return -1; \ + if (lua_isinteger(L, index)) return 0; else return -1; \ } \ - void convert_cpp_to_lua(lua_State* L, const _type_& v) \ + void convert_cpp_to_lua(lua_State* L, const _type_& v) \ { \ - lua_pushnumber(L, (double)v); \ + lua_pushinteger(L, (double)v); \ } // Basic LUA types @@ -258,8 +262,6 @@ namespace NLGUI LUA_REGISTER_BASIC(uint16) LUA_REGISTER_BASIC(sint32) LUA_REGISTER_BASIC(uint32) - // LUA_REGISTER_BASIC(sint) - // LUA_REGISTER_BASIC(uint) } } @@ -1381,7 +1383,7 @@ namespace NLGUI ls.push( (reflectedObject.*(property.GetMethod.GetBool))() ); break; case CReflectedProperty::SInt32: - ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetSInt32))() ); + ls.push( (lua_Integer)(reflectedObject.*(property.GetMethod.GetSInt32))() ); break; case CReflectedProperty::Float: ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetFloat))() ); @@ -1447,13 +1449,13 @@ namespace NLGUI } case CReflectedProperty::SInt32: { - sint32 val= (sint32)ls.toNumber(stackIndex); + sint32 val= (sint32)ls.toInteger(stackIndex); (target.*(property.SetMethod.SetSInt32))(val); return; } case CReflectedProperty::UInt32: { - uint32 val= (uint32)ls.toNumber(stackIndex); + uint32 val= (uint32)ls.toInteger(stackIndex); (target.*(property.SetMethod.SetUInt32))(val); return; } @@ -1474,7 +1476,7 @@ namespace NLGUI { ucstring val; // Additionaly return of CInterfaceExpr may be std::string... test std string too - if(ls.isString() || ls.isNumber()) + if(ls.isString() || ls.isNumber() || ls.isInteger()) { std::string str; ls.toString(stackIndex, str); diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index a50569858..5b44f32e2 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -150,7 +150,8 @@ namespace NLGUI // ************************************************* bool CLuaObject::isNil() const { push(); bool result = _LuaState->isNil(); _LuaState->pop(); return result; } bool CLuaObject::isNumber() const { push(); bool result = _LuaState->isNumber(); _LuaState->pop(); return result; } - bool CLuaObject::isBoolean() const { push(); bool result = _LuaState->isBoolean(); _LuaState->pop(); return result; } + bool CLuaObject::isInteger() const { push(); bool result = _LuaState->isInteger(); _LuaState->pop(); return result; } + bool CLuaObject::isBoolean() const { push(); bool result = _LuaState->isBoolean(); _LuaState->pop(); return result; } bool CLuaObject::isString() const { push(); bool result = _LuaState->isString(); _LuaState->pop(); return result; } bool CLuaObject::isFunction() const { push(); bool result = _LuaState->isFunction(); _LuaState->pop(); return result; } bool CLuaObject::isCFunction() const { push(); bool result = _LuaState->isCFunction(); _LuaState->pop(); return result; } @@ -168,6 +169,7 @@ namespace NLGUI // ************************************************* bool CLuaObject::toBoolean() const { push(); bool result = _LuaState->toBoolean(); _LuaState->pop(); return result; } lua_Number CLuaObject::toNumber() const { push(); lua_Number result = _LuaState->toNumber(); _LuaState->pop(); return result; } + lua_Integer CLuaObject::toInteger() const { push(); lua_Integer result = _LuaState->toInteger(); _LuaState->pop(); return result; } std::string CLuaObject::toString() const { push(); @@ -194,6 +196,8 @@ namespace NLGUI CLuaObject::operator bool() const { return toBoolean(); } CLuaObject::operator float() const { return (float) toNumber(); } CLuaObject::operator double() const { return (double) toNumber(); } + CLuaObject::operator sint32() const { return (sint32) toInteger(); } + CLuaObject::operator sint64() const { return (sint64) toInteger(); } CLuaObject::operator std::string() const { return toString(); } diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 19a6f4229..d7fec407b 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -856,7 +856,7 @@ int CInterface3DCharacter::luaSetupCharacter3D(CLuaState &ls) const char *funcName = "setupCharacter3D"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - setupCharacter3D((sint32) ls.toNumber(1)); + setupCharacter3D((sint32) ls.toInteger(1)); return 0; } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index e97aa475e..a104dd01d 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -3327,11 +3327,17 @@ void CInterfaceManager::getLuaValueInfo(std::string &str, sint index) sint type= ls.type(index); if(type==LUA_TNIL) + { str= "nil"; + } else if(type==LUA_TNUMBER) - str= NLMISC::toString(ls.toNumber(index)); + { + str= NLMISC::toString(ls.isInteger(index) ? ls.toInteger(index):ls.toNumber(index)); + } else if(type==LUA_TBOOLEAN) + { str= ls.toBoolean(index)?"true":"false"; + } else if(type==LUA_TSTRING) { ls.toString(index, str); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index fe4c6a716..db8018762 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -220,15 +220,22 @@ static DECLARE_INTERFACE_USER_FCT(lua) } else if(type==LUA_TNUMBER) { - // get and pop - double val= ls.toNumber(); - ls.pop(); - // set double or integer? - if(val==floor(val)) - result.setInteger(sint64(floor(val))); + if (ls.isInteger()) + { + // get and pop + sint64 val= ls.toInteger(); + ls.pop(); + result.setInteger(val); + ok= true; + } else + { + // get and pop + double val= ls.toNumber(); + ls.pop(); result.setDouble(val); - ok= true; + ok= true; + } } else if(type==LUA_TSTRING) { @@ -1020,7 +1027,7 @@ int CLuaIHMRyzom::setLuaBreakPoint(CLuaState &ls) #ifdef LUA_NEVRAX_VERSION if (LuaDebuggerIDE) { - LuaDebuggerIDE->setBreakPoint(ls.toString(1), (int) ls.toNumber(2)); + LuaDebuggerIDE->setBreakPoint(ls.toString(1), (int) ls.toInteger(2)); } #endif @@ -1144,7 +1151,7 @@ int CLuaIHMRyzom::getPlayerDirection(CLuaState &ls) int CLuaIHMRyzom::getPlayerGender(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerGender", 0); - ls.push((lua_Number)(UserEntity->getGender())); + ls.push((lua_Integer)(UserEntity->getGender())); return 1; } @@ -1210,7 +1217,7 @@ int CLuaIHMRyzom::getTargetGender(CLuaState &ls) CLuaIHM::checkArgCount(ls, "getTargetGender", 0); CCharacterCL* target = (CCharacterCL*)getTargetEntity(); if (!target) return (int)GSGENDER::unknown; - ls.push((lua_Number)(target->getGender())); + ls.push((lua_Integer)(target->getGender())); return 1; } @@ -1344,14 +1351,14 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls) CLuaIHM::checkArgType(ls, "getSheet2idx", 2, LUA_TNUMBER); const std::string & sheedtName = ls.toString(1); - uint32 slotId = (uint32)ls.toNumber(2); + uint32 slotId = (uint32)ls.toInteger(2); NLMISC::CSheetId sheetId; if (sheetId.buildSheetId(sheedtName)) { uint32 idx = CVisualSlotManager::getInstance()->sheet2Index(sheetId, (SLOTTYPE::EVisualSlot)slotId); - ls.push((lua_Number)idx); + ls.push((lua_Integer)idx); } else return 0; @@ -1362,7 +1369,7 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls) int CLuaIHMRyzom::getTargetSlot(CLuaState &ls) { uint32 slot = (uint32)getTargetSlotNr(); - ls.push((lua_Number)slot); + ls.push((lua_Integer)slot); return 1; } @@ -1372,7 +1379,7 @@ int CLuaIHMRyzom::getSlotDataSetId(CLuaState &ls) CLuaIHM::checkArgCount(ls, "getSlotDataSetId", 1); CLuaIHM::checkArgType(ls, "getSlotDataSetId", 1, LUA_TNUMBER); - uint32 slot = (uint32)ls.toNumber(1); + uint32 slot = (uint32)ls.toInteger(1); CEntityCL *e = getSlotEntity(slot); string id = toString(e->dataSetId()); ls.push(id); @@ -1676,7 +1683,7 @@ int CLuaIHMRyzom::displayBubble(CLuaState &ls) strs.push_back(it.nextKey().toString()); } - InSceneBubbleManager.webIgChatOpen((uint32)ls.toNumber(1), ls.toString(2), strs, links); + InSceneBubbleManager.webIgChatOpen((uint32)ls.toInteger(1), ls.toString(2), strs, links); return 1; } diff --git a/code/ryzom/client/src/r2/config_var.h b/code/ryzom/client/src/r2/config_var.h index 238cd9c3c..828f67768 100644 --- a/code/ryzom/client/src/r2/config_var.h +++ b/code/ryzom/client/src/r2/config_var.h @@ -144,9 +144,9 @@ typedef CConfigVar CConfigVarDouble; inline std::string getConfigVarTypename(const sint32 &/* dummy */) { return "sint32"; } inline bool getConfigVarValue(CLuaObject &luaValue, sint32 &dest) { - if (luaValue.isNumber()) + if (luaValue.isInteger()) { - dest = (sint32) luaValue.toNumber(); + dest = (sint32) luaValue.toInteger(); return true; } return false; diff --git a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp index b73813786..439265734 100644 --- a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp +++ b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp @@ -403,10 +403,10 @@ sint CComLuaModule::luaSaveUserComponentFile(lua_State* state) luaL_checktype(state, 1, LUA_TSTRING); luaL_checktype(state, 2, LUA_TNUMBER); std::string filename( lua_tostring(state, 1) ); - double mustCompress( lua_tonumber(state, 2) ); + bool mustCompress(lua_tointeger(state, 2) != 0); CComLuaModule* this2 = getInstance(state); - this2->_Client->getEditionModule().saveUserComponentFile(filename, mustCompress != 0); + this2->_Client->getEditionModule().saveUserComponentFile(filename, mustCompress); return 0; } @@ -425,7 +425,7 @@ sint CComLuaModule::luaUpdateUserComponentsInfo(lua_State* state) std::string filename( lua_tostring(state, 1) ); std::string name( lua_tostring(state, 2) ); std::string description( lua_tostring(state, 3) ); - uint32 timestamp( static_cast(lua_tonumber(state, 3) )); + uint32 timestamp( static_cast(lua_tointeger(state, 3) )); std::string md5Id( lua_tostring(state, 3) ); CComLuaModule* this2 = getInstance(state); @@ -441,7 +441,7 @@ sint CComLuaModule::luaGetSheetIdName(lua_State* state) CComLuaModule* this2 = getInstance(state); nlassert(this2); - uint32 sheetIdValue = static_cast( lua_tonumber(state, 1) ); + uint32 sheetIdValue = static_cast( lua_tointeger(state, 1) ); NLMISC::CSheetId sheetId(sheetIdValue); if(sheetId != NLMISC::CSheetId::Unknown) @@ -538,7 +538,7 @@ sint CComLuaModule::luaRequestSetWeather(lua_State* state) { //H_AUTO(R2_CComLuaModule_luaRequestSetWeather) luaL_checktype(state, 1, LUA_TNUMBER); - uint16 weatherValue = (uint16) lua_tonumber(state, 1); + uint16 weatherValue = (uint16) lua_tointeger(state, 1); CComLuaModule* this2 = getInstance(state); nlassert(this2); this2->_Client->getEditionModule().requestSetWeather(weatherValue); @@ -550,7 +550,7 @@ sint CComLuaModule::luaRequestSetSeason(lua_State* state) { //H_AUTO(R2_CComLuaModule_luaRequestSetSeason) luaL_checktype(state, 1, LUA_TNUMBER); - uint8 season = (uint8) lua_tonumber(state, 1); + uint8 season = (uint8) lua_tointeger(state, 1); CComLuaModule* this2 = getInstance(state); nlassert(this2); this2->_Client->getEditionModule().requestSetSeason(season); @@ -572,7 +572,7 @@ sint CComLuaModule::luaRequestStartAct(lua_State* state) { //H_AUTO(R2_CComLuaModule_luaRequestStartAct) luaL_checktype(state, 1, LUA_TNUMBER); - uint32 actId(static_cast(lua_tonumber(state, 1))); + uint32 actId(static_cast(lua_tointeger(state, 1))); CComLuaModule* this2 = getInstance(state); nlassert(this2); this2->_Client->getEditionModule().requestStartAct(actId); @@ -712,7 +712,7 @@ sint CComLuaModule::luaRequestMapConnection(lua_State* state) CHECK_LUA_ARG_COUNT(1, "requestMapConnection"); luaL_checktype(state, 1, LUA_TNUMBER); - uint32 adventureId = static_cast( lua_tonumber(state, 1) ); + uint32 adventureId = static_cast( lua_tointeger(state, 1) ); CComLuaModule* this2 = getInstance(state); nlassert(this2); @@ -751,7 +751,7 @@ sint CComLuaModule::requestInsertNode(lua_State* state, bool isGhost) std::string instanceId(lua_tostring(state, 1)); std::string attrName(lua_tostring(state, 2)); - sint position(static_cast(lua_tonumber(state, 3))); + sint position(static_cast(lua_tointeger(state, 3))); std::string key(lua_tostring(state, 4)); CObject* value = getObjectFromLua(state, 5); value->setGhost(isGhost); @@ -837,7 +837,7 @@ sint CComLuaModule::luaRequestEraseNode(lua_State* state) std::string attrName; sint position = -1; if (args>1){ attrName = lua_tostring(state, 2);} - if (args>2){ position = static_cast(lua_tonumber(state, 3));} + if (args>2){ position = static_cast(lua_tointeger(state, 3));} CComLuaModule* this2 = getInstance(state); nlassert(this2); this2->_Client->requestEraseNode( instanceId, attrName, position); @@ -863,11 +863,11 @@ sint CComLuaModule::luaRequestMoveNode(lua_State* state) std::string instanceId(lua_tostring(state, 1)); std::string attrName(lua_tostring(state, 2)); - sint position = static_cast(lua_tonumber(state, 3)); + sint position = static_cast(lua_tointeger(state, 3)); std::string instanceId2(lua_tostring(state, 4)); std::string attrName2(lua_tostring(state, 5)); - sint position2 = static_cast(lua_tonumber(state, 6)); + sint position2 = static_cast(lua_tointeger(state, 6)); CComLuaModule* this2 = getInstance(state); nlassert(this2); @@ -967,7 +967,7 @@ sint CComLuaModule::luaRequestNewMultiAction(lua_State* state) sint args = lua_gettop(state); CHECK_LUA_ARG_COUNT(2, funcName); luaL_checktype(state, 2, LUA_TNUMBER); - uint count = (uint) lua_tonumber(state, 2); + uint count = (uint) lua_tointeger(state, 2); lua_pop(state, 1); return luaRequestNewAction(state, false, count); } @@ -979,7 +979,7 @@ sint CComLuaModule::luaRequestNewPendingMultiAction(lua_State* state) sint args = lua_gettop(state); CHECK_LUA_ARG_COUNT(2, funcName); luaL_checktype(state, 2, LUA_TNUMBER); - uint count = (uint) lua_tonumber(state, 2); + uint count = (uint) lua_tointeger(state, 2); lua_pop(state, 1); return luaRequestNewAction(state, true, count); } @@ -1049,6 +1049,13 @@ void CComLuaModule::setObjectToLua(lua_State* state, CObject* object) lua_pushnil(state); return; } + + if ( object->isInteger() ) + { + lua_pushinteger(state, object->toInteger()); + return; + } + if ( object->isNumber() ) { lua_pushnumber(state, object->toNumber()); @@ -1226,9 +1233,20 @@ CObject* CComLuaModule::getObjectFromLua(lua_State* state, sint idx) { case LUA_TNUMBER: { - double value = lua_tonumber(state, -1); - lua_pop(state, 1); - return new CObjectNumber(value); +#if LUA_VERSION_NUM >= 503 + if (lua_isinteger(state, -1) != 0) + { + sint64 value = lua_tointeger(state, -1); + lua_pop(state, 1); + return new CObjectInteger(value); + } + else +#endif + { + double value = lua_tonumber(state, -1); + lua_pop(state, 1); + return new CObjectNumber(value); + } } break; @@ -1738,8 +1756,8 @@ sint CComLuaModule::luaTriggerUserTrigger(lua_State* state) //H_AUTO(R2_CComLuaModule_luaTriggerUserTrigger) CComLuaModule* this2 = getInstance(state); nlassert(this2); - uint32 actId( static_cast(lua_tonumber(state, 1) ) ); - uint32 id( static_cast(lua_tonumber(state, 2) )); + uint32 actId( static_cast(lua_tointeger(state, 1) ) ); + uint32 id( static_cast(lua_tointeger(state, 2) )); this2->_Client->getEditionModule().requestTriggerUserTrigger(actId, id); return 0; @@ -1869,7 +1887,7 @@ sint CComLuaModule::luaReserveIdRange(lua_State* state) CHECK_LUA_ARG_COUNT(1, "reserveIdRange"); luaL_checktype(state, 1, LUA_TNUMBER); - uint32 range=static_cast( lua_tonumber(state, 1) ); + uint32 range=static_cast( lua_tointeger(state, 1) ); this2->_Client->getEditionModule().reserveIdRange(range); @@ -1897,7 +1915,7 @@ sint CComLuaModule::luaRequestTpToEntryPoint(lua_State* state) CHECK_LUA_ARG_COUNT(1, "requestTpToEntryPoint"); luaL_checktype(state, 1, LUA_TNUMBER); - uint32 actIndex = static_cast( lua_tonumber(state, 1) ); + uint32 actIndex = static_cast( lua_tointeger(state, 1) ); this2->_Client->getEditionModule().requestTpToEntryPoint(actIndex); return 0; @@ -1914,7 +1932,7 @@ sint CComLuaModule::luaRequestSetStartingAct(lua_State* state) CHECK_LUA_ARG_COUNT(1, "requestSetStartingAct"); luaL_checktype(state, 1, LUA_TNUMBER); - uint32 actIndex = static_cast( lua_tonumber(state, 1) ); + uint32 actIndex = static_cast( lua_tointeger(state, 1) ); this2->_Client->getEditionModule().requestSetStartingAct(actIndex); return 0; @@ -1993,7 +2011,7 @@ sint CComLuaModule::luaSetDisplayInfo(lua_State* state) std::string formName( lua_tostring(state, 1) ); - bool displayInfo = static_cast(lua_tonumber(state, 2) == 0); + bool displayInfo = lua_tointeger(state, 2) != 0; //this2->_Client->getEditionModule().reserveIdRange(range); this2->_Client->getEditionModule().setDisplayInfo(formName, displayInfo); @@ -2024,7 +2042,7 @@ sint CComLuaModule::luaSetStartingActIndex(lua_State* state) sint args = lua_gettop(state); CHECK_LUA_ARG_COUNT(1, "setStartingActIndex"); luaL_checktype(state, 1, LUA_TNUMBER); - this2->_Client->getEditionModule().setStartingActIndex( static_cast(lua_tonumber(state, 1)) ); + this2->_Client->getEditionModule().setStartingActIndex( static_cast(lua_tointeger(state, 1)) ); return 0; } @@ -2229,12 +2247,12 @@ sint CComLuaModule::luaUpdateScenarioAck(lua_State* state) { std::string key = object->getKey(i); CObject* value = object->getValue(i); - if (value->isNumber()) + if (value->isInteger()) { if (key.size() == 1) { - level[key] = static_cast(value->toNumber()); + level[key] = static_cast(value->toInteger()); } } } diff --git a/code/ryzom/client/src/r2/dmc/property_accessor.cpp b/code/ryzom/client/src/r2/dmc/property_accessor.cpp index a6faf17b5..d8f7a1290 100644 --- a/code/ryzom/client/src/r2/dmc/property_accessor.cpp +++ b/code/ryzom/client/src/r2/dmc/property_accessor.cpp @@ -46,6 +46,14 @@ double CPropertyAccessor::getValueAsNumber(CObject* component, const std::string return object->toNumber(); } +sint64 CPropertyAccessor::getValueAsInteger(CObject* component, const std::string& attrName) const +{ + //H_AUTO(R2_CPropertyAccessor_getValueAsInteger) + const CObject* object=getPropertyValue((const CObject *) component, attrName); + if (!object || !object->isInteger()) { return 0; } + return object->toInteger(); +} + bool CPropertyAccessor::hasValueInBase(CObject *component, const std::string& attrName) { //H_AUTO(R2_CPropertyAccessor_hasValueInBase) diff --git a/code/ryzom/client/src/r2/dmc/property_accessor.h b/code/ryzom/client/src/r2/dmc/property_accessor.h index 062ce5829..4f4cbe862 100644 --- a/code/ryzom/client/src/r2/dmc/property_accessor.h +++ b/code/ryzom/client/src/r2/dmc/property_accessor.h @@ -46,6 +46,7 @@ namespace R2 //get The propertyValue as number or 0 if not found double getValueAsNumber(CObject* component, const std::string& attrName) const; + sint64 getValueAsInteger(CObject* component, const std::string& attrName) const; const CObject* getPropertyValue(const CObject* component, const std::string& attrName) const; diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index aa5995b05..cbc7ba19d 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -1297,13 +1297,13 @@ int CEditor::luaSetPlotItemInfos(CLuaState &ls) CLuaIHM::checkArgTypeUCString(ls, funcName, 3); CLuaIHM::checkArgTypeUCString(ls, funcName, 4); CLuaIHM::checkArgTypeUCString(ls, funcName, 5); - CItemSheet *item = dynamic_cast(SheetMngr.get(CSheetId((uint32) ls.toNumber(2)))); + CItemSheet *item = dynamic_cast(SheetMngr.get(CSheetId((uint32) ls.toInteger(2)))); if (!item || item->Family != ITEMFAMILY::SCROLL_R2) { CLuaIHM::fails(ls, "%s : bad sheet, r2 plot item required", funcName); } R2::TMissionItem mi; - mi.SheetId = (uint32) ls.toNumber(2); + mi.SheetId = (uint32) ls.toInteger(2); CLuaIHM::getUCStringOnStack(ls, 3, mi.Name); CLuaIHM::getUCStringOnStack(ls, 4, mi.Description); CLuaIHM::getUCStringOnStack(ls, 5, mi.Comment); @@ -1383,7 +1383,7 @@ int CEditor::luaKickCharacter(CLuaState &ls) CSessionBrowserImpl &sb = CSessionBrowserImpl::getInstance(); sb.kickCharacter(sb.getCharId(), R2::getEditor().getDMC().getEditionModule().getCurrentAdventureId(), - (uint32)ls.toNumber(2)); + (uint32)ls.toInteger(2)); if(!sb.waitOneMessage(sb.getMessageName("on_invokeResult"))) nlwarning("kickCharacter callback return false"); @@ -1401,7 +1401,7 @@ int CEditor::luaUnkickCharacter(CLuaState &ls) CSessionBrowserImpl &sb = CSessionBrowserImpl::getInstance(); sb.unkickCharacter(sb.getCharId(), R2::getEditor().getDMC().getEditionModule().getCurrentAdventureId(), - (uint32)ls.toNumber(2)); + (uint32)ls.toInteger(2)); if(!sb.waitOneMessage(sb.getMessageName("on_invokeResult"))) nlwarning("unkickCharacter callback return false"); @@ -1419,7 +1419,7 @@ int CEditor::luaTeleportToCharacter(CLuaState &ls) CClientEditionModule & cem = R2::getEditor().getDMC().getEditionModule(); cem.requestTeleportOneCharacterToAnother(cem.getCurrentAdventureId(), CSessionBrowserImpl::getInstance().getCharId(), - (uint32)ls.toNumber(2)); + (uint32)ls.toInteger(2)); return 0; } @@ -1954,17 +1954,17 @@ int CEditor::luaRemoveInstanceObserver(CLuaState &ls) const char *funcName = "removeInstanceObserver"; CLuaIHM::checkArgCount(ls, funcName, 2); // this is a method (self + 1 params) CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); // instance id - IInstanceObserver *observer = getEditor().getInstanceObserver((TInstanceObserverHandle) ls.toNumber(2)); + IInstanceObserver *observer = getEditor().getInstanceObserver((TInstanceObserverHandle) ls.toInteger(2)); if (observer == NULL) { - CLuaIHM::fails(ls, "Instance observer not found for handle = %d", (int) ls.toNumber(2)); + CLuaIHM::fails(ls, "Instance observer not found for handle = %d"NL_I64, ls.toInteger(2)); } CInstanceObserverLua *luaObserver = dynamic_cast(observer); if (luaObserver == NULL) { - CLuaIHM::fails(ls, "Instance observer found for handle %d, but has bad type, it wasn't registered from lua.", (int) ls.toNumber(2)); + CLuaIHM::fails(ls, "Instance observer found for handle %d"NL_I64", but has bad type, it wasn't registered from lua.", ls.toInteger(2)); } - getEditor().removeInstanceObserver((TInstanceObserverHandle) ls.toNumber(2)); + getEditor().removeInstanceObserver((TInstanceObserverHandle) ls.toInteger(2)); CLuaObject receiver = luaObserver->getReceiver(); delete luaObserver; receiver.push(); @@ -3221,10 +3221,10 @@ void CEditor::initObjectProjectionMetatable() throw ELuaWrappedFunctionException(&ls, "Attempt to access an erased object"); } - if (ls.isNumber(2)) + if (ls.isInteger(2)) { - // index is a number - const CObject *other = obj->getValue((uint32) ls.toNumber(2)); + // index is an integer + const CObject *other = obj->getValue((uint32) ls.toInteger(2)); if (other) { pushValue(ls, other); @@ -3481,6 +3481,10 @@ void CEditor::initObjectProjectionMetatable() { ls.push(obj->toString()); } + else if (obj->isInteger()) + { + ls.push(obj->toInteger()); + } else if (obj->isNumber()) { ls.push(obj->toNumber()); @@ -3574,9 +3578,9 @@ void CEditor::initObjectProjectionMetatable() // continuation of traversal // -> retrieve index from the key sint32 index; - if (ls.isNumber(2)) + if (ls.isInteger(2)) { - index = (uint32) ls.toNumber(2); + index = (uint32) ls.toInteger(2); } else { @@ -5384,12 +5388,12 @@ sint CEditor::getLeftQuota() CLuaState &ls = getLua(); CLuaStackChecker lsc(&ls); callEnvMethod("getLeftQuota", 0, 1); - if (!ls.isNumber(-1)) + if (!ls.isInteger(-1)) { ls.pop(1); return 0; } - sint result = (sint) ls.toNumber(-1); + sint result = (sint) ls.toInteger(-1); ls.pop(1); return result; } @@ -5419,7 +5423,7 @@ bool CEditor::verifyRoomLeft(uint aiCost, uint staticCost) if (aiCost) { CLuaStackChecker lsc(&ls); - getEditor().getLua().push((lua_Number)aiCost); + getEditor().getLua().push((lua_Integer)aiCost); callEnvMethod("checkAiQuota", 1, 1); if (!ls.isBoolean(-1)) { @@ -5433,7 +5437,7 @@ bool CEditor::verifyRoomLeft(uint aiCost, uint staticCost) if (staticCost) { CLuaStackChecker lsc(&ls); - getEditor().getLua().push((lua_Number)staticCost); + getEditor().getLua().push((lua_Integer)staticCost); callEnvMethod("checkStaticQuota", 1, 1); if (!ls.isBoolean(-1)) { @@ -5781,7 +5785,7 @@ void CEditor::scenarioUpdated(CObject* highLevel, bool willTP, uint32 initialAct // teleport in good island if (ClientCfg.Local) { - sint locationId = (uint) _ScenarioInstance->getLuaProjection()["Description"]["LocationId"].toNumber(); + sint locationId = (uint) _ScenarioInstance->getLuaProjection()["Description"]["LocationId"].toInteger(); CScenarioEntryPoints &sep = CScenarioEntryPoints::getInstance(); _IslandCollision.loadEntryPoints(); @@ -6647,10 +6651,16 @@ std::string getString(const CObject *obj, const std::string &attrName) double getNumber(const CObject *obj, const std::string &attrName) { obj = getObject(obj, attrName); - if (!obj) return 0; - return obj->isNumber() ? obj->toNumber() : 0; + if (!obj) return 0.0; + return obj->isNumber() ? obj->toNumber() : 0.0; } +sint64 getInteger(const CObject *obj, const std::string &attrName) +{ + obj = getObject(obj, attrName); + if (!obj) return 0; + return obj->isInteger() ? obj->toInteger() : 0; +} bool isEditionCurrent() { @@ -6703,7 +6713,7 @@ bool CEditor::getVisualPropertiesFromObject(CObject* object, SPropVisualA& vA, S //-------------------------random init npc visual properties - std::map< std::string, double > visualProps; + std::map< std::string, sint64 > visualProps; static const char* keys[] = { "GabaritHeight", "GabaritTorsoWidth", "GabaritArmsWidth", "GabaritLegsWidth", "GabaritBreastSize" @@ -6719,7 +6729,7 @@ bool CEditor::getVisualPropertiesFromObject(CObject* object, SPropVisualA& vA, S unsigned int last = sizeof(keys) / sizeof(keys[0]); for (; first != last; ++first) { - visualProps[keys[first]] = getNumber(object, keys[first]); + visualProps[keys[first]] = getInteger(object, keys[first]); } //vA.PropertySubData.Sex = (uint) visualProps["Sex"]; @@ -7054,10 +7064,10 @@ class CAHCreateEntity : public IActionHandler if (getEditor().getEnv().callMethodByNameNoThrow("randomNPCProperties", 2, 1)) { CLuaObject result(getEditor().getLua()); - std::map< std::string, double > visualProps; + std::map< std::string, sint64 > visualProps; ENUM_LUA_TABLE(result, it) { - visualProps[it.nextKey().toString()] = it.nextValue().toNumber(); + visualProps[it.nextKey().toString()] = it.nextValue().toInteger(); } // visual property A depends on the type of the entity diff --git a/code/ryzom/client/src/r2/instance.cpp b/code/ryzom/client/src/r2/instance.cpp index 7bb2087fe..2baec8431 100644 --- a/code/ryzom/client/src/r2/instance.cpp +++ b/code/ryzom/client/src/r2/instance.cpp @@ -650,9 +650,9 @@ sint CInstance::getSelectedSequence() const //H_AUTO(R2_CInstance_getSelectedSequence) CLuaObject selected = const_cast(this)->getLuaProjection()["User"]["SelectedSequence"]; sint index = 0; - if (selected.isNumber()) + if (selected.isInteger()) { - index = (sint) selected.toNumber(); + index = (sint) selected.toInteger(); } return index; } diff --git a/code/ryzom/client/src/r2/prim_render.cpp b/code/ryzom/client/src/r2/prim_render.cpp index 246f3f98e..e714b979a 100644 --- a/code/ryzom/client/src/r2/prim_render.cpp +++ b/code/ryzom/client/src/r2/prim_render.cpp @@ -43,7 +43,7 @@ void readFromLua(const CLuaObject &table, const char *key, float &dest) } void readFromLua(const CLuaObject &table, const char *key, uint &dest) { - if (table[key].isNumber()) dest = (uint) table[key].toNumber(); + if (table[key].isInteger()) dest = (uint) table[key].toInteger(); } void readFromLua(const CLuaObject &table, const char *key, std::string &dest) { diff --git a/code/ryzom/client/src/r2/tool_select_move.cpp b/code/ryzom/client/src/r2/tool_select_move.cpp index 67d166652..46c83d83e 100644 --- a/code/ryzom/client/src/r2/tool_select_move.cpp +++ b/code/ryzom/client/src/r2/tool_select_move.cpp @@ -66,17 +66,17 @@ bool CToolSelectMove::checkAdditionnalRoomLeftFor(CInstance &instance) CLuaStackRestorer lsr(&ls, 0); // check ai & static cost : if they are too big, can't create the duplicate if (!luaProj.callMethodByNameNoThrow("getAiCost", 0, 1) - || !ls.isNumber(-1)) + || !ls.isInteger(-1)) { return false; } - uint aiCost = (uint) ls.toNumber(-1); + uint aiCost = (uint) ls.toInteger(-1); ls.pop(); if (!luaProj.callMethodByNameNoThrow("getStaticObjectCost", 0, 1)) { return false; } - uint staticCost = (uint) ls.toNumber(-1); + uint staticCost = (uint) ls.toInteger(-1); ls.pop(); if (!getEditor().verifyRoomLeft(aiCost, staticCost)) { diff --git a/code/ryzom/client/src/session_browser_impl.cpp b/code/ryzom/client/src/session_browser_impl.cpp index 1802aefbf..c5e0fdcc3 100644 --- a/code/ryzom/client/src/session_browser_impl.cpp +++ b/code/ryzom/client/src/session_browser_impl.cpp @@ -194,7 +194,7 @@ int CSessionBrowserImpl::luaUpdateScenarioScores(CLuaState &ls) if (R2::getEditor().getMode() != R2::CEditor::NotInitialized) { CSessionBrowserImpl::getInstance().setPlayerRating(getCharId(), R2::getEditor().getDMC().getEditionModule().getCurrentAdventureId(), - (uint32) ls.toNumber(1), (uint32) ls.toNumber(2), (uint32) ls.toNumber(3), (uint32) ls.toNumber(4), (uint32) ls.toNumber(5)); + (uint32) ls.toInteger(1), (uint32) ls.toInteger(2), (uint32) ls.toInteger(3), (uint32) ls.toInteger(4), (uint32) ls.toInteger(5)); } return 0; @@ -210,7 +210,7 @@ int CSessionBrowserImpl::luaJoinRingSession(CLuaState &ls) CInterfaceManager *pIM = CInterfaceManager::getInstance(); CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance(); - sessionBrowser.joinSession(getCharId(), (TSessionId)(uint32) ls.toNumber(1), ClientCfg.ConfigFile.getVar("Application").asString(0)); + sessionBrowser.joinSession(getCharId(), (TSessionId)(uint32) ls.toInteger(1), ClientCfg.ConfigFile.getVar("Application").asString(0)); if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_joinSessionResult"))) { diff --git a/code/ryzom/common/src/game_share/object.cpp b/code/ryzom/common/src/game_share/object.cpp index 5f5394abf..a89245ad1 100644 --- a/code/ryzom/common/src/game_share/object.cpp +++ b/code/ryzom/common/src/game_share/object.cpp @@ -168,6 +168,12 @@ void CObject::inPlaceCopy(const CObjectNumber &src) copyMismatchMsg(src); } +void CObject::inPlaceCopy(const CObjectInteger &src) +{ + //H_AUTO(R2_CObject_inPlaceCopy) + copyMismatchMsg(src); +} + void CObject::inPlaceCopy(const CObjectTable &src) { //H_AUTO(R2_CObject_inPlaceCopy) @@ -189,6 +195,18 @@ bool CObject::isNumber(const std::string & prop) const return doIsNumber(); } +bool CObject::isInteger(const std::string & prop) const +{ + //H_AUTO(R2_CObject_isInteger) + if (!prop.empty()) + { + CObject* attr = getAttr(prop); + if (!attr) return false; + return attr->doIsInteger(); + } + return doIsInteger(); +} + bool CObject::isString(const std::string & prop) const { //H_AUTO(R2_CObject_isString) @@ -239,6 +257,12 @@ bool CObject::doIsNumber() const return false; } +bool CObject::doIsInteger() const +{ + //H_AUTO(R2_CObject_doIsInteger) + return false; +} + bool CObject::doIsString() const { //H_AUTO(R2_CObject_doIsString) @@ -272,6 +296,20 @@ double CObject::toNumber(const std::string & prop) const return doToNumber(); } +sint64 CObject::toInteger(const std::string & prop) const +{ + //H_AUTO(R2_CObject_toInteger) + if (!prop.empty()) + { + CObject* attr = getAttr(prop); + if (!attr) + { + BOMB("Try to use the method toInteger() on a NULL Object", return 0); + } + return attr->doToInteger(); + } + return doToInteger(); +} std::string CObject::toString(const std::string & prop) const { @@ -328,6 +366,14 @@ double CObject::doToNumber() const } +sint64 CObject::doToInteger() const +{ + //H_AUTO(R2_CObject_doToInteger) + BOMB("Try to convert an objet to integer without being allowed", return 0); + return 0; + +} + std::string CObject::doToString() const { //H_AUTO(R2_CObject_doToString) @@ -366,11 +412,18 @@ bool CObject::set(const std::string& /* key */, const std::string & /* value */) return false; } -bool CObject::set(const std::string& /* key */, double /* value */){ +bool CObject::set(const std::string& /* key */, double /* value */) +{ BOMB("Try to set the value of an object with a double on an object that does not allowed it", return false); return false; } +bool CObject::set(const std::string& /* key */, sint64 /* value */) +{ + BOMB("Try to set the value of an object with an integer on an object that does not allowed it", return false); + return false; +} + bool CObject::setObject(const std::string& /* key */, CObject* /* value */) { BOMB("Try to set the value of an object with an object that does not allowed it", return false); @@ -602,7 +655,7 @@ bool CObjectString::set(const std::string& key, const std::string & value) bool CObjectString::setObject(const std::string& key, CObject* value) { //H_AUTO(R2_CObjectString_setObject) - BOMB_IF( !key.empty() || ! (value->isString() || value->isNumber()) , "Try to set the a sub value of an object that does not allowed it", return false); + BOMB_IF( !key.empty() || ! (value->isString() || value->isNumber() || value->isInteger()) , "Try to set the a sub value of an object that does not allowed it", return false); bool canSet = set(key, value->toString()); if (canSet) { @@ -732,7 +785,7 @@ void CObjectNumber::inPlaceCopy(const CObjectNumber &src) } -std::string CObjectNumber::doToString() const { return NLMISC::toString("%d", _Value);} +std::string CObjectNumber::doToString() const { return NLMISC::toString("%lf", _Value);} void CObjectNumber::doSerialize(std::string& out, CSerializeContext& /* context */) const { @@ -767,9 +820,6 @@ bool CObjectNumber::set(const std::string& key, const std::string & value) //H_AUTO(R2_CObjectNumber_set) //XXX BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false); -// std::stringstream ss ; -// ss << value; -// ss >> _Value; NLMISC::fromString(value, _Value); return true; } @@ -808,12 +858,108 @@ bool CObjectNumber::equal(const CObject* other) const double otherValue = other->toNumber(); if (_Value == otherValue ) return true; /* - fabs + epsilon trick + TODO: fabs + epsilon trick */ return false; } +//----------------------- CObjectInteger ---------------------------------------- + + +CObjectInteger::CObjectInteger(sint64 value) : CObject(), _Value(value){} + +const char *CObjectInteger::getTypeAsString() const +{ + return "Integer"; +} + +void CObjectInteger::visitInternal(IObjectVisitor &visitor) +{ + //H_AUTO(R2_CObjectInteger_visit) + visitor.visit(*this); +} + + +void CObjectInteger::inPlaceCopyTo(CObject &dest) const +{ + //H_AUTO(R2_CObjectInteger_inPlaceCopyTo) + dest.inPlaceCopy(*this); +} + +void CObjectInteger::inPlaceCopy(const CObjectInteger &src) +{ + //H_AUTO(R2_CObjectInteger_inPlaceCopy) + _Value = src._Value; + setGhost(src.getGhost()); +} + + +std::string CObjectInteger::doToString() const { return NLMISC::toString("%d"NL_I64, _Value); } + +void CObjectInteger::doSerialize(std::string& out, CSerializeContext& /* context */) const +{ + //H_AUTO(R2_CObjectInteger_doSerialize) + nlassert(!getGhost()); + out += NLMISC::toString(_Value); +} + +bool CObjectInteger::set(const std::string& key, sint64 value) +{ + //H_AUTO(R2_CObjectInteger_set) + + BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false); + + _Value = value; + return true; +} + + +bool CObjectInteger::set(const std::string& key, const std::string & value) +{ + //H_AUTO(R2_CObjectInteger_set) + //XXX + BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false); + NLMISC::fromString(value, _Value); + return true; +} + + +sint64 CObjectInteger::doToInteger() const { return _Value; } + +CObject* CObjectInteger::clone() const +{ + //H_AUTO(R2_CObjectInteger_clone) + CObjectInteger *result = new CObjectInteger(_Value); + result->setGhost(getGhost()); + return result; +} + +bool CObjectInteger::doIsInteger() const { return true;} + + + +bool CObjectInteger::setObject(const std::string& /* key */, CObject* value) +{ + //H_AUTO(R2_CObjectInteger_setObject) + BOMB_IF(!value->isInteger(), NLMISC::toString("Try to set an element of a type '%s' with a value of type '%s' on an object that is not an integer", this->getTypeAsString(), value->getTypeAsString()), return false); + + _Value = value->toInteger(); + setGhost(value->getGhost()); + return true; +} + + + +bool CObjectInteger::equal(const CObject* other) const +{ + //H_AUTO(R2_CObjectInteger_equal) + if (!other || !other->isInteger()) return false; + sint64 otherValue = other->toInteger(); + return _Value == otherValue; +} + + //----------------------- CObjectTable ---------------------------------------- @@ -1756,7 +1902,7 @@ CObject* CObjectGenerator::instanciate(CObjectFactory* factory) const { CObject*defaultInBase = found->getAttr("DefaultInBase"); - if (!defaultInBase || (defaultInBase->isNumber() && defaultInBase->toNumber() != 1)) + if (!defaultInBase || (defaultInBase->isInteger() && defaultInBase->toInteger() != 1)) { std::string type = found->toString("Type"); @@ -1824,7 +1970,15 @@ void CObjectNumber::dump(const std::string prefix, uint depth) const { //H_AUTO(R2_CObjectNumber_dump) std::string result(depth * 4, ' '); - result += NLMISC::toString("%sNumber, ptr = 0x%p, value = %f, ghost = %s", prefix.c_str(), this, _Value, _Ghost ? "true" : "false"); + result += NLMISC::toString("%sNumber, ptr = 0x%p, value = %lf, ghost = %s", prefix.c_str(), this, _Value, _Ghost ? "true" : "false"); + nlwarning(result.c_str()); +} + +void CObjectInteger::dump(const std::string prefix, uint depth) const +{ + //H_AUTO(R2_CObjectInteger_dump) + std::string result(depth * 4, ' '); + result += NLMISC::toString("%sInteger, ptr = 0x%p, value = %d"NL_I64", ghost = %s", prefix.c_str(), this, _Value, _Ghost ? "true" : "false"); nlwarning(result.c_str()); } @@ -1929,96 +2083,169 @@ std::string CObject::uint32ToInstanceId(uint32 id) static void writeNumber( NLMISC::IStream& stream, double theValue) { - double value = theValue; - double absValue = fabs(value); - uint8 type; + double value = theValue; + double absValue = fabs(value); + uint8 type; - // It's 0 - if (absValue <= std::numeric_limits::epsilon()) - { - type = ObjectNumberZero; - stream.serial(type); - return; - } + // It's 0 + if (absValue <= std::numeric_limits::epsilon()) + { + type = ObjectNumberZero; + stream.serial(type); + return; + } - double integral; + double integral; - double fractional = modf(absValue, &integral); + double fractional = modf(absValue, &integral); - // It is an integral type (no fractional part) - if ( fractional <= std::numeric_limits::epsilon() ) + // It is an integral type (no fractional part) + if ( fractional <= std::numeric_limits::epsilon() ) + { + bool pos = 0.0 <= value; + // positif + if (pos) { - bool pos = 0.0 <= value; - // positif - if (pos) + if (integral <= uint8Max) { - if (integral <= uint8Max) - { - uint8 uint8value = static_cast(value); - type = ObjectNumberUInt8; - stream.serial(type); - stream.serial( uint8value); - return; - } + uint8 uint8value = static_cast(value); + type = ObjectNumberUInt8; + stream.serial(type); + stream.serial( uint8value); + return; + } - if (integral <= uint16Max) - { - uint16 uint16value = static_cast(value); - type = ObjectNumberUInt16; - stream.serial(type); - stream.serial(uint16value); - return; - } + if (integral <= uint16Max) + { + uint16 uint16value = static_cast(value); + type = ObjectNumberUInt16; + stream.serial(type); + stream.serial(uint16value); + return; + } - if (integral <= uint32Max) - { - uint32 uint32value = static_cast(value); - type = ObjectNumberUInt32; - stream.serial(type); - stream.serial(uint32value); - return; - } + if (integral <= uint32Max) + { + uint32 uint32value = static_cast(value); + type = ObjectNumberUInt32; + stream.serial(type); + stream.serial(uint32value); + return; } - //negatif - else + } + //negatif + else + { + if ( sint8Min <= integral && integral <= sint8Max) { - if ( sint8Min <= integral && integral <= sint8Max) - { - sint8 sint8value = static_cast(value); - type = ObjectNumberSInt8; - stream.serial(type); - stream.serial( sint8value); - return; - } - - if ( sint16Min <= integral && integral <= sint16Max) - { - sint16 sint16value = static_cast(value); - type = ObjectNumberSInt16; - stream.serial(type); - stream.serial( sint16value); - return; - } + sint8 sint8value = static_cast(value); + type = ObjectNumberSInt8; + stream.serial(type); + stream.serial( sint8value); + return; + } - if ( sint32Min <= integral && integral <= sint32Max) - { - sint32 sint32value = static_cast(value); - type = ObjectNumberSInt32; - stream.serial(type); - stream.serial( sint32value); - return; - } + if ( sint16Min <= integral && integral <= sint16Max) + { + sint16 sint16value = static_cast(value); + type = ObjectNumberSInt16; + stream.serial(type); + stream.serial( sint16value); + return; + } + if ( sint32Min <= integral && integral <= sint32Max) + { + sint32 sint32value = static_cast(value); + type = ObjectNumberSInt32; + stream.serial(type); + stream.serial( sint32value); + return; } } - //Default case - // Float are evil: you loose too much precision - type = ObjectNumberDouble; - double fValue = value; + } + + //Default case + // Float are evil: you loose too much precision + type = ObjectNumberDouble; + double fValue = value; + stream.serial(type); + stream.serial(fValue); +} + +static void writeInteger( NLMISC::IStream& stream, sint64 theValue) +{ + sint64 value = theValue; + uint8 type; + + // It's 0 + if (value == 0) + { + type = ObjectNumberZero; stream.serial(type); - stream.serial(fValue); + return; + } + + bool pos = value >= 0; + // positif + if (pos) + { + if (value <= uint8Max) + { + uint8 uint8value = static_cast(value); + type = ObjectNumberUInt8; + stream.serial(type); + stream.serial( uint8value); + return; + } + + if (value <= uint16Max) + { + uint16 uint16value = static_cast(value); + type = ObjectNumberUInt16; + stream.serial(type); + stream.serial(uint16value); + return; + } + + if (value <= uint32Max) + { + uint32 uint32value = static_cast(value); + type = ObjectNumberUInt32; + stream.serial(type); + stream.serial(uint32value); + return; + } + } + //negatif + else + { + if ( sint8Min <= value && value <= sint8Max) + { + sint8 sint8value = static_cast(value); + type = ObjectNumberSInt8; + stream.serial(type); + stream.serial( sint8value); + return; + } + + if ( sint16Min <= value && value <= sint16Max) + { + sint16 sint16value = static_cast(value); + type = ObjectNumberSInt16; + stream.serial(type); + stream.serial( sint16value); + return; + } + } + + // Default case + type = ObjectNumberSInt32; + sint32 fValue = (sint32)value; + stream.serial(type); + stream.serial(fValue); } static void serialStringInstanceId( NLMISC::IStream& stream, CObject*& data) @@ -2940,6 +3167,13 @@ void CObjectSerializerImpl::serialImpl(NLMISC::IStream& stream, CObject*& data, uint endLength = stream.getPos(); if (serializer->Log) { nldebug("R2NET: (%u) Null sent %u bytes", serializer->Level, endLength - initLength);} } + else if (data->isInteger()) + { + uint initLength = stream.getPos(); + writeInteger(stream, data->toInteger()); + uint endLength = stream.getPos(); + if (serializer->Log) { nldebug("R2NET: (%u) Integer sent %u bytes", serializer->Level, endLength - initLength); } + } else if (data->isNumber()) { uint initLength = stream.getPos(); diff --git a/code/ryzom/common/src/game_share/object.h b/code/ryzom/common/src/game_share/object.h index 41edf9087..71a30f32d 100644 --- a/code/ryzom/common/src/game_share/object.h +++ b/code/ryzom/common/src/game_share/object.h @@ -38,6 +38,7 @@ class CObjectTable; class CObjectString; class CObjectRefId; class CObjectNumber; +class CObjectInteger; class CSerializeContext; @@ -49,6 +50,7 @@ struct IObjectVisitor virtual void visit(CObjectRefId &/* obj */) {} virtual void visit(CObjectString &/* obj */) {} virtual void visit(CObjectNumber &/* obj */) {} + virtual void visit(CObjectInteger &/* obj */) {} virtual void visit(CObjectTable &/* obj */) {} }; @@ -82,6 +84,8 @@ public: // test type bool isNumber(const std::string & prop="") const; + bool isInteger(const std::string & prop="") const; + bool isString(const std::string & prop="") const; bool isTable(const std::string & prop="") const; @@ -93,6 +97,8 @@ public: // to Value double toNumber(const std::string & prop="") const; + sint64 toInteger(const std::string & prop="") const; + std::string toString(const std::string & prop="") const; CObjectTable* toTable(const std::string & prop="") const; @@ -127,12 +133,16 @@ public: void add(const std::string& key, double value); + void add(const std::string& key, sint64 value); + // set Value virtual bool set(const std::string& key, const std::string & value); virtual bool set(const std::string& key, double value); + virtual bool set(const std::string& key, sint64 value); + virtual bool setObject(const std::string& key, CObject* value); CObject* getParent() const; @@ -172,6 +182,8 @@ protected: virtual bool doIsNumber() const; + virtual bool doIsInteger() const; + virtual bool doIsString() const; virtual bool doIsTable() const; @@ -180,6 +192,8 @@ protected: virtual double doToNumber() const; + virtual sint64 doToInteger() const; + virtual std::string doToString() const; virtual CObjectTable* doToTable() const; @@ -192,6 +206,7 @@ public: virtual void inPlaceCopyTo(CObject &dest) const = 0; virtual void inPlaceCopy(const CObjectString &src); virtual void inPlaceCopy(const CObjectNumber &src); + virtual void inPlaceCopy(const CObjectInteger &src); virtual void inPlaceCopy(const CObjectTable &src); protected: void copyMismatchMsg(const CObject &src); @@ -307,6 +322,45 @@ private: }; +class CObjectInteger : public CObject +{ + +public: + explicit CObjectInteger(sint64 value); + + virtual const char *getTypeAsString() const; + + virtual bool set(const std::string& key, sint64 value); + virtual bool set(const std::string& key, const std::string &value); + + virtual bool setObject(const std::string& key, CObject* value); + + virtual CObject* clone() const; + + sint64 getValue() const { return _Value; } + + virtual void dump(const std::string prefix = "", uint depth = 0) const; + + virtual bool equal(const CObject* other) const; + +protected: + virtual void doSerialize(std::string& out, CSerializeContext& context) const; + + virtual bool doIsInteger() const; + + virtual sint64 doToInteger() const; + + virtual std::string doToString() const; + + virtual void inPlaceCopyTo(CObject &dest) const; + virtual void inPlaceCopy(const CObjectInteger &src); + + virtual void visitInternal(IObjectVisitor &visitor); + +private: + sint64 _Value; +}; + class CObjectTable: public CObject { diff --git a/code/ryzom/common/src/game_share/server_animation_module.cpp b/code/ryzom/common/src/game_share/server_animation_module.cpp index 3d3548d54..794d88212 100644 --- a/code/ryzom/common/src/game_share/server_animation_module.cpp +++ b/code/ryzom/common/src/game_share/server_animation_module.cpp @@ -609,9 +609,9 @@ public: void setAttributeAsBool(const std::string & attrName, const std::string& propName) { CObject* attr = _Object->getAttr(attrName); - if (attr && attr->isNumber()) + if (attr && attr->isInteger()) { - sint value = static_cast(attr->toNumber()); + sint value = static_cast(attr->toInteger()); _Primitive->addPropertyByName(propName.c_str(), new CPropertyString(value?"true":"false")); } } @@ -1093,7 +1093,7 @@ IPrimitive* CServerAnimationModule::getAction(CObject* action, const std::string CObject* weight = action->getAttr("Weight"); if(weight) { - uint32 w = (int)weight->toNumber(); + uint32 w = (int)weight->toInteger(); std::string weightStr = toString(w); pAction->addPropertyByName("Weight", new CPropertyString(weightStr)); } @@ -1381,7 +1381,7 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C animSession->Acts[actId] = rtAct; - if ( act->isNumber("LocationId") + if ( act->isInteger("LocationId") && act->isString("Name") && act->isString("ActDescription") && act->isString("PreActDescription") @@ -1390,7 +1390,7 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C rtAct->Name = act->toString("Name"); rtAct->ActDescription = act->toString("ActDescription"); rtAct->PreActDescription = act->toString("PreActDescription"); - rtAct->LocationId = static_cast(act->toNumber("LocationId")); + rtAct->LocationId = static_cast(act->toInteger("LocationId")); } else { @@ -1508,9 +1508,9 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C a2pAiState.setAttributeAsStringArray("Keywords", "keywords"); bool isTriggerZone = false; - if ( aiState->isNumber("IsTriggerZone") ) + if ( aiState->isInteger("IsTriggerZone") ) { - isTriggerZone = static_cast(aiState->toNumber("IsTriggerZone")) == 1; + isTriggerZone = aiState->toInteger("IsTriggerZone") == 1; } if (isTriggerZone) { @@ -1550,7 +1550,7 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C npc_group->addPropertyByName("name", new CPropertyString(prefix+component->toString("Id"))); npc_group->addPropertyByName("ai_type", new CPropertyString("GROUP_NPC")); // AJM - if (component->isNumber("AutoSpawn") && component->toNumber("AutoSpawn")==0) + if (component->isInteger("AutoSpawn") && component->toInteger("AutoSpawn")==0) { npc_group->addPropertyByName("autoSpawn", new CPropertyString("false")); } @@ -1740,9 +1740,9 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C npc_bot->insertChild(npc_bot_alias); // nlinfo("R2Anim: Bot %u %s", npc_bot_alias->getFullAlias(), std::string(prefix+objectNpc->toString("Id")).c_str()); uint32 dmProperty = 0; - if (objectNpc->isNumber("DmProperty")) + if (objectNpc->isInteger("DmProperty")) { - dmProperty = static_cast< uint32 > (objectNpc->toNumber("DmProperty")); + dmProperty = static_cast< uint32 > (objectNpc->toInteger("DmProperty")); } CRtNpc* rtNpc = new CRtNpc(npc_bot_alias->getFullAlias(), objectNpc, npc_group_alias->getFullAlias(), dmProperty); @@ -1770,9 +1770,9 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C CObject* eventObject = events->getValue(firstEvent); bool isTriggerZone = false; - if ( eventObject->isNumber("IsTriggerZone") ) + if ( eventObject->isInteger("IsTriggerZone") ) { - isTriggerZone = static_cast(eventObject->toNumber("IsTriggerZone")) == 1; + isTriggerZone = static_cast(eventObject->toInteger("IsTriggerZone")) == 1; } if (isTriggerZone) { @@ -1788,7 +1788,7 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C CObject *weatherValue = act->getAttr("WeatherValue"); if (weatherValue) { - animSession->Acts[actId]->WeatherValue = (uint16) weatherValue->toNumber(); + animSession->Acts[actId]->WeatherValue = (uint16) weatherValue->toInteger(); } @@ -1901,7 +1901,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi CObject* plotItem = plotItems->getValue(firstPlotItem); if (!plotItem || !plotItem->isTable() - || !plotItem->isNumber("SheetId") + || !plotItem->isInteger("SheetId") || !plotItem->isString("Name") || !plotItem->isString("Description") || !plotItem->isString("Comment") @@ -1911,7 +1911,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi return false; } - uint32 sheetIdAsInt = static_cast(plotItem->toNumber("SheetId")); + uint32 sheetIdAsInt = static_cast(plotItem->toInteger("SheetId")); CSheetId plotItemSheetId( sheetIdAsInt ); @@ -1958,7 +1958,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi CObject* location = locations->getValue(firstLocation); if (!location || !location->isTable() - || !location->isNumber("Season") + || !location->isInteger("Season") || !location->isString("Island") || !location->isString("EntryPoint") @@ -1969,7 +1969,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi } CRtLocation locationItem; - locationItem.Season = static_cast(location->toNumber("Season")); + locationItem.Season = static_cast(location->toInteger("Season")); locationItem.Island = location->toString("Island"); locationItem.EntryPoint = location->toString("EntryPoint"); animSession->Locations.push_back(locationItem); diff --git a/code/ryzom/common/src/game_share/small_string_manager.cpp b/code/ryzom/common/src/game_share/small_string_manager.cpp index 5d07ecb63..e57d7d17b 100644 --- a/code/ryzom/common/src/game_share/small_string_manager.cpp +++ b/code/ryzom/common/src/game_share/small_string_manager.cpp @@ -113,7 +113,7 @@ CSmallStringManager::CSmallStringManager(CObject* textManager) return; } CObject* texts = textManager->getAttr("Texts"); - uint32 maxId = static_cast(textManager->getAttr("MaxId")->toNumber()); + uint32 maxId = static_cast(textManager->getAttr("MaxId")->toInteger()); CObject* unused = textManager->getAttr("UnusedIds"); uint32 max = unused->getSize(); @@ -123,7 +123,7 @@ CSmallStringManager::CSmallStringManager(CObject* textManager) //unused ids for(uint32 i=0;i(unused->getValue(i)->toNumber()); + uint32 id = static_cast(unused->getValue(i)->toInteger()); _FreeIds.insert(id); } @@ -133,8 +133,8 @@ CSmallStringManager::CSmallStringManager(CObject* textManager) { CObject* entry = texts->getValue(i); std::string text = entry->getAttr("Text")->toString(); - uint32 textId = static_cast(entry->getAttr("TextId")->toNumber()); - uint32 textCount = static_cast(entry->getAttr("Count")->toNumber()); + uint32 textId = static_cast(entry->getAttr("TextId")->toInteger()); + uint32 textCount = static_cast(entry->getAttr("Count")->toInteger()); _StringToId.insert(std::pair(text, textId)); _IdToString.insert( std::pair >(textId, std::pair(text, textCount) ) ); } From aa3d209d39f8fa523ee8ee99bbb0c0d69ecebaa3 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 13 Nov 2015 19:18:41 +0100 Subject: [PATCH 3/6] Fixed: Crash in CLuaManager --HG-- branch : develop --- code/nel/include/nel/gui/lua_manager.h | 6 +++++- code/nel/src/gui/lua_manager.cpp | 19 ++++++++++++++++--- code/ryzom/client/src/release.cpp | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/code/nel/include/nel/gui/lua_manager.h b/code/nel/include/nel/gui/lua_manager.h index 00aecbe84..01c123f55 100644 --- a/code/nel/include/nel/gui/lua_manager.h +++ b/code/nel/include/nel/gui/lua_manager.h @@ -31,8 +31,8 @@ namespace NLGUI class CLuaManager { public: - ~CLuaManager(); + /// Get or create singleton static CLuaManager& getInstance() { if( instance == NULL ) @@ -42,6 +42,9 @@ namespace NLGUI return *instance; } + /// Release singleton + static void releaseInstance(); + /// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup. static void enableLuaDebugging(){ debugLua = true; } @@ -65,6 +68,7 @@ namespace NLGUI private: CLuaManager(); + ~CLuaManager(); static CLuaManager *instance; static bool debugLua; diff --git a/code/nel/src/gui/lua_manager.cpp b/code/nel/src/gui/lua_manager.cpp index 95e6767f1..2b354b0e4 100644 --- a/code/nel/src/gui/lua_manager.cpp +++ b/code/nel/src/gui/lua_manager.cpp @@ -33,8 +33,20 @@ namespace NLGUI CLuaManager::~CLuaManager() { - delete luaState; - luaState = NULL; + if (luaState) + { + delete luaState; + luaState = NULL; + } + } + + void CLuaManager::releaseInstance() + { + if (instance) + { + delete instance; + instance = NULL; + } } bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript ) @@ -60,7 +72,8 @@ namespace NLGUI void CLuaManager::ResetLuaState() { - delete luaState; + if (luaState) delete luaState; + luaState = new CLuaState( debugLua ); } diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index f88849197..e2a96c397 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -659,7 +659,7 @@ void release() CInterfaceExpr::release(); CPdrTokenRegistry::releaseInstance(); NLNET::IModuleManager::releaseInstance(); - delete &CLuaManager::getInstance(); + CLuaManager::releaseInstance(); NLGUI::CDBManager::release(); CWidgetManager::release(); From c854201d911c9265052aabfe35aaeaac22af608e Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 13 Nov 2015 19:36:46 +0100 Subject: [PATCH 4/6] Changed: Removed useless LoadLuaDebugger --HG-- branch : develop --- code/ryzom/client/src/client_cfg.cpp | 2 -- code/ryzom/client/src/client_cfg.h | 1 - 2 files changed, 3 deletions(-) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 20bf5362d..0d64f3227 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -680,7 +680,6 @@ CClientConfig::CClientConfig() DamageShieldEnabled = false; AllowDebugLua = false; - LoadLuaDebugger = false; DisplayLuaDebugInfo = false; BeepWhenLaunched = false; @@ -1764,7 +1763,6 @@ void CClientConfig::setValues() READ_BOOL_DEV(DamageShieldEnabled) READ_BOOL_DEV(AllowDebugLua) - READ_BOOL_DEV(LoadLuaDebugger) READ_BOOL_DEV(DisplayLuaDebugInfo) READ_BOOL_DEV(LuaDebugInfoGotoButtonEnabled) diff --git a/code/ryzom/client/src/client_cfg.h b/code/ryzom/client/src/client_cfg.h index 41b716d2d..8f96b4244 100644 --- a/code/ryzom/client/src/client_cfg.h +++ b/code/ryzom/client/src/client_cfg.h @@ -766,7 +766,6 @@ struct CClientConfig /// Allow Lua commands (commands beginning with Lua) bool AllowDebugLua; - bool LoadLuaDebugger; bool LuaDebugInfoGotoButtonEnabled; std::string LuaDebugInfoGotoButtonTemplate; From 630a22d42833928b1807e232ba83aa3f0637a6eb Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 13 Nov 2015 19:37:32 +0100 Subject: [PATCH 5/6] Changed: Minor changes --HG-- branch : develop --- code/nel/src/gui/ctrl_col_pick.cpp | 8 ++--- .../gamedev/interfaces_v3/game_config.lua | 34 +++++++++---------- .../src/interface_v3/sbrick_manager.cpp | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/code/nel/src/gui/ctrl_col_pick.cpp b/code/nel/src/gui/ctrl_col_pick.cpp index 610f545c6..2d62b6e74 100644 --- a/code/nel/src/gui/ctrl_col_pick.cpp +++ b/code/nel/src/gui/ctrl_col_pick.cpp @@ -169,25 +169,25 @@ namespace NLGUI if( _ColSelR.getNodePtr() != NULL ) s = _ColSelR.getNodePtr()->getFullName(); else - s = ""; + s.clear(); xmlSetProp( node, BAD_CAST "dbcolr", BAD_CAST s.c_str() ); if( _ColSelG.getNodePtr() != NULL ) s = _ColSelG.getNodePtr()->getFullName(); else - s = ""; + s.clear(); xmlSetProp( node, BAD_CAST "dbcolg", BAD_CAST s.c_str() ); if( _ColSelB.getNodePtr() != NULL ) s = _ColSelB.getNodePtr()->getFullName(); else - s = ""; + s.clear(); xmlSetProp( node, BAD_CAST "dbcolb", BAD_CAST s.c_str() ); if( _ColSelA.getNodePtr() != NULL ) s = _ColSelA.getNodePtr()->getFullName(); else - s = ""; + s.clear(); xmlSetProp( node, BAD_CAST "dbcola", BAD_CAST s.c_str() ); return node; diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.lua b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.lua index b5ed493d7..5354e1cc7 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.lua @@ -19,7 +19,7 @@ end ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------ --- WIDGET TO CHOOSE A COLOR +-- WIDGET TO CHOOSE A COLOR ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------ @@ -29,14 +29,14 @@ function game:mcwChooseColor(title, pal) local ui = getUICaller(); - -- get the color of the button and store it in temporary db location + -- get the color of the button and store it in temporary db location local rgba = ui.col_normal_rgba; game.ColorPicker.r = rgba.R; game.ColorPicker.g = rgba.G; game.ColorPicker.b = rgba.B; game.ColorPicker.button = ui; game.ColorPicker.pal = pal; - + -- setup the color picker window local uiModalWin = getUI('ui:interface:define_mcw_color'); if (game.ColorPicker.pal == 0) then @@ -64,8 +64,8 @@ end -- called when we have finished choosing the color in the modal window and the chosen color is valid function game:mcwValidateColor() - if (game.ColorPicker.button == nil) then - return; + if (game.ColorPicker.button == nil) then + return; end game.ColorPicker.button.col_normal = game.ColorPicker.r .. ' ' .. game.ColorPicker.g .. ' ' .. game.ColorPicker.b; --debugInfo(game.ColorPicker.button.col_normal) @@ -108,10 +108,10 @@ end -- hide all the pages of the config window function game:configHideAll() - local uiList = { + local uiList = { 'explanation', 'general', 'landscape', 'fx', 'char', 'hud', 'language', 'alpha_colors', - 'chat_colors', 'entity_colors', 'in_scene_user', 'in_scene_friend', 'in_scene_enemy', - 'in_scene_chat_messages', 'win_colors', 'win_colors_r2', 'mouse', 'keyb', 'vr', 'sound', 'landmark_colors', 'help' + 'chat_colors', 'entity_colors', 'in_scene_user', 'in_scene_friend', 'in_scene_enemy', + 'in_scene_chat_messages', 'win_colors', 'win_colors_r2', 'mouse', 'keyb', 'vr', 'sound', 'landmark_colors', 'help' }; for k,v in pairs(uiList) do @@ -127,19 +127,19 @@ function game:configShowOne(strUIToShow) game:configHideAll(); -- special case : if the display tab was shown, update the aspect ratio if needed local generalGrp = getUI('ui:interface:game_config:content:general'); - local uiGrp = getUI('ui:interface:game_config:content:' .. strUIToShow); + local uiGrp = getUI('ui:interface:game_config:content:' .. strUIToShow); -- Removed the following code to solve RT n°14720 - -- The 'game_config_change_screen_ratio_custom' action handler - -- should only be called if the user changed the apect ratio himself + -- The 'game_config_change_screen_ratio_custom' action handler + -- should only be called if the user changed the apect ratio himself -- (else the edit box containing the aspect ratio may not have been initiliazed here) - --if uiGrp ~= generalGrp then + --if uiGrp ~= generalGrp then -- runAH(nil, 'game_config_change_screen_ratio_custom', '') --end uiGrp.active = true; end ------------------------------------------------------------------------------------------------------------ --- +-- function game:configInit() -- init language @@ -187,9 +187,9 @@ function game:configInit() winActive("wc_r2_dialogs", r2WinOn) winActive("wc_r2_events", r2WinOn) winActive("wc_r2_activities", r2WinOn) - winActive("wc_r2_feature_help", r2WinOn) - winActive("wc_r2_connect", not r2WinOn) - winActive("wc_r2_session_browser", not r2WinOn) - winActive("wc_r2_scenario_control", true) + winActive("wc_r2_feature_help", r2WinOn) + winActive("wc_r2_connect", not r2WinOn) + winActive("wc_r2_session_browser", not r2WinOn) + winActive("wc_r2_scenario_control", true) winActive("wc_r2_player_tracking", r2WinOn) end diff --git a/code/ryzom/client/src/interface_v3/sbrick_manager.cpp b/code/ryzom/client/src/interface_v3/sbrick_manager.cpp index 691f85e7d..86946e2e1 100644 --- a/code/ryzom/client/src/interface_v3/sbrick_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sbrick_manager.cpp @@ -500,7 +500,7 @@ void CSBrickManager::compileBrickProperties() k++; } // get the key and replace text with value - if(key.size()) + if (!key.empty()) { // Parse all the brick properties if match the key float value= 0.f; From 08d50dc725ab630fccdb8f0a1e01bce512a31c42 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 13 Nov 2015 19:38:46 +0100 Subject: [PATCH 6/6] Changed: Don't try to convert string to CRGBA if less than 3 integers --HG-- branch : develop --- code/nel/src/misc/rgba.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/code/nel/src/misc/rgba.cpp b/code/nel/src/misc/rgba.cpp index 944ca50d3..822ee1006 100644 --- a/code/nel/src/misc/rgba.cpp +++ b/code/nel/src/misc/rgba.cpp @@ -734,17 +734,23 @@ void CRGBA::buildFromHLS(float h, float l, float s) CRGBA CRGBA::stringToRGBA( const char *ptr ) { - if (!ptr) - return NLMISC::CRGBA::White; - - int r = 255, g = 255, b = 255, a = 255; - sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a ); - clamp( r, 0, 255 ); - clamp( g, 0, 255 ); - clamp( b, 0, 255 ); - clamp( a, 0, 255 ); + if (ptr) + { + int r = 255, g = 255, b = 255, a = 255; + + // we need at least 3 integer values to consider string is valid + if (sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a ) >= 3) + { + clamp( r, 0, 255 ); + clamp( g, 0, 255 ); + clamp( b, 0, 255 ); + clamp( a, 0, 255 ); - return CRGBA( r,g,b,a ); + return CRGBA( r,g,b,a ); + } + } + + return NLMISC::CRGBA::White; } std::string CRGBA::toString() const