From cbbbc74a601df00d85e141dc922ee6f3cf82a488 Mon Sep 17 00:00:00 2001 From: Riasan Date: Tue, 15 Dec 2020 21:40:37 +0100 Subject: [PATCH 01/45] Changed: add lua function --- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 180 +++++++++++------- .../client/src/interface_v3/lua_ihm_ryzom.h | 8 +- 2 files changed, 112 insertions(+), 76 deletions(-) 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 8aa7af585..e7cbb0ea6 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -565,6 +565,8 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) LUABIND_FUNC(isDynStringAvailable), LUABIND_FUNC(isFullyPatched), LUABIND_FUNC(getSheetType), + LUABIND_FUNC(getSheetShape), + LUABIND_FUNC(getCharacterSheetScale), LUABIND_FUNC(getSheetFamily), LUABIND_FUNC(getSheetName), LUABIND_FUNC(getFameIndex), @@ -1245,7 +1247,7 @@ int CLuaIHMRyzom::getMousePos(CLuaState &ls) CTool::getMousePos(x, y); ls.push(x); ls.push(y); - + return 2; } @@ -1257,7 +1259,7 @@ int CLuaIHMRyzom::getMouseDown(CLuaState &ls) ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1266,11 +1268,11 @@ int CLuaIHMRyzom::getMouseMiddleDown(CLuaState &ls) sint32 x, y; bool down; CTool::getMouseMiddleDown(down, x, y); - + ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1279,11 +1281,11 @@ int CLuaIHMRyzom::getMouseRightDown(CLuaState &ls) sint32 x, y; bool down; CTool::getMouseRightDown(down, x, y); - + ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1294,10 +1296,10 @@ int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - + uint32 x = (uint32)ls.toInteger(1); - uint32 y = (uint32)ls.toInteger(2); - + uint32 y = (uint32)ls.toInteger(2); + uint32 w, h; CViewRenderer &viewRender = *CViewRenderer::getInstance(); viewRender.getScreenSize(w, h); @@ -1308,11 +1310,11 @@ int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls) float cursX = (float)x/(float)w; float cursY = (float)y/(float)h; - + sint32 instance_idx; EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx); ls.push(instance_idx); - + return 1; } @@ -1339,7 +1341,7 @@ int CLuaIHMRyzom::getGroundAtMouse(CLuaState &ls) worldViewRay.Up = camMatrix.getK().normed(); CVector sceneInter; CTool::TRayIntersectionType rayInterType = CTool::computeLandscapeRayIntersection(worldViewRay, sceneInter); - + ls.push(sceneInter.x); ls.push(sceneInter.y); ls.push(sceneInter.z); @@ -1367,7 +1369,7 @@ int CLuaIHMRyzom::moveCam(CLuaState &ls) float z = (float)ls.toNumber(3); CVector moves(x, y, z); UserEntity->setCameraMoves(moves); - + return 0; } @@ -1541,7 +1543,7 @@ int CLuaIHMRyzom::moveToTarget(CLuaState &ls) const std::string &url = ls.toString(1); CEntityCL *target = getTargetEntity(); if (!target) return 0; - + CLuaManager::getInstance().executeLuaScript("ArkTargetUrl = [["+url+"]]", 0); UserEntity->moveTo(UserEntity->selection(), 1.0, CUserEntity::OpenArkUrl); return 0; @@ -2180,7 +2182,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); sint32 idx = -1; - + if (!Scene) { nlwarning("No scene available"); @@ -2189,7 +2191,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) } string shape = ls.toString(1); - + float x = 0.0f, y = 0.0f, z = 0.0f; float scale = 1.0f; string context, url, skeleton, texture; @@ -2197,7 +2199,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) bool transparency = false; bool collision = true; bool inIgZone = false; - + if (ls.getTop() >= 2) { CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); @@ -2223,14 +2225,14 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) y = UserEntity->pos().y; z = UserEntity->pos().z; } - + CVector userDir = UserEntity->dir(); - + if (ls.getTop() >= 5) { CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); string angle = ls.toString(5); - + if (angle != "user") { float a; @@ -2238,7 +2240,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) userDir = CVector(sin(a), cos(a), 0.f); } } - + if (ls.getTop() >= 6) { CLuaIHM::checkArgType(ls, funcName, 6, LUA_TNUMBER); @@ -2250,19 +2252,19 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 7, LUA_TBOOLEAN); collision = ls.toBoolean(7); } - + if (ls.getTop() >= 8) { CLuaIHM::checkArgType(ls, funcName, 8, LUA_TSTRING); context = ls.toString(8); } - + if (ls.getTop() >= 9) { CLuaIHM::checkArgType(ls, funcName, 9, LUA_TSTRING); url = ls.toString(9); } - + if (ls.getTop() >= 10) { CLuaIHM::checkArgType(ls, funcName, 10, LUA_TBOOLEAN); @@ -2274,25 +2276,25 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 11, LUA_TBOOLEAN); transparency = ls.toBoolean(11); } - + if (ls.getTop() >= 12) { CLuaIHM::checkArgType(ls, funcName, 12, LUA_TSTRING); texture = ls.toString(12); } - + if (ls.getTop() >= 13) { CLuaIHM::checkArgType(ls, funcName, 13, LUA_TSTRING); skeleton = ls.toString(13); } - + if (ls.getTop() >= 14) { CLuaIHM::checkArgType(ls, funcName, 14, LUA_TBOOLEAN); inIgZone = ls.toBoolean(14); } - + CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector(x, y, z), context, url, collision, inIgZone, idx); UInstance instance = instref.Instance; @@ -2373,9 +2375,9 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) instance.setPos(CVector(x, y, z)); instance.setRotQuat(dir.getRot()); } - + instance.setTransformMode(UTransformable::RotEuler); - + // if the shape is a particle system, additionnal parameters are user params UParticleSystemInstance psi; psi.cast (instance); @@ -2398,7 +2400,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) } } }*/ - + UMovePrimitive *primitive = instref.Primitive; if (primitive) { @@ -2408,7 +2410,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) primitive->setReactionType(UMovePrimitive::Slide); primitive->setTriggerType(UMovePrimitive::NotATrigger); primitive->setAbsorbtion(0); - + primitive->setPrimitiveType(UMovePrimitive::_2DOrientedBox); primitive->setSize((bbox.getMax().x - bbox.getMin().x)*scale, (bbox.getMax().y - bbox.getMin().y)*scale); primitive->setHeight((bbox.getMax().z - bbox.getMin().z)*scale); @@ -2416,10 +2418,10 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) primitive->setCollisionMask(MaskColPlayer | MaskColNpc | MaskColDoor); primitive->setOcclusionMask(MaskColPlayer | MaskColNpc | MaskColDoor); primitive->setObstacle(true); - - + + primitive->setGlobalPosition(instance.getPos(), dynamicWI); - + primitive->insertInWorldImage(dynamicWI); } } @@ -2434,9 +2436,9 @@ int CLuaIHMRyzom::setupShape(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TTABLE); - + uint32 idx = (uint32)ls.toInteger(1); - + std::vector keys; std::vector values; CLuaObject params; @@ -2459,12 +2461,12 @@ int CLuaIHMRyzom::setupShape(CLuaState &ls) values.push_back(it.nextValue().toString()); keys.push_back(it.nextKey().toString()); } - + if (EntitiesMngr.setupInstance(idx, keys, values)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2476,15 +2478,15 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstancePos(idx); string x = ls.toString(2); string y = ls.toString(3); string z = ls.toString(4); - + float move_x = 0; float move_y = 0; float move_z = 0; @@ -2502,7 +2504,7 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.x = move_x; } } - + if (!y.empty()) { if (y[0] == '+') @@ -2516,7 +2518,7 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.y = move_y; } } - + if (!z.empty()) { if (z[0] == '+') @@ -2530,12 +2532,12 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.z = move_z; } } - + if (EntitiesMngr.setInstancePos(idx, pos)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2547,9 +2549,9 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector rot = EntitiesMngr.getInstanceRot(idx); string x = ls.toString(2); @@ -2573,7 +2575,7 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.x = rot_x; } } - + if (!y.empty()) { if (y[0] == '+') @@ -2587,7 +2589,7 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.y = rot_y; } } - + if (!z.empty()) { if (z[0] == '+') @@ -2601,12 +2603,12 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.z = rot_z; } } - + if (EntitiesMngr.setInstanceRot(idx, rot)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2615,7 +2617,7 @@ int CLuaIHMRyzom::deleteShape(CLuaState &ls) const char* funcName = "deleteShape"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + if (EntitiesMngr.deleteInstance((uint32)ls.toInteger(1))) ls.push(1); else @@ -2629,9 +2631,9 @@ int CLuaIHMRyzom::getShapePos(CLuaState &ls) const char* funcName = "getShapePos"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstancePos(idx); ls.push(pos.x); @@ -2645,9 +2647,9 @@ int CLuaIHMRyzom::getShapeRot(CLuaState &ls) const char* funcName = "getShapeRot"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector rot = EntitiesMngr.getInstanceRot(idx); ls.push(rot.x); @@ -2661,11 +2663,11 @@ int CLuaIHMRyzom::getShapeScale(CLuaState &ls) const char* funcName = "getShapeScale"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector scale = EntitiesMngr.getInstanceScale(idx); - + ls.push(scale.x); ls.push(scale.y); ls.push(scale.z); @@ -2677,11 +2679,11 @@ int CLuaIHMRyzom::getShapeColPos(CLuaState &ls) const char* funcName = "getShapeColPos"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstanceColPos(idx); - + ls.push(pos.x); ls.push(pos.y); ls.push(pos.z); @@ -2693,11 +2695,11 @@ int CLuaIHMRyzom::getShapeColScale(CLuaState &ls) const char* funcName = "getShapeColScale"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector scale = EntitiesMngr.getInstanceColScale(idx); - + ls.push(scale.x); ls.push(scale.y); ls.push(scale.z); @@ -2709,11 +2711,11 @@ int CLuaIHMRyzom::getShapeColOrient(CLuaState &ls) const char* funcName = "getShapeColOrient"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + double orient = EntitiesMngr.getInstanceColOrient(idx); - + ls.push(orient); return 1; } @@ -3469,6 +3471,38 @@ std::string CLuaIHMRyzom::getSheetType(const std::string &sheet) return CEntitySheet::typeToString(sheetPtr->Type); } +// *************************************************************************** +std::string CLuaIHMRyzom::getSheetShape(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_getSheetType) + const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); + + if (!sheetPtr) + return ""; + + if (sheetPtr->type() == CEntitySheet::ITEM) + { + CItemSheet *sheet = (CItemSheet*)sheetPtr; + return sheet->getShape(); + } + else if (sheetPtr->type() == CEntitySheet::FAUNA) + { + CCharacterSheet *sheet = (CCharacterSheet*)(sheetPtr); + return sheet->Body.getItem(); + } + + return ""; +} + +// *************************************************************************** +float CLuaIHMRyzom::getCharacterSheetScale(const std::string &sheet) +{ + const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); + const CCharacterSheet *charSheet = dynamic_cast(sheetPtr); + + if (charSheet) return charSheet->Scale; + return 1; +} // *************************************************************************** std::string CLuaIHMRyzom::getSheetFamily(const std::string &sheet) @@ -3481,7 +3515,7 @@ std::string CLuaIHMRyzom::getSheetFamily(const std::string &sheet) if (pIS) return ITEMFAMILY::toString(pIS->Family); } - + return ""; } @@ -3712,7 +3746,7 @@ float CLuaIHMRyzom::setChar3dDBfromVPX(const std::string &branch, const std::str cs.People = EGSPD::CPeople::fromString(people); SCharacter3DSetup::setupDBFromCharacterSummary(branch, cs); - + return cs.VisualPropC.PropertySubData.CharacterHeight; } @@ -4172,12 +4206,12 @@ int CLuaIHMRyzom::addLandMark(CLuaState &ls) point.LeftClickParam = ls.toString(6); point.RightClickAction = ls.toString(7); point.RightClickParam = ls.toString(8); - + point.Color = CRGBA(255,255,255,255); if (ls.getTop() >= 9) CLuaIHM::pop(ls, point.Color); - + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (pMap != NULL) pMap->addArkPoint(point); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 78b5a2a00..e134b00a0 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -15,7 +15,7 @@ private: static int luaClientCfgIndex(CLuaState &ls); static int luaClientCfgNewIndex(CLuaState &ls); - + // CInterfaceElement management on stack, stored by a CRefPtr. public: @@ -204,6 +204,8 @@ private: static bool isDynStringAvailable(sint32 dynStringId); static bool isFullyPatched(); static std::string getSheetType(const std::string &sheet); + static std::string getSheetShape(const std::string &sheet); + static float getCharacterSheetScale(const std::string &sheet); static std::string getSheetFamily(const std::string &sheet); static std::string getSheetName(uint32 sheetId); static sint32 getFameIndex(const std::string &factionName); @@ -251,7 +253,7 @@ private: static int addRespawnPoint(CLuaState &ls); static int delArkPoints(CLuaState &ls); static int setArkPowoOptions(CLuaState &ls); - + // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly // else, current command of the chat window will be replaced with tell 'player' @@ -260,7 +262,7 @@ private: static void updateTooltipCoords(); // test if the ctrl key is down (NB nico : I didn't add other key, // because it would be too easy to write a key recorder ...) - static bool isCtrlKeyDown(); + static bool isCtrlKeyDown(); static std::string encodeURLUnicodeParam(const ucstring &text); static std::string encodeURLParam(const std::string &text); From b984e2e3d81f4c5d20367cf0dffa332b0a1c5947 Mon Sep 17 00:00:00 2001 From: Nuno Date: Wed, 6 Jan 2021 12:51:59 +0100 Subject: [PATCH 02/45] Missing definition of getSheetShape --- code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 78b5a2a00..1ca8de42a 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -15,7 +15,7 @@ private: static int luaClientCfgIndex(CLuaState &ls); static int luaClientCfgNewIndex(CLuaState &ls); - + // CInterfaceElement management on stack, stored by a CRefPtr. public: @@ -204,6 +204,7 @@ private: static bool isDynStringAvailable(sint32 dynStringId); static bool isFullyPatched(); static std::string getSheetType(const std::string &sheet); + static std::string getSheetShape(const std::string &sheet); static std::string getSheetFamily(const std::string &sheet); static std::string getSheetName(uint32 sheetId); static sint32 getFameIndex(const std::string &factionName); @@ -251,7 +252,7 @@ private: static int addRespawnPoint(CLuaState &ls); static int delArkPoints(CLuaState &ls); static int setArkPowoOptions(CLuaState &ls); - + // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly // else, current command of the chat window will be replaced with tell 'player' @@ -260,7 +261,7 @@ private: static void updateTooltipCoords(); // test if the ctrl key is down (NB nico : I didn't add other key, // because it would be too easy to write a key recorder ...) - static bool isCtrlKeyDown(); + static bool isCtrlKeyDown(); static std::string encodeURLUnicodeParam(const ucstring &text); static std::string encodeURLParam(const std::string &text); From 9771d79bc3033af9a97f18dd15645d79f84dfa00 Mon Sep 17 00:00:00 2001 From: Nuno Date: Wed, 6 Jan 2021 19:32:42 +0100 Subject: [PATCH 03/45] Fixed bad conversion in getPlayerVp*Hex and getTargetVp*Hex --- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 43 +++++++++---------- .../client/src/interface_v3/lua_ihm_ryzom.h | 12 +++--- 2 files changed, 26 insertions(+), 29 deletions(-) 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 68a39bb2c..75b588ce0 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -3904,40 +3904,40 @@ sint32 CLuaIHMRyzom::getPlayerLevel() // *************************************************************************** std::string CLuaIHMRyzom::getPlayerVpaHex() { - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** std::string CLuaIHMRyzom::getPlayerVpbHex() { - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** std::string CLuaIHMRyzom::getPlayerVpcHex() { - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** -sint64 CLuaIHMRyzom::getPlayerVpa() +uint64 CLuaIHMRyzom::getPlayerVpa() { uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); return prop; } // *************************************************************************** -sint64 CLuaIHMRyzom::getPlayerVpb() +uint64 CLuaIHMRyzom::getPlayerVpb() { uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } // *************************************************************************** -sint64 CLuaIHMRyzom::getPlayerVpc() +uint64 CLuaIHMRyzom::getPlayerVpc() { uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); return prop; @@ -3989,8 +3989,8 @@ std::string CLuaIHMRyzom::getTargetVpaHex() CEntityCL *target = getTargetEntity(); if (!target) return 0; - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** @@ -3999,8 +3999,8 @@ std::string CLuaIHMRyzom::getTargetVpbHex() CEntityCL *target = getTargetEntity(); if (!target) return 0; - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** @@ -4009,40 +4009,37 @@ std::string CLuaIHMRyzom::getTargetVpcHex() CEntityCL *target = getTargetEntity(); if (!target) return 0; - uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); - return NLMISC::toString("%X", prop); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); + return NLMISC::toString("%" NL_I64 "X", prop); } // *************************************************************************** -sint64 CLuaIHMRyzom::getTargetVpa() +uint64 CLuaIHMRyzom::getTargetVpa() { CEntityCL *target = getTargetEntity(); if (!target) return 0; uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); - return prop; } // *************************************************************************** -sint64 CLuaIHMRyzom::getTargetVpb() +uint64 CLuaIHMRyzom::getTargetVpb() { CEntityCL *target = getTargetEntity(); if (!target) return 0; - sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } // *************************************************************************** -sint64 CLuaIHMRyzom::getTargetVpc() +uint64 CLuaIHMRyzom::getTargetVpc() { CEntityCL *target = getTargetEntity(); if (!target) return 0; - sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); - + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); return prop; } diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 1ca8de42a..f8db32363 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -272,9 +272,9 @@ private: static std::string getPlayerVpaHex(); static std::string getPlayerVpbHex(); static std::string getPlayerVpcHex(); - static sint64 getPlayerVpa(); - static sint64 getPlayerVpb(); - static sint64 getPlayerVpc(); + static uint64 getPlayerVpa(); + static uint64 getPlayerVpb(); + static uint64 getPlayerVpc(); static sint32 getTargetLevel(); // get current, precise level of the selected target, or -1 if there's no such selected target static sint32 getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target @@ -282,9 +282,9 @@ private: static std::string getTargetVpaHex(); static std::string getTargetVpbHex(); static std::string getTargetVpcHex(); - static sint64 getTargetVpa(); - static sint64 getTargetVpb(); - static sint64 getTargetVpc(); + static uint64 getTargetVpa(); + static uint64 getTargetVpb(); + static uint64 getTargetVpc(); static bool isTargetNPC(); // return 'true' if the target is an npc static bool isTargetPlayer(); // return 'true' if the target is a player static bool isTargetUser(); // return 'true' if the target is the user From 0a81f406065addc4cccc16ad95accf28756762a2 Mon Sep 17 00:00:00 2001 From: Riasan Date: Sun, 10 Jan 2021 19:09:48 +0100 Subject: [PATCH 04/45] Fixed: Typo --- code/ryzom/client/src/interface_v3/action_handler_game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 3e3ce9b8e..b200205be 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -4686,7 +4686,7 @@ class CHandlerOutgameNaviGetKeys : public IActionHandler id = "sel"; if (event != -1) -- CLuaManager::getInstance().executeLuaScript(toString("outgame:eventChar%sKeyGet(%i)", id.c_str(), event)); + CLuaManager::getInstance().executeLuaScript(toString("outgame:eventChar%sKeyGet(%i)", id.c_str(), event)); } // reset previous input Driver->AsyncListener.reset(); From ae9989dfe41362fc17d1b6dbad7fb01df73e1f29 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 14 Jan 2021 15:53:12 +0100 Subject: [PATCH 05/45] Updated default textures in client --- code/ryzom/client/src/client_cfg.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index df1debee2..6758d440a 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -326,8 +326,8 @@ CClientConfig::CClientConfig() Local = false; // Default is Net Mode. FSHost = ""; // Default Host. - TexturesInterface.push_back("texture_interfaces_v3"); - TexturesInterfaceDXTC.push_back("texture_interfaces_dxtc"); + TexturesInterface.push_back("texture_interfaces_v3_2x"); + TexturesInterfaceDXTC.push_back("texture_interfaces_dxtc_2x"); TexturesOutGameInterface.push_back("texture_interfaces_v3_outgame_ui"); @@ -782,8 +782,8 @@ void CClientConfig::setValues() READ_STRINGVECTOR_FV(TexturesOutGameInterfaceDXTC); // interface textures ingame and r2 - READ_STRINGVECTOR_FV(TexturesInterface); - READ_STRINGVECTOR_FV(TexturesInterfaceDXTC); + //READ_STRINGVECTOR_FV(TexturesInterface); + //READ_STRINGVECTOR_FV(TexturesInterfaceDXTC); // interface files login menus READ_STRINGVECTOR_FV(XMLLoginInterfaceFiles); From 4726e74dcd028de170f81d0117e41113065f18de Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 14 Jan 2021 16:04:54 +0100 Subject: [PATCH 06/45] Added marauder to static fames --- code/ryzom/common/src/game_share/fame.cpp | 13 +++++++++++-- code/ryzom/common/src/game_share/fame.h | 11 ++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/code/ryzom/common/src/game_share/fame.cpp b/code/ryzom/common/src/game_share/fame.cpp index cd9e2b850..19c3cbb80 100644 --- a/code/ryzom/common/src/game_share/fame.cpp +++ b/code/ryzom/common/src/game_share/fame.cpp @@ -534,7 +534,7 @@ void CStaticFames::loadTribeThreshold( const string& filename ) // check table structure uint nbTribe = ws.size()-2; nlassert(nbTribe<=_FameTableSize); - nlassert(ws.ColCount == 16); // 5 ( 4 people + neutral ) * 3 cult + 1 for tribe name + nlassert(ws.ColCount == 17); // 5 ( 4 people + neutral ) * 3 cult + 1 for tribe name + marauder _TribeCultThresholdPerCiv.resize(nbTribe); @@ -548,7 +548,7 @@ void CStaticFames::loadTribeThreshold( const string& filename ) _TribeCultThresholdPerCiv[i-2].FameIndex = index; - for( uint c=1; csetMarauder(thresholdMarauder*6000); } } } diff --git a/code/ryzom/common/src/game_share/fame.h b/code/ryzom/common/src/game_share/fame.h index fde8611b8..c0cc856bb 100644 --- a/code/ryzom/common/src/game_share/fame.h +++ b/code/ryzom/common/src/game_share/fame.h @@ -52,26 +52,30 @@ public: Kami = 0; Karavan = 0; Neutral = 0; + Marauder = 0; } void setKami(sint32 t) { Kami = t; } void setKaravan(sint32 t) { Karavan = t; } void setNeutral(sint32 t) { Neutral = t; } + void setMarauder(sint32 t) { Marauder = t; } sint32 getKami() const { return Kami; } sint32 getKaravan() const { return Karavan; } sint32 getNeutral() const { return Neutral; } + sint32 getMarauder() const { return Marauder; } private: sint32 Kami; sint32 Karavan; sint32 Neutral; + sint32 Marauder; }; class CTribeCultThresholdPerCiv { public: - bool getCultThresholdForCiv( PVP_CLAN::TPVPClan civ, sint32& kami, sint32& karavan, sint32& neutral) const + bool getCultThresholdForCiv( PVP_CLAN::TPVPClan civ, sint32& kami, sint32& karavan, sint32& neutral, sint32& marauder) const { const CTribeCultThreshold * tc = 0; switch( civ ) @@ -88,12 +92,16 @@ public: case PVP_CLAN::Neutral: tc = &Neutral; break; + case PVP_CLAN::Marauder: + tc = &Marauder; + break; default: return false; } kami = tc->getKami(); karavan = tc->getKaravan(); neutral = tc->getNeutral(); + marauder = tc->getMarauder(); return true; } @@ -103,6 +111,7 @@ public: CTribeCultThreshold Tryker; CTribeCultThreshold Zorai; CTribeCultThreshold Neutral; + CTribeCultThreshold Marauder; }; // declare scoped constant value From 951f000be4428e707eae5333305fcbbc47c341d3 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 14 Jan 2021 16:05:40 +0100 Subject: [PATCH 07/45] Keep missions window open when player accept one of them --- code/ryzom/client/src/interface_v3/bot_chat_manager.cpp | 6 ++++++ code/ryzom/client/src/interface_v3/bot_chat_manager.h | 3 +++ .../ryzom/client/src/interface_v3/bot_chat_page_mission.cpp | 1 + code/ryzom/client/src/interface_v3/bot_chat_page_mission.h | 1 + 4 files changed, 11 insertions(+) diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp index d25763bff..839381b91 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp @@ -86,6 +86,12 @@ void CBotChatManager::setCurrPage(CBotChatPage *page) UserEntity->trader(CLFECOMMON::INVALID_SLOT); } _CurrPage = page; + + if (page == NULL && !_AHAfterEnd.empty()) + { + CAHManager::getInstance()->runActionHandler(_AHAfterEnd, NULL, ""); + _AHAfterEnd = ""; + } } // ******************************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.h b/code/ryzom/client/src/interface_v3/bot_chat_manager.h index cbd2713f8..9b9f996fc 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.h +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.h @@ -93,12 +93,15 @@ public: // Called for local client debugging void debugLocalReceiveMissionInfo(); + void setAHAfterEnd(const std::string &ah) { _AHAfterEnd = ah ;} + ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// private: CBotChatPage *_CurrPage; uint16 _SessionID; + std::string _AHAfterEnd; static CBotChatManager *_Instance; //uint _ChosenMissionFlags; diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index ad95a35e5..4830fb096 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -161,6 +161,7 @@ void CBotChatPageMission::acceptMission() /// close the botchat //CBotChatManager::getInstance()->setCurrPage(NULL); _CurrSel = NULL; + CBotChatManager::getInstance()->setAHAfterEnd("context_choose_mission"); } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.h b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.h index 03cb8d95e..0e458fc7a 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.h +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.h @@ -51,6 +51,7 @@ private: // an observer to update big mission list from littles pages in server database CHugeListObs _MissionPagesObs; CDBCtrlSheet *_CurrSel; + bool _HaveAcceptedMission; MISSION_DESC::TClientMissionType _MType; }; From 46c7b0309d0891d514c77b34e551b43374507a41 Mon Sep 17 00:00:00 2001 From: Nuno Date: Tue, 19 Jan 2021 19:34:20 +0100 Subject: [PATCH 08/45] Added icons to broadcast --- .../interface_v3/group_in_scene_bubble.cpp | 33 +++++++++++++++++-- .../src/interface_v3/interface_manager.cpp | 19 ++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 2276eb506..015800173 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -28,6 +28,7 @@ #include "nel/gui/action_handler.h" #include "../entities.h" #include "nel/gui/group_paragraph.h" // For CCtrlLink +#include "nel/gui/view_bitmap.h" #include "../net_manager.h" #include "../string_manager_client.h" #include "../login.h" @@ -644,14 +645,42 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, "ui:interface", templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); if (group) { + ucstring finalMessage = message; + + ucstring::size_type pos = message.find(ucstring("|")); + if (pos != std::string::npos) + { + CViewBitmap *pViewIcon = dynamic_cast(group->getView("iconA")); + if (pViewIcon != NULL) + { + string texture = message.substr(0, pos).toString(); + pViewIcon->setTexture(texture); + } + + ucstring::size_type end = message.find(ucstring("|"), pos+1); + if (end != std::string::npos) + { + CViewBitmap *pViewIcon = dynamic_cast(group->getView("iconZ")); + if (pViewIcon != NULL) + { + string texture = message.substr(end+1).toString(); + pViewIcon->setTexture(texture); + } + finalMessage = message.substr(pos+1, end-pos-1); + } + else + finalMessage = message.substr(pos+1); + } + // Skill name CViewText *pViewName = dynamic_cast(group->getView("name")); if (pViewName != NULL) { - pViewName->setTextFormatTaged(message); + pViewName->setTextFormatTaged(finalMessage); pViewName->setColor (color); } + // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); @@ -865,7 +894,7 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, textSize = endOfOriginal; } } - + // Output the message in a bubble bool show = false; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index e81785ea8..5231dc19a 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2523,6 +2523,17 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat CClientConfig::SSysInfoParam::TMode mode = CClientConfig::SSysInfoParam::Normal; CRGBA color = CRGBA::White; + ucstring cleanStr = str; + ucstring::size_type pos = str.find(ucstring("|")); + if (pos != std::string::npos) + { + ucstring::size_type end = str.find(ucstring("|"), pos+1); + if (end != std::string::npos) + cleanStr = str.substr(pos+1, end-pos-1); + else + cleanStr = str.substr(pos+1); + } + // If broadcast, parse lua code if (toLower(cat) == "bc" && str.size() > 3 && str[0]=='@' && str[1]=='L' && str[2]=='U' && str[3]=='A') { @@ -2542,11 +2553,11 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat if (mode != CClientConfig::SSysInfoParam::OverOnly && mode != CClientConfig::SSysInfoParam::Around) { if (PeopleInterraction.SystemInfo) - PeopleInterraction.ChatInput.SystemInfo.displayMessage(str, color, 2); + PeopleInterraction.ChatInput.SystemInfo.displayMessage(cleanStr, color, 2); else { CPeopleInterraction::CSysMsg sysMsg; - sysMsg.Str = str; + sysMsg.Str = cleanStr; sysMsg.Cat = cat; PeopleInterraction.SystemMessageBuffer.push_back( sysMsg ); } @@ -2557,10 +2568,10 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat // If over popup a string at the bottom of the screen if ((mode == CClientConfig::SSysInfoParam::Over) || (mode == CClientConfig::SSysInfoParam::OverOnly)) - InSceneBubbleManager.addMessagePopup(str, color); + InSceneBubbleManager.addMessagePopup(cleanStr, color); else if ( (mode == CClientConfig::SSysInfoParam::Around || mode == CClientConfig::SSysInfoParam::CenterAround) && PeopleInterraction.AroundMe.Window) - PeopleInterraction.ChatInput.AroundMe.displayMessage(str, color, 2); + PeopleInterraction.ChatInput.AroundMe.displayMessage(cleanStr, color, 2); } From 98b091ab630f3d196110ba066a326605a919b898 Mon Sep 17 00:00:00 2001 From: Nuno Date: Sun, 24 Jan 2021 09:05:51 +0100 Subject: [PATCH 09/45] Added TeleportMarauder --- code/ryzom/common/src/game_share/magic_fx.h | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ryzom/common/src/game_share/magic_fx.h b/code/ryzom/common/src/game_share/magic_fx.h index 2a46475e8..414a6586a 100644 --- a/code/ryzom/common/src/game_share/magic_fx.h +++ b/code/ryzom/common/src/game_share/magic_fx.h @@ -136,6 +136,7 @@ namespace MAGICFX OtherFireWall = 14, TeleportKami = 15, // No effect aura TeleportKara = 16, // No effect aura + TeleportMarauder = 17, // No effect aura }; } From f61d10c75e7b3a6c20844c412975457a9c309d85 Mon Sep 17 00:00:00 2001 From: Nuno Date: Wed, 10 Feb 2021 09:11:03 +0100 Subject: [PATCH 10/45] Added executeRyzomScript, executeTutorial and processTutorialEvent lua callbacks --- code/nel/src/gui/group_html.cpp | 26 ++++++++++++++++--- .../src/interface_v3/group_quick_help.cpp | 2 ++ .../client/src/interface_v3/lua_ihm_ryzom.cpp | 17 ++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 50b381a3c..9531ff216 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -5503,7 +5503,7 @@ namespace NLGUI string suri = elm.getAttribute("href"); if(suri.find("ah:") == 0) { - if (_TrustedDomain) + if (_TrustedDomain || suri.find("ah:script:") == 0) _Link.back() = suri; } else @@ -6360,11 +6360,13 @@ namespace NLGUI void CGroupHTML::htmlOBJECTend(const CHtmlElement &elm) { - if (!_TrustedDomain) - return; + if (_ObjectType=="application/ryzom-data") { + if (!_TrustedDomain) + return; + if (!_ObjectData.empty()) { if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum)) @@ -6374,6 +6376,24 @@ namespace NLGUI _ObjectScript.clear(); } } + else if (_ObjectType=="application/ryzom-tutorial") + { + strFindReplace(_ObjectScript, "[[", "\\[\\["); + strFindReplace(_ObjectScript, "]]", "\\]\\]"); + strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[["); + strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[["); + CLuaManager::getInstance().executeLuaScript("\ngame:executeTutorial([["+_ObjectScript+"]])\n", true); + _ObjectScript.clear(); + } + else if (_ObjectType=="application/ryzom-script") + { + strFindReplace(_ObjectScript, "[[", "\\[\\["); + strFindReplace(_ObjectScript, "]]", "\\]\\]"); + strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[["); + strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[["); + CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+_ObjectScript+"]])\n", true); + _ObjectScript.clear(); + } _Object = false; } diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 0b789fccf..e89967193 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -74,6 +74,8 @@ bool CGroupQuickHelp::submitEvent (const char *event) // Update the text updateParagraph (); + + CLuaManager::getInstance().executeLuaScript(toString("\ngame:processTutorialEvent(\"%s\")\n", event), true); } } return false; 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 35d4042ee..87d2a52b4 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -184,6 +184,23 @@ private: REGISTER_ACTION_HANDLER(CHandlerLUA, "lua"); std::deque > CHandlerLUA::_UICallerStack; +// *************************************************************************** +class CHandlerSCRIPT : public IActionHandler +{ +public: + void execute(CCtrlBase *pCaller, const std::string &sParams) + { + string script = sParams; + strFindReplace(script, "[[", "\\[\\["); + strFindReplace(script, "]]", "\\]\\]"); + strFindReplace(script, "\\[\\[", "]]..'[['..[["); + strFindReplace(script, "\\]\\]", "]]..']]'..[["); + strFindReplace(script, "|", "\n"); + CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+script+"]])\n", true); + } +}; +REGISTER_ACTION_HANDLER(CHandlerSCRIPT, "script"); + // *************************************************************************** // Allow also to call script from expression static DECLARE_INTERFACE_USER_FCT(lua) From df69a1706f1d41e8773547399c9fb84e28903e18 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 11 Feb 2021 14:33:25 +0100 Subject: [PATCH 11/45] Fixed potential security hole --- code/nel/src/gui/group_html.cpp | 12 ++++-------- code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp | 6 ++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 9531ff216..efb6e9b65 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -6378,19 +6378,15 @@ namespace NLGUI } else if (_ObjectType=="application/ryzom-tutorial") { - strFindReplace(_ObjectScript, "[[", "\\[\\["); - strFindReplace(_ObjectScript, "]]", "\\]\\]"); - strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[["); - strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[["); + strFindReplace(_ObjectScript, "[", "〈"); + strFindReplace(_ObjectScript, "]", "〉"); CLuaManager::getInstance().executeLuaScript("\ngame:executeTutorial([["+_ObjectScript+"]])\n", true); _ObjectScript.clear(); } else if (_ObjectType=="application/ryzom-script") { - strFindReplace(_ObjectScript, "[[", "\\[\\["); - strFindReplace(_ObjectScript, "]]", "\\]\\]"); - strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[["); - strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[["); + strFindReplace(_ObjectScript, "[", "〈"); + strFindReplace(_ObjectScript, "]", "〉"); CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+_ObjectScript+"]])\n", true); _ObjectScript.clear(); } 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 87d2a52b4..32b37eb61 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -191,10 +191,8 @@ public: void execute(CCtrlBase *pCaller, const std::string &sParams) { string script = sParams; - strFindReplace(script, "[[", "\\[\\["); - strFindReplace(script, "]]", "\\]\\]"); - strFindReplace(script, "\\[\\[", "]]..'[['..[["); - strFindReplace(script, "\\]\\]", "]]..']]'..[["); + strFindReplace(script, "[", "〈"); + strFindReplace(script, "]", "〉"); strFindReplace(script, "|", "\n"); CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+script+"]])\n", true); } From 2aaa928cdcf9bf282b96da8b90098f74b01cdd52 Mon Sep 17 00:00:00 2001 From: Nuno Date: Thu, 11 Feb 2021 14:48:15 +0100 Subject: [PATCH 12/45] Fixed potential security hole --- code/nel/src/gui/group_html.cpp | 8 ++++---- code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index efb6e9b65..e88bdfbc5 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -6378,15 +6378,15 @@ namespace NLGUI } else if (_ObjectType=="application/ryzom-tutorial") { - strFindReplace(_ObjectScript, "[", "〈"); - strFindReplace(_ObjectScript, "]", "〉"); + while(strFindReplace(_ObjectScript, "[", "〈")); + while(strFindReplace(_ObjectScript, "]", "〉")); CLuaManager::getInstance().executeLuaScript("\ngame:executeTutorial([["+_ObjectScript+"]])\n", true); _ObjectScript.clear(); } else if (_ObjectType=="application/ryzom-script") { - strFindReplace(_ObjectScript, "[", "〈"); - strFindReplace(_ObjectScript, "]", "〉"); + while(strFindReplace(_ObjectScript, "[", "〈")); + while(strFindReplace(_ObjectScript, "]", "〉")); CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+_ObjectScript+"]])\n", true); _ObjectScript.clear(); } 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 32b37eb61..ca5de98c8 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -191,8 +191,8 @@ public: void execute(CCtrlBase *pCaller, const std::string &sParams) { string script = sParams; - strFindReplace(script, "[", "〈"); - strFindReplace(script, "]", "〉"); + while(strFindReplace(script, "[", "〈")); + while(strFindReplace(script, "]", "〉")); strFindReplace(script, "|", "\n"); CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+script+"]])\n", true); } From c75071b4887035feb940adbbe9a73d6fceb3bbfc Mon Sep 17 00:00:00 2001 From: Sit Melai Date: Mon, 15 Feb 2021 02:17:50 +0100 Subject: [PATCH 13/45] Handle hiding the flag and inversing translations for each language --- .../src/interface_v3/chat_text_manager.cpp | 21 ++++++++++++------- .../interface_v3/group_in_scene_bubble.cpp | 9 +++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp index ec0aee822..c8a07f0f8 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -424,27 +424,30 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C ucstring::size_type pos = 0; - // Manage Translations - CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TRANSLATION_ONLY_AS_TOOLTIP_CB", false); - bool originalFirst = node->getValueBool(); - string::size_type startTr = msg.find(ucstring("{:")); string::size_type endOfOriginal = msg.find(ucstring("}@{")); // Original/Translated case, example: {:enHello the world!}@{ Bonjour le monde ! if (startTr != string::npos && endOfOriginal != string::npos) { + string lang = toUpper(msg.substr(startTr+2, 2)).toString(); + + CCDBNodeLeaf *nodeInverse = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:TRANSLATION:" + lang + ":INVERSE_DISPLAY", false); + bool inverse = nodeInverse->getValueBool(); + CCDBNodeLeaf *nodeHideFlag = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:TRANSLATION:" + lang + ":HIDE_FLAG", false); + bool hideFlag = nodeHideFlag->getValueBool(); + CViewBase *vt = createMsgTextSimple(msg.substr(0, startTr), col, justified, NULL); para->addChild(vt); string texture = "flag-"+toLower(msg.substr(startTr+2, 2)).toString()+".tga"; ucstring original = msg.substr(startTr+5, endOfOriginal-startTr-5); - ucstring translation = msg.substr(endOfOriginal+3); + ucstring translation = msg.substr(endOfOriginal+4); CCtrlButton *ctrlButton = new CCtrlButton(CViewBase::TCtorParam()); ctrlButton->setTexture(texture); ctrlButton->setTextureOver(texture); ctrlButton->setTexturePushed(texture); - if (!originalFirst) + if (!inverse) { ctrlButton->setDefaultContextHelp(original); pos = endOfOriginal+3; @@ -456,7 +459,11 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C textSize = endOfOriginal; } ctrlButton->setId("tr"); - para->addChild(ctrlButton); + if (hideFlag) { + delete ctrlButton; + } else { + para->addChild(ctrlButton); + } } // quickly check if text has links or not diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 015800173..e2fca2053 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -875,16 +875,19 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, // Clean bubble from translation system - CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TRANSLATION_ONLY_AS_TOOLTIP_CB", false); - bool originalFirst = node->getValueBool(); ucstring::size_type pos = 0; ucstring::size_type textSize = ucsText.size(); string::size_type startTr = ucsText.find(ucstring("{:")); string::size_type endOfOriginal = ucsText.find(ucstring("}@{")); + + string lang = toUpper(ucsText.substr(startTr+2, 2)).toString(); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:TRANSLATION:" + lang + ":INVERSE_DISPLAY", false); + bool inverse = node->getValueBool(); + if (endOfOriginal != string::npos) { - if (!originalFirst) + if (!inverse) { pos = endOfOriginal+4; } From 4bcf9270eb0dd420abeb829b77b5e9d9cdc29964 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Mon, 15 Feb 2021 13:25:37 +0200 Subject: [PATCH 14/45] Show reload link when curl fails to open connection to website --- code/nel/include/nel/gui/group_html.h | 3 +++ code/nel/src/gui/group_html.cpp | 28 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 590c43a89..a78e203c0 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -115,6 +115,9 @@ namespace NLGUI // Browse error void browseError (const char *msg); + // Error message with html content + void browseErrorHtml(const std::string &html); + bool isBrowsing(); // Update coords diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 50b381a3c..f2aba9fa0 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -2642,6 +2642,17 @@ namespace NLGUI invalidateCoords(); } + void CGroupHTML::browseErrorHtml(const std::string &html) + { + releaseDownloads(); + removeContent(); + + renderHtmlString(html); + + updateRefreshButton(); + invalidateCoords(); + } + // *************************************************************************** bool CGroupHTML::isBrowsing() @@ -3964,11 +3975,22 @@ namespace NLGUI { if (!success) { + CUrlParser uri(_CurlWWW->Url); + + // potentially unwanted chars + std::string url = _CurlWWW->Url; + url = strFindReplaceAll(url, string("<"), string("%3C")); + url = strFindReplaceAll(url, string(">"), string("%3E")); + url = strFindReplaceAll(url, string("\""), string("%22")); + url = strFindReplaceAll(url, string("'"), string("%27")); + std::string err; - err = "Connection failed with cURL error: "; + err = "cURL error"; + err += "

