From e29fa9a719ae0031c621c2a9a480be4fdccc6918 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 19 Dec 2016 15:21:59 +0100 Subject: [PATCH 1/7] Changed: Display line numbers instead of a pointer --HG-- branch : develop --- code/nel/src/georges/form.cpp | 8 ++++---- code/nel/src/georges/form_dfn.cpp | 34 +++++++++++++++---------------- code/nel/src/georges/header.cpp | 8 ++++---- code/nel/src/georges/type.cpp | 20 +++++++++--------- code/nel/src/ligo/ligo_config.cpp | 2 +- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/code/nel/src/georges/form.cpp b/code/nel/src/georges/form.cpp index 07f4c2adf..22ed15a2e 100644 --- a/code/nel/src/georges/form.cpp +++ b/code/nel/src/georges/form.cpp @@ -188,8 +188,8 @@ void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const std if ( ((const char*)node->name == NULL) || (strcmp ((const char*)node->name, "FORM") != 0) ) { // Make an error message - warning (true, "read", "XML Syntax error in block line %p, node (%s) should be FORM.", - node->content, node->name); + warning (true, "read", "XML Syntax error in block line %d, node (%s) should be FORM.", + (sint)node->line, node->name); } // Get first struct node @@ -197,8 +197,8 @@ void CForm::read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const std if (child == NULL) { // Throw exception - warning (true, "read", "Syntax error in block line %p, node (%s) should have a STRUCT child node.", - node->content, node->name); + warning (true, "read", "Syntax error in block line %d, node (%s) should have a STRUCT child node.", + (sint)node->line, node->name); } // Read the struct diff --git a/code/nel/src/georges/form_dfn.cpp b/code/nel/src/georges/form_dfn.cpp index 86733470c..3f271b976 100644 --- a/code/nel/src/georges/form_dfn.cpp +++ b/code/nel/src/georges/form_dfn.cpp @@ -130,7 +130,7 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ( ((const char*)root->name == NULL) || (strcmp ((const char*)root->name, "DFN") != 0) ) { // Throw exception - warning (true, "read", "XML Syntax error in block line %p, node (%s) should be DFN.", root->content, root->name); + warning (true, "read", "XML Syntax error in block line %d, node (%s) should be DFN.", (sint)root->line, root->name); } // Count the parent @@ -162,8 +162,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, aguments Name not found.", - parent->name, parent->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, aguments Name not found.", + parent->name, (sint)parent->line); } // Next parent @@ -245,8 +245,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ((Entries[childNumber].Type == NULL) && !forceLoad) { // Throw exception - warning (true, "read", "In XML block (%s) line %p, file not found %s.", - child->name, child->content, Entries[childNumber].Filename.c_str ()); + warning (true, "read", "In XML block (%s) line %d, file not found %s.", + child->name, (sint)child->line, Entries[childNumber].Filename.c_str ()); } // Read the default value @@ -262,8 +262,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML In block (%s) line %p, no filename found for the .typ file.", - child->name, child->content); + warning (true, "read", "XML In block (%s) line %d, no filename found for the .typ file.", + child->name, (sint)child->line); } } else if (stricmp (typeName, "Dfn") == 0) @@ -279,15 +279,15 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const if ((Entries[childNumber].Dfn == NULL) && !forceLoad) { // Throw exception - warning (true, "read", "XML In block (%s) line %p, file not found %s.", - child->name, child->content, Entries[childNumber].Filename.c_str ()); + warning (true, "read", "XML In block (%s) line %d, file not found %s.", + child->name, (sint)child->line, Entries[childNumber].Filename.c_str ()); } } else { // Throw exception - warning (true, "read", "XML In block (%s) line %p, no filename found for the .typ file.", - child->name, child->content); + warning (true, "read", "XML In block (%s) line %d, no filename found for the .typ file.", + child->name, (sint)child->line); } } else if (stricmp (typeName, "DfnPointer") == 0) @@ -297,8 +297,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, element has not a valid type name attribut \"Type = %s\".", - child->name, child->content, typeName); + warning (true, "read", "XML Syntax error in block (%s) line %d, element has not a valid type name attribut \"Type = %s\".", + child->name, (sint)child->line, typeName); } // Delete the value @@ -307,8 +307,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, element has no type name attribut \"Type = [Type][Dfn][DfnPointer]\".", - child->name, child->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, element has no type name attribut \"Type = [Type][Dfn][DfnPointer]\".", + child->name, (sint)child->line); } // Get the array attrib @@ -325,8 +325,8 @@ void CFormDfn::read (xmlNodePtr root, CFormLoader &loader, bool forceLoad, const else { // Throw exception - warning (true, "read", "XML Syntax error in block (%s) line %p, aguments Name not found.", - root->name, root->content); + warning (true, "read", "XML Syntax error in block (%s) line %d, aguments Name not found.", + root->name, (sint)root->line); } // Next child diff --git a/code/nel/src/georges/header.cpp b/code/nel/src/georges/header.cpp index fcafd10e4..f814d5802 100644 --- a/code/nel/src/georges/header.cpp +++ b/code/nel/src/georges/header.cpp @@ -112,8 +112,8 @@ void CFileHeader::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning (true, "read", "XML Syntax error in TYPE block line %p, the Version argument is invalid.", - root->content); + warning (true, "read", "XML Syntax error in TYPE block line %d, the Version argument is invalid.", + (sint)root->line); } // Delete the value @@ -145,8 +145,8 @@ void CFileHeader::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning (true, "read", "XML Syntax error in TYPE block line %p, the State argument is invalid.", - root->content); + warning (true, "read", "XML Syntax error in TYPE block line %d, the State argument is invalid.", + (sint)root->line); } // Delete the value diff --git a/code/nel/src/georges/type.cpp b/code/nel/src/georges/type.cpp index 951acc3e0..cc3c44d6e 100644 --- a/code/nel/src/georges/type.cpp +++ b/code/nel/src/georges/type.cpp @@ -109,8 +109,8 @@ void CType::read (xmlNodePtr root) if ( ((const char*)root->name == NULL) || (strcmp ((const char*)root->name, "TYPE") != 0) ) { // Throw exception - warning2 (true, "read", "XML Syntax error in block line %p, node (%s) should be TYPE.", - root->content, root->name); + warning2 (true, "read", "XML Syntax error in block line %d, node (%s) should be TYPE.", + (sint)root->line, root->name); } // Read the type @@ -137,8 +137,8 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)value); // Throw exception - warning2 (true, "read", "XML Syntax error in TYPE block line %p, the Type value is unknown (%s).", - root->content, valueStr.c_str ()); + warning2 (true, "read", "XML Syntax error in TYPE block line %d, the Type value is unknown (%s).", + (sint)root->line, valueStr.c_str ()); } // Delete the value @@ -147,8 +147,8 @@ void CType::read (xmlNodePtr root) else { // Throw exception - warning2 (true, "read", "XML Syntax error in TYPE block line %p, the Type argument was not found.", - root->content); + warning2 (true, "read", "XML Syntax error in TYPE block line %d, the Type argument was not found.", + (sint)root->line); } // Read the UI @@ -255,8 +255,8 @@ void CType::read (xmlNodePtr root) xmlFree ((void*)label); // Throw exception - warning2 (true, "read", "XML Syntax error in DEFINITION block line %p, the Value argument was not found.", - childPtr->content); + warning2 (true, "read", "XML Syntax error in DEFINITION block line %d, the Value argument was not found.", + (sint)childPtr->line); } // Delete the value @@ -265,8 +265,8 @@ void CType::read (xmlNodePtr root) else { // Throw exception - warning2 (true, "read", "XML Syntax error in DEFINITION block line %p, the Label argument was not found.", - childPtr->content); + warning2 (true, "read", "XML Syntax error in DEFINITION block line %d, the Label argument was not found.", + (sint)childPtr->line); } // One more diff --git a/code/nel/src/ligo/ligo_config.cpp b/code/nel/src/ligo/ligo_config.cpp index 0025d4290..d898e44ed 100644 --- a/code/nel/src/ligo/ligo_config.cpp +++ b/code/nel/src/ligo/ligo_config.cpp @@ -530,7 +530,7 @@ void CLigoConfig::syntaxError (const std::string &filename, xmlNodePtr xmlNode, vsnprintf( buffer, 1024, format, args ); va_end( args ); - errorMessage ("(%s), node (%s), line (%p) :\n%s", filename.c_str(), xmlNode->name, xmlNode->content, buffer); + errorMessage ("(%s), node (%s), line (%d) :\n%s", filename.c_str(), xmlNode->name, (sint)xmlNode->line, buffer); } // *************************************************************************** From 8db7d75e7eed64155132b3a2863c338fe30c5144 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 19 Dec 2016 15:43:38 +0100 Subject: [PATCH 2/7] Fixed: Uninitialized variables --HG-- branch : develop --- code/nel/src/georges/form_elm.cpp | 2 +- code/nel/src/gui/group_html.cpp | 1 + code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/code/nel/src/georges/form_elm.cpp b/code/nel/src/georges/form_elm.cpp index 86ad9c142..cdf6fe00b 100644 --- a/code/nel/src/georges/form_elm.cpp +++ b/code/nel/src/georges/form_elm.cpp @@ -836,7 +836,7 @@ bool CFormElm::getInternalNodeByName (CForm *form, const std::string &name, cons bool inArrayIndex = false; // Index in the array - uint arrayIndex; + uint arrayIndex = 0; // Bool next token must be an array index bool wantArrayIndex = false; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index e6805df53..b7484ce45 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -838,6 +838,7 @@ namespace NLGUI result.R = 255 * hueToRgb(m1, m2, h + 1.0f/3.0f); result.G = 255 * hueToRgb(m1, m2, h); result.B = 255 * hueToRgb(m1, m2, h - 1.0f/3.0f); + result.A = 255; } class CNameToCol 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 4a06195ce..7881df9e1 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -2044,7 +2044,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) string shape = ls.toString(1); - float x,y,z = 0.0f; + float x = 0.0f, y = 0.0f, z = 0.0f; float scale = 1.0f; string context,url,skeleton,texture = ""; bool highlight, transparency, collision = false; From 408dbb64f63a650a16007db1e63e9928b02f4988 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 19 Dec 2016 15:44:08 +0100 Subject: [PATCH 3/7] Fixed: Uninitialized variable --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp b/code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp index d314dce93..be740a1f7 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp @@ -213,7 +213,7 @@ public: static SRes seekFunc(void *object, Int64 *pos, ESzSeek origin) { Q7zFile *me = (Q7zFile*)object; - qint64 newPos; + qint64 newPos = 0; switch(origin) { From f921040f80b4122aa7312f390bfb9af0471a4453 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 19 Dec 2016 15:46:05 +0100 Subject: [PATCH 4/7] Fixed: Use a string (default was a bool) --HG-- branch : develop --- code/nel/src/georges/form_elm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/georges/form_elm.cpp b/code/nel/src/georges/form_elm.cpp index cdf6fe00b..a28fe2e9c 100644 --- a/code/nel/src/georges/form_elm.cpp +++ b/code/nel/src/georges/form_elm.cpp @@ -1653,7 +1653,7 @@ bool CFormElm::setValueByName (NLMISC::CRGBA value, const std::string &name, boo { char tmp[512]; smprintf (tmp, 512, "%d,%d,%d", value.R, value.G, value.B); - return setValueByName (tmp, name, created); + return setValueByName(std::string(tmp), name, created); } // *************************************************************************** From db9fbd274609115c4eeb11eaa7e7b30d56857b1a Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 19 Dec 2016 15:49:50 +0100 Subject: [PATCH 5/7] Fixed: Strict aliasing warnings --HG-- branch : develop --- code/ryzom/client/src/commands.cpp | 29 +++++++++++++++++++-------- code/ryzom/client/src/entities.cpp | 12 +++++++++-- code/ryzom/client/src/r2/editor.cpp | 5 ++--- code/ryzom/client/src/user_entity.cpp | 12 +++++++++-- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 2d8547bd6..03ed956fb 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -2041,17 +2041,21 @@ NLMISC_COMMAND(entity, "Create an entity on the user or just remove it if Form n node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_ORIENTATION), false); if(node) { - float dir = (float)atan2(UserEntity->front().y, UserEntity->front().x); - prop = (sint64 *)(&dir); - node->setValue64(*prop); + union C64BitsRot + { + sint64 i64; + float f; + }; + + C64BitsRot rot; + rot.f = (float)atan2(UserEntity->front().y, UserEntity->front().x); + node->setValue64(rot.i64); } // Set Mode node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false); if(node) { - MBEHAV::EMode m = MBEHAV::NORMAL; - prop = (sint64 *)&m; - node->setValue64(*prop); + node->setValue64((sint64)MBEHAV::NORMAL); EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_MODE); } // Set Visual Properties @@ -2842,8 +2846,17 @@ NLMISC_COMMAND(orient, "Orient an entity", "Slot: [1-254] orient(degree) [dt(tic fromString(args[2], dt); // Write the position in the DB. float fRot= (float)(rot*Pi/180.f); - uint64 val= *(uint32*)(&fRot); - IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P"+toString(CLFECOMMON::PROPERTY_ORIENTATION), val); + + union C64BitsRot + { + sint64 i64; + float f; + }; + + C64BitsRot r; + r.f = fRot; + + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P"+toString(CLFECOMMON::PROPERTY_ORIENTATION), r.i64); // Update the position. EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+dt, slot, CLFECOMMON::PROPERTY_ORIENTATION); } diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index cb324d2bc..7e682a588 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -2584,8 +2584,16 @@ void CEntityManager::logPropertyChange(CLFECOMMON::TCLEntityId who, const CStage // Orientation else if(propLoged[i]==CLFECOMMON::PROPERTY_ORIENTATION) { - float rot= *(float*)(&value); - valStr= toString("%d", sint32(rot*180/Pi)); + union C64BitsRot + { + sint64 i64; + float f; + }; + + C64BitsRot rot; + rot.i64 = value; + + valStr= toString("%d", sint32(rot.f*180/Pi)); } diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index f9c047fd5..72d3a66e8 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -4905,11 +4905,10 @@ CEntityCL *CEditor::createEntity(uint slot, const NLMISC::CSheetId &sheetId, con node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false); if(node) { - MBEHAV::EMode m = MBEHAV::NORMAL; - prop = (sint64 *)&m; - node->setValue64(*prop); + node->setValue64((sint64)MBEHAV::NORMAL); EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_MODE); } + // Set Visual Properties SPropVisualA visualA; //visualA.PropertySubData.LTrail = 1; diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index f5b4b0f42..2b200d2e6 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -789,10 +789,18 @@ bool CUserEntity::mode(MBEHAV::EMode m) case MBEHAV::COMBAT: case MBEHAV::COMBAT_FLOAT: { + union C64BitsRot + { + sint64 i64; + float f; + }; + + C64BitsRot rot; + // Compute the angle const string propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_ORIENTATION); - sint64 ang = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); - _TargetAngle = *(float *)(&ang); + rot.i64 = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); + _TargetAngle = rot.f; // Initialize controls for the combat. UserControls.startCombat(); From 7aabc217b03a457a2cd9566807d1ed5902ea303b Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 19 Dec 2016 15:50:21 +0100 Subject: [PATCH 6/7] Fixed: Compilation under Linux --HG-- branch : develop --- code/ryzom/client/src/commands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 03ed956fb..35389633c 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -3769,7 +3769,7 @@ NLMISC_COMMAND(testLongBubble, "To display a bubble with a long text", " fromString(args[0], entityId); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring text = "test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n"; + ucstring text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n"); uint duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32(); CEntityCL *entity = EntitiesMngr.entity(entityId); From 4e0a19205c9f5ddb8beaf28c83e07f2d891f94d5 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 19 Dec 2016 15:50:54 +0100 Subject: [PATCH 7/7] Changed: Check return value of fwrite --HG-- branch : develop --- code/nel/src/misc/displayer.cpp | 25 +++++++++++++++---- .../src/r2/dmc/client_edition_module.cpp | 6 ++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 798a4f80a..8feaa9358 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -495,15 +495,30 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes if (_NeedHeader) { const char *hs = HeaderString(); - fwrite (hs, strlen (hs), 1, _FilePointer); + + if (fwrite(hs, strlen(hs), 1, _FilePointer) != 1) + { + printf("Unable to write header: %s\n", hs); + } + _NeedHeader = false; } - if(!str.empty()) - fwrite (str.c_str(), str.size(), 1, _FilePointer); + if (!str.empty()) + { + if (fwrite(str.c_str(), str.size(), 1, _FilePointer) != 1) + { + printf("Unable to write string: %s\n", str.c_str()); + } + } - if(!args.CallstackAndLog.empty()) - fwrite (args.CallstackAndLog.c_str(), args.CallstackAndLog.size (), 1, _FilePointer); + if (!args.CallstackAndLog.empty()) + { + if (fwrite(args.CallstackAndLog.c_str(), args.CallstackAndLog.size(), 1, _FilePointer) != 1) + { + printf("Unable to write call stack: %s\n", args.CallstackAndLog.c_str()); + } + } fflush (_FilePointer); } diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index 37caebc3e..649996256 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -1652,7 +1652,11 @@ void CClientEditionModule::saveUserComponentFile(const std::string& filename, bo FILE* output = nlfopen(uncompressedName, "wb"); if (output) { - fwrite(component->UncompressedData, sizeof(char) , component->UncompressedDataLength, output); + if (fwrite(component->UncompressedData, sizeof(char), component->UncompressedDataLength, output) != component->UncompressedDataLength) + { + nlwarning("Unable to write %s", component->UncompressedData); + } + fclose(output); } }