Connection failed with cURL error

"; err += error; - err += "\nURL '" + _CurlWWW->Url + "'"; - browseError(err.c_str()); + err += "
(" + uri.scheme + "://" + uri.host + ") reload"; + err += ""; + browseErrorHtml(err); return; } From 91b3ff25b48d88062dec670408da0c65c483a227 Mon Sep 17 00:00:00 2001 From: Sit Melai Date: Tue, 16 Feb 2021 00:04:04 +0100 Subject: [PATCH 15/45] Add disabling of translation per channel --- .../src/interface_v3/chat_text_manager.cpp | 2 +- .../client/src/interface_v3/chat_window.cpp | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp index c8a07f0f8..32558f642 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -450,7 +450,7 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C if (!inverse) { ctrlButton->setDefaultContextHelp(original); - pos = endOfOriginal+3; + pos = endOfOriginal+4; } else { diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 13f7bc66d..51e4a96a3 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -216,7 +216,23 @@ void CChatWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGr gl = dynamic_cast(_Chat->getGroup("cb:text_list")); - CViewBase *child = ctm.createMsgText(msg, col); + + + CCDBNodeLeaf *nodeNoTranslation = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:TRANSLATION:" + toUpper(CChatGroup::groupTypeToString(gt)) + ":DISABLE", false); + bool noTranslation = nodeNoTranslation->getValueBool(); + + ucstring msgNoTranslate = msg; + + if (noTranslation) { + string::size_type startTr = msg.find(ucstring("{:")); + string::size_type endOfOriginal = msg.find(ucstring("}@{")); + + if (startTr != string::npos && endOfOriginal != string::npos) { + msgNoTranslate = msg.substr(0, startTr) + msg.substr(startTr+5, endOfOriginal-startTr-5); + } + } + + CViewBase *child = ctm.createMsgText(msgNoTranslate, col); if (child) { if (gl) gl->addChild(child); @@ -568,6 +584,18 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC ucstring newmsg = msg; ucstring prefix; + CCDBNodeLeaf *nodeNoTranslation = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:TRANSLATION:" + toUpper(CChatGroup::groupTypeToString(gt)) + ":DISABLE", false); + bool noTranslation = nodeNoTranslation->getValueBool(); + + if (noTranslation) { + string::size_type startTr = msg.find(ucstring("{:")); + string::size_type endOfOriginal = msg.find(ucstring("}@{")); + + if (startTr != string::npos && endOfOriginal != string::npos) { + newmsg = newmsg.substr(0, startTr) + newmsg.substr(startTr+5, endOfOriginal-startTr-5); + } + } + CViewBase *child = NULL; if (gl != NULL) { From 8cd863ff443190b30f0173cb96c5a4a63e323cd6 Mon Sep 17 00:00:00 2001 From: Riasan Date: Mon, 22 Feb 2021 16:13:02 +0100 Subject: [PATCH 16/45] Added: new privs TESTER for teleport via Map / Command --- code/ryzom/client/src/connection.cpp | 1 + code/ryzom/client/src/connection.h | 1 + code/ryzom/client/src/game_context_menu.cpp | 2 +- code/ryzom/client/src/interface_v3/group_map.cpp | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 82564354e..b4d7b5296 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -193,6 +193,7 @@ bool hasPrivilegeG() { return (UserPrivileges.find(":G:") != std::string::npos); bool hasPrivilegeEM() { return (UserPrivileges.find(":EM:") != std::string::npos); } bool hasPrivilegeEG() { return (UserPrivileges.find(":EG:") != std::string::npos); } bool hasPrivilegeOBSERVER() { return (UserPrivileges.find(":OBSERVER:") != std::string::npos); } +bool hasPrivilegeTESTER() { return (UserPrivileges.find(":TESTER:") != std::string::npos); } // Restore the video mode (fullscreen for example) after the connection (done in a window) diff --git a/code/ryzom/client/src/connection.h b/code/ryzom/client/src/connection.h index 79a72fb0e..72a44d31c 100644 --- a/code/ryzom/client/src/connection.h +++ b/code/ryzom/client/src/connection.h @@ -52,6 +52,7 @@ bool hasPrivilegeEM(); bool hasPrivilegeEG(); bool hasPrivilegeVG(); bool hasPrivilegeOBSERVER(); +bool hasPrivilegeTESTER(); // connection with the server. (login, shard list, etc.). diff --git a/code/ryzom/client/src/game_context_menu.cpp b/code/ryzom/client/src/game_context_menu.cpp index 78e58c4b5..1306c0704 100644 --- a/code/ryzom/client/src/game_context_menu.cpp +++ b/code/ryzom/client/src/game_context_menu.cpp @@ -267,7 +267,7 @@ void CGameContextMenu::update() setupContextMenuCantTalk(); // can't talk by default - bool showGMOptions = (hasPrivilegeDEV() || hasPrivilegeSGM() || hasPrivilegeGM() || hasPrivilegeVG() || hasPrivilegeSG() || hasPrivilegeEM() || hasPrivilegeEG() || hasPrivilegeOBSERVER()); + bool showGMOptions = (hasPrivilegeDEV() || hasPrivilegeSGM() || hasPrivilegeGM() || hasPrivilegeVG() || hasPrivilegeSG() || hasPrivilegeEM() || hasPrivilegeEG() || hasPrivilegeOBSERVER() || hasPrivilegeTESTER()); if (_TextInvisible) _TextInvisible->setActive(showGMOptions); diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 9bae00d6c..35a1fc4e6 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -2654,7 +2654,7 @@ void CGroupMap::createContinentLandMarks() static void hideTeleportButtonsInPopupMenuIfNotEnoughPriv() { - bool showTeleport = (hasPrivilegeDEV() || hasPrivilegeSGM() || hasPrivilegeGM() || hasPrivilegeVG() || hasPrivilegeSG() || hasPrivilegeEM() || hasPrivilegeEG() || hasPrivilegeOBSERVER()); + bool showTeleport = (hasPrivilegeDEV() || hasPrivilegeSGM() || hasPrivilegeGM() || hasPrivilegeVG() || hasPrivilegeSG() || hasPrivilegeEM() || hasPrivilegeEG() || hasPrivilegeOBSERVER()|| hasPrivilegeTESTER()); CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceElement *ie = CWidgetManager::getInstance()->getElementFromId("ui:interface:map_menu:teleport"); From 719f178f70aa628be65713105df65fa23fd4784b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 25 Oct 2020 01:55:35 +0800 Subject: [PATCH 17/45] Disconnect if UDP Login fails, ryzom/ryzomcore#622 --- code/ryzom/client/src/network_connection.cpp | 12 ++++++++++++ code/ryzom/client/src/network_connection.h | 1 + 2 files changed, 13 insertions(+) diff --git a/code/ryzom/client/src/network_connection.cpp b/code/ryzom/client/src/network_connection.cpp index 731677043..c1e9d8975 100644 --- a/code/ryzom/client/src/network_connection.cpp +++ b/code/ryzom/client/src/network_connection.cpp @@ -680,6 +680,7 @@ bool CNetworkConnection::connect(string &result) _LatestLoginTime = ryzomGetLocalTime (); _LatestSyncTime = _LatestLoginTime; _LatestProbeTime = _LatestLoginTime; + m_LoginAttempts = 0; nlinfo("CNET[%p]: Client connected to shard, attempting login", this); return true; @@ -1091,6 +1092,17 @@ bool CNetworkConnection::stateLogin() { sendSystemLogin(); _LatestLoginTime = _UpdateTime; + if (m_LoginAttempts > 24) + { + m_LoginAttempts = 0; + disconnect(); // will send disconnection message + nlwarning("CNET[%p]: Too many LOGIN attempts, connection problem", this); + return false; // exit now from loop, don't expect a new state + } + else + { + ++m_LoginAttempts; + } } return false; diff --git a/code/ryzom/client/src/network_connection.h b/code/ryzom/client/src/network_connection.h index d11702682..84bb26d43 100644 --- a/code/ryzom/client/src/network_connection.h +++ b/code/ryzom/client/src/network_connection.h @@ -822,6 +822,7 @@ private: void sendSystemLogin(); bool stateLogin(); NLMISC::TTime _LatestLoginTime; + int m_LoginAttempts; // void receiveSystemSync(NLMISC::CBitMemStream &msgin); From 2528e542cbeb4b12a715e4c3a5c6db212c6e17f7 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 25 Oct 2020 01:56:10 +0800 Subject: [PATCH 18/45] Don't probe if normal received in probe state, otherwise server will not enter probe state, ryzom/ryzomcore#622, ryzom/ryzomcore#133 --- code/ryzom/client/src/network_connection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ryzom/client/src/network_connection.cpp b/code/ryzom/client/src/network_connection.cpp index c1e9d8975..4778641c0 100644 --- a/code/ryzom/client/src/network_connection.cpp +++ b/code/ryzom/client/src/network_connection.cpp @@ -2320,6 +2320,7 @@ bool CNetworkConnection::stateProbe() else { nlwarning("CNET[%p]: received normal in state Probe", this); + _LatestProbeTime = _UpdateTime; } } } From dba92deea558cff642112ba7ff5f8a3085286b44 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 04:19:02 +0800 Subject: [PATCH 19/45] Avoid useless string operations --- code/nel/include/nel/misc/string_common.h | 7 ++++--- code/nel/src/gui/interface_element.cpp | 9 ++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index 3fd46b835..372ee4be5 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -246,9 +246,10 @@ inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf( inline bool fromString(const std::string &str, float &val) { bool ret = sscanf(str.c_str(), "%f", &val) == 1; if (!ret) val = 0.0f; return ret; } inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(str.c_str(), "%lf", &val) == 1; if (!ret) val = 0.0; return ret; } -// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, anything else is undefined. -// (str[0] == '1' || (str[0] & 0xD2) == 0x50) -// - Kaetemi +/// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, and empty strings, anything else is undefined. +/// - Kaetemi +inline bool toBool(const char *str) { return str[0] == '1' || (str[0] & 0xD2) == 0x50; } +inline bool toBool(const std::string &str) { return toBool(str.c_str()); } // Safe because first byte may be null bool fromString(const std::string &str, bool &val); diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 4a736314d..98f4ab7d6 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -1028,21 +1028,16 @@ namespace NLGUI } // ------------------------------------------------------------------------------------------------ - bool CInterfaceElement::convertBool (const char *ptr) + bool CInterfaceElement::convertBool (const char *ptr) { - std::string str = toLower(ptr); - bool b = false; - fromString( str, b ); - return b; + return NLMISC::toBool(ptr); } // ------------------------------------------------------------------------------------------------ NLMISC::CVector CInterfaceElement::convertVector (const char *ptr) { float x = 0.0f, y = 0.0f, z = 0.0f; - sscanf (ptr, "%f %f %f", &x, &y, &z); - return CVector(x,y,z); } From fdb271bdb3afe172d4ef0753f9429f7ebf2892fb Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 31 Mar 2021 13:30:43 +0300 Subject: [PATCH 20/45] Add macros to read properties from xmlNode --- code/nel/include/nel/misc/xml_macros.h | 74 ++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 code/nel/include/nel/misc/xml_macros.h diff --git a/code/nel/include/nel/misc/xml_macros.h b/code/nel/include/nel/misc/xml_macros.h new file mode 100644 index 000000000..d25cd4c30 --- /dev/null +++ b/code/nel/include/nel/misc/xml_macros.h @@ -0,0 +1,74 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef XML_MACROS_H +#define XML_MACROS_H + +// +// xmlNodePtr cur; +// CXMLAutoPtr prop; +// +// sint i; +// XML_READ_SINT(cur, "prop_name", i, -1); +// + +#define XML_READ_UINT(node, name, var, def) { \ + uint tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_SINT(node, name, var, def) { \ + sint tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_BOOL(node, name, var, def) { \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop) \ + var = NLMISC::toBool((const char*)prop); \ + else \ + var = def; \ +} + +#define XML_READ_COLOR(node, name, var, def) { \ + NLMISC::CRGBA tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_STRING(node, name, var, def) { \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop) \ + var = (const char*)prop; \ + else \ + var = def; \ +} + +#endif // XML_MACROS_H + From c09ed63120947d871ad2c32115609d670333ba12 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 1 Apr 2021 14:23:36 +0300 Subject: [PATCH 21/45] Add xml options for icon regen text --- .../client/src/interface_v3/dbctrl_sheet.cpp | 128 ++++++++++++++---- .../client/src/interface_v3/dbctrl_sheet.h | 23 ++++ 2 files changed, 122 insertions(+), 29 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 7b188742c..9306003c4 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -56,6 +56,7 @@ #include "../r2/editor.h" #include "nel/gui/lua_manager.h" +#include "nel/misc/xml_macros.h" extern CSheetManager SheetMngr; @@ -543,6 +544,14 @@ CCtrlDraggable(param) _RegenText = NULL; _RegenTextValue = 0; + _RegenTextEnabled = true; + _RegenTextShadow = true; + _RegenTextOutline = false; + _RegenTextY = 2; + _RegenTextFontSize = 8; + _RegenTextColor = NLMISC::CRGBA::White; + _RegenTextShadowColor = NLMISC::CRGBA::Black; + _RegenTextOutlineColor = NLMISC::CRGBA::Black; } // ---------------------------------------------------------------------------- @@ -655,6 +664,15 @@ bool CDBCtrlSheet::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)"focus_buff_icon" ); if (prop) _FocusBuffIcon = string((const char *)prop); + XML_READ_BOOL(cur, "regen_text", _RegenTextEnabled, true); + XML_READ_BOOL(cur, "regen_text_shadow", _RegenTextShadow, true); + XML_READ_BOOL(cur, "regen_text_outline", _RegenTextOutline, false); + XML_READ_SINT(cur, "regen_text_y", _RegenTextY, 2); + XML_READ_UINT(cur, "regen_text_fontsize", _RegenTextFontSize, 8); + XML_READ_COLOR(cur, "regen_text_color", _RegenTextColor, NLMISC::CRGBA::White); + XML_READ_COLOR(cur, "regen_text_shadow_color", _RegenTextShadowColor, NLMISC::CRGBA::Black); + XML_READ_COLOR(cur, "regen_text_outline_color", _RegenTextOutlineColor, NLMISC::CRGBA::Black); + updateActualType(); // Init size for Type initSheetSize(); @@ -2097,35 +2115,8 @@ void CDBCtrlSheet::draw() rVR.drawQuad(_RenderLayer + 1, regenTris[tri], backTex, CRGBA::White, false); } - if (!_RegenText) { - _RegenText = new CViewText(CViewBase::TCtorParam()); - _RegenText->setId(getId() + ":regen"); - _RegenText->setParent(_Parent); - _RegenText->setOverflowText(ucstring("")); - _RegenText->setModulateGlobalColor(false); - _RegenText->setMultiLine(false); - _RegenText->setTextMode(CViewText::ClipWord); - _RegenText->setFontSizing("0", "0"); - // TODO: font size / color hardcoded. - _RegenText->setFontSize(8); - _RegenText->setColor(CRGBA::White); - _RegenText->setShadow(true); - _RegenText->setActive(true); - _RegenText->updateTextContext(); - } - - // TODO: ticks in second hardcoded - uint32 nextValue = _RegenTickRange.EndTick > LastGameCycle ? (_RegenTickRange.EndTick - LastGameCycle) / 10 : 0; - if (_RegenTextValue != nextValue) - { - _RegenTextValue = nextValue; - _RegenText->setText(toString("%d", _RegenTextValue)); - _RegenText->updateTextContext(); - } - _RegenText->setXReal(_XReal+1); - _RegenText->setYReal(_YReal+2); - _RegenText->setRenderLayer(_RenderLayer+2); - _RegenText->draw(); + if (_RegenTextEnabled) + drawRegenText(); } } @@ -2155,6 +2146,85 @@ void CDBCtrlSheet::draw() } } +// ---------------------------------------------------------------------------- +void CDBCtrlSheet::drawRegenText() +{ + if (!_RegenText) { + _RegenText = new CViewText(CViewBase::TCtorParam()); + _RegenText->setId(getId() + ":regen"); + _RegenText->setParent(_Parent); + _RegenText->setOverflowText(std::string()); + _RegenText->setModulateGlobalColor(false); + _RegenText->setMultiLine(false); + _RegenText->setTextMode(CViewText::ClipWord); + _RegenText->setFontSize(_RegenTextFontSize); + _RegenText->setColor(_RegenTextColor); + // do not set shadow if outline is set to avoid clearing it on draw (would call invalidate) + _RegenText->setShadow(_RegenTextShadow && !_RegenTextOutline); + _RegenText->setShadowOutline(false);//_RegenTextOutline); + _RegenText->setShadowColor(_RegenTextShadowColor); + + _RegenText->setActive(true); + _RegenText->updateTextContext(); + } + + // TODO: 10 hardcoded (ticks in second) + uint32 nextValue = _RegenTickRange.EndTick > LastGameCycle ? (_RegenTickRange.EndTick - LastGameCycle) / 10 : 0; + if (_RegenTextValue != nextValue) + { + _RegenTextValue = nextValue; + // format as "10m", "9'59", "59" + if (_RegenTextValue > 600) + { + _RegenText->setText(toString("%dm", _RegenTextValue / 60)); + } + else if (_RegenTextValue > 0) + { + if (_RegenTextValue < 60) + _RegenText->setText(toString("%d", _RegenTextValue)); + else + _RegenText->setText(toString("%d'%02d", _RegenTextValue / 60, _RegenTextValue % 60)); + } + else + { + _RegenText->setText(ucstring()); + } + + _RegenText->updateTextContext(); + // todo: posref + _RegenText->setX(_WReal / 2 -_RegenText->getMaxUsedW() / 2); + // move RegenTextY=0 to baseline + _RegenText->setY(_RegenTextY - _RegenText->getFontLegHeight()); + } + + _RegenText->setXReal(_XReal + _RegenText->getX()); + _RegenText->setYReal(_YReal + _RegenText->getY()); + _RegenText->setRenderLayer(_RenderLayer+2); + + // TODO: create shader for this + if (_RegenTextOutline) + { + // player.xml t_bonus_text template way of drawing + sint x = _RegenText->getXReal(); + sint y = _RegenText->getYReal(); + + _RegenText->setColor(_RegenTextShadowColor); + _RegenText->setXReal(x-1); _RegenText->setYReal(y+0); _RegenText->draw(); + _RegenText->setXReal(x+1); _RegenText->setYReal(y+0); _RegenText->draw(); + _RegenText->setXReal(x+0); _RegenText->setYReal(y-1); _RegenText->draw(); + _RegenText->setXReal(x+0); _RegenText->setYReal(y+1); _RegenText->draw(); + + _RegenText->setColor(_RegenTextColor); + _RegenText->setXReal(x); _RegenText->setYReal(y); + _RegenText->draw(); + _RegenText->draw(); + } + else + { + _RegenText->draw(); + _RegenText->draw(); + } +} // ---------------------------------------------------------------------------- void CDBCtrlSheet::drawRotatedQuad(CViewRenderer &vr, float angle, float scale, uint renderLayer, uint32 texId, sint32 texWidth, sint32 texHeight) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index f9a85dd05..9f3d04397 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -602,6 +602,16 @@ public: void setRegenTickRange(const CTickRange &tickRange); const CTickRange &getRegenTickRange() const { return _RegenTickRange; } + // Default regen text is displayed on bottom of icon. + void setRegenText(bool b) { _RegenTextEnabled = b; } + void setRegenTextY(sint32 y) { _RegenTextY = y; } + void setRegenTextShadow(bool b) { _RegenTextShadow = b; } + void setRegenTextShadowColor(NLMISC::CRGBA c) { _RegenTextShadowColor = c; } + void setRegenTextOutline(bool b) { _RegenTextOutline = b; } + void setRegenTextOutlineColor(NLMISC::CRGBA c) { _RegenTextOutlineColor = c; } + void setRegenTextFontSize(uint32 s) { _RegenTextFontSize = s; } + void setRegenTextColor(NLMISC::CRGBA c) { _RegenTextColor = c; } + // start notify anim (at the end of regen usually) void startNotifyAnim(); @@ -739,6 +749,16 @@ protected: CTickRange _RegenTickRange; NLGUI::CViewText *_RegenText; uint32 _RegenTextValue; + // + bool _RegenTextEnabled; + bool _RegenTextShadow; + bool _RegenTextOutline; + sint32 _RegenTextY; + uint32 _RegenTextFontSize; + NLMISC::CRGBA _RegenTextShadowColor; + NLMISC::CRGBA _RegenTextOutlineColor; + NLMISC::CRGBA _RegenTextColor; + /// D'n'd sint32 _DragX, _DragY; @@ -852,6 +872,9 @@ private: // gelper to draw the notify animation void drawRotatedQuad(CViewRenderer &vr, float angle, float scale, uint renderLayer, uint32 textureId, sint32 texWidth, sint32 texHeight); + // create and draw regen text over icon + void drawRegenText(); + }; /** User type (used with expression system of the interface, see interface_expr.h, that contains a pointer to a CDBCtrlSheet From 383e362ed75f41f06b415689fda645107479f1fe Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 1 Apr 2021 14:24:15 +0300 Subject: [PATCH 22/45] Show bonus/malus timer text if available --- .../client/src/interface_v3/dbctrl_sheet.cpp | 68 ++++++++-- .../client/src/interface_v3/dbctrl_sheet.h | 13 +- .../dbgroup_list_sheet_bonus_malus.cpp | 127 ++++++++++-------- .../dbgroup_list_sheet_bonus_malus.h | 29 +++- 4 files changed, 164 insertions(+), 73 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 9306003c4..b69a428db 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -547,6 +547,7 @@ CCtrlDraggable(param) _RegenTextEnabled = true; _RegenTextShadow = true; _RegenTextOutline = false; + _RegenTextFctLua = false; _RegenTextY = 2; _RegenTextFontSize = 8; _RegenTextColor = NLMISC::CRGBA::White; @@ -672,6 +673,8 @@ bool CDBCtrlSheet::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) XML_READ_COLOR(cur, "regen_text_color", _RegenTextColor, NLMISC::CRGBA::White); XML_READ_COLOR(cur, "regen_text_shadow_color", _RegenTextShadowColor, NLMISC::CRGBA::Black); XML_READ_COLOR(cur, "regen_text_outline_color", _RegenTextOutlineColor, NLMISC::CRGBA::Black); + XML_READ_STRING(cur, "regen_text_fct", _RegenTextFct, ""); + _RegenTextFctLua = startsWith(_RegenTextFct, "lua:"); updateActualType(); // Init size for Type @@ -2155,13 +2158,13 @@ void CDBCtrlSheet::drawRegenText() _RegenText->setParent(_Parent); _RegenText->setOverflowText(std::string()); _RegenText->setModulateGlobalColor(false); - _RegenText->setMultiLine(false); + _RegenText->setMultiLine(true); _RegenText->setTextMode(CViewText::ClipWord); _RegenText->setFontSize(_RegenTextFontSize); _RegenText->setColor(_RegenTextColor); // do not set shadow if outline is set to avoid clearing it on draw (would call invalidate) _RegenText->setShadow(_RegenTextShadow && !_RegenTextOutline); - _RegenText->setShadowOutline(false);//_RegenTextOutline); + _RegenText->setShadowOutline(false); _RegenText->setShadowColor(_RegenTextShadowColor); _RegenText->setActive(true); @@ -2169,29 +2172,62 @@ void CDBCtrlSheet::drawRegenText() } // TODO: 10 hardcoded (ticks in second) - uint32 nextValue = _RegenTickRange.EndTick > LastGameCycle ? (_RegenTickRange.EndTick - LastGameCycle) / 10 : 0; + sint32 nextValue; + if (_RegenTickRange.EndTick > LastGameCycle) + nextValue = (_RegenTickRange.EndTick - LastGameCycle) / 10; + else if (_RegenTextFctLua) + nextValue = ((sint64)_RegenTickRange.EndTick - (sint64)LastGameCycle) / 10; + else + nextValue = 0; + if (_RegenTextValue != nextValue) { _RegenTextValue = nextValue; - // format as "10m", "9'59", "59" - if (_RegenTextValue > 600) - { - _RegenText->setText(toString("%dm", _RegenTextValue / 60)); - } - else if (_RegenTextValue > 0) + if (_RegenTextFct.empty()) { - if (_RegenTextValue < 60) - _RegenText->setText(toString("%d", _RegenTextValue)); + // format as "10m", "9'59", "59" + if (_RegenTextValue > 600) + { + _RegenText->setText(toString("%dm", _RegenTextValue / 60)); + } + else if (_RegenTextValue > 0) + { + if (_RegenTextValue < 60) + _RegenText->setText(toString("%d", _RegenTextValue)); + else + _RegenText->setText(toString("%d'%02d", _RegenTextValue / 60, _RegenTextValue % 60)); + } else - _RegenText->setText(toString("%d'%02d", _RegenTextValue / 60, _RegenTextValue % 60)); + { + _RegenText->setText(ucstring()); + } } else { - _RegenText->setText(ucstring()); + std::string fct; + if (_RegenTextFctLua) + { + CCDBNodeBranch *root = getRootBranch(); + if (root) + fct = toString("%s(%d, '%s')", _RegenTextFct.c_str(), _RegenTextValue, root->getFullName().c_str()); + else + fct = toString("%s(%d, nil)", _RegenTextFct.c_str(), _RegenTextValue); + } + else + { + fct = toString("%s(%d)", _RegenTextFct.c_str(), _RegenTextValue); + } + + // if using color tags in format, then RegenText color should be set to CRGBA::White + // as tag color is modulated with main color + std::string result; + if (CInterfaceExpr::evalAsString(fct, result)) + _RegenText->setTextFormatTaged(result); } _RegenText->updateTextContext(); // todo: posref + // note: if x,y is moved outside icon area it might get cliped and not be visible (wreal/hreal == 0) _RegenText->setX(_WReal / 2 -_RegenText->getMaxUsedW() / 2); // move RegenTextY=0 to baseline _RegenText->setY(_RegenTextY - _RegenText->getFontLegHeight()); @@ -4813,6 +4849,12 @@ std::string CDBCtrlSheet::getContextHelpWindowName() const return CCtrlBase::getContextHelpWindowName(); } +// *************************************************************************** +void CDBCtrlSheet::setRegenTextFct(const std::string &s) +{ + _RegenTextFct = s; + _RegenTextFctLua = startsWith(s, "lua:"); +} // *************************************************************************** void CDBCtrlSheet::setRegenTickRange(const CTickRange &tickRange) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 9f3d04397..6b0e08ee6 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -604,6 +604,15 @@ public: // Default regen text is displayed on bottom of icon. void setRegenText(bool b) { _RegenTextEnabled = b; } + // Allow to override default formatter. + // First parameter will be replaced with current timer value (always >= 0) + // If its a lua function, then parameters are + // 1: current timer value; can be negative + // 2: DB path for ctrl root (ie UI:VARIABLES:BONUSES:0), or nil + // + // ie: "secondsToTimeStringShort" -> CInterfaceExpr::evalAsString("secondsToTimeStringShort(123)", ret) + // ie: "lua:secondsToTimeStringShort" -> CInterfaceExpr::evalAsString("lua:secondsToTimeStringShort(123, 'UI:VARIABLES:BONUSES:0')", ret) + void setRegenTextFct(const std::string &s); void setRegenTextY(sint32 y) { _RegenTextY = y; } void setRegenTextShadow(bool b) { _RegenTextShadow = b; } void setRegenTextShadowColor(NLMISC::CRGBA c) { _RegenTextShadowColor = c; } @@ -748,8 +757,10 @@ protected: CTickRange _RegenTickRange; NLGUI::CViewText *_RegenText; - uint32 _RegenTextValue; + sint32 _RegenTextValue; // + std::string _RegenTextFct; + bool _RegenTextFctLua; bool _RegenTextEnabled; bool _RegenTextShadow; bool _RegenTextOutline; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp index 175d7339b..f41dd3085 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp @@ -23,7 +23,7 @@ #include "stdpch.h" #include "dbgroup_list_sheet_bonus_malus.h" #include "interface_manager.h" - +#include "nel/misc/xml_macros.h" using namespace std; using namespace NLMISC; @@ -35,87 +35,106 @@ NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetBonusMalus, std::string, "lis // *************************************************************************** CDBGroupListSheetBonusMalus::CDBGroupListSheetBonusMalus(const TCtorParam ¶m) -: CDBGroupListSheet(param) +: CDBGroupListSheet(param), + _RegenTextEnabled(true), + _RegenTextY(-14), _RegenTextFontSize(8), + _RegenTextColor(NLMISC::CRGBA::White), + _RegenTextDisabledColor(NLMISC::CRGBA(127,127,127)) { - _TextId= -1; - // want leave space between controls in the list // Yoyo: I think it's better like this, + this is important for space consideration and because of XPCat/PVPOutpost //_ListLeaveSpace= false; } - // *************************************************************************** -bool CDBGroupListSheetBonusMalus::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) +CDBGroupListSheetBonusMalus::CSheetChildTimer::CSheetChildTimer() +: TimerDB(NULL), DisabledDB(NULL), TimerCache(0), + _RegenTextColor(NLMISC::CRGBA::White), + _RegenTextDisabledColor(NLMISC::CRGBA(127,127,127)) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); +} - if(!CDBGroupListSheet::parse(cur, parentGroup)) - return false; +// *************************************************************************** +void CDBGroupListSheetBonusMalus::CSheetChildTimer::init(CDBGroupListSheet *pFather, uint index) +{ + // init my parent + CSheetChild::init(pFather, index); - // read the texture - CXMLAutoPtr prop; - prop = (char*) xmlGetProp( cur, (xmlChar*)"disable_texture" ); - if (prop) + CCDBNodeBranch *root = Ctrl->getRootBranch(); + if (root) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TextId= rVR.getTextureIdFromName ((const char *)prop); + TimerDB = dynamic_cast(root->getNode(ICDBNode::CTextId("DISABLED_TIME"), false)); + DisabledDB = dynamic_cast(root->getNode(ICDBNode::CTextId("DISABLED"), false)); } - // get the Node leaves to be tested each frame - uint i= 0; - for(;;) + if (Ctrl) { - string db= toString("%s:%d:" DISABLE_LEAF, _DbBranchName.c_str(), i); - CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(db, false); - if(!node) + CDBGroupListSheetBonusMalus *owner = dynamic_cast(pFather); + if (owner) { - break; + _RegenTextColor = owner->_RegenTextColor; + _RegenTextDisabledColor = owner->_RegenTextDisabledColor; + Ctrl->setRegenText(owner->_RegenTextEnabled); + Ctrl->setRegenTextY(owner->_RegenTextY); + Ctrl->setRegenTextColor(owner->_RegenTextColor); + Ctrl->setRegenTextFontSize(owner->_RegenTextFontSize); + if (!owner->_RegenTextFct.empty()) + Ctrl->setRegenTextFct(owner->_RegenTextFct); } - else - { - _DisableStates.push_back(node); - i++; - } - } - return true; + Ctrl->setRegenTextOutline(true); + } } // *************************************************************************** -void CDBGroupListSheetBonusMalus::draw () +void CDBGroupListSheetBonusMalus::CSheetChildTimer::update(CDBGroupListSheet * /* pFather */) { - CDBGroupListSheet::draw(); - -// CInterfaceManager *pIM= CInterfaceManager::getInstance(); -// CViewRenderer &rVR= *CViewRenderer::getInstance(); - -// sint32 drl= getRenderLayer()+1; + if(!TimerDB) + return; - // May draw disable bitmaps on the ctrl sheets if disabled. - uint numCtrls= (uint)min(_SheetChildren.size(), _DisableStates.size()); - for(uint i=0;igetValue32(); + if (TimerCache != tick) { - CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; - // if the ctrl is displayed, and if the state is disabled - if(ctrl->getActive()) + TimerCache = TimerDB->getValue32(); + Ctrl->setRegenTickRange(CTickRange(LastGameCycle, TimerCache)); + if (DisabledDB) { - if(_DisableStates[i]->getValue32()!=0) + if (DisabledDB->getValue32() == 0) { - ctrl->setGrayed(true); - /* - // YOYO: for now, don't display the gray bitmap. cross not cool. - CRGBA crossColor= ctrl->getSheetColor(); - crossColor.A>>= 2; - // Draw the disable bitmap on this control. +1 for the slot (ugly) - rVR.drawRotFlipBitmap(drl, ctrl->getXReal()+1, ctrl->getYReal()+1, - CCtrlSheetInfo::BrickSheetWidth, CCtrlSheetInfo::BrickSheetHeight, 0, 0, _TextId, crossColor); - */ + // active timer + Ctrl->setGrayed(false); + Ctrl->setRegenTextColor(_RegenTextColor); } else - ctrl->setGrayed(false); + { + // skill disabled timer + Ctrl->setGrayed(true); + Ctrl->setRegenTextColor(_RegenTextDisabledColor); + } + } + else + { + Ctrl->setGrayed(true); } } } +// *************************************************************************** +bool CDBGroupListSheetBonusMalus::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) +{ + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + + if(!CDBGroupListSheet::parse(cur, parentGroup)) + return false; + + CXMLAutoPtr prop; + XML_READ_BOOL(cur, "regen_text", _RegenTextEnabled, true); + XML_READ_SINT(cur, "regen_text_y", _RegenTextY, -14); + XML_READ_UINT(cur, "regen_text_fontsize", _RegenTextFontSize, 8); + XML_READ_COLOR(cur, "regen_text_color", _RegenTextColor, NLMISC::CRGBA::White); + XML_READ_COLOR(cur, "regen_text_disabled_color", _RegenTextDisabledColor, NLMISC::CRGBA(127, 127, 127)); + XML_READ_STRING(cur, "regen_text_fct", _RegenTextFct, ""); + + return true; +} + diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h index 05774ec8d..d63e664ed 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h @@ -25,7 +25,6 @@ #include "nel/misc/types_nl.h" #include "dbgroup_list_sheet.h" - // *************************************************************************** /** * Special list_sheet that display some disalbe bitmap if needed according to DB @@ -40,14 +39,34 @@ public: /// Constructor CDBGroupListSheetBonusMalus(const TCtorParam ¶m); - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + // A child node + struct CSheetChildTimer : public CDBGroupListSheet::CSheetChild + { + CSheetChildTimer(); + virtual void init(CDBGroupListSheet *pFather, uint index) NL_OVERRIDE; + virtual void update(CDBGroupListSheet *pFather) NL_OVERRIDE; + + NLMISC::CCDBNodeLeaf *TimerDB; + NLMISC::CCDBNodeLeaf *DisabledDB; + uint TimerCache; + + NLMISC::CRGBA _RegenTextColor; + NLMISC::CRGBA _RegenTextDisabledColor; + }; + + virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup) NL_OVERRIDE; - virtual void draw (); + virtual CSheetChild *createSheetChild() NL_OVERRIDE { return new CSheetChildTimer; } private: - sint32 _TextId; + friend CSheetChildTimer; - std::vector _DisableStates; + bool _RegenTextEnabled; + std::string _RegenTextFct; + sint32 _RegenTextY; + uint32 _RegenTextFontSize; + NLMISC::CRGBA _RegenTextColor; + NLMISC::CRGBA _RegenTextDisabledColor; }; From 26482eef1b8fba8ebefd8d5d4a8a89444f3fb674 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 1 Apr 2021 20:51:57 +0300 Subject: [PATCH 23/45] Revert "Add missing PowerRoot effect families to sheetid conversions table." This reverts commit ff9aa6c6081a61444cb36a3e79e49c92d0abf084. --- .../ryzom/common/src/game_share/effect_families.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/code/ryzom/common/src/game_share/effect_families.cpp b/code/ryzom/common/src/game_share/effect_families.cpp index 391626393..8d00cf200 100644 --- a/code/ryzom/common/src/game_share/effect_families.cpp +++ b/code/ryzom/common/src/game_share/effect_families.cpp @@ -323,19 +323,6 @@ namespace EFFECT_FAMILIES { "thorn_wall_aura.sbrick", PowerThornWall }, { "water_wall_aura.sbrick", PowerWaterWall }, { "lightning_wall_aura.sbrick", PowerLightningWall }, - - { "life_aura.sbrick", PowerRootLifeAura }, - { "stamina_aura.sbrick", PowerRootStaminaAura }, - { "sap_aura.sbrick", PowerRootSapAura }, - { "umbrella_aura.sbrick", PowerRootUmbrella }, - { "melee_protection_aura.sbrick", PowerRootProtection }, - { "anti_magic_shield_aura.sbrick", PowerRootAntiMagicShield }, - { "war_cry_aura.sbrick", PowerRootWarCry }, - { "fire_wall_aura.sbrick", PowerRootFireWall }, - { "thorn_wall_aura.sbrick", PowerRootThornWall }, - { "water_wall_aura.sbrick", PowerRootWaterWall }, - { "lightning_wall_aura.sbrick", PowerRootLightningWall }, - { "chg_charac.sbrick", PowerChgCharac }, { "mod_defense.sbrick", PowerModDefenseSkill }, { "mod_dodge.sbrick", PowerModDodgeSkill }, From bf2f8e39a5a979e0144b5dd9dc4db2362161e825 Mon Sep 17 00:00:00 2001 From: Nuno Date: Fri, 2 Apr 2021 19:04:36 +0200 Subject: [PATCH 24/45] Added nopatch arg for use with Ryztart --- code/ryzom/client/src/client.cpp | 1 + code/ryzom/client/src/far_tp.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index e824f6529..4e933b6da 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -180,6 +180,7 @@ int main(int argc, char **argv) Args.setVersion(getDisplayVersion()); Args.setDescription("Ryzom client"); + Args.addArg("n", "nopatch", "value", "Use this to not use patch system"); Args.addArg("p", "profile", "id", "Use this profile to determine what directory to use by default"); Args.addAdditionalArg("login", "Login to use", true, false); Args.addAdditionalArg("password", "Password to use", true, false); diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index 0a594e540..1c2a6e612 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -49,12 +49,12 @@ #include "login_progress_post_thread.h" #include "interface_v3/action_handler_base.h" #include "item_group_manager.h" +#include "nel/misc/cmd_args.h" #ifdef DEBUG_NEW #define new DEBUG_NEW #endif - using namespace NLMISC; using namespace NLNET; using namespace NL3D; @@ -210,6 +210,7 @@ extern bool IsInRingSession; extern void selectTipsOfTheDay (uint tips); #define BAR_STEP_TP 2 +extern NLMISC::CCmdArgs Args; CLoginStateMachine::TEvent CLoginStateMachine::waitEvent() { @@ -462,12 +463,14 @@ void CLoginStateMachine::run() case st_check_patch: /// check the data to check if patch needed CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_PostLogin, "login_step_post_login")); - if (!ClientCfg.PatchWanted) + + if (!ClientCfg.PatchWanted || (Args.haveArg("n") && Args.getLongArg("nopatch").front() == "1")) { // client don't want to be patched ! _CurrentState = st_display_eula; break; } + initPatchCheck(); SM_BEGIN_EVENT_TABLE if (isBGDownloadEnabled()) @@ -1517,4 +1520,3 @@ void CFarTP::farTPmainLoop() if(welcomeWindow) initWelcomeWindow(); } - From de90245f271dbd3e8344d6c2e7b1e82669f651e0 Mon Sep 17 00:00:00 2001 From: Nuno Date: Fri, 16 Apr 2021 14:08:37 +0200 Subject: [PATCH 25/45] Added GvE and GvG to TPVPType enum --- code/ryzom/common/src/game_share/outpost.cpp | 2 ++ code/ryzom/common/src/game_share/outpost.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/code/ryzom/common/src/game_share/outpost.cpp b/code/ryzom/common/src/game_share/outpost.cpp index b2cbde97f..d94254c83 100644 --- a/code/ryzom/common/src/game_share/outpost.cpp +++ b/code/ryzom/common/src/game_share/outpost.cpp @@ -33,6 +33,8 @@ namespace OUTPOSTENUMS NL_STRING_CONVERSION_TABLE_ENTRY(RVR) NL_STRING_CONVERSION_TABLE_ENTRY(Full) NL_STRING_CONVERSION_TABLE_ENTRY(UnknownPVPType) + NL_STRING_CONVERSION_TABLE_ENTRY(GVE) + NL_STRING_CONVERSION_TABLE_ENTRY(GVG) NL_END_STRING_CONVERSION_TABLE(TPVPType, StaticCOutpostTPVPTypeConversion, UnknownPVPType) NL_BEGIN_STRING_CONVERSION_TABLE (TPVPSide) diff --git a/code/ryzom/common/src/game_share/outpost.h b/code/ryzom/common/src/game_share/outpost.h index a951d1afb..391779ad0 100644 --- a/code/ryzom/common/src/game_share/outpost.h +++ b/code/ryzom/common/src/game_share/outpost.h @@ -50,7 +50,9 @@ namespace OUTPOSTENUMS PVE, // can only be attacked if the outpost is held by a tribe and if the attacking guild comes from the same continent as the outpost PVP, // can only be attacked if the attacking guild comes from the same continent as the outpost RVR, // can only be attacked if the attacking guild comes from another continent as the outpost - Full // same as RVR but cant be set by the high council + Full, // same as RVR but cant be set by the high council + GVE, // Only one guild vs tribes + GVG, // Only one guild vs another guild }; enum TPVPSide From 6402a31e4e27fb6155a1c94c7a0c164b9ad85afe Mon Sep 17 00:00:00 2001 From: Nuno Date: Wed, 21 Apr 2021 18:47:13 +0200 Subject: [PATCH 26/45] Added boost allegories family --- code/ryzom/common/src/game_share/brick_families.cpp | 1 + code/ryzom/common/src/game_share/brick_families.h | 3 ++- code/ryzom/common/src/game_share/fame.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/ryzom/common/src/game_share/brick_families.cpp b/code/ryzom/common/src/game_share/brick_families.cpp index 684eb0d25..c36593da0 100644 --- a/code/ryzom/common/src/game_share/brick_families.cpp +++ b/code/ryzom/common/src/game_share/brick_families.cpp @@ -558,6 +558,7 @@ namespace BRICK_FAMILIES NL_STRING_CONVERSION_TABLE_ENTRY(BSCMC) NL_STRING_CONVERSION_TABLE_ENTRY(BSCMD) NL_STRING_CONVERSION_TABLE_ENTRY(BSGMC) + NL_STRING_CONVERSION_TABLE_ENTRY(BSGMCB) NL_STRING_CONVERSION_TABLE_ENTRY(BSXCA) diff --git a/code/ryzom/common/src/game_share/brick_families.h b/code/ryzom/common/src/game_share/brick_families.h index 49a73fbaa..7903f6e5e 100644 --- a/code/ryzom/common/src/game_share/brick_families.h +++ b/code/ryzom/common/src/game_share/brick_families.h @@ -675,7 +675,8 @@ namespace BRICK_FAMILIES BSCMD, // heal Focus EndPowerParameter = BSCMD, - BSGMC, // jewels s2e0 + BSGMC, // allegories + BSGMCB, // boost allegories BeginMagicPowerCredit, BSXCA = BeginMagicPowerCredit, // recast time diff --git a/code/ryzom/common/src/game_share/fame.cpp b/code/ryzom/common/src/game_share/fame.cpp index 19c3cbb80..03bf10e45 100644 --- a/code/ryzom/common/src/game_share/fame.cpp +++ b/code/ryzom/common/src/game_share/fame.cpp @@ -633,7 +633,7 @@ sint32 CStaticFames::getStaticFameIndexed(uint factionIndex1, uint factionIndex2 if (factionIndex1 >= _FameTableSize || factionIndex2 >= _FameTableSize) { - nlwarning("FAME: CStaticFames::getStaticFame invalid faction, return 0"); + //nlwarning("FAME: CStaticFames::getStaticFame invalid faction, return 0"); return 0; } From c09f82db16b23de92aff3164666a9203abbbb362 Mon Sep 17 00:00:00 2001 From: Nuno Date: Fri, 23 Apr 2021 18:29:31 +0200 Subject: [PATCH 27/45] Added boost icons --- .../client/src/interface_v3/dbctrl_sheet.cpp | 19 ++++++++++++++++++- .../client/src/interface_v3/dbctrl_sheet.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 7b188742c..9485cb2b7 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1086,6 +1086,7 @@ void CDBCtrlSheet::clearIconBuffs() { _EnchantIcons.clear(); _BuffIcons.clear(); + _BoostIcons.clear(); } // *************************************************************************** @@ -1118,8 +1119,15 @@ void CDBCtrlSheet::infoReceived() if (brick) { if (!brick->isRoot() && !brick->isCredit() && !brick->isParameter()) + if (brick->BrickFamily == BRICK_FAMILIES::BSGMCB) // Boost of Allegories, use it as boost icon { if (!haveRoot) + _BoostIcons.push_back(SBuffIcon(rVR.getTextureIdFromName(brick->getIcon()), brick->IconColor)); + rVR.getTextureSizeFromId(_BoostIcons.back().TextureId, _BoostIcons.back().IconW, _BoostIcons.back().IconH); + } + else if (!brick->isRoot() && !brick->isCredit() && !brick->isParameter()) + { + if (!haveRoot && !brick->getIconBack().empty()) { _EnchantIcons.push_back(SBuffIcon(rVR.getTextureIdFromName(brick->getIconBack()), brick->IconBackColor)); rVR.getTextureSizeFromId(_EnchantIcons.back().TextureId, _EnchantIcons.back().IconW, _EnchantIcons.back().IconH); @@ -2444,10 +2452,18 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti } yIcon -= hIcon; rVR.drawRotFlipBitmap(_RenderLayer + 1, xIcon, yIcon, wIcon, hIcon, 0, false, _EnchantIcons[0].TextureId, fastMulRGB(curSheetColor, _EnchantIcons[0].Color)); - rVR.drawRotFlipBitmap(_RenderLayer+1, xIcon, yIcon, wIcon, hIcon, 0, false, _EnchantIcons[i].TextureId, fastMulRGB(curSheetColor, _EnchantIcons[i].Color)); + rVR.drawRotFlipBitmap(_RenderLayer + 1, xIcon, yIcon, wIcon, hIcon, 0, false, _EnchantIcons[i].TextureId, fastMulRGB(curSheetColor, _EnchantIcons[i].Color)); + + + if ((i - 1) < _BoostIcons.size()) { + nlinfo("Boost icon = %s", rVR.getTextureNameFromId(_BoostIcons[i-1].TextureId).c_str()); + rVR.drawRotFlipBitmap(_RenderLayer + 2, xIcon+wIcon-_BoostIcons[i-1].IconW, yIcon, _BoostIcons[i-1].IconW, _BoostIcons[i-1].IconH, 0, false, _BoostIcons[i-1].TextureId, fastMulRGB(curSheetColor, _BoostIcons[i-1].Color)); + } } } + + // Draw Quality. -1 for lookandfeel. Draw it with global color if (_DispQuality != -1) { @@ -3804,6 +3820,7 @@ void CDBCtrlSheet::resetAllTexIDs() _ItemInfoChanged = true; _EnchantIcons.clear(); _BuffIcons.clear(); + _BoostIcons.clear(); } diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index f9a85dd05..0052335fb 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -682,6 +682,7 @@ protected: }; std::vector _BuffIcons; std::vector _EnchantIcons; + std::vector _BoostIcons; // Level Brick or Quality union From d665e1fc455d49f362f64ef979c278000582cefa Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 25 Apr 2021 14:25:26 +0300 Subject: [PATCH 28/45] Fix detecting jpg image --- code/nel/src/misc/bitmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index c21b30fb7..dfd2be701 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -3570,7 +3570,7 @@ void CBitmap::loadSize(NLMISC::IStream &f, uint32 &retWidth, uint32 &retHeight) } while(!eof); } - else if(fileType == JPG_HEADER) + else if(memcmp(&fileType, &JPG_HEADER, 2) == 0) { uint8 blockMarker1 = 0; uint8 blockMarker2 = 0; From 155418b20beb113f70801ac1231974fcd6142285 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 25 Apr 2021 09:55:20 +0300 Subject: [PATCH 29/45] Fix temp file collision and image update on http/304 response --- code/nel/include/nel/gui/group_html.h | 1 + code/nel/src/gui/group_html.cpp | 100 +++++++++++++------------- 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index a78e203c0..8b4a635b9 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -857,6 +857,7 @@ namespace NLGUI CCurlWWWData *data; std::string url; std::string dest; + std::string tmpdest; std::string luaScript; std::string md5sum; TDataType type; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index f2aba9fa0..dd5be59e7 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -524,18 +524,19 @@ namespace NLGUI return false; } - string tmpdest = download.dest + ".tmp"; + // use browser Id so that two browsers would not use same temp file + download.tmpdest = localImageName(_Id + download.dest) + ".tmp"; // erase the tmp file if exists - if (CFile::fileExists(tmpdest)) + if (CFile::fileExists(download.tmpdest)) { - CFile::deleteFile(tmpdest); + CFile::deleteFile(download.tmpdest); } - FILE *fp = nlfopen (tmpdest, "wb"); + FILE *fp = nlfopen (download.tmpdest, "wb"); if (fp == NULL) { - nlwarning("Can't open file '%s' for writing: code=%d '%s'", tmpdest.c_str (), errno, strerror(errno)); + nlwarning("Can't open file '%s' for writing: code=%d '%s'", download.tmpdest.c_str (), errno, strerror(errno)); return false; } @@ -543,7 +544,7 @@ namespace NLGUI if (!curl) { fclose(fp); - CFile::deleteFile(tmpdest); + CFile::deleteFile(download.tmpdest); nlwarning("Creating cURL handle failed, unable to download '%s'", download.url.c_str()); return false; @@ -607,54 +608,57 @@ namespace NLGUI void CGroupHTML::finishCurlDownload(const CDataDownload &download) { - std::string tmpfile = download.dest + ".tmp"; - if (download.type == ImgType) { - // there is race condition if two browser instances are downloading same file - // second instance deletes first tmpfile and creates new file for itself. - if (CFile::getFileSize(tmpfile) > 0) + if (CFile::fileExists(download.tmpdest) && CFile::getFileSize(download.tmpdest) > 0) { try { // verify that image is not corrupted uint32 w, h; - CBitmap::loadSize(tmpfile, w, h); + CBitmap::loadSize(download.tmpdest, w, h); if (w != 0 && h != 0) { - // if not tmpfile, then img is already in cache - if (CFile::fileExists(tmpfile)) - { - if (CFile::fileExists(download.dest)) - { - CFile::deleteFile(download.dest); - } - - // to reload image on page, the easiest seems to be changing texture - // to temp file temporarily. that forces driver to reload texture from disk - // ITexture::touch() seem not to do this. - // cache was updated, first set texture as temp file - for(uint i = 0; i < download.imgs.size(); i++) - { - setImage(download.imgs[i].Image, tmpfile, download.imgs[i].Type); - setImageSize(download.imgs[i].Image, download.imgs[i].Style); - } - - CFile::moveFile(download.dest, tmpfile); - } + if (CFile::fileExists(download.dest)) + CFile::deleteFile(download.dest); + // to reload image on page, the easiest seems to be changing texture + // to temp file temporarily. that forces driver to reload texture from disk + // ITexture::touch() seem not to do this. + // cache was updated, first set texture as temp file for(uint i = 0; i < download.imgs.size(); i++) { - setImage(download.imgs[i].Image, download.dest, download.imgs[i].Type); + setImage(download.imgs[i].Image, download.tmpdest, download.imgs[i].Type); setImageSize(download.imgs[i].Image, download.imgs[i].Style); } + CFile::moveFile(download.dest, download.tmpdest); } } catch(const NLMISC::Exception &e) { // exception message has .tmp file name, so keep it for further analysis - nlwarning("Invalid image (%s): %s", download.url.c_str(), e.what()); + nlwarning("Invalid image (%s) from url (%s): %s", download.tmpdest.c_str(), download.url.c_str(), e.what()); + } + } + + if (CFile::fileExists(download.dest) && CFile::getFileSize(download.dest) > 0) + { + try + { + // verify that image is not corrupted + uint32 w, h; + CBitmap::loadSize(download.dest, w, h); + if (w != 0 && h != 0) + for(uint i = 0; i < download.imgs.size(); i++) + { + setImage(download.imgs[i].Image, download.dest, download.imgs[i].Type); + setImageSize(download.imgs[i].Image, download.imgs[i].Style); + } + } + catch(const NLMISC::Exception &e) + { + nlwarning("Invalid image (%s) from url (%s): %s", download.dest.c_str(), download.url.c_str(), e.what()); } } @@ -663,13 +667,13 @@ namespace NLGUI if (download.type == StylesheetType) { - if (CFile::fileExists(tmpfile)) + if (CFile::fileExists(download.tmpdest)) { if (CFile::fileExists(download.dest)) { CFile::deleteFile(download.dest); } - CFile::moveFile(download.dest, tmpfile); + CFile::moveFile(download.dest, download.tmpdest); } cssDownloadFinished(download.url, download.dest); @@ -680,20 +684,20 @@ namespace NLGUI { bool verified = false; // no tmpfile if file was already in cache - if (CFile::fileExists(tmpfile)) + if (CFile::fileExists(download.tmpdest)) { - verified = download.md5sum.empty() || (download.md5sum != getMD5(tmpfile).toString()); + verified = download.md5sum.empty() || (download.md5sum != getMD5(download.tmpdest).toString()); if (verified) { if (CFile::fileExists(download.dest)) { CFile::deleteFile(download.dest); } - CFile::moveFile(download.dest, tmpfile); + CFile::moveFile(download.dest, download.tmpdest); } else { - CFile::deleteFile(tmpfile); + CFile::deleteFile(download.tmpdest); } } else if (CFile::fileExists(download.dest)) @@ -745,7 +749,7 @@ namespace NLGUI if (type != OverImage) { std::string temp = dest; - if (!CFile::fileExists(temp)) + if (!CFile::fileExists(temp) || CFile::getFileSize(temp) == 0) { temp = placeholder; } @@ -971,9 +975,9 @@ namespace NLGUI { fclose(it->fp); - if (CFile::fileExists(it->dest + ".tmp")) + if (CFile::fileExists(it->tmpdest)) { - CFile::deleteFile(it->dest + ".tmp"); + CFile::deleteFile(it->tmpdest); } } } @@ -4102,10 +4106,9 @@ namespace NLGUI obj.LastModified = data.data->getLastModified(); CHttpCache::getInstance()->store(data.dest, obj); - std::string tmpfile = data.dest + ".tmp"; - if (code == 304 && CFile::fileExists(tmpfile)) + if (code == 304 && CFile::fileExists(data.tmpdest)) { - CFile::deleteFile(tmpfile); + CFile::deleteFile(data.tmpdest); } } else if ((code >= 301 && code <= 303) || code == 307 || code == 308) @@ -4133,10 +4136,9 @@ namespace NLGUI LOG_DL("Redirect '%s'", location.c_str()); // no finished callback called, so cleanup old temp - std::string tmpfile = data.dest + ".tmp"; - if (CFile::fileExists(tmpfile)) + if (CFile::fileExists(data.tmpdest)) { - CFile::deleteFile(tmpfile); + CFile::deleteFile(data.tmpdest); } return; } From d8f54820c4a984af88dfe9978107e7e6e49fbb99 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 25 Apr 2021 11:05:07 +0300 Subject: [PATCH 30/45] Ignore first linebreak after pre, textarea open tag --- code/nel/src/gui/html_parser.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/nel/src/gui/html_parser.cpp b/code/nel/src/gui/html_parser.cpp index 3d7303706..91c287a7d 100644 --- a/code/nel/src/gui/html_parser.cpp +++ b/code/nel/src/gui/html_parser.cpp @@ -66,7 +66,15 @@ namespace NLGUI { if (node->type == XML_TEXT_NODE) { - parent.Children.push_back(CHtmlElement(CHtmlElement::TEXT_NODE, (const char*)(node->content))); + // linebreak right after pre,textare open tag should be removed + if (parent.Children.empty() && (*node->content == '\n') && (parent.ID == HTML_PRE || parent.ID == HTML_TEXTAREA)) + { + parent.Children.push_back(CHtmlElement(CHtmlElement::TEXT_NODE, (const char*)(node->content) + 1)); + } + else + { + parent.Children.push_back(CHtmlElement(CHtmlElement::TEXT_NODE, (const char*)(node->content))); + } } else if (node->type == XML_ELEMENT_NODE) From 291d332b56c0b6560ae719662f169a0c0360e1cf Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sat, 2 Jan 2021 16:45:39 +0200 Subject: [PATCH 31/45] Fix css style order when using external css files --- code/nel/include/nel/gui/group_html.h | 7 ++- code/nel/include/nel/gui/html_parser.h | 17 ++++-- code/nel/src/gui/group_html.cpp | 83 ++++++++++++++++---------- code/nel/src/gui/html_parser.cpp | 16 ++--- 4 files changed, 80 insertions(+), 43 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 8b4a635b9..d04593870 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -27,6 +27,7 @@ #include "nel/gui/ctrl_button.h" #include "nel/gui/group_table.h" #include "nel/gui/html_element.h" +#include "nel/gui/html_parser.h" #include "nel/gui/css_style.h" // forward declaration @@ -378,7 +379,9 @@ namespace NLGUI // true if renderer is waiting for css files to finish downloading (link rel=stylesheet) bool _WaitingForStylesheet; // list of css file urls that are queued up for download - std::vector _StylesheetQueue; + std::vector _StylesheetQueue; + //